You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
The memory map for the RP2040 in probe-rs describes a 256 KiB block at 0x2000_0000 (SRAM_REGION_0 .. SRAM_REGION_3, striped) and then two 4 KiB blocks at 0x2004_0000 (SRAM_REGION_4) and 0x2004_1000 (SRAM_REGION_5).
probe-rs finds the reset stack pointer, and then assumes that the stack must lie within a single memory region.
I have written an application where the top of stack is at 0x2004_1000 and I have 8 KiB of space allocated - 4 KiB from a SRAM_REGION_4 and then 4 KiB from the top of the striped region. The regions are consecutive, so this works fine.
However, probe-run tells me I only have 4096 bytes of stack (not 8192 bytes) and thus tells me I have used all of my stack, when I have not.
To Reproduce
Steps to reproduce the behavior:
memory.x:
MEMORY {
/*
* This is bootloader for the RP2040. It must live at the start of the
external flash chip.
*/
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
/*
* The Pico has 2048 KiB of external Flash Memory. We allow ourselves 128
* KiB for the BIOS, leaving the rest
* for the OS and any user applications.
*/
FLASH : ORIGIN = 0x10000100, LENGTH = 128K - 0x100
/*
* This is the remainder of the 2048 KiB flash chip.
*/
FLASH_OS : ORIGIN = 0x10020000, LENGTH = 2048K - 128K
/*
* This is the bottom of the four striped banks of SRAM in the RP2040.
*/
RAM_OS : ORIGIN = 0x20000000, LENGTH = 0x39000
/*
* This is the top of the four striped banks of SRAM in the RP2040.
*
* We give ourselves size 4K pages [0x39_000..0x3E_FFF]
*/
RAM : ORIGIN = 0x20039000, LENGTH = 24K
/*
* This 4K from the top of striped RAM, plus the fifth bank - another a 4KB
* block. We use this for Core 0 Stack. We tried 4K but it wasn't enough.
*/
RAM_CORE0_STACK : ORIGIN = 0x2003F000, LENGTH = 8K
/*
* This is the sixth bank, a 4KB block. We use this for Core 1 Stack.
* As of 0.5.1 Pico BIOS uses about 316 bytes of this but we give it the
* full 4K so it can have uncontended access to this SRAM bank.
*/
RAM_CORE1_STACK : ORIGIN = 0x20041000, LENGTH = 4K
}
/*
* This is where the call stack for Core 0 will be located. The stack is of
* the full descending type. You may want to use this variable to locate the
* call stack and static variables in different memory regions.
*/
_stack_start = ORIGIN(RAM_CORE0_STACK) + LENGTH(RAM_CORE0_STACK);
_stack_bottom = ORIGIN(RAM_CORE0_STACK);
_stack_len = LENGTH(RAM_CORE0_STACK);
Expected and observed behavior
probe-run could:
Realise that memory regions may be contiguous and a stack may spread across them
Use the symbol table to find where each value in memory lives.
Start at the stack top and work downwards until it hits a discontinuity in the memory regions, or it hits memory allocated for a variable.
config.toml
The contents of your project's .cargo/config.toml file
[target.thumbv6m-none-eabi]
# This will make a UF2 and copy it to the RP2040's Mass Storage Device bootloader# runner = "elf2uf2-rs -d"# This will flash over SWD with any compatible probe it finds. You need 0.3.1 or higher for RP2040 support.runner = "probe-run --chip RP2040 --measure-stack"rustflags = [
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95"-C",
"link-arg=--nmagic",
# LLD (shipped with the Rust toolchain) is used as the default linker"-C",
"link-arg=-Tlink.x",
# Support defmt formatted logging"-C",
"link-arg=-Tdefmt.x",
]
[build]
target = "thumbv6m-none-eabi"# Cortex-M0 and Cortex-M0+
Describe the bug
The memory map for the RP2040 in probe-rs describes a 256 KiB block at
0x2000_0000
(SRAM_REGION_0 .. SRAM_REGION_3, striped) and then two 4 KiB blocks at0x2004_0000
(SRAM_REGION_4) and0x2004_1000
(SRAM_REGION_5).probe-rs finds the reset stack pointer, and then assumes that the stack must lie within a single memory region.
I have written an application where the top of stack is at
0x2004_1000
and I have 8 KiB of space allocated - 4 KiB from a SRAM_REGION_4 and then 4 KiB from the top of the striped region. The regions are consecutive, so this works fine.However, probe-run tells me I only have 4096 bytes of stack (not 8192 bytes) and thus tells me I have used all of my stack, when I have not.
To Reproduce
Steps to reproduce the behavior:
memory.x:
Expected and observed behavior
probe-run could:
config.toml
The contents of your project's
.cargo/config.toml
fileProbe details
Operating System:
Linux
The text was updated successfully, but these errors were encountered: