BOSSA icon indicating copy to clipboard operation
BOSSA copied to clipboard

"Removed knowledge of the bootloader size from BOSSA" commit is dangerously compatibility-breaking

Open aswild opened this issue 6 years ago • 9 comments

https://github.com/shumatech/BOSSA/commit/dbdd088909c57bdf9aee191720bf6c6159217e22 is great, but also dangerous to Arduino SAMx21 users who don't understand its implications.

The first time I ran my "make upload" target, which doesn't specify --offset and worked on v1.8, I bricked my chip by erasing the bootloader code. I have an SWD programmer so it was easy enough to re-flash the bootloader, but others users may not be so fortunate.

There's also a flags incompatibility issue:

Version --offset=0x0000 (default) --offset=0x2000
1.8 Correct, writes to 0x2000 Incorrect, writes to 0x4000 (but bootloader still works)
1.9 Dangerous, writes to 0x0000 and kills the bootloader Correct, writes to 0x2000

I don't have any great ideas for handling the changes to --offset, but I think it could be beneficial to print a warning and require confirmation (or an explicit --offset=0 argument) before erasing/writing anything at address 0.

aswild avatar Jun 16 '18 00:06 aswild

Thanks ! I know understand what happened to my SAMD21 !

deladriere avatar Jun 16 '18 05:06 deladriere

does bossa always flashes from 0x2000 by default? i am using 4kb bootloader....

fedorcomander avatar Jul 20 '18 10:07 fedorcomander

The default flash address (for SAMx21 chips) changed from 0x2000 (8k) to 0x0000 in version 1.9. If you need to flash your application at 0x1000 (4k) then you can do that with --offset=0x1000 on BOSSA 1.9.

aswild avatar Jul 20 '18 13:07 aswild

Took me 2 hours to realise that… ;) Just switched to UF2 bootloader with some changes, works way easier for me ;) No tool required for update ;)

fedorcomander avatar Jul 20 '18 14:07 fedorcomander

I just ran into the same thing. Luckily the fuses were set to prevent overwriting the boot loader. The guide I was following didn't specify to use an offset and I now realize that guide was written based on bossa 1.8 which assumes a default of 0x2000. I think @aswild suggestions are good. Maybe just getting rid of a default value requiring an offset would be best.

matt448 avatar Aug 21 '18 16:08 matt448

I'm fine with requiring that it be explicitly specified for non-ROM bootloaders like the SAMD's.

shumatech avatar Aug 25 '18 21:08 shumatech

I think this also affects SAMx51.

tuupola avatar Aug 26 '18 13:08 tuupola

@shumatech how to set the offset in the bossa GUI ? It keeps saying : "Error Flash offset is invalid" whatever I type: 0x2000, 2000 or 8192 ?

deladriere avatar Aug 28 '18 05:08 deladriere

@shumatech any updates on how to set the offset in the GUI ?

deladriere avatar Nov 15 '18 11:11 deladriere