DSP BIOS Debugging Tips

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

This topic describes a list of scenarios/samples of common mistakes/problems that users run into when using DSP/BIOS.

Contents

Problem: Software instability, i.e. code jumps to random location, crashes, behaves erratically

BIOS itself is extremely stable software. However, there are several common mistakes that can cause instability. Luckily, most of these mistakes can be avoided or else detected/corrected.

Cause: Stack overflow

Description: From a software perspective, stack problems are the most common cause of stability issues. These issues can result from a stack overflow, a stack corruption or a stack-pointer (SP) corruption. This could be related to the system stack used by HWIs and SWIs as well as the individual task stats.
How to diagnose (Method 1):

KOV - no overflow
KOV - stack overflow


How to diagnose (Method 2):

bios.TSK.CALLSWITCHFXN = 1;
bios.TSK.SWITCHFXN = prog.extern("TSK_checkstacks");

How to diagnose (Method 3):

/* Import BIOS TSK switch hook fxn so we can e.g. debug stack-pointer */
utils.importFile("tsk_switch_dbg.tci");



How to resolve:

Bios debugging tips interrupts3.JPG

Cause: Improper use of the interrupt keyword

Description: CLK functions and ISRs that use the interrupt dispatcher should not use the interrupt keyword.

Bios debugging tips interrupts1.JPG

How to diagnose:

Additional data:


Cause: Invoking BIOS APIs from the wrong context

Description: The BIOS API Guide has an appendix called "Function Callability Table". The table lists all BIOS APIs and specifies from what thread context it is legal to call them. Calling an API from the wrong context can cause stability issues.

Common mistakes:

Bios debugging tips interrupts2.JPG


Cause: Uninitialized global variables

Description: By default global variables are not automatically initialized. This could be a problem because the user may assume an initialization of zero of these global variables.
Avoiding the issue:

  1. In your code make sure you always assign an initial value to variables before using them.
  2. Have startup code zero out the sections where global variables are allocated.
    • Extract Init_utility.tar.gz at your location of choice.
    • Load zeroInitSectionsCmdFile.tci and call the function zeroInitSectionsCmdFile in your .tcf file.



Cause: MBX message size does not correspond to size of message buffer

Related Symptoms/Problems: data missing in message buffer received
Description: All MBX objects have a message size property that is either set statically via BIOS configuration or passed dynamically through MBX_create. It is important for this size to match the size of the buffer that is passed in through MBX_pend and MBX_post, since these APIs do a memcpy internally to copy the message to and from the mailbox's own internal buffers. If there is a size mismatch, problems could occur in the following two scenarios:

How to diagnose:

Additional Data:



Cause: Non-reentrant RTS functions only callable from TSK

Description: Some RTS functions are not reentrant. The bulk of these functions are the file I/O functions (printf, fprintf, scanf, etc.). These RTS functions call lock(), which in a BIOS application gets linked to LCK_pend and LCK_post, and can not be called in the context of a SWI or HWI thread. For a complete list of RTS functions callable from TSK threads only you can search the rts sources for "lock".
How to diagnose:


Other note on C I/O functions: Regardless of whether or not BIOS is being used, the C I/O functions from the RTS library make use of the heap. If you have not defined a heap or have defined too small of a heap the C I/O functions will not operate correctly.

Cause: Improper register/stack handling in hand-written assembly

Description: Hand-written assembly often is developed/tested in isolation and therefore issues related to handling of stack/registers go undetected until the algorithm gets integrated. Detection: One method of detecting these issues is simply bracketing the algorithm process call with _disable_interrupts() and _restore_interrupts().


Problem: The Real Time Analysis Tools Aren't Working!

Cause: Improper setup of BIOS configuration file
Cause: Necessary interrupts for RTDX not enabled

For a deep dive into this topic please see the RTA troubleshooting wiki page.


Problem: Program hits a SYS call, but I can't see any output/error message.

Common Symptoms: Program gets stuck spinning in UTL_halt, can't see output message from SYS_printf
Description: When SYS_abort, SYS_error is called, the error/system message is added to the system log. Other SYS functions such as SYS_printf, SYS_vprintf will output to the memory area labeled _SYS_PUTCBEG.
How to diagnose:

Problem: Performance is really bad

Description: Performance is much worse than you think it should be (orders of magnitude).

Cause 1: Improper cache configuration can cause serious performance degradation.
Solution 1: Follow the directions in the article Enabling 64x+ Cache. Also, make sure the cache coherency is being maintained (see this page). Newer C6000 processors have device drivers that already take this effect into account.

Cause 2: Suboptimal code/data placement in the internal/external memory.
Solution 2: See this FAQ for tips on which sections to place in internal memory.

Problem: My code isn't behaving the way I think it should.

<TODO> Add usage of LOG_printf, execution graph, message log to see what's happening.

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox