We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello everyone,
I am trying to use printf via ITM-Port (Debug (printf) Viewer) within an RTX-Application on a STM32F103.
Here is what happens:
The message is written to the viewer window, but after writing the first messag it falls into the hard fault handler. After the message is displayed it calls _mutex_acquire (the standard implementation in RTX_lib.c) where mutex_wait (what is a define for _os_mut_wait) is called. It is the first time _mutex_acquire is called. mutex_wait is a SVC-Call. According to the call stack window the SVC_handler (I assume mutex_wait) calls rt_mut_wait where the HardFault occures. I noticed that _mutex_initialize seemes not to be called. The hard fault handler is called because I haven't activated any other handlers. The fault reports say that there is an IMPRECISERR bus fault.
Any idea how to make it work?
Many thanks in advance and best regards Alex
Hi,
did you try what happens if you just use the ITM Sendchar func?
void TextOut(const char *str) { do { if(*str=='\n') ITM_SendChar('\r'); ITM_SendChar(*str); } while(*str++); }
Thank you very much for your Answer. This works, but it is just another workaround. What also works is to modify _mutex_acuire (as shown below) or use the MicroLIB (it is not thread safe any more). I've got the same problem trying it at home on a stm32f4-Discovery board.
Upgrading _mutex_acquire to following code makes it work (changes are marked):
__used void _mutex_acquire (OS_ID *mutex) { static int initialized = 0; if( initialized == 0) { /* initialize the mutex */ _mutex_initialize(mutex); initialized = 1; } /* Acquire a system mutex, lock stdlib resources. */ if (runtask_id ()) { /* RTX running, acquire a mutex. */ mutex_wait (*mutex); } }
Do I really have to trigger _mutex_initialize manually?