From 67f2e870c1582a2fb71540067cabaa170387488d Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sat, 23 Nov 2024 14:51:29 -0800 Subject: [PATCH] Finish linker script --- .../TOOLCHAIN_GCC_ARM/memmap_default_mbed.ld | 22 ++++++++++++------- .../TARGET_RP2040/flash_api.c | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default_mbed.ld b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default_mbed.ld index 883fdbdffa6..f98d891ff2c 100644 --- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default_mbed.ld +++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default_mbed.ld @@ -37,8 +37,17 @@ MEMORY * Scratch banks are commonly used for critical data and functions accessed only by one core (when only * one core is accessing the RAM bank, there is no opportunity for stalls). */ - SCRATCH_X(rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_SCRATCH_X_START, LENGTH = MBED_CONFIGURED_RAM_BANK_SCRATCH_X_SIZE - SCRATCH_Y(rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_SCRATCH_Y_START, LENGTH = MBED_CONFIGURED_RAM_BANK_SCRATCH_Y_SIZE + SCRATCH_X(rwx) : ORIGIN = MBED_RAM_BANK_SCRATCH_X_START, LENGTH = MBED_RAM_BANK_SCRATCH_X_SIZE + SCRATCH_Y(rwx) : ORIGIN = MBED_RAM_BANK_SCRATCH_Y_START, LENGTH = MBED_RAM_BANK_SCRATCH_Y_SIZE + +/* If we are at the start of RAM, we are core 0. Otherwise we are core 1. */ +#if MBED_CONFIGURED_RAM_BANK_IRAM1_START == MBED_RAM_BANK_IRAM1_START +#define STACK_SCRATCH SCRATCH_X +#define STACK_SCRATCH_STATIC_END_SYMBOL __scratch_x_end__ +#else +#define STACK_SCRATCH SCRATCH_Y +#define STACK_SCRATCH_STATIC_END_SYMBOL __scratch_y_end__ +#endif } ENTRY(_entry_point) @@ -221,21 +230,18 @@ SECTIONS } > RAM /* Check if data + heap exceeds RAM limit */ - ASSERT(__HeapLimit >= ORIGIN(RAM) + LENGTH(RAM), "region RAM overflowed") + ASSERT(__end__ < ORIGIN(RAM) + LENGTH(RAM), "region RAM overflowed") .flash_end : { PROVIDE(__flash_binary_end = .); } > FLASH - /* stack limit is poorly named, but historically is maximum heap ptr */ - __StackTop = ORIGIN(SCRATCH) + LENGTH(SCRATCH_Y); + __StackTop = ORIGIN(STACK_SCRATCH) + LENGTH(STACK_SCRATCH); __StackLimit = __StackTop - MBED_CONF_TARGET_BOOT_STACK_SIZE; __StackBottom = __StackLimit; + ASSERT(__StackLimit >= STACK_SCRATCH_STATIC_END_SYMBOL, "stack scratch region overflowed") PROVIDE(__stack = __StackTop); - /* Check if data + heap + stack exceeds RAM limit */ - ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") - ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") /* todo assert on extra code */ } \ No newline at end of file diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c index ff8ddc8e54d..969e9eefc54 100644 --- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c +++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c @@ -88,7 +88,7 @@ uint32_t flash_get_size(const flash_t *obj) { (void)(obj); - return PICO_FLASH_SIZE_BYTES; + return MBED_ROM_BANK_QSPI_FLASH_SIZE; } uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)