Module 0185: Debugging RTK related issues

Tak Auyeung, Ph.D.

October 17, 2018

Contents

1 About this module
2 Tools
3 LEDs
4 RTK_STACK_SIZE

1 About this module

2 Tools

Use avarice to talk to the JTAG ICE debugger device, and open up a local socket:

avarice --program --file test.out --jtag /dev/ttyUSB0 :4242  
  

Next, use avr-gdb to debug. In the debugger, use the following command to connect to the socket opened by avarice:

target remote localhost:4242  
  

Once the connection is established, use continue to start runnig the program. Do not use run! Also, set up break points before using continue to stop the program at a specific place.

3 LEDs

Use LEDs to indicate the program reaches a certain point. Move the code that turns on an LED around to find out where is unreachable (but should be).

4 RTK_STACK_SIZE

When the RTK sleeps (to save power), it uses the RTK’s own stack. The size of this stack is determined by the macro RTK_STACK_SIZE. If you have interrupt service routines (ISRs) that require a deep stack, be sure to specify RTK_STACK_SIZE in the compiler’s command line. The default value is 64, which is not sufficient for more complex ISRs that call many levels of subroutines.