Tutorial on bare-metal programming with the VisionFive 2

Hi everyone,

I’ve been playing around with writing bare-metal code for the VisionFive 2. If this is interesting to you, I’ve written up a small article about how to get some basic bare-metal programs working (blink an LED and print over the UART): https://zyedidia.github.io/blog/posts/2-baremetal-visionfive/. The associated code can be found here. The code is written in D, but should be easy understand if you know C. If you are new to bare-metal programming, you can also check out the first post in the series, which describes how to write a bare-metal RISC-V program that is simulated in QEMU.



Awesome and nice job, learning right now.

1 Like

Awesome! Let me know if you have any questions or issues.

Terrific work!

I have done bare metal programming with riscv chips from SiFive and WCh using assembly language. This write up is a great summary of how to start working with this sbc.

Thanks for your hard work!

1 Like

According to this patch: [v4,19/19] riscv: dts: starfive: Add StarFive JH7110 VisionFive 2 board device tree - Patchwork
mtime frequency should be 4Mhz if you use same clock config as upstream device tree.

Very interesting. I measured the 4.8 MHz number assuming the CPU clock speed was 1.5 GHz. If the timer is actually 4 MHz then this would indicate that the CPU clock speed is 1.25 GHz by default. I wonder if you need to do some device I/O to increase the clock speed to the maximum 1.5 GHz. I’ll try looking into it tonight.

1 Like

Yes I can confirm that the timer frequency is actually 4 MHz, and the board seems to run at 1.25 GHz by default. Thanks!

1 Like