This page will guide you on how to run bare-metal newlib printf demo on following target boards.
Nitrogen Cortex-M4 target
Beaglebone Black Arm cortex A8 target
Hikey 96Board AArch64 cortex A53 target
Anchor Nitro Nitro
Nitrogen Cortex-M4 target:
Nitro | |
Nitro |
Startup code for cortex M4 MCUs CMSIS:
Source:
- https://github.com/ARM-software/CMSIS/blob/master/Device/ARM/ARMCM4/Source/GCC/startup_ARMCM4.S
- https://github.com/ARM-software/CMSIS/blob/master/Device/ARM/ARMCM4/Source/GCC/startup_ARMCM4.c
- https://github.com/ARM-software/CMSIS/blob/master/Device/ARM/ARMCM4/Source/GCC/gcc_arm.ld
Building a semi-hosting printf demo for Nitrogen Board:
Make sure your gcc_arm.ld reflects memory layout of nitrogen board in MEMORY section.
You may use startup code either from startup_ARMCM4.S or startup_ARMCM4.c
Pre-requisite:
- arm-none-eabi-gcc
Sample demo code:
Code Block | ||
---|---|---|
| ||
#include <stdio.h> int main() { printf("Hello, world!"); printf("\n"); return 0; } #ifndef __NO_SYSTEM_INIT void SystemInit() {} #endif |
Build command line:
Code Block | ||
---|---|---|
| ||
arm-none-eabi-gcc semihost.c startup_ARMCM4.S -mthumb -mcpu=cortex-m4 -ffunction-sections -fdata-sections --specs = rdimon.specs -lc -T gcc_arm.ld -o semihost-CM4.axf |
Start openOCD connected to Nitrogen board via CMSIS-DAP:
Instructions to build openOCD from source can be found here:
Code Block | ||
---|---|---|
| ||
./src/openocd -s tcl/ -f interface/cmsis-dap.cfg -c "transport select swd" -f target/nrf52.cfg |
Run demo using GDB:
Start arm-none-eabi-gdb with Nitrogen board semihosting bare-metal demo
Code Block language bash arm-none-eabi-gdb semihost-CM4.axf
Connect to OpenOCD GDB stub while OpenOCD is connected to Nitrogen board via CMSIS-DAP
Code Block language bash target extended-remote :3333
Send command to OpenOCD to enable arm semihosting via gdb monitor command
Code Block language bash monitor arm semihosting enable
Load executable to the tagert
Code Block language bash load
Run demo and you will see semihosting printf output on OpenOCD console
Code Block language bash run
Enable OpenOCD semihosting_filio to view printf output on gdb console
Code Block language bash monitor arm semihosting_fileio enable
Anchor BBB BBB
Beaglebone Black Arm cortex A8 target:
BBB | |
BBB |
Make sure following configuration is applied to openOCD source to enable bare-metal debugging on Beaglebone Black.
Pre-requisite:
- arm-none-eabi-gcc
Sample demo code:
Code Block | ||
---|---|---|
| ||
#include <stdio.h> int main() { printf("Hello, world!"); printf("\n"); return 0; } |
Build command line:
Code Block | ||
---|---|---|
| ||
arm-none-eabi-gcc --specs=rdimon.specs -Xlinker -Ttext-segment=0x80000000 -Xlinker --defsym=__stack=0x80040000 -o arm-test-rdimon sample_demo.c |
Start openOCD connected to Beaglebone Black via flyswatter2 debug adapter:
Instructions to build openOCD from source can be found here:
Code Block | ||
---|---|---|
| ||
./src/openocd -s tcl/ -f interface/ftdi/flyswatter2.cfg -f board/ti_beaglebone_black.cfg |
Run demo using GDB:
Start arm-none-eabi-gdb with Beaglebone Black board semihosting bare-metal demo
Code Block language bash arm-none-eabi-gdb arm-test-rdimon
Connect to OpenOCD GDB stub while OpenOCD is connected to Beaglebone Black via flyswatter2 debug adapter
Code Block language bash target extended-remote :3333
Send command to OpenOCD to enable arm semihosting via gdb monitor command
Code Block language bash monitor arm semihosting enable
Load executable to the tagert
Code Block language bash load
Run demo and you will see semihosting printf output on OpenOCD console
Code Block language bash run
Enable OpenOCD semihosting_filio to view printf output on gdb console
Code Block language bash monitor arm semihosting_fileio enable
Note: You might have to connect/disconnect GDB with target a couple of times to ensure target is in stable connected state with openOCD.
Anchor Hikey Hikey
Hikey 96Board AArch64 cortex A53 target:
Hikey | |
Hikey |
Make sure following configuration is applied to openOCD source to enable bare-metal debugging on Hikey.
Pre-requisite:
- aarch64-elf-gcc
Note |
---|
Note: You may also need Newlib sisroot and in that case have to build newlib for aarch64 targets |
Sample demo code:
Code Block | ||
---|---|---|
| ||
#include <stdio.h> int main() { printf("Hello, world!"); printf("\n"); return 0; } |
...
Code Block | ||
---|---|---|
| ||
aarch64-elf-gcc -g -O0 -I${newlib-install}/aarch64-elf/include --sysroot=${newlib-install}/aarch64-elf/ -Xlinker --defsym=__stack=0x05D00000 --specs=rdimon.specs -o aarch64-test-rdimon sample_demo.c |
Start openOCD connected to Hikey Board via BusBlaster v2 debug adapter:
Instructions to build openOCD from source can be found here:
Code Block | ||
---|---|---|
| ||
./src/openocd -s tcl/ -f interface/ftdi/dp_busblaster.cfg -f board/lemaker_hikey.cfg |
Run demo using GDB:
Start AArch64-elf-gdb with Hikey board semihosting bare-metal demo
Code Block language bash aarch64-elf-gdb aarch64-test-rdimon
Connect to OpenOCD GDB stub while OpenOCD is connected to Hikey via BusBlaster v2 debug adapter
Code Block language bash target extended-remote :3333
Send command to OpenOCD to enable arm semihosting via gdb monitor command
Code Block language bash monitor arm semihosting enable
Load executable to the tagert
Code Block language bash load
Run demo and you will see semihosting printf output on OpenOCD console
Code Block language bash run
Enable OpenOCD semihosting_filio to view printf output on gdb console
Code Block language bash monitor arm semihosting_fileio enable
Note |
---|
Note: You might have to connect/disconnect GDB with target a couple of times to ensure target is in stable connected state with openOCD. |