Link

EDBG

EDBG is software we use on our PC to program microcontrollers using a cmsis-dap tool.

  1. EDBG
  2. Installing EDBG
    1. Linux Only
    2. Mac Only
    3. Mac M1 Only
  3. Using EDBG
  4. Common Errors

Installing EDBG

To install it, find the latest build in the git repository’s actions tab. Click on the most recent, and look for artefacts near the bottom of the page: select whichever is appropriate for your system. IIRC need to be logged in to github to download these. I’ll mirror them here, as a treat:

Linux Only

Linux users need libudev-dev which should be install-able using:

sudo apt update
sudo apt install libudev-dev

Mac Only

(Thanks to Manvitha Ponnapati)

  1. Downloaded the edbg GitHub code here https://github.com/ataradov/edbg
  2. You have to install hidapi on your computer for edbg to work - it is a dependency you need. First, you need to install brew if you don’t already have it https://brew.sh
  3. Then you can install hidapi with brew install hidapi
  4. Note that edbg looks for hidapi by default - LIBS += /usr/local/lib/libhidapi.a CFLAGS += -I/usr/local/include/hidapi
  5. Your brew install may not install it there. You can find where your install is by doing brew info hidapi when you are finished installing it.
  6. Once you have the path go into the Makefile in the edbg directory and update these two lines with where your installation is
     LIBS += /usr/local/lib/libhidapi.a 
     CFLAGS += -I/usr/local/include/hidapi
    
  7. One other thing to note - when you did hidapi install you may not find the libhidapi.a but instead have a dynamic file libhidapi.dylib - you can use either for LIBS+
  8. Once you update those flags in the makefile you can then run make all to install edbg
  9. Before you run the binaries - add your edbg folder to your Mac path - export PATH="/Users/manu/edbg/:$PATH"
  10. You should be able to use edbg on your Mac terminal now.

Mac M1 Only

(Thanks to Ido Calman)

Here are some simple steps to get edbg working on Mac with M1 processor and on Mac in general:

First, if using Mac with M1: make sure that your Homebrew is installed to /usr/local and that you are running your terminal using Rosetta

  1. Install hidapi using brew: brew install hidapi
  2. Clone the repository to whatever folder you want: git clone https://github.com/ataradov/edbg
  3. Change the Makefile file where it says libhidapi.a to libhidapi.dylib
  4. Now run make all

Using EDBG

Collect the EDBG executable (in those downloads) and the .bin file you want to load onto the microcontroller into a folder on your machine.

For prebuilt binaries for ATSAMD11 or ATSAMD21 arduino bootloaders, check here, and for the CMSIS-DAP firmware (to program a programmer), check here.

Now, open a terminal or command prompt in this folder (remember, the terminal is localized, so is git bash on windows).

More detail on usage can be found in the project’s repository, but the basics we can do here:

First, make sure edbg has the right permissions (this only for mac / linux):

chmod +x edbg

Now, we can run the program, here’s an example loading the D11C bootloader for arduino, in macos / linux:

sudo ./edbg -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin

Windows doesn’t have ‘sudo’, and we have to include the .exe in the file name:

./edbg.exe -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin

Here, sudo gives the program administrator permissions, then ./edbg or ./edbg.exe invokes the executable, -b tells it to produce verbose messages, -t samd11 tells edbg which board you’re flashing, -pv tells it to program, then verify, and -f sam_ba_Generic_D11C14A_SAMD11C14A.bin points it to the .bin file you’ll flash.

To see which targets edbg supports, use -t list as a command like:

sudo ./edbg -t list sudo ./edbg.exe -t list

Common targets for us are simply: samd11 samd21 samd51

Common Errors

A common error is:

Debugger: Alex Taradov Generic CMSIS-DAP Adapter 98CA5665 v0.1 (S)
Clock frequency: 16.0 MHz
Error: invalid response during transfer (count = 0/1, status = 0)

This could be either a problem with the target board, or a bad software install. Try with a known good board to confirm.