X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=tools%2Fkwboot.c;h=4be094c9c8d81ebca06170a386718527880a587e;hb=b0436b94047caf4c2ec67b599581198317f395b1;hp=26b394963cd836be1f63ce80145895f06878fb96;hpb=c733c18e35c161fefdd4141bdce7a69b1bcfd302;p=oweals%2Fu-boot.git diff --git a/tools/kwboot.c b/tools/kwboot.c index 26b394963c..4be094c9c8 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -182,7 +182,7 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo) } n = read(fd, buf, len); - if (n < 0) + if (n <= 0) goto out; buf = (char *)buf + n; @@ -286,6 +286,7 @@ kwboot_bootmsg(int tty, void *msg) { int rc; char c; + int count; if (msg == NULL) kwboot_printv("Please reboot the target into UART boot mode..."); @@ -297,10 +298,12 @@ kwboot_bootmsg(int tty, void *msg) if (rc) break; - rc = kwboot_tty_send(tty, msg, 8); - if (rc) { - usleep(msg_req_delay * 1000); - continue; + for (count = 0; count < 128; count++) { + rc = kwboot_tty_send(tty, msg, 8); + if (rc) { + usleep(msg_req_delay * 1000); + continue; + } } rc = kwboot_tty_recv(tty, &c, 1, msg_rsp_timeo); @@ -426,6 +429,9 @@ kwboot_xmodem(int tty, const void *_data, size_t size) kwboot_printv("Sending boot image...\n"); + sleep(2); /* flush isn't effective without it */ + tcflush(tty, TCIOFLUSH); + do { struct kwboot_block block; int n; @@ -466,7 +472,7 @@ kwboot_term_pipe(int in, int out, char *quit, int *s) char _buf[128], *buf = _buf; nin = read(in, buf, sizeof(buf)); - if (nin < 0) + if (nin <= 0) return -1; if (quit) { @@ -664,14 +670,6 @@ kwboot_img_patch_hdr(void *img, size_t size) hdr_v0->srcaddr = hdr_v0->ext ? sizeof(struct kwb_header) : sizeof(*hdr_v0); - } else { - /* - * Subtract mkimage header size from destination address - * as this header is not expected by the Marvell BootROM. - * This way, the execution address is identical to the - * one the image is compiled for (TEXT_BASE). - */ - hdr->destaddr = hdr->destaddr - sizeof(struct image_header); } hdr->checksum = kwboot_img_csum8(hdr, hdrsz) - csum; @@ -829,7 +827,7 @@ main(int argc, char **argv) perror("debugmsg"); goto out; } - } else { + } else if (bootmsg) { rc = kwboot_bootmsg(tty, bootmsg); if (rc) { perror("bootmsg");