Skip to content

Commit

Permalink
Finish linker script
Browse files Browse the repository at this point in the history
  • Loading branch information
multiplemonomials committed Nov 23, 2024
1 parent a5e3545 commit 67f2e87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
}
2 changes: 1 addition & 1 deletion targets/TARGET_RASPBERRYPI/TARGET_RP2040/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 67f2e87

Please sign in to comment.