shumatech / BOSSA

BOSSA is a flash programming utility for Atmel's SAM family of flash-based ARM microcontrollers. The motivation behind BOSSA is to create a simple, easy-to-use, open source utility to replace Atmel's SAM-BA software. BOSSA is an acronym for Basic Open Source SAM-BA Application to reflect that goal.
http://www.shumatech.com/web/products/bossa
BSD 3-Clause "New" or "Revised" License
361 stars 251 forks source link

Bossa 1.9.1 occasionally fails mid-download #120

Open dledge opened 4 years ago

dledge commented 4 years ago

Hi,

I have a custom SAMD51 Arduino board that uses UF2.

Things work great on Windows 10. On OS X, I've found that once in every 10 downloads or so, bossac will fail on a page write. When it fails, it's usually the first page write but sometimes it makes it to the block starting with page 32.

[=                             ] 6% (24/373 pages)write(addr=0x20004034,size=0x1000)
writeBuffer(scr_addr=0x20004034, dst_addr=0x7000, size=0x1000)

[==                            ] 8% (32/373 pages)
SAM-BA operation failed
write(addr=0x20004034,size=0x1000)
An error occurred while uploading the sketch

I've seen this behavior in 1.7.0, 1.8.0, and 1.9.1 on OS X. And this only happens on OS X (Mojave and Catalina).

It's interesting, it seems that if I run the erase command before the program/write command on OS X, things work a lot more reliably. I haven't seen the failure when I do this:

./bossac -e  --port=cu.usbmodem14314101 -R 
sleep 2
./bossac --port=cu.usbmodem14314101 -U -i -e --offset=0x4000 -w (path to binary) -R 

I remember seeing a mention in Adafruit's comments about bossac not waiting long enough for the flash to be erased on the SAMD51s before writing to the memory which lead me to the above experiment. But in looking at source code, would expect to see a similar behavior on Windows 10 which I'm not.

Any ideas?

Thanks!!

dledge commented 4 years ago

I think I found the issue and just created a pull request #121 that seems to have fixed the issue for me (haven't seen these failures since making the change).