2015-04-10 10:24 AM
Hi,
I am trying to do semihosting, so that I can print debug messages to the console on Eclipse + OpenOCD.It works except that the printf s take a long time to print. For example if I want to print ''Hello World''. It prints 'H', then .5 seconds later it prints 'e', another .5seconds, then 'l', and so on.Does anyone know how to fix this? #semihosting2015-04-10 01:56 PM
Does anyone know how to fix this?
Don't use OpenOCD? The ST-LINK Utilities support an SWV (Serial Wire Viewer) window, benchmark it against that.Semi-hosting in Keil or GNU/GCC on the DISCO boards, and others, is very rapid.2015-04-10 05:06 PM
2015-04-10 05:13 PM
http://www.st.com/st-web-ui/active/en/catalog/tools/PF258168
2015-04-10 05:38 PM
2015-04-10 06:30 PM
2015-04-10 08:29 PM
Dear OP
Can you use a professional tool suite with ST-Link, such as IAR or Keil? It's so easy, well integrated, fast. Well worth the cost for a professional user. I use IAR.2015-04-10 11:55 PM
first, by definition semihosting is pretty slow, each call triggers a BKPT exception that is trapped by the debugger, processed and execution returns. openocd is notoriously slow in this respect.
then, you can output your message via stdout or via stderr. in newlib, stderr is not buffered, and each character is written immediately, not when the line ends, as in the stdout case.also, the semihosting API has multiple functions, for different purposes, for example there is a separate DEBUG channel for trace messages. unfortunately the interface design is not great, it expects a null terminated string, while most callers are write() functions, which come with an array of bytes, and the lazy implementation is to iterate the array and output bytes one by one, which is extremely inefficient.I use extensively semihosting in the projects generated by the , and I did my best to implement semihosting as efficient as possible, so I somehow compensate for the interface and openocd problems. the only case that is still slow is when you use fprintf(stderr, ''...''), but it is not that slow as you mention it.with openocd there may be also a problem with the initialisation script you use, it might set the speed pretty low, and since the semihosting protocol involves a lot of exchanges between the debugger and the application, it might also contribute to the overall speed.I suggest you experiment with the GNU ARM Eclipse plug-in templates and possibly use the trace_printf() call, which is generally faster.2015-04-11 09:24 AM
2015-04-13 06:23 AM
actually the 16 byte buffer solved the slowness issue ;)
I'm glad it worked for you,Liviu