From d7b9eb6b63e073238480cb2a95b0cf529e17541a Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 8 Aug 2020 02:33:49 -0400 Subject: [PATCH] ROLO - Enable multiboot firmware I never added multiboot awareness to ROLO When a new firmware file was loaded [Bootdata] would not be copied to the new instance resulting in the firmware running off the internal drive till next reboot Bootloaders shares the rb-loader code but should not be affected by the removal of static from write_bootdata() Change-Id: Iccb18eebeee5c59f9534df51eb6826876c441762 --- firmware/common/rb-loader.c | 2 +- firmware/rolo.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/firmware/common/rb-loader.c b/firmware/common/rb-loader.c index 8bf553a3a8..1ded8c2335 100644 --- a/firmware/common/rb-loader.c +++ b/firmware/common/rb-loader.c @@ -36,7 +36,7 @@ * Returns payload len on success, * On error returns EKEY_NOT_FOUND */ -static int write_bootdata(unsigned char* buf, int len, unsigned int boot_volume) +int write_bootdata(unsigned char* buf, int len, unsigned int boot_volume) { struct boot_data_t bl_boot_data; struct boot_data_t *fw_boot_data = NULL; diff --git a/firmware/rolo.c b/firmware/rolo.c index 9a527e9074..769346662b 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c @@ -48,6 +48,11 @@ #define LOAD_FIRMWARE(a,b,c) load_rkw(a,b,c) #else #include "rb-loader.h" +#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) +#include "bootdata.h" +#include "crc32.h" +extern int write_bootdata(unsigned char* buf, int len, unsigned int boot_volume); /*rb-loader.c*/ +#endif #define LOAD_FIRMWARE(a,b,c) load_firmware(a,b,c) #endif @@ -236,6 +241,15 @@ int rolo_load(const char* filename) filebuf = core_get_data(rolo_handle); 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_bootdata(filebuf, filebuf_size, boot_data.boot_volume); /* rb-loader.c */ +#endif if (err <= 0) {