Problem uploading on Adafruit Feather M4 CAN

I’ve got 2 brand new Feather M4 CAN boards from Adafruit. I can upload code fine using Arduino IDE.
However when I try to upload a blank arduino project using PlatformIO (trough the USB port using sam-ba), upload fails:
PlatformIO successfully makes the board enter bootloader mode (a new COM port appears on device manager), but just hangs there and timeouts.
No luck if I put the chip in bootloader mode before upload (by double pressing the button)
Here’s the log:

  Configuring upload protocol...
AVAILABLE: atmel-ice, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: /dev/cu.usbmodem14101
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem14101
Waiting for the new upload port...
Uploading .pio/build/adafruit_feather_m4_can/firmware.bin
No device found on cu.usbmodem14101
*** [upload] Error 1

This appears on my Windows PC but also on my Macbook Pro.

Any ideas? Thanks!

I’ve done a bit more research:
I uploaded code usign Arduino IDE in verbose mode. This is the command being invoked:

Users/myuser/Library/Arduino15/packages/arduino/tools/bossac/1.8.0-48-gb176eee/bossac -i -d --port=cu.usbmodem14101 -U -i --offset=0x4000 -w -v /var/folders/wd/qh8t1ck15z911_tr4sjmg27w0000gp/T/arduino_build_17105/sketch_mar20a.ino.bin -R

I replaced the location of the “sketch_mar20a.ino.bin” with the location of the PlatformIO generated .bin, and hurrah!

Now is there a way I can modify the folder so that I can make it work from PlatformIO directly? I think I have identified the bit that invokes bossac and the arguments, but I couldn’t edit it successfully.

Any tips?

Can you please do the following:

  • Open a CLI and execute pio upgrade --dev and pio platform update atmelsam
  • Restart VSCode
  • Retry normal uploading
  • if it does not work, use the project task “Advanced → Verbose Upload” and post the log here

I have pretty much the same issue but with Adafruit Hallowing M4 - same chip
here is the output of the Verose upload :

CURRENT: upload_protocol = sam-ba
BeforeUpload([“upload”], [".pio/build/adafruit_hallowing_m4/firmware.bin"])
Use manually specified: /dev/cu.usbmodem142201
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem142201
Waiting for the new upload port…
bossac --info --debug --port “cu.usbmodem142201” --write --verify --reset -U --offset 0x4000 .pio/build/adafruit_hallowing_m4/firmware.bin
No device found on cu.usbmodem142201
*** [upload] Error 1

Please notice that I can upload via the same port with Arduino IDE.

Just to make 100% sure you have a Adafruit Hallowing M4 with the ATSAMD51J19A and not a Adafruit Hallowing with the ATSAMD21G18?

Does it work, as a test, when you add this

board_upload.use_1200bps_touch = no
board_upload.wait_for_upload_port = no

to the platformio.ini, and then double-tap the reset button on the board (to put it in bootloader mode), then press upload?

Confirming it is Hallowing M4 with SAMD51 , will try the your suggestion later today.

Tried the suggested settings, the result is the same

Building in release mode
MethodWrapper(["checkprogsize"], [".pio/build/adafruit_hallowing_m4/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.8% (used 7460 bytes from 196608 bytes)
Flash: [=         ]  11.7% (used 59312 bytes from 507904 bytes)
.pio/build/adafruit_hallowing_m4/firmware.elf  :
section            size        addr
.text             58608       16384
.data               704   536870912
.hsram             1024   536871616
.bss               6756   536872640
.ARM.attributes      48           0
.comment             67           0
.debug_frame       5296           0
.stab               204           0
.stabstr            441           0
Total             73148
<lambda>(["upload"], [".pio/build/adafruit_hallowing_m4/firmware.bin"])
AVAILABLE: atmel-ice, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
BeforeUpload(["upload"], [".pio/build/adafruit_hallowing_m4/firmware.bin"])
Use manually specified: /dev/cu.usbmodem142201
bossac --info --debug --port "cu.usbmodem142201" --write --verify --reset -U --offset 0x4000 .pio/build/adafruit_hallowing_m4/firmware.bin
No device found on cu.usbmodem142201
*** [upload] Error 1
============================================================ [FAILED] Took 6.90 seconds ============================================================
The terminal process "platformio 'run', '--verbose', '--target', 'upload', '--environment', 'adafruit_hallowing_m4'" terminated with exit code: 1.

Then there’s either a difference in invocation or used tool version.

I’ve downloaded bossasc 1.9.1 from Releases · shumatech/BOSSA · GitHub and created a PIO package thereof in GitHub - maxgerhardt/pio-bossac-updates.

Can you please do the following: Add

platform_packages =

to the platformio.ini and retry upload.

Thank you for your help.
I tried what you suggested , the result is the same - however I noticed that the downloaded bossac is version 1.109 from August 2018 :
ls -l bossac
-rwxr-xr-x 1 alex wheel 94860 Aug 25 2018 bossac
cat package.json
{"name": "tool-bossac", "version": "1.10901.210325", "description": "Basic Open Source SAM-BA Application (BOSSA)", "keywords": ["tools", "uploader"], "license": "BSD-3-Clause", "system": ["darwin_x86_64", "darwin_arm64"], "repository": {"type": "git", "url": ""}}

It is the same as I had installed in my system - NOT 1.91

This is semantic versioning encoding for major-package-version 1, 10901 → 1.9.1, Datecode (20)21-03-25, that’s correct. You can also open a shell and execute ./bossac --help and in the header text you should see

Copyright (c) 2011-2018 ShumaTech (

which is the time of release per links above.

But hm, if this is now used but still not working, there’s something wrong.

Please open the Arduino IDE and go to File->Preferences->Show verbose output during upload. Then upload any sketch to your board. Post the full invocation line of bossac.

The output should also show the exact path where your bossac is located. Please execute --help on that file and post the header, it should reveal the version / year.

This is from the Arduino, successful upload :

Found upload port: /dev/cu.usbmodem142201
/Users/alex/Library/Arduino15/packages/arduino/tools/bossac/1.8.0-48-gb176eee/bossac -i -d --port=cu.usbmodem142201 -U -i --offset=0x4000 -w -v /var/folders/q9/yy0nsq9d2jxfd2ww28x_rzxr0000gn/T/arduino_build_812791/Hallowing_M4_mar20b.ino.bin -R 
Set binary mode
version()=v1.1 [Arduino:XYZ] Jul 23 2019 16:43:41
Connected at 921600 baud
version()=v1.1 [Arduino:XYZ] Jul 23 2019 16:43:41
Device       : ATSAMD51x19
Version      : v1.1 [Arduino:XYZ] Jul 23 2019 16:43:41
Address      : 0x0
Pages        : 1024
Page Size    : 512 bytes
Total Size   : 512KB
Planes       : 1
Lock Regions : 32
Locked       : none
Security     : false
BOD          : false
BOR          : true
Write 12608 bytes to flash (25 pages)
[                              ] 0% (0/25 pages)write(addr=0x20004034,size=0x1000)
writeBuffer(scr_addr=0x20004034, dst_addr=0x4000, size=0x1000)
[=========                     ] 32% (8/25 pages)write(addr=0x20004034,size=0x1000)
writeBuffer(scr_addr=0x20004034, dst_addr=0x5000, size=0x1000)
[===================           ] 64% (16/25 pages)write(addr=0x20004034,size=0x1000)
writeBuffer(scr_addr=0x20004034, dst_addr=0x6000, size=0x1000)
[============================  ] 96% (24/25 pages)write(addr=0x20004034,size=0x200)
writeBuffer(scr_addr=0x20004034, dst_addr=0x7000, size=0x200)
[==============================] 100% (25/25 pages)
Done in 0.164 seconds
Verify 12608 bytes of flash
checksumBuffer(start_addr=0x4000, size=0x200) = edc2
[=                             ] 4% (1/25 pages)checksumBuffer(start_addr=0x4200, size=0x200) = 1104
[==                            ] 8% (2/25 pages)checksumBuffer(start_addr=0x4400, size=0x200) = 2131
[===                           ] 12% (3/25 pages)checksumBuffer(start_addr=0x4600, size=0x200) = cc80
[====                          ] 16% (4/25 pages)checksumBuffer(start_addr=0x4800, size=0x200) = 5a40
[======                        ] 20% (5/25 pages)checksumBuffer(start_addr=0x4a00, size=0x200) = 4235
[=======                       ] 24% (6/25 pages)checksumBuffer(start_addr=0x4c00, size=0x200) = e1f3
[========                      ] 28% (7/25 pages)checksumBuffer(start_addr=0x4e00, size=0x200) = 2cc8
[=========                     ] 32% (8/25 pages)checksumBuffer(start_addr=0x5000, size=0x200) = c3d5
[==========                    ] 36% (9/25 pages)checksumBuffer(start_addr=0x5200, size=0x200) = 1e71
[============                  ] 40% (10/25 pages)checksumBuffer(start_addr=0x5400, size=0x200) = c34c
[=============                 ] 44% (11/25 pages)checksumBuffer(start_addr=0x5600, size=0x200) = 5422
[==============                ] 48% (12/25 pages)checksumBuffer(start_addr=0x5800, size=0x200) = 8c34
[===============               ] 52% (13/25 pages)checksumBuffer(start_addr=0x5a00, size=0x200) = 1f72
[================              ] 56% (14/25 pages)checksumBuffer(start_addr=0x5c00, size=0x200) = 2807
[==================            ] 60% (15/25 pages)checksumBuffer(start_addr=0x5e00, size=0x200) = d6ba
[===================           ] 64% (16/25 pages)checksumBuffer(start_addr=0x6000, size=0x200) = 2ce9
[====================          ] 68% (17/25 pages)checksumBuffer(start_addr=0x6200, size=0x200) = 767f
[=====================         ] 72% (18/25 pages)checksumBuffer(start_addr=0x6400, size=0x200) = 45da
[======================        ] 76% (19/25 pages)checksumBuffer(start_addr=0x6600, size=0x200) = 4e4d
[========================      ] 80% (20/25 pages)checksumBuffer(start_addr=0x6800, size=0x200) = f085
[=========================     ] 84% (21/25 pages)checksumBuffer(start_addr=0x6a00, size=0x200) = 3473
[==========================    ] 88% (22/25 pages)checksumBuffer(start_addr=0x6c00, size=0x200) = a8a9
[===========================   ] 92% (23/25 pages)checksumBuffer(start_addr=0x6e00, size=0x200) = b1e5
[============================  ] 96% (24/25 pages)checksumBuffer(start_addr=0x7000, size=0x140) = 33c6
[==============================] 100% (25/25 pages)
Verify successful
Done in 0.300 seconds

Bossa tool seems to be Ok :

bossac --help
Usage: bossac [OPTION...] [FILE]
Basic Open Source SAM-BA Application (BOSSA) Version 1.9.1
Flash programmer for Atmel SAM devices.
Copyright (c) 2011-2018 ShumaTech `(`

  bossac -e -w -v -b image.bin   # Erase flash, write flash with image.bin,
                                 # verify the write, and set boot from flash
  bossac -r0x10000 image.bin     # Read 64KB from flash and store in image.bin

Just as a quick test, if you instruct PlatformIO to instruct the BOSSAC binary from the Arduino IDE, does it work?

Use as platformio.ini

platform = atmelsam
board = adafruit_hallowing_m4
framework = arduino
upload_protocol = custom 
upload_flags = 
upload_command = /Users/alex/Library/Arduino15/packages/arduino/tools/bossac/1.8.0-48-gb176eee/bossac $UPLOAD_FLAGS $SOURCE

You might have to reset the board to bootloader mode first by quickly double-tapping reset again.

Max, quick update :

  1. I have updated my Arduino IDE with the latest bossac - it works just fine.
  2. I have tried uploading by calling bossac directly from shell – it does not , complain about Device not found on port
  3. ) have removed
    board_upload.use_1200bps_touch = no
    board_upload.wait_for_upload_port = no

from my platformio.ini and now it worked from the PlatformIO as well !

my platformio.ini now looks like

platform = atmelsam
board = adafruit_hallowing_m4
framework = arduino
upload_protocol = sam-ba
; board_upload.use_1200bps_touch = no
; board_upload.wait_for_upload_port = no
platform_packages =
lib_ldf_mode = deep+
lib_deps = 
	adafruit/Adafruit Arcada Library@^2.5.1
	adafruit/Adafruit WavePlayer Library@^1.0.3

So basically I have restored the original config but now it works ! Go figure,
Thank you for you help, now I feel I know more about the whole process :slight_smile:

When you uncomment this to use the older bossac, does it fail again?

Yes, it fails, but something else is going on - it now fails again with both old and new bossac in platform and works with both in Arduino.
I also noticed that when I click the upload arrow in platform the first time after editing plaftormio.ini it pops an error message in the lower right corner command platformio-ide.upload' not found`
If I click it again, it starts the upload process. Not sure if it is related to the problem.

That’s just a asynchronous refresh problem, saving the platformio.ini triggers a rebuild of the internal command set and pressing the uplaod button to early before it’s finished causes that.

o_O. When you upload it once with Arduino, does it work with PIO + latest BOSSAC? Does putting the board into bootloader mode have any effect?

I am not able to upload from PlO + latest BOSSAC after a successful Arduino upload anymore - regardless whether board in the boot loader mode or not.
I can upload from Arduino in either bootloader mode or not.

I tried something different :
I am on a MacBookPro 2019, so I changed the usb-C to USB adapter I used to an Apple branded one, now
the platformIO starts uploading but gets stuck at about 2/3s uploads in about 50% of the attempts, and successfully finishes in 50%. Arduino uploads no problem.
So there is probably a HW aspect to it as well but how could be different in these case - beats me. It is the same bossac