Occasionally I'll get the following errors while programming my SAMD21 chip. Anyone know the reason?

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 10

If I spam sudo openocd then programming will eventually succeed. Below is my script. I'm totally new to this stuff and copied my script with minor modifications from an Adafruit guide.


source [find interface/raspberrypi2-native.cfg]
transport select swd

set CHIPNAME at91samd21g18
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

reset halt
at91samd bootloader 0
program image.bin verify
# at91samd bootloader 8192

I'm running this on a Raspberry Pi 3B+. I have no need for a bootloader on the SAMD21. I can confirm that my simple "hello world" image works correctly when it's successfully programmed.


1 Answer 1


Try increasing the

adapter_nsrst_delay 100


adapter_nsrst_delay 200

I had a similar problem on the RPi-3B and custom SAMD board.

  • 2
    \$\begingroup\$ Welcome to EE.SE. We don't expect every post to be perfect, but posts with correct spelling, punctuation, and grammar are easier to read. They also tend to get read and upvoted more frequently. (Proper capitalisation includes sentences, part numbers, brand names, SI unit symbols - V and A, etc.) Remember, you can always go back at any time and edit your post to improve it. This is site policy. See Write to the best of your ability on the site's help pages. \$\endgroup\$
    – Transistor
    Apr 17, 2019 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.