This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Data Integrity Issue with Custom .rawdata Section in Linker Script on ARM Cortex-M4

I'm working on an embedded project using an **ARM Cortex-M4** processor (specifically, an `STM32F4` microcontroller) and I've encountered a peculiar issue related to memory sections defined in my linker script. I'm using the `arm-none-eabi-gcc` toolchain for compilation.

I have a binary file that I want to include in my firmware. I've created a custom section (`.rawdata`) in my assembly file to include this binary file, and I've modified my `linker script` to place this section in the `Flash` memory. However, I'm facing an issue with the integrity of the data in the .rawdata section during runtime.

When I place the `.rawdata` section within the `.data` section or in the `.text` section in my `linker script`, everything works as expected: the data is correctly allocated in memory, and the actual data is stored correctly. I can access and print the data during runtime without any issues.

However, when I try to create a standalone `.rawdata` section (outside of `.data`) or place it within the `.text` section, the data seems to be allocated, but the content is not what I expect. During runtime, when I print the content of the `.rawdata` section, I get incorrect values (not matching the original `.bin` content).
Interestingly, when I inspect the `.elf` file using `arm-none-eabi-objdump`, the `.rawdata` section appears to contain the correct data. This discrepancy only occurs during runtime.

Linker Script Snippet:

ld
.rawdata :
{
. = ALIGN(4);
_mstart = .;
KEEP(*(.rawdata))
. = ALIGN(4);
_mend = .;
} >FLASH


Why does placing the `.rawdata` section inside the `.data` section work correctly, but creating it as a standalone section leads to incorrect runtime data?
Is there a specific consideration or configuration I'm missing for custom sections in the linker script for **ARM Cortex-M4** processors?

How can I ensure that the `.rawdata` section's data remains intact during runtime when it's defined outside the .data section?

Any insights or suggestions on how to resolve this issue would be greatly appreciated. Thank you in advance for your help!