make sure g_bsp_rom_registers is not dropped by linker in cmake build.

always reserve 0x100 for option setting in linker to prevent possible bricked mcu
This commit is contained in:
hathach
2024-12-16 22:03:06 +07:00
parent 380bfc0a63
commit 656772fc9d
8 changed files with 26 additions and 1 deletions

View File

@@ -173,6 +173,9 @@ SECTIONS
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400; . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
KEEP(*(.rom_registers*)) KEEP(*(.rom_registers*))
/* Reserving 0x100 bytes of space for ROM registers. */
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
/* Allocate flash write-boundary-aligned /* Allocate flash write-boundary-aligned
* space for sce9 wrapped public keys for mcuboot if the module is used. * space for sce9 wrapped public keys for mcuboot if the module is used.
*/ */

View File

@@ -173,6 +173,9 @@ SECTIONS
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400; . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
KEEP(*(.rom_registers*)) KEEP(*(.rom_registers*))
/* Reserving 0x100 bytes of space for ROM registers. */
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
/* Allocate flash write-boundary-aligned /* Allocate flash write-boundary-aligned
* space for sce9 wrapped public keys for mcuboot if the module is used. * space for sce9 wrapped public keys for mcuboot if the module is used.
*/ */

View File

@@ -173,6 +173,9 @@ SECTIONS
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400; . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
KEEP(*(.rom_registers*)) KEEP(*(.rom_registers*))
/* Reserving 0x100 bytes of space for ROM registers. */
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
/* Allocate flash write-boundary-aligned /* Allocate flash write-boundary-aligned
* space for sce9 wrapped public keys for mcuboot if the module is used. * space for sce9 wrapped public keys for mcuboot if the module is used.
*/ */

View File

@@ -173,6 +173,9 @@ SECTIONS
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400; . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
KEEP(*(.rom_registers*)) KEEP(*(.rom_registers*))
/* Reserving 0x100 bytes of space for ROM registers. */
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
/* Allocate flash write-boundary-aligned /* Allocate flash write-boundary-aligned
* space for sce9 wrapped public keys for mcuboot if the module is used. * space for sce9 wrapped public keys for mcuboot if the module is used.
*/ */

View File

@@ -173,6 +173,9 @@ SECTIONS
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400; . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
KEEP(*(.rom_registers*)) KEEP(*(.rom_registers*))
/* Reserving 0x100 bytes of space for ROM registers. */
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
/* Allocate flash write-boundary-aligned /* Allocate flash write-boundary-aligned
* space for sce9 wrapped public keys for mcuboot if the module is used. * space for sce9 wrapped public keys for mcuboot if the module is used.
*/ */

View File

@@ -177,6 +177,9 @@ SECTIONS
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400; . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
KEEP(*(.rom_registers*)) KEEP(*(.rom_registers*))
/* Reserving 0x100 bytes of space for ROM registers. */
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
/* Allocate flash write-boundary-aligned /* Allocate flash write-boundary-aligned
* space for sce9 wrapped public keys for mcuboot if the module is used. * space for sce9 wrapped public keys for mcuboot if the module is used.
*/ */

View File

@@ -173,6 +173,9 @@ SECTIONS
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400; . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
KEEP(*(.rom_registers*)) KEEP(*(.rom_registers*))
/* Reserving 0x100 bytes of space for ROM registers. */
. = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
/* Allocate flash write-boundary-aligned /* Allocate flash write-boundary-aligned
* space for sce9 wrapped public keys for mcuboot if the module is used. * space for sce9 wrapped public keys for mcuboot if the module is used.
*/ */

View File

@@ -54,7 +54,6 @@ function(add_board_target BOARD_TARGET)
${FSP_RA}/src/bsp/mcu/all/bsp_io.c ${FSP_RA}/src/bsp/mcu/all/bsp_io.c
${FSP_RA}/src/bsp/mcu/all/bsp_irq.c ${FSP_RA}/src/bsp/mcu/all/bsp_irq.c
${FSP_RA}/src/bsp/mcu/all/bsp_register_protection.c ${FSP_RA}/src/bsp/mcu/all/bsp_register_protection.c
${FSP_RA}/src/bsp/mcu/all/bsp_rom_registers.c
${FSP_RA}/src/bsp/mcu/all/bsp_sbrk.c ${FSP_RA}/src/bsp/mcu/all/bsp_sbrk.c
${FSP_RA}/src/bsp/mcu/all/bsp_security.c ${FSP_RA}/src/bsp/mcu/all/bsp_security.c
${FSP_RA}/src/r_ioport/r_ioport.c ${FSP_RA}/src/r_ioport/r_ioport.c
@@ -125,12 +124,17 @@ function(family_configure_example TARGET RTOS)
# BSP # BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
# Explicitly added bsp_rom_registers here, otherwise MCU can be bricked if g_bsp_rom_registers is dropped by linker
${FSP_RA}/src/bsp/mcu/all/bsp_rom_registers.c
) )
target_include_directories(${TARGET} PUBLIC target_include_directories(${TARGET} PUBLIC
# family, hw, board # family, hw, board
${CMAKE_CURRENT_FUNCTION_LIST_DIR} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
) )
target_compile_options(${TARGET} PUBLIC
-Wno-error=undef
)
# # RA has custom freertos port # # RA has custom freertos port
# if (NOT TARGET freertos_kernel_port) # if (NOT TARGET freertos_kernel_port)