Ada Drivers Library available for REV B (aka, program your board with Ada)



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?

  1. Get the RISC V Ada toolchain form AdaCore if your Linux distro does not have one (which is very likely, so use AdaCore’s): 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.
  2. Clone the Ada Drivers Library repo.
  3. Add the RISC V Ada toolchain to your PATH. Eg:
    $ PATH=/home/fernando/GNAT/2019-riscv32-elf/bin/:$PATH
    Do not copy paste the line above, this is just an example, please, adapt it to your installation path.
  4. Inside the Ada Drivers Library go to examples folder and into your board (in our case, it is examples/HiFive1_rev_B/).
  5. Build the project/example (See the 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 Production flag.
  6. It will compile all the modules and the example file (located in src). The compilation files will be left in the newly created obj folder. Go into the obj folder.
  7. Sadly, the compilation procedure only produces an elf file, but we need a binary hex file. 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 elf file is named main without extension (if you are doing your own project and change the name of the generated file, update the command above).
  8. With the hex file 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 hex file into the rev B.
  9. Press the reset button.
  10. ??
  11. Profit

More info

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: 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