Code Monkey home page Code Monkey logo

ch552-daplink's Introduction

CH552 DAPLink

The DAPLink, based on the CH552 microcontroller, is a debugging probe that follows the CMSIS-DAP standard. It supports both SWD and JTAG protocols, making it suitable for programming Microchip SAM and other ARM-based microcontrollers. In addition, it includes a Virtual COM Port (VCP) which adds an extra debugging capability. The SWD firmware is derived from Ralph Doncaster's DAPLink implementation for CH55x microcontrollers, along with Deqing Sun's CH55xduino port.

DAPLink_pic1.jpg

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. As a USB HID compliant device, it typically does not require any drivers for the operating system. For more information refer to the CMSIS-DAP Handbook.

CMSIS-DAP.png

Compiling and Installing Firmware

Preparing the CH55x Bootloader

Installing Drivers for the CH55x Bootloader

On Linux you do not need to install a driver. However, by default Linux will not expose enough permission to upload your code with the USB bootloader. In order to fix this, open a terminal and run the following commands:

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="4348", ATTR{idProduct}=="55e0", MODE="666"' | sudo tee /etc/udev/rules.d/99-ch55x.rules
sudo service udev restart

For Windows, you need the CH372 driver. Alternatively, you can also use the Zadig Tool to install the correct driver. Here, click "Options" and "List All Devices" to select the USB module, and then install the libusb-win32 driver. To do this, the board must be connected and the CH55x must be in bootloader mode.

Entering CH55x Bootloader Mode

A brand new chip starts automatically in bootloader mode as soon as it is connected to the PC via USB. Once firmware has been uploaded, the bootloader must be started manually for new uploads. To do this, the board must first be disconnected from the USB port and all voltage sources. Now press the BOOT button and keep it pressed while reconnecting the board to the USB port of your PC. The chip now starts again in bootloader mode, the BOOT button can be released and new firmware can be uploaded within the next couple of seconds.

Compiling and Uploading using the makefile

Installing SDCC Toolchain for CH55x

Install the SDCC Compiler. In order for the programming tool to work, Python3 must be installed on your system. To do this, follow these instructions. In addition pyusb must be installed. On Linux (Debian-based), all of this can be done with the following commands:

sudo apt install build-essential sdcc python3 python3-pip
sudo pip install pyusb

Compiling and Uploading Firmware

  • Open a terminal.
  • Navigate to the folder with the makefile.
  • Connect the board and make sure the CH552 is in bootloader mode.
  • Run make flash to compile and upload the firmware.
  • If you don't want to compile the firmware yourself, you can also upload the precompiled binary. To do this, just run python3 ./tools/chprog.py daplink.bin.

Operating Instructions

Connect the DAPLink to the target board via the pin header. You can supply power via the 3V3 pin or the 5V pin (max 400 mA). Plug the DAPLink into a USB port on your PC. Since it is recognized as a Human Interface Device (HID), no driver installation is required. However, Windows users may need to install a CDC driver for the Virtual COM Port (VCP) using the Zadig Tool. The DAPLink should work with any debugging software that supports CMSIS-DAP (e.g. OpenOCD or PyOCD). Of course, it also works with the SAMD DevBoards in the Arduino IDE (Tools -> Programmer -> Generic CMSIS-DAP). The virtual COM port (8N1 only) can be used with any serial monitor.

References, Links and Notes

  1. EasyEDA Design Files
  2. ARMmbed DAPLink
  3. CH55xduino
  4. Ralph Doncaster's Implementation
  5. CMSIS-DAP Handbook
  6. SDCC Compiler
  7. CH55x SDK for SDCC
  8. OpenOCD
  9. SAMD DevBoards
  10. picoDAP

DAPLink_pic2.jpg DAPLink_pic3.jpg

License

license.png

This work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. (http://creativecommons.org/licenses/by-sa/3.0/)

ch552-daplink's People

Contributors

wagiminator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kashiakashia

ch552-daplink's Issues

CDC_write is blocking

First off a big thank you for creating this and putting it on github!

I created a board with a CH551 on it to use as a build in SWD, however the DAPLink would become unresponsive. After some debugging I realized this was because my target was sending serial data to the CH551 UART, but I didn't have a serial monitor connected. This caused CDC_write to hang at the following line:

while(CDC_writeBusyFlag); // wait for ready to write

My quick and dirty fix was to use the DTR flag to decide if it should try to write the data to the CDC, so I changed line 97 of daplink.c to:
if(CDC_getDTR() && UART_available()) {

This of course requires the serial monitor to set DTR, but it solved the problem for me.
With no terminal connected the UART just continues happily overwriting the old data in buffer.

how to use it with arduino ide

"Of course, it also works with the SAMD DevBoards in the Arduino IDE (Tools -> Programmer -> Generic CMSIS-DAP)."

"Generic CMSIS-DAP" cannot be found in arduino ide, is it because "SAMD-Development-Boards" is not updated? I hope you can introduce in detail how to use it with arduino ide. Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.