From 6ffd42548bf10cda13a01555ff4fa56d4213cdf2 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Thu, 22 Dec 2022 19:23:29 +0000 Subject: multiboot: Refactor boot data validation, add version numbers Instead of verifying the CRC before every access of the boot data, verify the CRC once at startup and set a flag to indicate the boot data is valid. Also add a framework to support multiple boot protocol versions. Firmware declares the maximum supported protocol version using a version byte in the boot data header. The bootloader chooses the highest version supported by it and the firmware when deciding what boot protocol to use. Change-Id: I810194625dc0833f026d2a23b8d64ed467fa6aca --- firmware/rolo.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'firmware/rolo.c') diff --git a/firmware/rolo.c b/firmware/rolo.c index a3e6d5c2b9..1b37b6f771 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c @@ -250,12 +250,9 @@ int rolo_load(const char* filename) err = LOAD_FIRMWARE(filebuf, filename, filebuf_size); #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) - /* write the bootdata as if rolo were the bootloader */ - unsigned int crc = 0; - if (strcmp(filename, BOOTDIR "/" BOOTFILE) == 0) - crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff); - - if(crc > 0 && crc == boot_data.crc) + /* write the bootdata as if rolo were the bootloader + * FIXME: this won't work for root redirect... */ + if (!strcmp(filename, BOOTDIR "/" BOOTFILE) && boot_data_valid) write_bootdata(filebuf, filebuf_size, boot_data.boot_volume); /* rb-loader.c */ #endif -- cgit v1.2.3