diff --git a/libraries/AP_HAL_ChibiOS/Util.cpp b/libraries/AP_HAL_ChibiOS/Util.cpp index a5b3bee893..82cfdc1e0f 100644 --- a/libraries/AP_HAL_ChibiOS/Util.cpp +++ b/libraries/AP_HAL_ChibiOS/Util.cpp @@ -233,7 +233,7 @@ bool Util::flash_bootloader() EXPECT_DELAY_MS(11000); - uint8_t *fw = AP_ROMFS::find_decompress(fw_name, fw_size); + const uint8_t *fw = AP_ROMFS::find_decompress(fw_name, fw_size); if (!fw) { hal.console->printf("failed to find %s\n", fw_name); return false; @@ -242,14 +242,14 @@ bool Util::flash_bootloader() const uint32_t addr = hal.flash->getpageaddr(0); if (!memcmp(fw, (const void*)addr, fw_size)) { hal.console->printf("Bootloader up-to-date\n"); - free(fw); + AP_ROMFS::free(fw); return true; } hal.console->printf("Erasing\n"); if (!hal.flash->erasepage(0)) { hal.console->printf("Erase failed\n"); - free(fw); + AP_ROMFS::free(fw); return false; } hal.console->printf("Flashing %s @%08x\n", fw_name, (unsigned int)addr); @@ -264,12 +264,12 @@ bool Util::flash_bootloader() continue; } hal.console->printf("Flash OK\n"); - free(fw); + AP_ROMFS::free(fw); return true; } hal.console->printf("Flash failed after %u attempts\n", max_attempts); - free(fw); + AP_ROMFS::free(fw); return false; } #endif // !HAL_NO_FLASH_SUPPORT && !HAL_NO_ROMFS_SUPPORT diff --git a/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat index ce3fc3bba6..2b3bc6999b 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat @@ -146,3 +146,7 @@ env APP_DESCRIPTOR MissionPlanner RAM_RESERVE_START 256 # define CH_DBG_ENABLE_STACK_CHECK TRUE + +# keep ROMFS uncompressed as we don't have enough RAM +# to uncompress the bootloader at runtime +env ROMFS_UNCOMPRESSED True diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 06cc5d375f..7a0f7d8ed9 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -673,6 +673,8 @@ def write_mcu_config(f): #define HAL_USE_I2C FALSE #define HAL_USE_PWM FALSE ''') + if env_vars.get('ROMFS_UNCOMPRESSED', False): + f.write('#define HAL_ROMFS_UNCOMPRESSED\n') def write_ldscript(fname): '''write ldscript.ld for this board'''