A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

mkboot: fix the buffer size used for constructing the final firmware image

It was short by a fair number of bytes which could be reached when
attempting to insert bootloaders near the maximum size of 64k. This
ensures even the largest acceptable bootloader will not overflow the
buffer.

Change-Id: I8fbc92d4e3452192bf47104d7a32b49248eefc0e

+13 -1
+13 -1
tools/mkboot.c
··· 23 23 #include <string.h> 24 24 #include "mkboot.h" 25 25 26 + #define SECTOR_SIZE 0x200 27 + #define RAW_IMAGE_SIZE 0x400000 28 + #define TOTAL_IMAGE_SIZE (RAW_IMAGE_SIZE + HEADER2_SIZE) 29 + #define ALIGNED_IMAGE_SIZE (TOTAL_IMAGE_SIZE + SECTOR_SIZE - (TOTAL_IMAGE_SIZE % SECTOR_SIZE)) 30 + #define HEADER1_SIZE SECTOR_SIZE 31 + #define HEADER2_SIZE 0x20 32 + 26 33 #ifndef RBUTIL 27 34 static void usage(void) 28 35 { ··· 63 70 } 64 71 #endif 65 72 66 - static unsigned char image[0x400000 + 0x220 + 0x400000/0x200]; 73 + /* 74 + * initial header size plus 75 + * the rounded up size (includes the raw data and its length header) plus 76 + * the checksums for the raw data and its length header 77 + */ 78 + static unsigned char image[ALIGNED_IMAGE_SIZE + HEADER1_SIZE + ALIGNED_IMAGE_SIZE / SECTOR_SIZE]; 67 79 68 80 int mkboot_iriver(const char* infile, const char* bootfile, const char* outfile, int origin) 69 81 {