I'm attempting to flash a bootloader on to an atsamd11c14a using openocd on an rpi model 3b+ but encountering some trouble.

No issues on installing openocd (following adafruit's guide) and I believe my wiring is correct (was following some other guides). Reset pin is currently not connected.

Where I'm running in to issues is during the actual upload. The output I'm getting is:

Open On-Chip Debugger 0.10.0+dev-01151-gd9ffe75e-dirty (2020-03-26-09:28)
Licensed under GNU GPL v2
For bug reports, read
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : JTAG and SWD modes enabled
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd11c14a.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 3333 for gdb connections
Error: at91samd11c14a.cpu -- clearing lockup after double fault
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0xd1000003 pc: 0xfffffffe msp: 0xffffffd8
target halted due to debug-request, current mode: Thread
xPSR: 0xd1000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread
xPSR: 0xd1000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Info : SAMD MCU: SAMD11C14A (16KB Flash, 4KB RAM)
Error: SAMD: NVM programming error
Error: Failed to erase row containing 00000100
Error: SAMD: failed to erase sector 1 at 0x00000100
Error: failed erasing sectors 0 to 15
embedded:startup.tcl:522: Error: ** Programming Failed **
in procedure 'script'
at file "embedded:startup.tcl", line 26
in procedure 'program' called at file "openocd.cfg", line 33
in procedure 'program_error' called at file "embedded:startup.tcl", line 587
at file "embedded:startup.tcl", line 522
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections

I've attempted looking up the first few error lines but not having any luck. My openocd config file is as follows:

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

reset halt

at91samd bootloader
program sam_ba_Generic_D11C14A_SAMD11C14A.bin verify
at91samd bootloader 4096

I've also tried adding at91samd chip-erase just before programming (was suggested somewhere as a way to clear a lock if there was one), but didn't have any real effect aside from saying '''chip erase started''' before the programming attempt. The chips themselves are brand new, so I believe (not sure how to verify) that they should already be empty.

  • \$\begingroup\$ not every chip/family has flash support in openocd, have you confirmed this chip/family does? If nothing else then put a ram based bootloader on then have that write the flash either through other ram placed by openocd or a uart or other way to move the data into the bootloader. \$\endgroup\$ – old_timer Apr 3 at 3:10
  • \$\begingroup\$ looking at my notes for a samd21 chip-erase, etc works, your config has raspberry pi stuff in it is that the interface? git rid of init on down to the end, figure out how to do it first before writing as script. \$\endgroup\$ – old_timer Apr 3 at 3:17
  • 1
    \$\begingroup\$ telnet into localhost 4444 and then type help to see the commands and work through those. \$\endgroup\$ – old_timer Apr 3 at 3:27
  • \$\begingroup\$ Hi, thanks for taking a look. I want to say it does have support as I was following a guide that was targeting samd11d variant and does seem to be mentioned in the source files for openocd. Originally I did remove and only had "init" and "targets" and the output seemed to be good. I can amend that output to my post if you wish to see it. Finally, yes the rpi stuff seems to be the interface. I've gone through it and checked the rpi pin outs for SWCLK/SWDIO, etc (I can also amend this file too; just didn't want to clutter up the original post with all the files) \$\endgroup\$ – mitim Apr 3 at 3:46
  • \$\begingroup\$ Thanks, I was able to figure it out after all, after your suggestion to telnet and manually try commands. Was able to figure out some logic and get the samd11c working but having issue on the samd21e, though I think it might be a different issue altogether.. \$\endgroup\$ – mitim Apr 7 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.