HI all,
I have a maybe kiddy question. I’m still newbie in bootchain.
I want to slightly change OpenSBI from vendor image for some reasons, so I need to rebuild it.
Additionally it seems it will be useful to know how to build and install UBoot too.
I’ve tried to find some info about how to make it step by step (at least and generally).
I’ve found something but still have some questions. Maybe because I still have puzzles but don’t have a full picture in my mind.
The bootchain is a basically a tarball in ESWIN’s format that can be read by the ROM of the chip. It describes different stage images, such as secondary init second_boot_fw, DDR init ddr_fw.bin, and the actual bootloader fw_payload.bin (opensbi+u-boot). What actually happened is the small 32-bit SCPU core starts first on power-on and runs ROM, then it parses from the bootchain in SPI flash and invokes secondary init + DDR init. Finally it copies bootloader (opensbi+u-boot) to DRAM, and kick start the 64-bit MCPU cores. This kind of bootchain is packaged by Esbd-77serial-nsign. second/ddr_fw are all closed source blobs from ESWIN, but bootloader we can change it.
If you go the meta-sifive route, then there’s no need to care about the versioning of different components. They are already specified by the manifest files. Just check-out this branch GitHub - sifiveinc/meta-sifive at rel/meta-sifive/hifive-premier-p550 and it’ll describe all the git commits of all repos + any private patches applied on top of it.
If you decide to do everything manually, then mimic what meta-sifive does is a good start. For me, I do everything manually for bootchain, and what I learned:
For u-boot/opensbi, need to be careful. opensbi doesn’t ship any device-trees, so it uses (and actually shares) the same device-trees from u-boot. If there’s incompatibility, it’ll crash on boot. You can try the upstream latest version of opensbi, in which I just added support for EIC770x/P550 before new year. You can follow instructions here: platform: generic: eswin: add EIC7700 · riscv-software-src/opensbi@e5797e0 · GitHubNote: you must use this u-boot branch GitHub - ganboing/u-boot-eic7x at eic7x-dt-fix because the vendor u-boot device-tree has inconsistencies from the Linux upstream, and I fixed that. It simplified many things, and got rid of those crazy build parameters (see below).
For u-boot/OS compatibility, no need to worry so much. Ubuntu carries it’s own device-tree for kernel, and kernel/grub speaks EFI protocol to u-boot, so it’s properly interfaced.
And yes, you can es_burn the new bootchain to the board. Just make sure you know how to recover the board before attempting. Following the board recover procedure is a good exercise.
BTW, you can use the discord channel from Works with RISC-V to chat on eic770x/p550: Discord
Hi, Bo,
Thanks a lot for deep explanation. Your answers are great, as usual.
It seems that in generally all clear and it looks like I mostly used the right way but after your explanation I will try to correct it. I mean will use your uboot and other feature mentioned by you.
Do I need to apply meta-sifive (provided by sifiveinc) additional patches for my ESWIN openSBI (provided by eswin)?
Wouldn’t that lead to chaos in openSBI? Because ESWIN openSBI already has some features from meta-sifive patches and some features that doesn’t have meta-sifive and vanilla openSBI.
I have one more question.
If someone could shed some light on this, I’d appreciate it
I want to load opensbi part from tftp. I can make ext4load usb 0 0x90000000 bootloader_ddr5_secboot.bin
But if I can change OpenSBI on the fly (without burning it to a SPI flash) it will be more flexible.
I’ve found that I can compile fw_dynamic or fw_jump (opensbi+u-boot parts).
Can I load fw_dynamic or fw_jump from tftp in Uboot shell?
If yes, can I install for example OpenSBI 1.2 (that contain a ddr training and etc) and load fw_dynamic or fw_jump from (for example) OpenSBI 1.3 from tftp in Uboot shell?
Or Do I have to use all the parts of OpenSBI from the same version?
You are really hacking deep! Basically you can’t change OpenSBI on the fly when the 64-bit cores (MCPU) has already started opensbi/u-boot, so no, you can’t do it in u-boot. However, good news is that you can do it with UART boot. See my instructions here:
I used it to be able to iterate quickly. That’s how I managed to code up the support for EIC7700 in upstream OpenSBI. It allows me to boot a new OpenSBI/u-boot build without flash in 1 minute, which is pretty fast actually.
I’ve already could see something like this but decided to put close looking at this on the back burner.
It seems now it’s a high time to deep dive to this too.
Thanks a lot for your instructions. It really helpful.