NetBurner 3.1
Smart Traps

While smart traps is not a specific PC application, the interface is accomplished by running the MTTTY serial terminal. During software development it is possible for a software developer to download an application with a coding error severe enough to cause an application to crash. Common causes of a system crash are: task stack overflow, indexing an array out of bounds and bad pointer assignments. When a system crash occurs a device will usually recover by a reboot of the system. The purpose of the SmartTrap utility is to provide more information about the system when the crash occurred to assist with debugging the problem. Smart traps are automatically enabled by the init() function. Note that smart traps are disabled when building an application in debug mode.

SmartTraps is commonly used for:

  • Debugging an application crash

SmartTraps can be started from:

  • SmartTraps is used in conjunction with the MTTTY serial terminal program. The SmartTraps information will be displayed on the debug serial port
SmartTrapsOutput.jpg
Example Smart Traps Output

The output has four sections. It is beyond the scope of this document to go into detail on each of the processor registers, please refer to the processor manual manual for more information, located in the directory of your development tools installation.

Trap Information

This section displays the processor status and error registers. The most significant is the Faulted PC, with is the Program Counter register indicating the area where the fault occurred. In this example the program counter value at the time a trap was detected is 0x02000152.

Register Information

This section displays the processor's Address and Data registers.

RTOS Information

Identifies the RTOS Task Control Block and the current running task. The priority number is in hexadecimal. Traps caused by stack overflows may corrupt this section of the report.

Task Information

This is a very useful section of the report. It identifies each task, as well as its current state, wait time, and call stack. If you look at the Main task, you can see 6 entries with 0x02000152 (the faulted pc) at the left, and 0 at the right. The value of 0 is the start of the call stack. Each hexadecimal address between those two numbers represents each function that was called.

Each address can be related to the corresponding line number in the source code by using the WinAddr2Line utility. By selecting the .elf file location and each address in the call stack you can determine the calling sequence starting from 0 on the right and moving to the left. The last line signifies the end of the SmartTrap output. Since the boot monitor is configured to "boot to application", the device reboots after the trap occurs.