Hello,
I'm having an issue debugging using an elf file compiled and linked with GNU ARM Embedded toolchain using GCC >= 5 (). The issue is not present in GNU ARM toolchain using GCC 4.9.
I'm not sure if this is the right forum, but at least I can share my findings with you.
Our flash layout reserves 0x8000 bytes at the start of the flash (0x08000000) for a bootloader.
Display All
When debugging the application directly (ie. the bootloader is not executed) we expect the PC to be set to the application Reset_Handler function in the Ozone Event handler AfterTargetDownload()
Display All
However, both PC and SP is set to zero.
Ozone console:
Elf.GetBaseAddr();
Target.SetReg ("SP", 0x0);
Target.SetReg ("PC", 0x0);
Here's a dump from readelf()
Display All
I'm no expert on elf files, but it seems that "Flags" is missing the "has entry point" (Flags should have been 0x5000402) which might cause Elf.GetBaseAddr() to return 0. When using GCC 4.9 using the same source/linker script "has entry point" is set.
As a workaround, I hardcoded VectorTableAddr to 0x08008000 in the Ozone project file, but it would be nice to know if I am doing anything wrong or missing an obvious gotcha.
I'm having an issue debugging using an elf file compiled and linked with GNU ARM Embedded toolchain using GCC >= 5 (). The issue is not present in GNU ARM toolchain using GCC 4.9.
I'm not sure if this is the right forum, but at least I can share my findings with you.
Our flash layout reserves 0x8000 bytes at the start of the flash (0x08000000) for a bootloader.
Source Code
When debugging the application directly (ie. the bootloader is not executed) we expect the PC to be set to the application Reset_Handler function in the Ozone Event handler AfterTargetDownload()
Source Code
- void AfterTargetDownload (void) {
- unsigned int SP;
- unsigned int PC;
- unsigned int VectorTableAddr;
- VectorTableAddr = Elf.GetBaseAddr();
- if (VectorTableAddr == 0xFFFFFFFF) {
- Util.Log("Project file error: failed to get program base");
- } else {
- SP = Target.ReadU32(VectorTableAddr);
- Target.SetReg("SP", SP);
- PC = Target.ReadU32(VectorTableAddr + 4);
- Target.SetReg("PC", PC);
- }
- }
Ozone console:
Elf.GetBaseAddr();
Target.SetReg ("SP", 0x0);
Target.SetReg ("PC", 0x0);
Here's a dump from readelf()
Source Code
- arm-none-eabi-readelf -h artifacts\app_gcc_5.2.elf
- ELF Header:
- Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
- Class: ELF32
- Data: 2's complement, little endian
- Version: 1 (current)
- OS/ABI: UNIX - System V
- ABI Version: 0
- Type: EXEC (Executable file)
- Machine: ARM
- Version: 0x1
- Entry point address: 0x803e859
- Start of program headers: 52 (bytes into file)
- Start of section headers: 15229296 (bytes into file)
- Flags: 0x5000400, Version5 EABI, hard-float ABI
- Size of this header: 52 (bytes)
- Size of program headers: 32 (bytes)
- Number of program headers: 7
- Size of section headers: 40 (bytes)
- Number of section headers: 41
- Section header string table index: 38
As a workaround, I hardcoded VectorTableAddr to 0x08008000 in the Ozone project file, but it would be nice to know if I am doing anything wrong or missing an obvious gotcha.