Closed paolok17 closed 2 years ago
It looks like what is happening is that the .dma section is defined in your linker script in such a way that makes it look like neither your .data or .bss section. It has initial contents that are non-zero but weren't loaded into FLASH to be copied into RAM from the startup code.
What do you expect the initial contents of the globals/statics in this .dma section to be?
To me it looks like the linker script is written in such a way that globals placed in the .dma section should be considered uninitialized when main() starts but one of the globals given an attribute to be placed in this section is also assigned an explicit non-zero value in its definition. Given that this initial data didn't make it into the FLASH of the device, I doubt you have modified startup code which actually initializes it to match those non-zero values either.
You probably need to fix the definitions of the globals placed in this section to not have non-zero initializers. Get rid of the '=' signs from their definitions and if they need initial values then write code that explicitly initializes them as expected.
Hi Adam, thank you for the quick feedback.
All the dma buffers are global/statics without initializers, eg:
static uint8_t ep0tempbuf[MAXDESCRBUF] __attribute__((section(".dma"), aligned(32)));
Usually they would go in .bss section but we assign them to .dma where we don't care about initialization.
From objdump the first 0x40A0 bytes of the section seem to be zero initialized:
objdump -s -j .dma filename.elf
Contents of section .dma:
20078000 00000000 00000000 00000000 00000000 ................
20078010 00000000 00000000 00000000 00000000 ................
20078020 00000000 00000000 00000000 00000000 ................
20078030 00000000 00000000 00000000 00000000 ................
20078040 00000000 00000000 00000000 00000000 ................
20078050 00000000 00000000 00000000 00000000 ................
20078060 00000000 00000000 00000000 00000000 ................
20078070 00000000 00000000 00000000 00000000 ................
[...]
2007c020 00000000 00000000 00000000 00000000 ................
2007c030 00000000 00000000 00000000 00000000 ................
2007c040 00000000 00000000 00000000 00000000 ................
2007c050 00000000 00000000 00000000 00000000 ................
2007c060 00000000 00000000 00000000 00000000 ................
2007c070 00000000 00000000 00000000 00000000 ................
2007c080 00000000 00000000 00000000 00000000 ................
2007c090 00000000 00000000 00000000 00000000 ................
This is an excerpt of the linker script:
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(8);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(8);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
[...]
/* this rule places the .dma buffers into the DMA area of RAM */
.dma :
{
*(.dma)
} > DMARAM
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
Can you try adding the NOLOAD type for the dma section in the script? Like this:
/* this rule places the .dma buffers into the DMA area of RAM */
.dma (NOLOAD):
{
*(.dma)
} > DMARAM
Hi, adding the NOLOAD attribute to .dma section solves the issue. Thank you!
This is the objdump after adding NOLOAD:
9 .data 0000be18 20000000 081086b0 000c8770 2**3
CONTENTS, ALLOC, LOAD, DATA
10 .dma 000040a0 20078000 20078000 000d4588 2**2
ALLOC
11 .bss 00049094 2000be18 2000be18 000d4588 2**3
ALLOC
Happy to hear that it worked.
Closing this issue.
When running CrashDebug passing an elf file an exception is thrown when loading dump data to .dma section. Passing the corresponding bin file works fine.
Command: arm-none-eabi-gdb filename.elf -ex "set target-charset ASCII" -ex "target remote | CrashDebug --elf filename.elf --dump crash_dump.log" Error: ERROR: The dump file failed to load RAM memory region at 0x20078000 - 0x20080000 [...] Encountered unexpected error: 19
elf file objdump excerpt :
crash_dump.log