Showing posts with label debugging. Show all posts
Showing posts with label debugging. Show all posts

Debugging with JLink on Eclipse I: FreeRTOS thread awareness

I've been using Eclipse with Segger's JLink for a while now to write my FreeRTOS applications. It's all good, until you want to check the state of threads. When you pause execution in debug mode, what you'll see most likely is idle thread. Because that's what embedded systems do for most of the time - they idle. Often when some task dies or hangs, everything else is still working. At least idle task is working. Unless the system experiences hardfault.

So I finally decided to improve my debugging facilities to obtain at least some info on the state of the system. I'll document my findings as I figure things out. This one will be about threads.

Debugging STM32 with JLink and Eclipse

Debugging with JLINK

J-Link is a rather nice general-purpose ARM debugger and offers more standardized GDB implementation than the ST-Link. Also, EDU version is priced at about 50 euros, while basic full version is not that much more expensive at about 300 euros. The super-duper Ultra version goes for about 600, or 800 with Ethernet. Since I use it for research and education, non-commercial EDU version suits me just fine. Although it does have some limitations license-wise, it is identical to JLink Base.

STM32F4 interrupt status register gotcha

I have been trying to implement UART line idle detection. Idle condition is considered, if no control bits are received within time frame of next byte.

Seemed reasonably simple - enable RXNE (receive buffer not empty) and IDLE interrupts. Sometimes it would work, and sometimes it wouldn't. All Most of the time I had USART peripheral memory reading enabled in debugger and it would show, that the IDLE bit is set in status register, but code would read the value without the bit. And, of course, that would break all the ISR logic. After banging my head against it for 2 days, I realized, that to reset the IDLE flag, one has to read the register. And then it dawned on me, that my debugger is reading the register before code gets there, and, hence, it is reset.

*facepalm*