probe-rs / rusty-probe-firmware

35 stars 11 forks source link

Add option to send bytes over USB to trigger a reboot + scripts #6

Closed datdenkikniet closed 1 year ago

datdenkikniet commented 1 year ago

Now, sending 0xDABAD000 (in big endian order) over the USB serial triggers a restart into the USB bootloader with a specific feature enabled.

Pin defmt version to v0.3.2 for now to avoid the wire-breaking change.

Add some scripts that help with automagically restarting the probe, running elf2uf2-rs and starting defmt-print on the relevant serial port :D

This makes debugging/programming without a debugger to attach to the probe even more seamless

TODO:

Yatekii commented 1 year ago

I like this feature, but can we make it something else than 0xDEADBEEF? While I myself take no offense and would choose a value like that I have seen people make a fuss about it in the past.

datdenkikniet commented 1 year ago

Huh, absolutely! I wasn't aware that it was a "controversial" magic number, but will keep that in mind for the future now.

Yatekii commented 1 year ago

Yeah, I have trouble tracking controversial values myself as it feels many things are controversial nowadays ... Thanks for changing it =)

Yatekii commented 1 year ago

Also, the code looks nice, great work, I love this feature!

Do you think it would be possible to make the script a cargo xtask (or similar) (you could take a look at probe-rs for an example as we use it in the release process)? While I despise windows, I heard quite some folks use it and I am generally trying to be aware of portability :)

datdenkikniet commented 1 year ago

I will try! Yeah, the scripts are (for the most part) a quick and dirty solution. It would be nice if they're a bit more portable.

datdenkikniet commented 1 year ago

Done! I guess we should follow the xtask people's advice and set up the workspace properly? Now it's a bit of a mess when it comes to setting up the correct compilation target... (but it does work! And only "1" tool needed to perform all the tricks)

datdenkikniet commented 1 year ago

This also takes me back to the 2nd point on the TODO list: if we have this whole tool that only really works if we've got the defmt-bbq and usb-serial-reboot features enabled, should they be on by default?

Yatekii commented 1 year ago

This is awesome!

I am not sure how realistic it is that UART accidentally triggers the magic byte? Maybe it's a bit risky?

datdenkikniet commented 1 year ago

Honestly, I have no idea. But, just adding an alias in .cargo/config that builds with the correct features and then delegates to xtask is probably better, now that I think of it xd.

datdenkikniet commented 1 year ago

Okay, I forgot how annoying it is to mix-and-match different targets (without having to explicitly specify the targets you want), so even with the workspace setup it will be pretty annoying to use properly. I don't think changing it to that setup now will make any difference.

Yatekii commented 1 year ago

Yeah workspaces in general are a bit annoying to manage imo ... mixed targets is even worse ...

But an alias with correct features would be very nice =)

datdenkikniet commented 1 year ago

There, updated the README and .cargo/config.toml for some ease-of-use