Bootloader restore

This is a very dangerous condition, because it means if your Rust code does something sufficiently bad then it can get into a state where the JLINK can not communicate with the CPU to load new programs.

An example of something sufficiently bad would be turning off the clock, or setting it to a speed the board can’t run at. Or things such as a trap or interrupt happening without an appropriate and correct trap handler installed.

The bootloader code used on the original HiFive1 is here:

I don’t know what code is used on the Rev B. I don’t know of any reason this code would not work, other than the obvious one that FINAL_ADDRESS needs changing to something that is inside the small flash the Rev B has (normally 0x2001000, as you mention).

If you wanted to, and you never wanted to run anything except Rust binaries, you could simply include (a translation of) this code at the start of each Rust binary.