|
ChibiOS/RT offers several mechanisms that can help in the debug phase of the development cycle. |
|
This guide assumes knowledge in following areas:
There are several settings in your kernel configuration file (chconf.h, see the kernel reference manual) that you may want to enable while debugging and in general during the whole development process.
CH_OPTIMIZE_SPEED=FALSE, this disables inlining into the kernel code and makes it easier to debug, you may also want to reduce or disable compiler optimizations (-O0 using GCC).CH_DBG_ENABLE_CHECKS=TRUE, this setting enables the checks on the API parameters, useful to understand if you are passing wrong parameters to the OS functions.CH_DBG_ENABLE_ASSERTS=TRUE, this setting enables the OS internal consistency checks, this can trap several kind of errors in the user code (or in the kernel itself).CH_DBG_ENABLE_STACK_CHECK=TRUE, this setting enables checks on threads stack overflow. Note that this option is not available in all ports, check your port documentation. If not supported then it is silently ignored, see also the article ”Stacks and Stack Sizes”.CH_DBG_FILL_THREADS=TRUE, this setting enables the threads workspace filling, this can help when examining the stack usage from your debugger.CH_DBG_SYSTEM_STATE_CHECK, this setting enables the system state checker which makes sure that all calls to OS functions are performed in a proper context (this option is only available starting from version 2.3.3).
Note that all the failed checks lock the kernel into the port_halt() function. In order to assess what triggered the lock the global variable panic_msg must be inspected using the debugger, the variable is a pointer to an error message (a zero terminated string), the pointer may contain NULL if the lock has been triggered by a stack overflow.
Starting from versions 2.2.7 stable and 2.3.3 unstable the ChibiOS/RT distribution includes a Debug Plugin for eclipse enhancing it with RTOS awareness. The plugin allows to inspect the Kernel data structures at runtime and is a formidable support. Accessible information include:
There are some common errors while using an RTOS, use the following table as a check list, if your problem is not a generic programming error then probably it is one of the following common RTOS/embedded related mistakes:
port_halt() function.For the less expert users, there are several things you may do in order to minimize the need for debugging:
./test” you will find examples for almost any API in the ChibiOS/RT kernel and most common RTOS related tasks../testhal” there are examples regarding the various device drivers.