We are pleased to announce we have added CMSIS-DAP support to the mbed HDK firmware for the following targets:
- mbed NXP LPC1768
- mbed NXP LPC11U24
The new firmware upgrade, in addition to a drag n drop flash programming and a virtual serial port interface, provide a CMSIS-DAP interface in order to fully debug your platform for tools that support the CMSIS-DAP protocol.
This, combined with the exporting to toolchain features, means if and when you transition to a full debug toolchain as part of productisation, you don't need to change your hardware to:
- set breakpoints to stop the program at some event or at a specified instruction to examine the current state
- step by step execute a program to track the control flow
- check variables values
- inspect and modify memory contents
You can now upgrade your board very easily to support full CMSIS-DAP debug. Just select your board and follow the instructions:
Whilst the Online IDE doesn't support a debugger, here is an example of using this new feature with uVision MDK:
In this post, I would like to explain in more detail how CMSIS-DAP works.
What is CMSIS-DAP?
CMSIS-DAP provides a standardized way to access the Coresight Debug Access Port (DAP) of an ARM Cortex microcontroller via USB. CMSIS-DAP is generally implemented as an on-board interface chip, providing direct USB connection from a development board to a debugger running on a host computer on one side, and over JTAG (Joint Test Action Group) or SWD (Serial Wire Debug) to the target device to access the Coresight DAP on the other.
Why the need for CMSIS-DAP?
Before the CMSIS-DAP standard, a lot of USB wigglers implemented their own protocols. With this configuration, the host debugger has to be aware of these different protocols and has to implement all of them, which produces a lot of fragmentation and re-inventing the wheel. At the same time, the protocols were usually defined at the JTAG level, meaning they are slow. CMSIS-DAP provides a standardised interface for debuggers that is defined at the Coresight DAP level, allowing for a standard interface and fast driverless implementations.
How CMSIS-DAP can be integrated?
The CMSIS-DAP firmware has been implemented as part of the mbed HDK. In addition to the existing Mass Storage and the Virtual Serial port interfaces, a new HID endpoint is used to establish a CMSIS-DAP communication with a debugger. We chose to use a HID communication as HID drivers are built-in in all Operating Systems, there is no need for a specific driver to be installed on the host computer.
This means all mbed-enabled boards now have CMSIS-DAP built in (even ones already sold via a firmware upgrade), and if you implement the mbed HDK as part of your own development board or product, CMSIS-DAP will be freely available on that too!
Overview of the CMSIS-DAP standard
Packets are exchanged between the host debugger and the Interface Chip. Basically, the host sends a command and the debug unit sends the response of the command.
Different types of commands can be issued by the host:
- General Commands: request information and control the debug unit. Also used to connect/disconnect the debug unit.
- Common SWD/JTAG commands: used for instance to set the clock speed
- SWD specific commands: configure the parameters for SWD mode
- JTAG specific commands: configure the JTAG device chain
- Transfer Commands: read/write CoreSight registers. These commands are independent of the transport (SWD or JTAG)
Example: Read memory over CMSIS-DAP
Let's say that a debugger needs to read the value at a specific location in memory. The following commands have to be sent by the host:
- Transfer Command: write the CSW register (Control/Status Word Register). This will configure the transfer (32bits/16bits/8bits transfer)
- Transfer Command: write the TAR register (Transfer Address Register) with the address of the memory location
- Transfer Command: read the DRW register (Data Read/Write register) to read the value at the location specified earlier
Use CMSIS-DAP to debug your projects
To use it, you just need to update the firmware on your board (don't worry, it is easily upgraded and reverted) and connect with a CMSIS-DAP compliant toolchain. We've been using MDK as one of our test toolchains which has CMSIS-DAP support in it publicly from MDK uVision 4.60. To find out more about enabling your board with CMSIS-DAP, installing Keil MDK and debugging your first applications, please see the following page:
We'll be announcing more supported toolchains and scripts as they become available!