FA2022 Embedded Programming Environment
UPDI Programmer
What to make
USB-D11C-serial |
Serial UPDI-3 pin |
|
|
SAMD11C Regulator 3.3V SOT23-3 Capacitor 1uF 0 ohm Registor x2 2x2 SMD PinHeader for SWD(0.1”) 1x5 SMD angle PinSocket for Serial |
1x5 SMD angle PinHeader for Serial 4.99 kohm 1x3 SMD angle PinSocket for UPDI |
traces offset number: 0 ( = fill) interior |
traces interior |
How to make
Programmer to make UPDI Programmer
MAX32625PICO |
14 USD |
|
ARM Cortex M4 |
Raspberry Pi 4B |
45 USD(2GB) - 75 USD(8GB) |
|
Linux OpenOCD Ref |
Raspberry Pi Pico |
4 USD |
|
ARM Cortex M0+
OpenOCD Picprobe Ref |
Words
Words |
. |
OpenOCD softwaer in PC |
Open On-Chip Debugger cross platform, open source |
EDBG softwaer in PC |
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 |
Free-DAP firmware in programmer board |
free and open implementation of the CMSIS-DAP debugger firmware DAP: Debug Access Port SWD and JTAG protocols are supported |
DAPLink firmware in programmer board |
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 |
SWD interface for verifying and testing |
Serial Wire Debug 2 signal lines + Vref + GND ARM specific protocol designed specifically for micro debugging SWCLK, SWDIO |
Mac OS
Install Homebrew
| % which brew
/usr/local/bin/brew
|
Install hidapi
Download EDBG FAIL
1
2
3
4
5
6
7
8
9
10
11
12 | % cd Downloads
% ls
edbg-master.zip
% unzip edbg-master.zip
% ls
edbg-master
edbg-master.zip
% cd edbg-master
% make all
gcc -I/usr/local/include/hidapi -W -Wall -Wextra -O3 -std=gnu11 dap.c edbg.c target.c target_atmel_cm0p.c target_atmel_cm3.c target_atmel_cm4.c target_atmel_cm7.c target_atmel_cm4v2.c target_mchp_cm23.c target_st_stm32g0.c target_gd_gd32f4xx.c target_nu_m480.c target_lattice_lcmxo2.c dbg_mac.c -framework IOKit -framework Foundation -framework CoreFoundation -framework Cocoa /usr/local/lib/libhidapi.a -o edbg
clang: error: no such file or directory: '/usr/local/lib/libhidapi.a'
make: *** [edbg] Error 1
|
Download binary edbg-macos
- Ref.EDBG
- Sign in GitHub is required
- latest build > Artifacts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | % cd Downloads
% ls
edbg-macos.zip
% unzip edbg-macos.zip
% ls
edbg
edbg-macos.zip
% edbg -h
zsh: permission denied: edbg
% ls -la | grep edbg
-rw-r--r--@ 1 yuichi staff 133736 9 16 11:01 edbg
% chmod u+x edbg
% ls -la | grep edbg
-rwxr--r--@ 1 yuichi staff 133736 9 16 11:01 edbg
% edbg -h
zsh: killed edbg -h
|
Security Alert |
. |
|
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
9
10
11
12
13
14
15
16
17
18
19
20
21 | % 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
9
10
11
12
13
14 | % 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
| % source ~/.zshrc
% echo $PATH
/Users/yuichi/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
% cd Desktop
% edbg -h
CMSIS-DAP SWD programmer. Built Sep 16 2021 11:01:45.
|
Connection between USB-D11C-serial board and programmer
ATMEL ICE
{width=300}
Bootloader
Download bootloader: sam_ba_Generic_D11C14A_SAMD11C14A.bin
ATMEL ICE
| % lsusb
Bus 020 Device 006: ID 03eb:2141 Atmel Corporation Atmel-ICE CMSIS-DAP Serial: J41800075942
|
Burn bootloader to USB-D11C-serial board from pragrammer board
| % cd Downloads
% ls
sam_ba_Generic_D11C14A_SAMD11C14A.bin
% edbg -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
Debugger: ATMEL Atmel-ICE CMSIS-DAP J41800075942 1.0 (SJ)
Clock frequency: 16.0 MHz
Error: invalid response during transfer (count = 0/1, status = 0)
|
MAX32625PICO
Ref.MAX32625PICO
Hold down the button while connecting the board to your computers USB port. A drive named “MAINTENANCE” will appear.
Download max32625pico_daplink.bin default DAPLink image
Save the program binary file to your MAINTENANCE Microcontroller Disk, just like you would with a normal USB disk
disconnected and reconnected, the board will appear as a drive named “DAPLINK”
| % lsusb
Bus 020 Device 002: ID 0d28:0204 0d28 DAPLink CMSIS-DAP Serial: 04090000b9e3081500000000000000000000000097969906
% edbg -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
Error: invalid response received
% edbg -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin -s 04090000b9e3081500000000000000000000000097969906
Error: invalid response received
|
Mac OS
Ref. README.macOS
| % brew install openocd
% which openocd
/usr/local/bin/openocd
|
Download bootloader for SAMD11
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | % 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
|
ATMEL ICE FAIL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 | % 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
|
ref. ATMelICE signed dummy kext for MacOS X High Sierra
MAX32625PICO FAIL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | % 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
|
USB-D11C-SWD-10 pin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 | % 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.
Raspberry Pi
Set up
Download Raspberry Pi Imager
Ctrl-Shift-X to open Advanced menu
Write Operating System RASPBERRY PI OS (32-BIT)
to Storage microSD card
Ref. Programming Microcontrollers using OpenOCD on a Raspberry Pi
In mac’s terminal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | % 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
|
Connection
| $ 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
9
10
11
12
13
14
15
16 | 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
9
10
11
12
13
14 | $ 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
|
Connection (Pi3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | $ pinout
3V3 (1) (2) 5V
GPIO2 (3) (4) 5V
GPIO3 (5) (6) GND
GPIO4 (7) (8) GPIO14
GND (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND
GPIO22 (15) (16) GPIO23
3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND
GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8
GND (25) (26) GPIO7
GPIO0 (27) (28) GPIO1
GPIO5 (29) (30) GND
GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
GND (39) (40) GPIO21
$ cd /usr/local/share/openocd/scripts/interface
$ nano raspberrypi2-native.cfg
|
bcm2835gpio_peripheral_base
raspi Zero:0x20000000
bcm2835gpio peripheral_base 0x20000000
raspi 3B/3B+:0x3F000000
bcm2835gpio peripheral_base 0x3F000000
raspi 4B:0x7E000000
bcm2835gpio peripheral_base 0x7E000000
| 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
| $ 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
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | 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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 | $ 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
|
—
Ubuntu
Download binary edbg-linux
- Ref.EDBG
- Sign in GitHub is required
- latest build > Artifacts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 | $ sudo apt update
$ sudo apt install libudev-dev
$ cd Downloads/
$ ls
edbg-linux.zip
$ unzip edbg-linux.zip
$ ls
edbg
edbg-linux.zip
$ ./edbg --help
bash: ./edbg: Permission denied
$ ls -la
-rw-r--r-- 1 parallels parallels 113016 Nov 19 19:07 edbg
$ chmod u+x edbg
$ ls -la
-rwxr--r-- 1 parallels parallels 113016 Nov 19 19:07 edbg
$ ./edbg -h
CMSIS-DAP SWD programmer. Built Nov 19 2021 19:07:46.
Usage: ./edbg [options]
Options:
-h, --help print this help message and exit
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | $ wget https://github.com/mattairtech/ArduinoCore-samd/blob/master/bootloaders/zero/binaries/sam_ba_Generic_D11C14A_SAMD11C14A.bin
$ ls
edbg
edbg-linux.zip
sam_ba_Generic_D11C14A_SAMD11C14A.bin
$ lsusb
Bus 001 Device 012: ID 03eb:2141 Atmel Corp. ICE debugger
$ ./edbg -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
debugger write(): Bad file descriptor
$ ./edbg -b -t samd11 -epv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
debugger write(): Bad file descriptor
$ sudo ./edbg -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
[sudo] password for parallels:
Debugger: ATMEL Atmel-ICE CMSIS-DAP J41800075942 1.0 (SJ)
Clock frequency: 16.0 MHz
Error: invalid response during transfer (count = 0/1, status = 0)
$ lsusb
Bus 002 Device 002: ID 0d28:0204 NXP LPC1768
$ sudo ./edbg -b -t samd11 -pv -f sam_ba_Generic_D11C14A_SAMD11C14A.bin
Debugger: ARM DAPLink CMSIS-DAP 04090000b9e3081500000000000000000000000097969906 1.0 (S)
Clock frequency: 16.0 MHz
Error: invalid response during transfer (count = 0/1, status = 7)
|
Raspbery Pi 3 + OpenOCD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 | $ 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
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | 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
Wiring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 | $ pinout
3V3 (1) (2) 5V
GPIO2 (3) (4) 5V
GPIO3 (5) (6) GND
GPIO4 (7) (8) GPIO14
GND (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND
GPIO22 (15) (16) GPIO23
3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND
GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8
GND (25) (26) GPIO7
GPIO0 (27) (28) GPIO1
GPIO5 (29) (30) GND
GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
GND (39) (40) GPIO21
|
SAMD11C board |
Raspberry Pi3 |
RST |
GPIO18 |
GND |
GND |
DIO |
GPIO24 |
CLK |
GPIO25 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | $ 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
|
| $ git clone https://gitlab.cba.mit.edu/pub/hello-world/atsamd11.git
|
Add below at the end of openocd.cfg
| at91samd bootloader 0
program sam_ba_Generic_D11C14A_SAMD11C14A.bin verify
at91samd bootloader 4096
reset
shutdown
|
$ nano openocd.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 | 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 speed 200
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
reset init
at91samd bootloader 0
program sam_ba_Generic_D11C14A_SAMD11C14A.bin verify
at91samd bootloader 4096
reset
shutdown
|
Result
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 | 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
9
10
11
12
13
14
15 | $ 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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 | 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 speed 200
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
reset init
at91samd bootloader 0
program sam_ba_Generic_D11C14A_SAMD11C14A_2.bin verify
at91samd bootloader 4096
reset
shutdown
|
$ nano
Last update: February 19, 2022