Embedded Debugger CMSIS-DAP programmer through SWD interface works on Linux, Mac OS X and Windows tested with Atmel mEDBG- and EDBG-based boards, Atmel-ICE and Free-DAP-based debuggers
Arm Mbed DAPLink open source software project that programs and debugs application software running on Arm Cortex CPUs
JTAG interface for verifying and testing
Joint Test Action Group 4 signal lines + Vref + GND in use for multiple microcontroller/processor architectures aside from ARM TCK, TMS, TDI, TDO, TRES
Cannot open because the developer cannot be verified Cancel Click “?” on left to get hint
Security and Privacy Allow applications from App Store and confirmed developers Use of edbg was blocked because the developer was not confirmed Allow as it is
Unable to verify the developer of edbg. Are you sure you want to open it? Open
1 2 3 4 5 6 7 8 9101112131415161718192021
% edbg -h
CMSIS-DAP SWD programmer. Built Sep 16 2021 11:01:45.
Usage: edbg [options]
Options:
-h, --help print this help message and exit
-b, --verbose print verbose messages
-e, --erase perform a chip erase before programming
-p, --program program the chip
-v, --verify verify memory
-k, --lock lock the chip (set security bit)
-u, --unlock unlock the chip (forces chip erase in most cases)
-r, --read read the whole content of the chip flash
-f, --file <file> binary file to be programmed or verified; also read output file name
-t, --target <name> specify a target type (use '-t list' for a list of supported target types)
-l, --list list all available debuggers
-s, --serial <number> use a debugger with a specified serial number or index in the list
-c, --clock <freq> interface clock frequency in kHz (default 16000)
-o, --offset <offset> offset for the operation
-z, --size <size> size for the operation
-F, --fuse <options> operations on the fuses (use '-F help' for details)
PATH
1 2 3 4 5 6 7 8 91011121314
% pwd
/Users/yuichi/Downloads
% mv edbg ~
% cd ~
% ls
edbg
% pwd
/Users/yuichi
% echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
% ls -la
.zshrc
% nano .zshrc
Add export PATH="/Users/yuichi:$PATH" in .zshrc and save
% cd Downloads
% ls
atsamd11-master-bootloader.zip
% unzip atsamd11-master-bootloader.zip
% ls
atsamd11-master-bootloader
atsamd11-master-bootloader.zip
% cd atsamd11-master-bootloader
bootloader
% cd bootloader/
% ls
sam_ba_Generic_D11C14A_SAMD11C14A.bin
openocd.cfg
unprotect_bootloader.cfg
% ls
sam_ba_Generic_D11C14A_SAMD11C14A.bin
openocd.cfg
unprotect_bootloader.cfg
% lsusb
Bus 020 Device 038: ID 03eb:2141 Atmel Corporation Atmel-ICE CMSIS-DAP Serial: J41800075942
% openocd
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter driver' not 'interface'
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Serial# = J41800075942
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Error: Error connecting DP: cannot read IDR
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
% lsusb
Bus 020 Device 043: ID 0d28:0204 0d28 DAPLink CMSIS-DAP Serial: 04090000b9e3081500000000000000000000000097969906
% openocd
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter driver' not 'interface'
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Error: Error connecting DP: cannot read IDR
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
% openocd
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter driver' not 'interface'
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = v0.1
Info : CMSIS-DAP: Serial# = 774E439B
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd11c14a.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd11c14a.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x41000000 pc: 0x000004a0 msp: 0x20000ffc
target halted due to debug-request, current mode: Thread
xPSR: 0x41000000 pc: 0x000004a0 msp: 0x20000ffc
** Programming Started **
Info : SAMD MCU: SAMD11C14A (16KB Flash, 4KB RAM)
** Programming Finished **
** Verify Started **
** Verified OK **
shutdown command invoked
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
disable protection for overwrite
Note that once the bootloader is on your board, OpenOCD will complain if you try to overwrite it with something else. This happens because the bootloader is protected.
To disable this protection, run openocd -f unprotect_bootloader.cfg
Then you can overwrite it without any issues.
% ssh pi@raspberrypi.local
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
% ssh-keygen -R raspberrypi.local
The authenticity of host 'raspberrypi.local (fe80::faab:348c:edcd:446f%en0)' can't be established.
ECDSA key fingerprint is SHA256:Dxs24lNBk9lAubin3bRb9H4FMjG5NFNVr6mNUVaCcbw.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
$ sudo apt-get update
$ sudo apt-get install git autoconf libtool make pkg-config libusb-1.0-0 libusb-1.0-0-dev
$ git clone http://openocd.zylin.com/openocd
$ ls
openocd
$ cd openocd
$ ls
bootstrap
$ ./bootstrap
$ ./configure --enable-sysfsgpio --enable-bcm2835gpio
$ ls
makefile
$ make
$ sudo make install
$ cd /usr/local/share/openocd/scripts/interface
$ ls
raspberrypi2-native.cfg
$ cd ~
$ mkdir bootloader
$ cd bootloader
$ wget https://github.com/mattairtech/ArduinoCore-samd/blob/master/bootloaders/zero/binaries/sam_ba_Generic_D11C14A_SAMD11C14A.bin
$ ls
sam_ba_Generic_D11C14A_SAMD11C14A.bin
$ nano openocd.cfg
Copy below and save
You may need to also comment out like # reset_config srst_nogate
1 2 3 4 5 6 7 8 910111213141516
source [find interface/raspberrypi2-native.cfg]
transport select swd
set CHIPNAME at91samd11c14a
source [find target/at91samdXX.cfg]
# did not yet manage to make a working setup using srst
#reset_config srst_only
reset_config srst_nogate
adapter_nsrst_delay 100
adapter_nsrst_assert_width 100
init
targets
reset halt
Burn Bootloader (Pi4) FAIL
1 2 3 4 5 6 7 8 91011121314
$ sudo openocd
Open On-Chip Debugger 0.11.0+dev-00450-gbe57b0ab8 (2021-11-13-12:31)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter srst delay' not 'adapter_nsrst_delay'
DEPRECATED! use 'adapter srst pulse_width' not 'adapter_nsrst_assert_width'
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 400 kHz
Error: Error connecting DP: cannot read IDR
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
bcm2835gpio peripheral_base 0x3F000000
# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: 23 22
bcm2835gpio swd_nums 11 25
SWCLK GPIO_11 (Pin23)
SWDIO GPIO_25 (Pin22)
GND (Pin20)
3V3 (Pin1) if not connected USB RST NOT CONNECT ANY PIN
Burn Bootloader (Pi3) better
12345678
$ cd
$ ls
bootloader
$ cd bootloader
$ ls
openocd.cfg sam_ba_Generic_D11C14A_SAMD11C14A.bin
$ openocd
$ nano bootloader.cfg
Copy the following into bootloader.cfg
1 2 3 4 5 6 7 8 9101112131415161718192021222324
source [find interface/raspberrypi2-native.cfg]
bcm2835gpio_speed_coeffs 194938 48
transport select swd
set CHIPNAME at91samd11c14a
source [find target/at91samdXX.cfg]
# did not yet manage to make a working setup using srst
#reset_config srst_only
reset_config srst_nogate
adapter_nsrst_delay 100
adapter_nsrst_assert_width 100
init
targets
reset halt
at91samd bootloader 0
program sam_ba_Generic_D11C14A_SAMD11C14A.bin
at91samd bootloader 8192
reset
shutdown
$ openocd -f bootloader.cfg
Open On-Chip Debugger 0.11.0+dev-00471-gcaa169813 (2021-11-20-12:24)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'bcm2835gpio speed_coeffs' not 'bcm2835gpio_speed_coeffs'
DEPRECATED! use 'adapter speed' not 'adapter_khz'
DEPRECATED! use 'adapter srst delay' not 'adapter_nsrst_delay'
DEPRECATED! use 'adapter srst pulse_width' not 'adapter_nsrst_assert_width'
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 125 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd11c14a.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd11c14a.cpu: target has 4 breakpoints, 2 watchpoints
Info : at91samd11c14a.cpu: external reset detected
Info : starting gdb server for at91samd11c14a.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x71000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread
xPSR: 0x71000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Info : SAMD MCU: SAMD11C14A (16KB Flash, 4KB RAM)
Warn : no flash bank found for address 0x00004000
** Programming Finished **
Error: at91samd11c14a.cpu -- clearing lockup after double fault
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x71000003 pc: 0xfffffffe msp: 0x0a0a09e8
shutdown command invoked
$ cat /usr/local/share/openocd/scripts/interface/raspberrypi2-native.cfg
#
# Config for using Raspberry Pi's expansion header
#
# This is best used with a fast enough buffer but also
# is suitable for direct connection if the target voltage
# matches RPi's 3.3V and the cable is short enough.
#
# Do not forget the GND connection, pin 6 of the expansion header.
#
adapter driver bcm2835gpio
bcm2835gpio peripheral_base 0x3F000000
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# bcm2835gpio speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio speed_coeffs 146203 36
# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 23 22 19 21
bcm2835gpio jtag_nums 11 25 10 9
# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: 23 22
bcm2835gpio swd_nums 11 25
# If you define trst or srst, use appropriate reset_config
# Header pin numbers: TRST - 26, SRST - 18
# bcm2835gpio trst_num 7
# reset_config trst_only
# bcm2835gpio srst_num 24
# reset_config srst_only srst_push_pull
# or if you have both connected,
# reset_config trst_and_srst srst_push_pull
Note
As default in raspberrypi2-native.cfg ,
SWD CLK is GPIO_11
SWD DIO is GPIO_25
SWD RST does not set
$ nano openocd.cfg
1 2 3 4 5 6 7 8 9101112131415161718192021222324
source [find interface/raspberrypi2-native.cfg]
transport select swd
set CHIPNAME at91samd11c14a
source [find target/at91samdXX.cfg]
# did not yet manage to make a working setup using srst
#reset_config srst_only
reset_config srst_nogate
# says next two lines are deprecated
#adapter_nsrst_delay 100
#adapter_nsrst_assert_width 100
adapter srst delay 100
adapter srst pulse_width 100
bcm2835gpio_swd_nums 25 24
#bcm2835gpio_trst_num 7
bcm2835gpio_srst_num 18
init
targets
reset halt
Note
You can set SWD pins like bcm2835gpio_swd_nums 25 24
SWD CLK is GPIO_25
SWD DIO is GPIO_24
Reset pin can be set like bcm2835gpio_srst_num 18
SWD RST is GPIO_18
$ sudo openocd
Open On-Chip Debugger 0.11.0+dev-00502-gf66a16c4a (2021-11-28-15:06)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'bcm2835gpio swd_nums' not 'bcm2835gpio_swd_nums'
DEPRECATED! use 'bcm2835gpio srst_num' not 'bcm2835gpio_srst_num'
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd11c14a.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd11c14a.cpu: target has 4 breakpoints, 2 watchpoints
Error: at91samd11c14a.cpu -- clearing lockup after double fault
Info : at91samd11c14a.cpu: external reset detected
Info : starting gdb server for at91samd11c14a.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x91000000 pc: 0xfffffffe msp: 0xfffffffc
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Open On-Chip Debugger 0.11.0+dev-00502-gf66a16c4a (2021-11-28-15:06)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 200 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd11c14a.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd11c14a.cpu: target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd11c14a.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x91000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread
xPSR: 0x91000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Info : SAMD MCU: SAMD11C14A (16KB Flash, 4KB RAM)
Warn : no flash bank found for address 0x00004000
** Programming Finished **
** Verify Started **
Error: at91samd11c14a.cpu -- clearing lockup after double fault
Error: error executing cortex_m crc algorithm
Info : SWD DPIDR 0x0bc11477
Error: Failed to read memory at 0x00004000
embedded:startup.tcl:1070: Error: ** Verify Failed **
in procedure 'script'
at file "embedded:startup.tcl", line 26
in procedure 'program' called at file "openocd.cfg", line 27
in procedure 'program_error' called at file "embedded:startup.tcl", line 1131
at file "embedded:startup.tcl", line 1070
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
1 2 3 4 5 6 7 8 9101112131415
$ cd
$ git clone https://gitlab.cba.mit.edu/pub/hello-world/atsamd11.git
$ ls
atsamd11
$ cd atsamd11
$ ls
bootloader
$ cd bootloader/
$ ls
openocd.cfg
README.md
sam_ba_Generic_D11C14A_SAMD11C14A.bin
unprotect_bootloader.cfg
$ nano openocd.cfg