FreeCalypso > hg > freecalypso-sw
comparison loadtools/romload.c @ 49:54392d1ea474
loadtools: first beginnings for the baud rate switching logic
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 23 Jun 2013 02:53:16 +0000 |
parents | 24b88c119465 |
children | f1df95eed62c |
comparison
equal
deleted
inserted
replaced
48:38664e0b7c32 | 49:54392d1ea474 |
---|---|
11 #include <stdio.h> | 11 #include <stdio.h> |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 #include <strings.h> | 13 #include <strings.h> |
14 #include <termios.h> | 14 #include <termios.h> |
15 #include <unistd.h> | 15 #include <unistd.h> |
16 #include "baudrate.h" | |
16 #include "srecreader.h" | 17 #include "srecreader.h" |
17 | 18 |
18 extern int errno; | 19 extern int errno; |
19 | 20 |
20 extern char *target_ttydev; | 21 extern char *target_ttydev; |
21 extern int target_fd; | 22 extern int target_fd; |
23 extern struct baudrate baud_rate_table[]; | |
22 | 24 |
23 struct srecreader iramimage; | 25 struct srecreader iramimage; |
26 struct baudrate *romload_baud_rate = baud_rate_table; /* 1st entry default */ | |
24 | 27 |
25 static int beacon_interval = 13; /* in milliseconds */ | 28 static int beacon_interval = 13; /* in milliseconds */ |
26 | 29 |
27 static u_char beacon_cmd[2] = {'<', 'i'}; | 30 static u_char beacon_cmd[2] = {'<', 'i'}; |
28 | 31 |
151 send_beacons(); | 154 send_beacons(); |
152 printf("Got beacon response, attempting download\n"); | 155 printf("Got beacon response, attempting download\n"); |
153 | 156 |
154 usleep(SERIAL_FLUSH_DELAY * 1000); | 157 usleep(SERIAL_FLUSH_DELAY * 1000); |
155 tcflush(target_fd, TCIFLUSH); | 158 tcflush(target_fd, TCIFLUSH); |
159 param_cmd[2] = romload_baud_rate->bootrom_code; | |
156 write(target_fd, param_cmd, sizeof param_cmd); | 160 write(target_fd, param_cmd, sizeof param_cmd); |
157 resp = expect_response(INTERMEDIATE_TIMEOUT); | 161 resp = expect_response(INTERMEDIATE_TIMEOUT); |
158 if (resp != 'p') { | 162 if (resp != 'p') { |
159 if (resp < 0) | 163 if (resp < 0) |
160 fprintf(stderr, "No response to <p command\n"); | 164 fprintf(stderr, "No response to <p command\n"); |
166 fprintf(stderr, | 170 fprintf(stderr, |
167 "Got > %02X in response to <p command; expected >p\n", | 171 "Got > %02X in response to <p command; expected >p\n", |
168 resp); | 172 resp); |
169 exit(1); | 173 exit(1); |
170 } | 174 } |
171 printf("<p command successful, switching to 115200 baud\n"); | 175 printf("<p command successful, switching to %s baud\n", |
172 switch_baud_rate(B115200); | 176 romload_baud_rate->name); |
177 switch_baud_rate(romload_baud_rate); | |
173 usleep(SERIAL_FLUSH_DELAY * 1000); | 178 usleep(SERIAL_FLUSH_DELAY * 1000); |
174 tcflush(target_fd, TCIFLUSH); | 179 tcflush(target_fd, TCIFLUSH); |
175 | 180 |
176 image_cksum = 0; | 181 image_cksum = 0; |
177 for (rec_count = 0; ; ) { | 182 for (rec_count = 0; ; ) { |