Browse Source

HAL_ChibiOS: support uncompressed bootloader on f103-periph

this allows update with very low memory
master
Andrew Tridgell 5 years ago
parent
commit
49e669aa1f
  1. 10
      libraries/AP_HAL_ChibiOS/Util.cpp
  2. 4
      libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat
  3. 2
      libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py

10
libraries/AP_HAL_ChibiOS/Util.cpp

@ -233,7 +233,7 @@ bool Util::flash_bootloader()
EXPECT_DELAY_MS(11000); 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) { if (!fw) {
hal.console->printf("failed to find %s\n", fw_name); hal.console->printf("failed to find %s\n", fw_name);
return false; return false;
@ -242,14 +242,14 @@ bool Util::flash_bootloader()
const uint32_t addr = hal.flash->getpageaddr(0); const uint32_t addr = hal.flash->getpageaddr(0);
if (!memcmp(fw, (const void*)addr, fw_size)) { if (!memcmp(fw, (const void*)addr, fw_size)) {
hal.console->printf("Bootloader up-to-date\n"); hal.console->printf("Bootloader up-to-date\n");
free(fw); AP_ROMFS::free(fw);
return true; return true;
} }
hal.console->printf("Erasing\n"); hal.console->printf("Erasing\n");
if (!hal.flash->erasepage(0)) { if (!hal.flash->erasepage(0)) {
hal.console->printf("Erase failed\n"); hal.console->printf("Erase failed\n");
free(fw); AP_ROMFS::free(fw);
return false; return false;
} }
hal.console->printf("Flashing %s @%08x\n", fw_name, (unsigned int)addr); hal.console->printf("Flashing %s @%08x\n", fw_name, (unsigned int)addr);
@ -264,12 +264,12 @@ bool Util::flash_bootloader()
continue; continue;
} }
hal.console->printf("Flash OK\n"); hal.console->printf("Flash OK\n");
free(fw); AP_ROMFS::free(fw);
return true; return true;
} }
hal.console->printf("Flash failed after %u attempts\n", max_attempts); hal.console->printf("Flash failed after %u attempts\n", max_attempts);
free(fw); AP_ROMFS::free(fw);
return false; return false;
} }
#endif // !HAL_NO_FLASH_SUPPORT && !HAL_NO_ROMFS_SUPPORT #endif // !HAL_NO_FLASH_SUPPORT && !HAL_NO_ROMFS_SUPPORT

4
libraries/AP_HAL_ChibiOS/hwdef/f103-periph/hwdef.dat

@ -146,3 +146,7 @@ env APP_DESCRIPTOR MissionPlanner
RAM_RESERVE_START 256 RAM_RESERVE_START 256
# define CH_DBG_ENABLE_STACK_CHECK TRUE # 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

2
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_I2C FALSE
#define HAL_USE_PWM FALSE #define HAL_USE_PWM FALSE
''') ''')
if env_vars.get('ROMFS_UNCOMPRESSED', False):
f.write('#define HAL_ROMFS_UNCOMPRESSED\n')
def write_ldscript(fname): def write_ldscript(fname):
'''write ldscript.ld for this board''' '''write ldscript.ld for this board'''

Loading…
Cancel
Save