Cannot Get Semihosting To Print (STM32F4, OpenOCD)
When I try to use semihosting to simply print to the console, my program compiles fine, and runs without breakpoints/
* arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.7.3 20121207 (release) [ARM/embedded-
* openocd 0.6.1
* STM32F4DISCOVERY
My link flags include "--specs=nano.specs --specs=
I run OpenOCD, and then connect GDB to it to load the program to flash and run it. I enable semihosting by issuing the command "monitor arm semihosting enable". The program's stdout is printed to neither OpenOCD nor GDB.
However, if I implement semihosting myself:
void dbg_write_str(const char *msg)
{
#ifdef __arm__
// Manual semi-hosting, because the GCC ARM Embedded's semihosting wasn't working.
for (; *msg; ++msg)
{
// Moves a pointer to msg into r1, sets r0 to 0x03,
// and then performs a special breakpoint that OpenOCD sees as
// the semihosting call. r0 tells OpenOCD which semihosting
// function we're calling. In this case WRITEC, which writes
// a single char pointed to by r1 to the console.
__asm__ ("mov r1,%0; mov r0,$3; BKPT 0xAB" :
);
}
#else
printf ("%s", msg);
#endif
}
That works just fine, and I see output in OpenOCD's console. I haven't looked at rdimon's code yet. Does it implement semihosting correctly or am I doing something wrong?
Thank you.
Question information
- Language:
- English Edit question
- Status:
- Expired
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: