SAMD21 Pro RF doesn't accept upload

I have an increasing number of SAMD21 Pro RF boards (3) that seem to allow me to upload a compiled Arduino sketch one time but do not allow me to connect and overwrite on a second revision.

I am Using Ubuntu 18.04 as my desktop/Programming environment and Arduino 1.8.8 as the development IDE. Nothing attached to the boards except an antenna (wire) to provide a load should the RF become activated. No soldering, no excessive handling. I have been USB 2 A-> uB cables attached to either USB 3 or USB 2 ports on my machine.

In all cases the first time I attach a device and turn it on an entry for /dev/ttyACM0 appears ( I check every time). The second time (after turning off the switch on the board and disconnecting it from USB) on reconnection no /dev/ttyACM0 entry appears.

I will attach a log showing what I see when I attach (sacrifice) a virgin board and upload a sketch the first time:

Arduino: 1.8.8 (Linux), Board: "SparkFun SAMD21 Pro RF"

Sketch uses 22472 bytes (8%) of program storage space. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, } / {} => {}
PORTS {} / {/dev/ttyACM0, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/home/dave/.arduino15/packages/arduino/tools/bossac/1.7.0/bossac -i -d --port=ttyACM0 -U true -i -e -w -v /tmp/arduino_build_86891/sf-loChat.ino.bin -R 
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Sep 24 2018 14:26:24
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] Sep 24 2018 14:26:24
Version      : v2.0 [Arduino:XYZ] Sep 24 2018 14:26:24
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0x7000a
BOD          : true
readWord(addr=0x40000834)=0x7000a
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 5.005 seconds

Write 22752 bytes to flash (356 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)

SAM-BA operation failed
An error occurred while uploading the sketch

[=====                         ] 17% (64/356 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)

[==========                    ] 35% (128/356 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x1000)

[================              ] 53% (192/356 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x5000, size=0x1000)

[=====================         ] 71% (256/356 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x6000, size=0x1000)

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

After this I am unable to connect to the board a second time.

What am I doing wrong?

Dave

Hi Dave.

It sounds like something in your code is causing the SAMD21 to hang and not enumerate on the USB bus. Try this:

  • Double tap the reset button to enter bootloader mode.
  • - Watch for a breathing blue __*STAT*__ LED.
  • - Check to see what COM port the board has been assigned. (it will be different than you're used too)
  • - Set Arduino to that port
  • - Upload the 'Blink' example sketch to the board.
  • That should restore the board so that you can upload new code to it again. Be aware that the COM port will change between bootloader and normal mode so double check that before trying to upload another sketch.

    Thanks @TS-Chris!

    I got it sorted. I had encountered the weirdness with the reset button once before, but forgotten the ‘quick double tap’ bit. I was just pushing it one time. A note concerning this should plastered everywhere these M0-based boards are discussed.

    The bit about checking what ‘COM port the board has been assigned’ sounds a bit Windows-specific to me. On Ubuntu it always seems to come up as /dev/ttyACM0 if it comes up at all. Of course that is if that device is not otherwise in use.

    Thanks,

    Dave