# Intermittent NVM programming error

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.

Script:

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

init
targets
reset halt
program image.bin verify
reset
shutdown


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.

Try increasing the

adapter_nsrst_delay 100


to

adapter_nsrst_delay 200


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

• 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. – Transistor Apr 17 at 17:16