[Newbie Q] What libraries/functionality is usable out of the box?


My HiFive1 has finally arrived in Europe and I can’t wait to get started.

I am a little unsure about the sdk. I have installed it and poked around the makefiles etc.
under /toolchain/riscv32-unknown-elf/include/ I found a set of header files including malloc.h , pthread.h etc…
Can I use these out of the box, like using actual threads and malloc etc. out of the box or would this require a linux running on the hifive1?

I feel like I am missing some context regarding the toolchain / bsp / dev flow here, can somone pls elaborate or give me some hints about how to get my own projects started?

Thank you for your time,

Did you read https://dev.sifive.com/hifive1/hifive1-getting-started-guide/ ?

It recommends using GNU screen or similar to monitor the USB serial. I actually prefer to have the Arduino IDE open and use its terminal interface.


I have read this but unfortunately, this did not answer my questions nor helped me understand the toolchain.

Kind regards.

So have you successfully compiled and uploaded and ran the included projects? Or no?

Get your own projects started by duplicating one of the included ones.

On such a small machine there is usually just main program and interrupts. It would be possible to implement some kind of threads but with only 16 KB of RAM the stacks would have to be very small – plus you need 128 bytes to store the state of each non-running thread.

Normal malloc & free is also a problem. Probably best limited to things which malloc something at the start of the program and never release it. I think I saw an implementation of malloc somewhere there that just incremented the brk and made free a no-op. Can’t remember if it was in Arduino or SDK stuff (and I’m not at my PC now)

No doubt SiFive people will be here after the US weekend.

Hi @tmoe, welcome!

You’re right, it can be unclear what you’re looking at with the freedom-e-sdk. In my mind, the SDK really has 3 parts:

  1. Source for tools that you need to develop for RISC-V systems, which are found in the riscv-gnu-toolchain directory. These include the compilers, debuggers, disassemblers, GNU libraries, etc. These things are useful for developing for any RISC-V system, and not specific to your HiFive1 board. We provide versions of these tools because they’re in active development, and we want to make sure you have a version that we know works with your HW and the rest of the tools. As such, there is a lot of stuff included here that may not make sense for your board, which only has M-mode (no Supervisor or User modes).

  2. Files that are specific to your HiFive1 board and the Freedom E platform (or other boards we may come up with in the future). These are the files in bsp directory (stands for “Board Support Package”), and include things like headers and drivers for the different peripheral devices, and configuration scripts to allow talking to your hardware. In general, you may find things in this directory useful for any project on your HiFive1 board. Notably, for your HiFive1 board, we replace some of the libraries from (1) with our own minimalistic versions that works better with the limited resources on the board, in the bsb/libwrap directory.

  3. Some example programs and a Makefile flow to compile them. These are found in the software directory. These give a quick launchpad for how to write, compile, and upload a program for your board. As @brucehoult suggests, starting with one of these and modifying it can be an easy way to play around with the features of your board, but aren’t really a comprehensive demo of everything the board can do.

Thank you for the Information.

Kind regards.