qemu reports wrong info via SYS_HEAPINFO RDI monitor command to newlib startup code?
Hi,
I have a problem which might be related to qemu, semihosting on arm or newlib or to my compiler settings or it could be just my ignorance... I try to run a small application in qemu v2.0.50.0, compiled with gcc-arm-
I invoke qemu using the following command line:
qemu-system-arm.exe -M lm3s6965evb -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -kernel hello-CM3.elf -gdb tcp::1234,ipv4 -S
hello-CM3.elf is compiled and linked using the following compiler settings:
arm-none-eabi-gcc hello.c -mthumb -mcpu=cortex-m3 -Os -flto -ffunction-sections -fdata-sections --specs=nano.specs --specs=
where gcc.ld is the default linker description file from the compiler's examples folder: "share/
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}
I use eclipse CDT's embedded hardware debugger plug-in and the compiler's arm-none-eabi-gdb tool to debug the application via qemu. I can successfully connect to qemu from eclipse and I am able to debug the start-up code of the compiled application in assembler mode right from the entry point. The stack and the application entry point is read and configured by qemu from the elf executable image.
The start-up code of newlib(-nano) implemented in crt0.S (.../gcc-
__heap_base: 0x4000000
__heap_limit: 0x8000000
__stack_base: 0x8000000
__stack_limit: 0x0000000
The above information is somewhat hard-coded into qemu's arm_semi.c module. I have tried other machine types too and I always get this information whatever I tried...
Based on the above information the stack pointer (SP) is set to 0x8000000 by the start-up code and this is where my problem starts... according to my knowledge, the available RAM memory area of the lm3s6965evb qemu machine type is 64K only and the RAM address space starts at 0x20000000. In eclipse I can modify the memory area at 0x20000000. I can write new values and read them back. When the first function is entered by the start-up code which uses the stack, called initialise_
Why qemu reports to my application those hard-coded heap and stack memory pool data when they does not really exist? Why does newlib's start-up code set a new stack pointer based on SYS_HEAPINFO when it already has a valid value configured into it by the reset sequence?
Am I missing or misunderstanding something? Do I have to configure qemu in a different way?
Is there a way to figure out via GDB or via qemu command line parameters the actual memory map of the simulated machine?
Based on armv7m_init() in qemu's source code I would say that my linker settings are correct for my application.
Any help would be very welcome, thank you in advance for your kind support.
Best regards,
Tamas
_
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Tamas Kleiber
- Solved:
- Last query:
- Last reply: