Skip to end of banner
Go to start of banner

How to use openOCD semi-hosting support

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 37 Next »

This page will guide you on how to run bare-metal newlib printf demo on following target boards.

Nitrogen Cortex-M4 target:

Startup code for cortex M4 MCUs CMSIS:

Source:

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:

#include <stdio.h>
int main()
{
    printf("Hello, world!");
	printf("\n");
	return 0;
}


#ifndef __NO_SYSTEM_INIT
void SystemInit()
{}
#endif

Build command line:

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:

./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

    arm-none-eabi-gdb semihost-CM4.axf
  • Connect to OpenOCD GDB stub while OpenOCD is connected to Nitrogen board via CMSIS-DAP

    target extended-remote :3333
  • Send command to OpenOCD to enable arm semihosting via gdb monitor command

    monitor arm semihosting enable
  • Load executable to the tagert

    load
  • Run demo and you will see semihosting printf output on OpenOCD console

    run
  • Enable OpenOCD semihosting_filio to view printf output on gdb console

    monitor arm semihosting_fileio enable


Beaglebone Black Arm cortex A8 target:

Make sure following configuration is applied to openOCD source to enable bare-metal debugging on Beaglebone Black.

Sample demo code:

#include <stdio.h>
int main()
{
    printf("Hello, world!");
	printf("\n");
	return 0;
}

Build command line:

arm-none-eabi-gcc --specs=rdimon.specs -Xlinker -Ttext-segment=0x80000000 -Xlinker --defsym=__stack=0x80040000 -o 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:

./src/openocd -s tcl/ -f interface/ftdi/flyswatter2.cfg -f board/ti_beaglebone_black.cfg


Hikey 96Board AArch64 cortex A53 target:

Make sure following configuration is applied to openOCD source to enable bare-metal debugging on Hikey.

Sample demo code:

#include <stdio.h>
int main()
{
    printf("Hello, world!");
	printf("\n");
	return 0;
}

Build command line:

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:

./src/openocd -s tcl/ -f interface/ftdi/dp_busblaster.cfg -f board/lemaker_hikey.cfg
  • No labels