-
Notifications
You must be signed in to change notification settings - Fork 153
Description
Summary: While the HiFive1 rev B is just like its predecessor, the boot sequence has been changed and the tooling to upload the .hex files.
Introduction: I recently got my hands on the HiFive1 rev B and learned that there were Ada drivers for it. Upon trying them, they failed. A bit of research shows the original version has a bootloader that jumps to 0x20400000 to start executing code. The new version (rev B) changed the bootloader to jump to 0x20100000. The new model also has less internal memory (from 128Mbit down to 32Mbit), 2 UARTs and 1 I2C, a low-power state, optional bluetooth and wifi (which come by default if the boards is bought from Crowdsupply), uploading mechanism and an updated version of the debugging interface (version 0.13).
In order to make Ada work, even in a rough state, I changed the HiFive configuration (the link.ld and the zfp.gpr) to set the origin of the elf to 0x20100000. Which made the resulting binary work (after manually transforming the elf to hex). The upload method used was just copying the resulting .hex to the "USB" entry in the file manager, since the new rev B version only allows for JLink and copying into memory (OpenOCD is not officially supported, but there are people working on it, see https://forums.sifive.com/t/progress-getting-openocd-usable-with-revb/3415)
I have seen that the file /scripts/config/boards.py also contains the 0x204... address. I did not change it (I actually forgot) but the project still runs fine. Therefore, I don't know if the Python script is used to build the project or not. After all, it seems to contain generic information about the boards
Conclusion: while the modification presented allows Ada to build working binaries, it is quite unsatisfactory. I believe there are enough differences between HiFive1 and HiFive1 rev B that a new board entry is needed, since selecting the boot entry with a build flag could potentially "break" a board. In this new entry, the boot address, upload mechanism and other hardware modifications could be added. Obviously, the new entry would be based on the original. Notice: this is just what I found in a day of fiddling with the board, there may be more issues.
However, my knowledge of embedded programming only extends to Arduino boards and PICs, which may not be ideal for me to handle this correctly. Furthermore, I am just getting started with Ada, so there is not much I can do for now (well, I could try different things, but I doubt they will have the necessary quality standards).
Further comments: the default optimization flag when building a "Production" build, is -O3. In microcontrollers, this tends to be -Os (just to fit more into less), and is the default flag when compiling C code from the Freedom Studio platform (official SiFive IDE which uses the Freedom E SDK). This is just a comment, I am not proposing a change here.
Any input on the subject is very welcome. I wouldn't mind doing a simple pull request updating the boot address and the README files if they are welcome.