We are trying to setup semihosting with a new Cortex-A32 SoC.
We are using gcc-arm-none-eabi v9.X to compile a bare-metal "hello world".
Does ARM DS 2020.1 support semihosting out-of-the-box for Cortex-A32 bare-metal application compiled with the abovementioned GCC?
We have enable semihosting with CLI, and when we step, we can observed SVC handler getting called.
But the App Console is not showing any of the printf().
Anything that we need to take care of specifically for Cortex-A32? This is a AArch32-only ARMv8 core.
Hi KahhoYes, Arm DS supports semihosting for Cortex-A32 with GCC.For semihosting to work, semihosting C libraries must be linked-into the executable image at link time, and the Debugger must have semihosting enabled. The Debugger enables semihosting automatically if either symbols "__auto_semihosting" or "__semihosting_library_function" are present in the loaded executable. Arm Compiler 6 adds "__semihosting_library_function" automatically to an executable at link time if that image uses any semihosting-using functions, but GCC does not, however you can use an alias symbol definition, e.g.:void __auto_semihosting(void) __attribute__ ((alias("main")));After connecting the Debugger to the target, you should see in the Commands view:Semihosting server socket created at port 8000Semihosting enabled automatically due to semihosting symbol detected in imageIf not, try explicitly enabling semihosting by adding "set semihosting enabled on" into the "Execute debugger commands" box in the debug launcher dialog.A ready-made example for Cortex-A32 FVP model with GCC and semihosting is provided in the Examples. Please take a look at the "startup_Cortex-A32_GCC" example:1) Launch Arm DS2) File > Import, Arm Development Studio > Examples & Programming Libraries3) Expand Examples > Armv8 Bare-Metal, select "startup_Cortex-A32_GCC"4) In Project Explorer view, expand the project. This example project comes with source code, pre-built executable, and debug launcher to run on an FVP model.5) Double-click on startup_Cortex-A32x1_GCC-FVP.launch
Hope this helps
Thanks Stephen for your detailed description!
After some tracing, we managed to narrow down the root cause, which we wish to share with the community here.
1. We have a typo error in our startup.S; it was jumping to main directly instead of jumping to mainCRTStartup.
ldr r0, =main
ldr r0, =_mainCRTStartup
2. We added the follow CLI, per 2020.1 documentation:
set semihosting vector 0x10000040
PS: our SVC trap is located at 0x10000040
We had overlooked the user guide mentioning that AArch32 on ARMv8 is different vs ARMv7, which needs to use the above mentioned mechanism in order for debugger to trap semihosting calls.
3. From our earlier experience in DS5 with FVP (ARMv7 core), added the first 4 statements below before enabling semihosting (otherwise semihosting does not work properly it seems):
set semihosting stack-base 0
set semihosting stack-limit 0
set semihosting heap-base 0
set semihosting heap-limit 0
set semihosting enabled on
PS: We are not very sure about the exact result why; it seems with the above, debugger will get these from _mainCRTStartup()?
Glad to hear you have this working now. Thanks for letting us know, and sharing with the Community :)
View all questions in Arm Development Studio forum