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