Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate all boards upload tool from bossac 1.8 to 1.9 and auto-generate boards.txt #319

Merged
merged 2 commits into from
Jan 26, 2022

Conversation

hathach
Copy link
Member

@hathach hathach commented Jan 25, 2022

Also do a bit of testing with actual hardware feather m0, feather m4, proxlight trinkey all seem to work well.

@hathach hathach requested a review from ladyada January 25, 2022 15:52
Copy link

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bossac19 is very dangerous if you forget the --offset argument. The default is 0x000, and so it will wipe the bootloader. and the fuses The default was incompatibly changed from 1.8 to 1.9.

https://learn.adafruit.com/welcome-to-circuitpython/non-uf2-installation#run-the-bossac-command-3000302-16

@hathach
Copy link
Member Author

hathach commented Jan 25, 2022

thanks @dhalbert luckily we did specific --offset in command line option https://github.com/adafruit/ArduinoCore-samd/blob/bossac-1.9/platform.txt#L161 But it is indeed dangerous, I saw that commit in bossa log, but didn't aware of what it means.

Sum up: we are still good, since offset is specified for all boards.

@dhalbert
Copy link

We could fork bossac and protect against this. I am mostly worried about people using the installed bossac manually and then bricking their boards.

@hathach
Copy link
Member Author

hathach commented Jan 25, 2022

We could fork bossac and protect against this. I am mostly worried about people using the installed bossac manually and then bricking their boards.

Arduino user won't probably using bossac manually, I have never run bossac manually before as well. However, in case of bricking, is it possible to erase and re-flash the bootloader ?

Update: just realized that bossac is just a bootloader client 🤦, user would need an jlink to reflash bootloader

@ladyada
Copy link
Member

ladyada commented Jan 25, 2022

isnt the bootloader fuse protected against writing to 0x0 by accident?

@dhalbert
Copy link

If BOOTPROT is set, then the bootloader will be protected. But if the offset is zero (the default), it appears to use the ERASE ALL command, and sets the fuses to all ones: shumatech/BOSSA#99 (comment).

@ladyada
Copy link
Member

ladyada commented Jan 25, 2022

huh and BOOTPROT doesnt listen to that?

@dhalbert
Copy link

huh and BOOTPROT doesnt listen to that?

It doesn't overwrite the bootloader, but it does overwrite the fuses with all ones (apparently). I can try this myself.

@hathach
Copy link
Member Author

hathach commented Jan 26, 2022

I have done more reading on this, bossac 1.9 only erase-all if -e option is passed to command line. We don't actually use -e option in 1.8 and 1.9 upload pattern at all, only -w for sector erase. So I guess it is safe enough with offset and no -e

tools.bossac19.upload.pattern="{path}/{cmd}" {upload.verbose} --port={serial.port.file} -U -i --offset={upload.offset} -w -v "{build.path}/{build.project_name}.bin" -R

IMHO, we don't really need to worry about user manual execution of the command. Actually bossac 1.9 will probably be downloaded in user arduino15 already since it is an dependency tool required by Arduino mbed core. Mine have all 1.7, 1.8 and 1.9

image

@hathach
Copy link
Member Author

hathach commented Jan 26, 2022

@dhalbert @ladyada in order to minimize the mistake in manual addition of a board e.g incorrect offset for samd21/samd51. I have added the makeboard.py script

The generated boards.txt does fix some existing typo. The diff may look large but it is mostly macro arrangement in the extra_flags since we don't do in consistent order currently. Please review and let me know if changes makes sense to you.

Copy link
Member Author

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ladyada I made some highlight for the changes in generated boards.txt , please check out if you have time and/or if it makes sense to you. Let me know if you want to make any changes to the script/generated boards.txt

boards.txt Show resolved Hide resolved
boards.txt Show resolved Hide resolved
boards.txt Show resolved Hide resolved
boards.txt Show resolved Hide resolved
@dhalbert
Copy link

It doesn't overwrite the bootloader, but it does overwrite the fuses with all ones (apparently). I can try this myself.

I used bossac v1.9.1 to write a .bin at offset zero, with -e, and the fuses did not get overwritten, with and without BOOTPROT set properly. There is fuse repair code in the bootloader, but I changed the fuses slightly to notice whether it was triggered or not, and it wasn't. So never mind about this. I still wish bossac hadn't made this dangerous change, but it does appear we can live with it.

@hathach hathach changed the title migrate all boards upload tool from bossac 1.8 to 1.9 migrate all boards upload tool from bossac 1.8 to 1.9 and boards.txt generalization Jan 26, 2022
@hathach hathach changed the title migrate all boards upload tool from bossac 1.8 to 1.9 and boards.txt generalization migrate all boards upload tool from bossac 1.8 to 1.9 and auto-generate boards.txt Jan 26, 2022
Copy link
Member

@ladyada ladyada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like we have makeboards.py - it will be very very helpful given the large qty of PCBs!

@hathach
Copy link
Member Author

hathach commented Jan 26, 2022

thank you @dhalbert for helpful information and hand-on testing. I am glad we got everything covered safely now.

@hathach hathach merged commit d8893ff into master Jan 26, 2022
@hathach hathach deleted the bossac-1.9 branch January 26, 2022 18:15
@dansteingart
Copy link

Thanks for this thread: is there a new boards .json I can point to? Everything still seems to reference arduino:bossac@1.8.0-48-gb176eee. TIA.

@hathach
Copy link
Member Author

hathach commented Feb 15, 2022

@dansteingart we reverted the bossac back to 1.8 due to 1.9 compatible issue with macos #323 . And we won't upgrade it back until the issue is fixed by bossac. If you are using aarch64, you could try to install 1.7.8 instead. I am working on manual way to install bsp for aarch64 user (but in middle of other works just now).

@dansteingart
Copy link

Thanks: apologies for the dumb question but how do I override the bossac chain? I’ve replaced the library in the package.json install, and I can compile correctly, but something is still looking for 1.8

Error during Upload: Failed uploading: cannot execute upload tool: fork/exec {runtime.tools.bossac-1.8.0-48-gb176eee.path}/bossac: no such file or directory

@hathach
Copy link
Member Author

hathach commented Feb 16, 2022

copy your bossac binary to following path of arduino15, create middle folder if needed:

arduino15/packages/arduino/tools/bossac/1.8.0-48-gb176eee/

@hathach
Copy link
Member Author

hathach commented Feb 17, 2022

if adafruit/arduino-board-index#98 is approved then aarch64 will just work with 1.7.10 without any hassle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants