osmoload: allow running without firmware image

This commit is contained in:
Ingo Albrecht 2010-04-18 08:08:03 +02:00
parent 3f998d80eb
commit e4ad7b6827
1 changed files with 12 additions and 11 deletions

View File

@ -850,14 +850,16 @@ static int handle_read(void)
printf("Received PROMPT1 from phone, responding with CMD\n"); printf("Received PROMPT1 from phone, responding with CMD\n");
dnload.print_hdlc = 0; dnload.print_hdlc = 0;
dnload.state = WAITING_PROMPT2; dnload.state = WAITING_PROMPT2;
rc = write(dnload.serial_fd.fd, dnload_cmd, sizeof(dnload_cmd)); if(dnload.filename) {
rc = write(dnload.serial_fd.fd, dnload_cmd, sizeof(dnload_cmd));
/* re-read file */ /* re-read file */
rc = read_file(dnload.filename); rc = read_file(dnload.filename);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "read_file(%s) failed with %d\n", fprintf(stderr, "read_file(%s) failed with %d\n",
dnload.filename, rc); dnload.filename, rc);
exit(1); exit(1);
}
} }
} else if (!memcmp(buffer, phone_prompt2, sizeof(phone_prompt2))) { } else if (!memcmp(buffer, phone_prompt2, sizeof(phone_prompt2))) {
printf("Received PROMPT2 from phone, starting download\n"); printf("Received PROMPT2 from phone, starting download\n");
@ -1438,12 +1440,11 @@ int main(int argc, char **argv)
} }
if (argc <= optind) { if (argc <= optind) {
fprintf(stderr, "You have to specify the filename\n"); dnload.filename = NULL;
usage(argv[0]); } else {
dnload.filename = argv[optind];
} }
dnload.filename = argv[optind];
dnload.serial_fd.fd = serial_init(serial_dev); dnload.serial_fd.fd = serial_init(serial_dev);
if (dnload.serial_fd.fd < 0) { if (dnload.serial_fd.fd < 0) {
fprintf(stderr, "Cannot open serial device %s\n", serial_dev); fprintf(stderr, "Cannot open serial device %s\n", serial_dev);