Search by Tags

Enable the debug messages

 

Compare with Revision




Subscribe for this article updates

Debug messages can be very helpful for developing or debugging applications. The debug messages provided by Windows CE are normally not visible. There are two ways to get to these messages:

  • Use a serial port and a terminal (all BSP versions)
  • Use the Debug Message Buffer feature of Windows CE (PXA only and BSP 4.1 and higher)

 

Debug Messages over Serial

You can enable debug messages over the serial port. Using the serial port for debug messages slows down the system. It's not recommended to use the debug serial port for large amount of debug data.
To enable the debug messages over serial please follow the steps mentioned below:

  1. Enter the Bootloader Menu
  2. In the bootloader, type:
    X
    set dbg.serial = 1 // 0: disable, 1: enable
    save dbg
  3. Restart the system

The debug messages are now sent out through the serial port and can be monitored running a terminal application on the PC.


Instead of using the bootloader commands above, the ConfigBlock Editor can be used to make the setting.

Warning: Enabling debug messages will make the serial port unavailable for the operating system.

Debug Message Buffer

The bootloader and Windows CE use a special ring-buffer in RAM to store the debug messages. These messages can be read through the tool Debug Message Logger or by accessing the RAM buffer directly by an application.

Availability

The Debug Message Buffer feature is available on the following modules:

  • Colibri PXA (image V4.1 onwards)
  • Colibri and Apalis Txx modules (image V2.1beta2 onwards)
  • Colibri iMX7 modules (image 1.1b2 onwards )

Enable the Debug Message Buffer

To enable the debug messages buffer please follow the steps mentioned below:

  1. Enter the Bootloader Menu
  2. In the bootloader, type:
    X
    set dbg.msgbuf = 1 // 0: disable, 1: enable
    save dbg
    on Colibri iMX7, the following two commands are required additionally
    set mem.dbgmsgram 10 // set buffer size (in kB)
    save mem
  3. Restart the system.


Instead of using the bootloader commands above, the ConfigBlock Editor can be used to make the setting.

Controlling the Debug Message Buffer Size on PXA Modules

This registry setting is only available on PXA The size of this buffer is fix 2k in the bootloader and adjustable for Windows CE (10k default). The following registry key lets you change the size or even disable the feature:

[HKLM\System\Config]
"DbgMsgBufSize"  =   dword:0x00002800     ;buffer size in bytes, 0=feature disabled, 0x2800=10k(default)

Show the Debug Message Buffer Content

See Debug Message Logger for details.

Access the Debug Message Buffer from an Application

The debug message buffer is implemented as a memory mapped file. The following code snippet demonstrates the access to this buffer.

// Struct used for the debug message buffer
typedef struct {
    DWORD version;                         // version of the message buffer
    DWORD bufSize;                         // message buffer size, w/o header bytes (this means size starting from buf offest)
    DWORD head;                            // head pointer which points to the character which gets written next
    DWORD flags;                           // see flag description below
    DWORD reserved[3];                     // reserved, do not use
    char buf[];                            // start of the debug message buffer (ring buffer)
} DBGMSGBUF;
// flag definitions
#define DBGMSGBUF_F_OVERFLOW  (1<< 0)      // set (1) means, there was at least one wrap around performed on the message buffer
 
// C code (no error handling done, more information about the used Windows APIs can be found on MSDN)
HANDLE hMapFile;
DBGMSGBUF * pDbgMsgBuf;
hMapFile= CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READONLY, 0, 0, L"DbgMsgBuffer");
pDbgMsgBuf = (DBGMSGBUF*) MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
// start using the debug message buffer. e.g.
if(pDbgMsgBuf->version != 1)
...