HiFive1 Rev b Boot Program

I am trying to create a boot program and I have gotten quite far. But now, I’m at an impasse. The below stackoverflow post should catch you up to speed. but if you would rather not. I’ll describe where I am.

I have the gnu gcc toolchain.
It appears the design doc for the boot program indicates that the boot sector starts at 0x20000000 and runs to 0x20400000 before the first user code is executed.

So my questions are as follows.

  1. How do you recommend I flash my program onto the device?
  2. 0x20400000 indicates 516mb. Isn’t there only 512 mb on this device?
  3. 0x20000000 indicates 512mb. Does this program get read at the end and work backwards? But that doesn’t make sense because of what step two is indicating.
  4. If the program really runs backwards, wouldn’t the first user code execute at 0x1FE00000?

The HiFive 1

The HiFive1 and HiFive1 Rev B have different memory maps. On the HiFive1, the boot program is at 0x20000000 and the user program is at 0x20400000. On the HiFive1 Rev B, the boot program is at 0x20000000 and the user program is at 0x20010000. See the appropriate getting started guides.

512MB is 0x20000000 so there is memory from 0x20000000 to 0x40000000.

The boot program is for safety. It ensures that you can always talk to the board, even if a broken user program is loaded. If you overwrite the boot program with a bad user program you may have to go through a recovery process.

1 Like

Would I not be able to just reflash to the device? Also the recovery process indicated just holding down the reset button. Is this not the case? Should I be worried my boot program might make the flash completely unrecoverable? seems unlikely based on my research.

Also thanks @jimw for clarifying that the flash memory starts at 0x2000000 and goes to 0x40000000 and the user code begins 0x20010000 on the rev1 b!

I think I grabbed the wrong manual originally and it keeps throwing me off.

But, is there a particular reason why it starts at 512mb and goes to 1024mb address space rather than start at 0?

I don’t have a HiFive1 or HF1 Rev B. But I think the answer about flashing is that it depends on the environment, e.g. if you are using some higher level interface (like Arduino?) then you are in trouble if you write over the boot loader, but if you are directly connected via jtag and are comfortable with rewriting flash then it doesn’t really matter. There is a chapter in the getting started docs that talks about how the boot program works.

You can find memory maps in the ASIC documentation. sifive.com/documentation and Freedom E310-G002 is the one on the HiFive1 Rev B. Chapter 4 of the manual is the memory map. For our parts, typically addresses from 0 to 0x80000000 are reserved for memory mapped I/O and peripherals, and DRAM is 0x80000000 and above, but the low cost boards don’t have DRAM, and flash is essentially a peripheral device.

That’s 0x20000000 not 0x2000000.

There might be space in the memory map for that, but there sure isn’t so much actual flash memory!

In the HiFive1 Rev B there is 4 MB (0x400000) of flash, starting at 0x20000000 and ending at 0x203FFFFF. The original HiFive1’s default user program start address is just past the end of the flash on the HiFive1 Rev B’s flash chip, so won’t work – the original board has 16 MB of flash.

The Rev B’s user program starting address of 0x20010000 will work fine for both boards. Leaving 4 MB of space for the failsafe bootloader was always a little bit excessive. Even the current 64k is excessive :slight_smile: