Hello,
I am running baremetal programs on FVP. I compiled using llvm toolchain with baremetal support and created the .axf binaries under the debug directory of the project folder. This .axf executable Is something I like to test on morello board without any OS environment. when I tried to run the .axf binary on the board using the ARM development studio IDE morello edition, under the run> debug config> made the settings and when I I started debugging it gets stuck at the HLT instruction (when performing debug from symbol) or starting from the initial address and going into an infinite loop when starting from entry point. while on the terminal console I couldn't see the output of the printf statement which i was expecting. even if I try to run directly or debug it step by step. (the program is correct because I already tested on FVP) ..I am being redirected to the debug configuration. and iterating thru the same process as described without seeing the actual output on the terminal which I configured with the /dev/ttyusb2 115200 command. Any suggestions please.
I have also used the semihosting code
set semihosting heap-base 0set semihosting heap-limit 0x80800000set semihosting stack-limit 0x80800000set semihosting stack-base 0x81000000set semihosting enabled on
Hi,
I am not facing any exceptions presently. My program has been built with 0 errors and warnings and generated the .axf file. But then after loading it..Run>Debug Configuration..set the debugger from entry point and points to the axf file..it is getting stuck at HLT. and after further stepping it going to a loop...without showing the output on APP Console.
It said in the command:
And in the disassembly it is getting stuck to the HLT and further stepping is not working..the pointer got stuck at HLT.
Code execution should not stop at the HLT instruction if semihosting has been enabled correctly in the debugger. The debugger should trap the HLT instruction, then handle the semihosting request itself. The semihosting #0x16 call that you see in _start should read the stack/heap base/limit addresses from the debugger that you have set up.See github.com/.../semihosting.rstI suspect that semihosting has not been enabled correctly.You might need to set the address where the semihosting trap is placed, with, e.g.: set semihosting vector ADDR EL2N:0x200This command should be added in your script before where semihosting is enabled.
See developer.arm.com/.../set-semihostingIf you need more help, please attach a copy of the text from the Commands view, from the beginning to where the HLT instn triggers a halt.Stephen
Sure..here I am enclosing the command output. When I am setting the semihostin to on..what I noticed is it bypasses the HLT instruction and then enters into
a loop as shown in the disassembly view below: After which I interrupted the execution. If you suspect any other problem I can create a step by step of all the procedure I followed with screenshots and can create a document and post it.
The output of command is as shown below:
Connected to stopped target Arm - Morello SDPcd "/home/sanu/developmentstudio-workspace_2"Working directory "/home/sanu/developmentstudio-workspace_2"loadfile "/home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elf"Execution stopped in EL2h mode at EL2N:0x0000000000000200EL2N:0x0000000000000200 UDF #0Loaded section .rela.dyn: EL2N:0x0000000080000200 ~ EL2N:0x00000000800027F7 (size 0x25F8)Loaded section .rodata: EL2N:0x0000000080002800 ~ EL2N:0x0000000080002EDF (size 0x6E0)Loaded section .text: EL2N:0x0000000080013000 ~ EL2N:0x0000000080022B2B (size 0xFB2C)Loaded section .init: EL2N:0x0000000080022B2C ~ EL2N:0x0000000080022B5F (size 0x34)Loaded section .fini: EL2N:0x0000000080022B60 ~ EL2N:0x0000000080022B93 (size 0x34)Loaded section .data.rel.ro: EL2N:0x0000000080032BA0 ~ EL2N:0x00000000800330AF (size 0x510)Loaded section .init_array: EL2N:0x00000000800330B0 ~ EL2N:0x00000000800330BF (size 0x10)Loaded section .got: EL2N:0x00000000800330C0 ~ EL2N:0x00000000800333BF (size 0x300)Loaded section .data: EL2N:0x0000000080044000 ~ EL2N:0x0000000080048001 (size 0x4002)Loaded section .data.rel.ro: EL2N:0x0000000080032BA0 ~ EL2N:0x00000000800330AF (size 0x510)Loaded section .init_array: EL2N:0x00000000800330B0 ~ EL2N:0x00000000800330BF (size 0x10)Loaded section .got: EL2N:0x00000000800330C0 ~ EL2N:0x00000000800333BF (size 0x300)Entry point EL2N:0x0000000080013000add-symbol-file "/home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elf"ERROR(ITR575): Symbols for image /home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elf are already loaded at offset EL2N:0x0000000000000000set debug-from *$ENTRYPOINTstartStarting target with image /home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elfRunning from entry pointwaitExecution stopped in EL2h mode at EL2N:0x0000000080013000In _start (no debug info)EL2N:0x0000000080013000 ADR x1,#0x280set semihosting enabled onSemihosting server socket created at port 8000waitcontinueSemihosting stack/heap configured using values:Stack: 0x800584A0 ~ 0x80057CA0Heap: 0x800484A0 ~ 0x80057C9CinterruptExecution stopped in EL2h mode at EL2N:0x0000000000000200EL2N:0x0000000000000200 UDF #0
=======================================================================
The debug configuration is as shown below:
Hi again,It looks like semihosting is not being enabled correctly.The use of "set semihosting enabled on" in "Execute debugger commands" will enable it too late.To enable semihosting (early) when connected to real hardware, first create a "target initialization" .ds script containing:set semihosting heap-base 0set semihosting heap-limit 0x80800000set semihosting stack-limit 0x80800000set semihosting stack-base 0x81000000set semihosting enabled onChoose the addresses appropriately for your system.You might also need to set the address where the semihosting trap is placed, with, e.g.:set semihosting vector ADDR EL2N:0x200Then, in the debug configuration .launch file, select the Debugger tab, and add the script in the "Run target initialization debugger script" field. This will ensure semihosting is enabled before any other connection operation is performed.Hope this helpsStephen
I have added the script below in the initialization.ds script and have pointed it to the run target initialization debugger script.
Stephen Theobald said:set semihosting heap-base 0set semihosting heap-limit 0x80800000set semihosting stack-limit 0x80800000set semihosting stack-base 0x81000000set semihosting enabled on
But the problem still persists..I have provided a memory view after the program got stuck. So from this information can I get a hint as to what address should I take for heap and stack respectively? Are the address mentioned in the .ds script not compatible with the system?
Hi againWhat happens when you carefully single-step at instruction-level from _start, one instruction at a time? Does the HLT instruction get executed? Again, please attach a copy of the text from the Commands view, from the beginning to where the exception occurs.See also this post which looks similar to your situation:community.arm.com/.../program-gets-stuck-in-_start-crt0-on-morello-hardware-on-angel-command-dissassembled-to-hlt-0xf000-at-el2The addresses for stack and heap should be ok as a starting point, but it is ultimately up to you to decide on where you want to place the stack and heap, within the constraints of the memory system.Did you try adding:set semihosting vector ADDR EL2N:0x200If you are still stuck, it might be a good idea to start with a simpler project, which doesn't use semihosting:git.morello-project.org/.../standalone-baremetal-readme.rstStephen
Hello Stephen,
here I am including the copy of the text from the command view where the program below is getting halted as shown in the pic below. Here also I am not using semihosting, but the problem still persists.
======================================
#include <stdio.h>#include <stdlib.h>#define PLAT_ARM_BOOT_UART_BASE 0x2A400000volatile char * ptr = (volatile char*) PLAT_ARM_BOOT_UART_BASE;int main(){ *ptr='h'; *ptr='e'; *ptr='l'; *ptr='l'; *ptr='o'; while (1); return 0;}
=============================================
================ Command view =================================================
Connected to stopped target Arm - Morello SDPcd "/home/sanu/developmentstudio-workspace_2"Working directory "/home/sanu/developmentstudio-workspace_2"Execution stopped in EL2h mode at EL2N:0x0000000000000200loadfile "/home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elf"EL2N:0x0000000000000200 UDF #0Loaded section .rela.dyn: EL2N:0x0000000080000200 ~ EL2N:0x0000000080001E1F (size 0x1C20)Loaded section .rodata: EL2N:0x0000000080001E20 ~ EL2N:0x0000000080001E3F (size 0x20)Loaded section .text: EL2N:0x0000000080012000 ~ EL2N:0x00000000800184BB (size 0x64BC)Loaded section .init: EL2N:0x00000000800184BC ~ EL2N:0x00000000800184EF (size 0x34)Loaded section .fini: EL2N:0x00000000800184F0 ~ EL2N:0x0000000080018523 (size 0x34)Loaded section .data.rel.ro: EL2N:0x0000000080028530 ~ EL2N:0x00000000800285AF (size 0x80)Loaded section .init_array: EL2N:0x00000000800285B0 ~ EL2N:0x00000000800285BF (size 0x10)Loaded section .got: EL2N:0x00000000800285C0 ~ EL2N:0x00000000800287BF (size 0x200)Loaded section .data: EL2N:0x0000000080039000 ~ EL2N:0x000000008003CDD1 (size 0x3DD2)Loaded section .data.rel.ro: EL2N:0x0000000080028530 ~ EL2N:0x00000000800285AF (size 0x80)Loaded section .init_array: EL2N:0x00000000800285B0 ~ EL2N:0x00000000800285BF (size 0x10)Loaded section .got: EL2N:0x00000000800285C0 ~ EL2N:0x00000000800287BF (size 0x200)Entry point EL2N:0x0000000080012000add-symbol-file "/home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elf"ERROR(ITR575): Symbols for image /home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elf are already loaded at offset EL2N:0x0000000000000000set debug-from *$ENTRYPOINTstartStarting target with image /home/sanu/developmentstudio-workspace_2/Proj_HelloWorld/Debug/Proj_HelloWorld.elfRunning from entry pointwaitExecution stopped in EL2h mode at EL2N:0x0000000080012000In _start (no debug info)EL2N:0x0000000080012000 ADR x1,#0x280waitstepiExecution stopped in EL2h mode at EL2N:0x0000000080012004EL2N:0x0000000080012004 MOV w0,#0x16waitstepiExecution stopped in EL2h mode at EL2N:0x0000000080012008EL2N:0x0000000080012008 HLT #0xf000waitstepiExecution stopped in EL2h mode due to a breakpoint or watchpoint: EL2N:0x0000000080012008EL2N:0x0000000080012008 HLT #0xf000
========================================================================================================
GUI:
Debug Config view and selected debug from entry point.
I am using the compiler path as shown below:
with the C build settings for the project
For reference, I am also enclosing the contents of the header section of the elf file that is being generated.
I am not sure why this problem still persists. Is there any step where I am making a mistake please?