PLL setting and boot problem with FE310-G002

Hi everyone. I’m using Freedom Studio (on windows) to program FE310-G002 on LoFive R1 using a J-Link debugger.

I guess the MCU is running at 16MHz. It’s too slow for me and I’m trying to set up the PLL inside the MCU, but I can’t find any document or example on how to use PLL from the freedom metal library to set a higher clock frequency such as 256MHz.

Besides, the MCU doesn’t run the program after a hardware reset or when powering on. It only works when I load a new program into the SPI flash by JTAG debugger (the program does exist in the flash). I think there is something wrong with the starting sequence inside the ROM memory, which makes the MCU not booting from the SPI flash.

Has anyone here ever encountered these problems? Please let me know your thinking on this.

Thank you!

Edit: I found a solution for the first problem

You either erased the bootloader of your firmware base address doesn’t match the one bootloader expects.

Thank you. I tested with two LoFive R1 modules and the same thing happened. I didn’t mess up with the firmware nor bootloader :slightly_frowning_face:

People in this forum have been talking about checking ROM content by address. However, I can’t find any tools to do that. Do you have any idea about that, @Disasm ?

Update: Now I have one HiFive1 rev b and two LoFive R1 boards. The HiFive1 doen’s have the second problem of booting when debugging on Freedom studio, only those LoFive R1 boards do. But after I debug HiFive1 by Segger IDE, I got the same problem again.

Try recovering your bootloader with GitHub - riscv-rust/hifive1-recover
Then check that you do not overwrite the bootloader while flashing (the base address of the binary should not be 0x20000000).

To check that your OTP is initialized, you can read 0x00020000 with debugger.

1 Like

Also note that LoFive r1 and HiFive1 RevB memory maps differ: HiFive1 bootloader expects your firmware at 0x20010000, but LoFive expects it at 0x20400000.

1 Like

Thanks Disasm, that’s correct. I counldn’t find any way to work with LoFive R1. But fortunately, everything has worked well when I use HiFive1 on Segger IDE with a correct package. However, the peripheral libraries are limited on Segger IDE and I had to write more libraries myself. But it worked wonderfully after all.

Ironically, Freedom Studio does not have much freedom when I couldn’t go deeper into their metal library. So everything in Freedom Studio was useless when I write the libraries for Segger IDE.

If you’re familiar with Rust, you can also check out the example and relevant libraries: GitHub - riscv-rust/riscv-rust-quickstart: A template for building Rust applications for HiFive1 boards

1 Like

Thank you so much!