We need to work on the -bios option in QEMU. Currently the separated firmware and kernel mechanism only works in the “virt” machine and requires a recent bbl compiled with no payload. The documentation is in the code currently. It’s similar in concept to an FSBL that loads multiple images and places the addresses in device-tree, and it is based on the same mechanism used to point the kernel at a loaded initrd. It uses the device-tree “chosen” node which contains configuration versus hardware description (chosen can also point to the chosen console device):
chosen {
“riscv,kernel-start” = [ ... ],
“riscv,kernel-end” = [ ... ],
“linux,initrd-start” = [ ... ],
“linux,initrd-end” = [ ... ]
}
There were some email bug reports about ROM overlaps and I discovered while testing, that QEMU tries to add the ROMs in the -bios <rom_file> option even if this is not supported by the machine, so if this experimental BBL/vmlinux split -bios option is used on another QEMU machine such as “sifive_e” or “sifive_u”, then this ROM overlap message can appear. This appears to be some issue with target independent code. I need to look into it. We didn’t add the option to the other machines as we want them to match hardware, and currently HiFive Unleashed FSBL only loads one binary.
Tangentially, there is an -initrd option that was added to “virt” but it does not work as the associated Linux patch was not added. This might have been a good decision, as the code was copied from target/arm and makes different assumptions on load address of the initrd/initramfs. The code loaded the initrd in the middle of memory so that it did not overlap with a kernel that decompressed itself. It may be more wise to specify that the initrd is loaded below the kernel image.
These issues will get fleshed out as the boot protocol evolves and there are multiple RISC-V Supervisor loaders. u-boot, coreboot and other loaders will allow us to work on how the early boot mechanism becomes standardized.
Here are some things we need to keep in mind:
- firmware, kernel split in hardware
- supporting FreeBSD and other S-mode OSes
- initrd loading (linux specific)
- Mask ROM overrides in QEMU
Some folk also want to control the first instruction after reset in spike or QEMU. This is more equivalent to a Mask ROM override and is slightly different from a firmware override. Currently the -bios option in virt still relies on a tiny Mask ROM at 0x1000. For simulation, it would be useful to override this. QEMU has generic code for handling multiple ROMs, and I think may even support .hex files on some architectures. We’ll have to think carefully how we evolve QEMU (and spike) so we can keep backwards compatibility that use the current options.
To get back to the original posters question, I think freedom-u-sdk has the best build recipe for bbl/vmlinux. I have some scripts I am working on that I have not published yet for running a statically linked /sbin/init from a ramdisk that just prints hello and then powers off. We need that in the CI...
Oh forgot about this. We have the bbl build steps in documentation vs source form here:
We need to update the Linux versions mentioned in the docs.
Michael