armstm32armv7linker-scripts

How to store some uninitialized address space for data storage in DTCM in assembly code (ARM-v7, STMCubeIDE)?


I have some initialized data that I store in the .data section. Then I use uninitialized address space using the .bss section. I have the DTCM enabled and I can store and read data from there via __attribute__((section(".dtcm"))) when written in C code, and this confirms that my linker script is properly set up. However, I don't know what the equivalent expression is for using the address space in assembly code. I don't want to store the whole .bss section in DTCM, just a subset of data on which I wish to have faster access. How is this done?

Is there an authoritative document for assembly coding ARM ASM? I've used this so far and it's been very useful but it doesn't cover my case in general and tightly coupled memory in particular.

FWIW, this is for an STM32H745.


Solution

  • Firstly, note that the .bss section is zero-initialized, not uninitialized.

    In assembly you can write .section .dtcm. Since this is not a standard section name, you should probably set the flags to let the linker know what type of segment the section can be allocated to, eg: .section .dtcm, "aw", %nobits

    You will want to read the GNU as manual for details of the .section directive.

    This ARM community blog post may be helpful as well.