diff options
author | Tom Rini <trini@konsulko.com> | 2021-07-31 08:18:14 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-07-31 08:18:14 -0400 |
commit | 85769006fce951d0ebf61585ae0ab6b7d880735d (patch) | |
tree | 12a2b59bf6475489ce9d20ba79b65dc26286b1fa /tools/kwboot.c | |
parent | 15f7e0dc01d8a851fb1bfbf0e47eab5b67ed26b3 (diff) | |
parent | 2cc4be280c259ac1e8e74c643c72e0331266056f (diff) |
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell
- kwboot / kwbimage improvements reducing image size (Pali & Marek)
- a37xx: pinctrl: Correct PWM pins definitions (Marek)
- Convert the Dreamplug Ethernet and SATA to Driver Model (Tony)
- serial: a37xx: DEBUG_UART improvements / fixes (Pali)
Diffstat (limited to 'tools/kwboot.c')
-rw-r--r-- | tools/kwboot.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c index 4be094c9c8..7feeaa45a2 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -26,12 +26,6 @@ #include <sys/mman.h> #include <sys/stat.h> -#ifdef __GNUC__ -#define PACKED __attribute((packed)) -#else -#define PACKED -#endif - /* * Marvell BootROM UART Sensing */ @@ -68,7 +62,7 @@ struct kwboot_block { uint8_t _pnum; uint8_t data[128]; uint8_t csum; -} PACKED; +} __packed; #define KWBOOT_BLK_RSP_TIMEO 1000 /* ms */ @@ -471,7 +465,7 @@ kwboot_term_pipe(int in, int out, char *quit, int *s) ssize_t nin, nout; char _buf[128], *buf = _buf; - nin = read(in, buf, sizeof(buf)); + nin = read(in, buf, sizeof(_buf)); if (nin <= 0) return -1; @@ -485,13 +479,14 @@ kwboot_term_pipe(int in, int out, char *quit, int *s) return 0; buf++; nin--; - } else + } else { while (*s > 0) { nout = write(out, quit, *s); if (nout <= 0) return -1; (*s) -= nout; } + } } } @@ -564,7 +559,9 @@ kwboot_terminal(int tty) } } while (quit[s] != 0); - tcsetattr(in, TCSANOW, &otio); + if (in >= 0) + tcsetattr(in, TCSANOW, &otio); + printf("\n"); out: return rc; } @@ -637,7 +634,7 @@ kwboot_img_patch_hdr(void *img, size_t size) } image_ver = image_version(img); - if (image_ver < 0) { + if (image_ver != 0 && image_ver != 1) { fprintf(stderr, "Invalid image header version\n"); errno = EINVAL; goto out; @@ -648,6 +645,11 @@ kwboot_img_patch_hdr(void *img, size_t size) else hdrsz = KWBHEADER_V1_SIZE(hdr); + if (size < hdrsz) { + errno = EINVAL; + goto out; + } + csum = kwboot_img_csum8(hdr, hdrsz) - hdr->checksum; if (csum != hdr->checksum) { errno = EINVAL; |