There is now initial Ada Drivers Library support for the Rev B. It allows you to write 100% Ada code into your boards. Continue reading if you want an introduction on how to use it.
Story and introduction
I recently got my hands on the HiFive1 (Rev B) and I was surprised when I learned that it “had” Ada support for it. As someone who has been toying with the idea of learning Ada, this was a perfect thing to play around with.
Issues and initial fix
Sadly, the support was for the original board, which meant that some parameters had to be tweaked. After creating a new board entry (it is important that you use the rev B entry and not the original), the “boot” address was updated. That was enough to allow Ada hex files to be uploaded successfully. Thank Fabien for that.
I am interested, how do I use it?
- Get the RISC V Ada toolchain form AdaCore if your Linux distro does not have one (which is very likely, so use AdaCore’s): https://www.adacore.com/download/more Select the risv entry (Linux host). Sadly, this method only works for Linux systems. If you are using another OS, you will have to build the toolchain manually.
- Clone the Ada Drivers Library repo.
- Add the RISC V Ada toolchain to your PATH. Eg:
Do not copy paste the line above, this is just an example, please, adapt it to your installation path.
- Inside the Ada Drivers Library go to examples folder and into your board (in our case, it is examples/HiFive1_rev_B/).
- Build the project/example (See the README.md in that same folder, I know it could use some improvements)
$ gprbuild -f -p -P hifive1_rev_B_example.gpr -XPLATFORM_BUILD=Debug
If you don’t like to build a Debug build, go for the
- It will compile all the modules and the example file (located in src). The compilation files will be left in the newly created
objfolder. Go into the
- Sadly, the compilation procedure only produces an
elffile, but we need a binary
hexfile. So, we need to create it manually (though hopefully, we will automate this step in the near future). Run:
$ riscv32-elf-objcopy -O ihex main main.hex
Notice that we are making the assumption that the produced
elffile is named
mainwithout extension (if you are doing your own project and change the name of the generated file, update the command above).
- With the
hexfile generated, we just need to upload it to the board. Luckily, this does not require any fancy procedure thanks to the Rev B board appearing as a USB drive. So, go into your file manager, open the HiFive Rev B board, and copy the newly generated
hexfile into the rev B.
- Press the reset button.
A lot more testing needs to be done. And as it was mentioned, the only change that we have done is updating the boot address; the rev B has more changes than just that one. If you are interested, your help is welcome and needed. The Ada telegram community is wonderful and has helped me greatly with this project, I would recommend you join it, even if you are just someone interested in Ada! (link:
https://t.me/ada_lang) Should there be any more news, I will post them here.
P.S: I would have loved to put more links, however, as a new user, I am still not allowed to do so.
Fernando Oleo Blanco