comparison loadtools/compalload.c @ 250:8c011177adb9

loadtools reworked to use factored-out libserial
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 21 Sep 2017 23:07:01 +0000
parents b77005f6d315
children
comparison
equal deleted inserted replaced
249:d0a4c05d98dc 250:8c011177adb9
11 #include <sys/ioctl.h> 11 #include <sys/ioctl.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <stdlib.h> 13 #include <stdlib.h>
14 #include <string.h> 14 #include <string.h>
15 #include <strings.h> 15 #include <strings.h>
16 #include <termios.h>
17 #include <unistd.h> 16 #include <unistd.h>
18 17
19 extern char default_compalstage_dir[]; 18 extern char default_compalstage_dir[];
20 extern char *target_ttydev; 19 extern char *target_ttydev;
21 extern int target_fd; 20 extern int target_fd;
22 extern struct termios target_termios;
23 21
24 static char compalstage_pathname[MAXPATHLEN]; 22 static char compalstage_pathname[MAXPATHLEN];
25 static u_char *compalstage_imgbuf; 23 static u_char *compalstage_imgbuf;
26 static size_t compalstage_len, compalstage_totlen; 24 static size_t compalstage_len, compalstage_totlen;
27 static int rx_state; 25 static int rx_state;
151 if (handle_rx_byte(rdbuf[i])) 149 if (handle_rx_byte(rdbuf[i]))
152 return; 150 return;
153 } 151 }
154 } 152 }
155 153
156 perform_compal_stage(for_boot_rom) 154 perform_compal_stage()
157 { 155 {
158 int fd; 156 int fd;
159 struct stat st; 157 struct stat st;
160 static int zero = 0; 158 static int zero = 0;
161 159
195 } 193 }
196 close(fd); 194 close(fd);
197 compute_checksum(); 195 compute_checksum();
198 196
199 printf("Using Compal stage image %s\n", compalstage_pathname); 197 printf("Using Compal stage image %s\n", compalstage_pathname);
200 cfsetispeed(&target_termios, B115200); 198 set_fixed_baudrate("115200");
201 cfsetospeed(&target_termios, B115200);
202 if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
203 perror("tcsetattr to switch baud rate");
204 exit(1);
205 }
206 ioctl(target_fd, FIONBIO, &zero); 199 ioctl(target_fd, FIONBIO, &zero);
207 printf("Waiting for PROMPT1 from target (%s) at 115200 baud\n", 200 printf("Waiting for PROMPT1 from target (%s) at 115200 baud\n",
208 target_ttydev); 201 target_ttydev);
209 read_loop(); 202 read_loop();
210 free(compalstage_imgbuf); 203 free(compalstage_imgbuf);
211 204
212 if (for_boot_rom) {
213 cfsetispeed(&target_termios, B19200);
214 cfsetospeed(&target_termios, B19200);
215 if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
216 perror("tcsetattr to switch baud rate");
217 exit(1);
218 }
219 }
220
221 return(1); 205 return(1);
222 } 206 }