diff options
-rw-r--r-- | halfkay.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -93,7 +93,7 @@ static void fmtcmd(void *_dest, const struct flashparams *fp, size_t addr) addr >>= fp->addrshft; for (size_t i = 0; i < fp->cmdsz; i++) - dest[i] = (addr >> (i * CHAR_BIT)) & 0xFF; + dest[i] = (addr >> (i * 8)) & 0xFF; } int flash(const struct flashparams *fp, const char *file) @@ -152,13 +152,14 @@ int reboot(const struct flashparams *fp) { size_t tsize = fp->blksz + fp->cmdsz; unsigned char *cmd = malloc(tsize); + memset(cmd, 0x00, tsize - 3); + memset(cmd, 0xff, 3); usbopen(); - - fmtcmd(cmd, fp, SIZE_MAX); usbsendcmd(cmd, tsize, true); - usbclose(); + free(cmd); + return 0; } |