Hi, I’m having trouble uploading to Feather M0, despite it works fine with Arduino IDE. The problem as I can see is that PIO forcing reset the device and wait for new comport to appear, whereas the board is expecting no reset since resetting results in not being in the bootloader mode (bootloader needs double click reset button).
UPDATE: Just found Arduino IDE does force reset as well, see log below. After force reset, the upload port actually reappears, and the difference between PlatformIO and Arduino IDE is that PIO does not think the port that reappeared is the one it’s looking for, so it stops using it.
Any workaround?
Log from the upload terminal:
Executing task in folder keyboard_mouse: platformio run --target upload
Processing adafruit_feather_m0 (platform: https://github.com/platformio/platform-atmelsam.git; board: adafruit_feather_m0; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/adafruit_feather_m0.html
PLATFORM: Atmel SAM 3.8.0 #916cc6f > Adafruit Feather M0
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES: toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), framework-arduinosam 4.3.190711, tool-bossac 1.10900.0 (1.9.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Keyboard> 1.0.2
| |-- <HID> 1.0
Checking size .pio/build/adafruit_feather_m0/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA: [= ] 9.2% (used 3020 bytes from 32768 bytes)
PROGRAM: [= ] 5.1% (used 13268 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: /dev/cu.usbmodem1451101
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem1451101
Waiting for the new upload port...
Uploading .pio/build/adafruit_feather_m0/firmware.bin
bossac: extra arguments found
Try 'bossac -h' or 'bossac --help' for more information
*** [upload] Error 1
Compare to terminal command input from Arduino IDE:
Sketch uses 15772 bytes (6%) of program storage space. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem1451101
Found upload port: /dev/cu.usbmodem1451101
Library/Arduino15/packages/arduino/tools/bossac/1.7.0/bossac -i -d --port=cu.usbmodem1451101 -U true -i -e -w -v KeyboardMessage.ino.bin -R
Set binary mode
readWord(addr=0)=0x20002dd8
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v1.1 [Arduino:XYZ] May 12 2018 18:17:10
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20002dd8
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)=0x20002dd8
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID : 10010005
version()=v1.1 [Arduino:XYZ] May 12 2018 18:17:10
Version : v1.1 [Arduino:XYZ] May 12 2018 18:17:10
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 1.064 seconds
Write 16044 bytes to flash (251 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)
[======= ] 25% (64/251 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)
[=============== ] 50% (128/251 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x1000)
[====================== ] 76% (192/251 pages)write(addr=0x20005000,size=0xec0)
writeBuffer(scr_addr=0x20005000, dst_addr=0x5000, size=0xec0)
[==============================] 100% (251/251 pages)
done in 0.099 seconds
Verify 16044 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = 7d9e
checksumBuffer(start_addr=0x3000, size=0x1000) = 1086
checksumBuffer(start_addr=0x4000, size=0x1000) = 2ca2
checksumBuffer(start_addr=0x5000, size=0xeac) = 6b36
Verify successful
done in 0.022 seconds
CPU reset.
readWord(addr=0)=0x20002dd8
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)