diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/chibios_board.mk b/libraries/AP_HAL_ChibiOS/hwdef/common/chibios_board.mk index 14382747e7..5f2a87faaa 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/chibios_board.mk +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/chibios_board.mk @@ -250,6 +250,10 @@ endif # Define ASM defines here UADEFS = +ifeq ($(COPY_VECTORS_TO_RAM),yes) + UADEFS += -DCRT0_INIT_VECTORS=1 +endif + # List all user directories here UINCDIR = diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index a4f77ac8ff..4bb546ffb1 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1292,12 +1292,25 @@ MEMORY INCLUDE common.ld ''' % (flash_base, flash_length, ram0_start, ram0_len)) - else: + elif int_flash_primary: if ext_flash_size > 32: error("We only support 24bit addressing over external flash") env_vars['HAS_EXTERNAL_FLASH_SECTIONS'] = 1 f.write('''/* generated ldscript.ld */ MEMORY +{ + flash : org = 0x%08x, len = %uK + ext_flash : org = 0x%08x, len = %uK + ram0 : org = 0x%08x, len = %u +} + +INCLUDE common_mixf.ld +''' % (flash_base, flash_length, ext_flash_base, ext_flash_length, ram0_start, ram0_len)) + else: + self.env_vars['HAS_EXTERNAL_FLASH_SECTIONS'] = 1 + self.build_flags.append('COPY_VECTORS_TO_RAM=yes') + f.write('''/* generated ldscript.ld */ +MEMORY { default_flash (rx) : org = 0x%08x, len = %uK instram : org = 0x%08x, len = %uK