I am trying to initalize the RAM of a microcontroller (STM32F429I-DISC1) with a Hexspeak value (e.g. DEADBEEF). In C it worked by adding following lines to the linker script:
My first idea was to change the memory.x file, but I don't know the exact syntax to initialize the RAM like I did in C. My memory.x file currently looks like this:
MEMORY
{
/* NOTE K = KiBi = 1024 bytes */
FLASH : ORIGIN = 0x08000000, LENGTH = 2M
RAM : ORIGIN = 0x20000000, LENGTH = 192K
}
/* This is where the call stack will be allocated. */
/* The stack is of the full descending type. */
/* NOTE Do NOT modify `_stack_start` unless you know what you are doing */
_stack_start = ORIGIN(RAM) + LENGTH(RAM);
Yes, I already tried that but i get the following error while building:
"<user>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/libcompiler_builtins-09c3e5620e7b76e8.rlib" "-Tlink.x" "-Bdynamic"
= note: rust-lld: error: memory.x:8: unknown directive: .fill
>>> .fill :
>>> ^
error: aborting due to previous error; 3 warnings emitted
error: could not compile `stm32f429i-disc
To your question: My goal isn't to compare the the RAM fill speed. I want to determine the maximum heap workload. By overwriting the whole RAM with a hexspeak value I can see how many values changed after my program finished. The number of changed values then describes how high the workload is.
@bjorn3 is correct. I forgot that the GNU linker supports some options that the default Rust linker doesn't. In order to switch to the GNU linker, see Configuration - The Cargo Book
Sorry for my late response, I was trying to make it work.
At the end, like you said, the linker was the problem. I updated the rustflags in the config file to use the same linker I used in C. After that, my memory got filled as expected.
Thanks for the help