I wrote a simple hello world program for the K82F that uses semihosting rather than UART:
#include <stdio.h> int main(void) { printf("Hello World\n"); while(1); return 1; }
If I build this program using the supporting files from KSDK_2.0 then running the program in GDB successfully prints Hello World to the terminal.
I can build the program using the MK82FN256xxx15_qspi.ld linker script but if I go through the same process of creating an .sb file and flashing it to the device as in the hello_world_qspi example project from KSDK_2.0 then it doesn't print anything when connecting to it with GDB.
Is semihosting supposed to work from QSPI?
Hi, Jozefl,
Regarding you question, I suppose that the "semihosting" is the console of the GDB debugger tools, in the case, Kinetis transfer the words of printf() to console via JTAG port, so the printf() function is valid only in the debugger environment after the debugger tools has initialized the JTAG port.
In conclusion, the printf() can not run in stand along mode,it is valid in debugger environment. If you want to run it in stand along mode, you have to use UART port.
Hope it can help you.
BR
Xiangjun rong
Hi Xiangjun,
Yes, I was talking about using semihosting in GDB.
If I flash the program to QSPI using blhost and then launch GDB, connect to the device and execute the following commands:
mon semihosting enable
mon semihosting IOClient=3
continue
then nothing to get printed to the GDB console.
The hello_world_qspi project is built with the -ffreestanding flag by default. By removing this flag semihosting works.