
Boot Linux on RISC-V in QEMU With OpenSBI and U-Boot
Build OpenSBI, U-Boot and a Linux 6.12 Image for riscv64, boot them on QEMU virt in the real firmware chain and load the kernel from an ext4 disk with booti.
Tag
82 posts

Build OpenSBI, U-Boot and a Linux 6.12 Image for riscv64, boot them on QEMU virt in the real firmware chain and load the kernel from an ext4 disk with booti.

Load a kernel module at every boot with /etc/modules-load.d and set its options in /etc/modprobe.d; the file formats, ordering, initramfs and how to verify.

getauxval reads the kernel's auxiliary vector: page size, CPU features, secure-mode flag, random bytes and the executable name, without parsing /proc.

Compare a module's vermagic string with uname -r using modinfo to see why insmod says Invalid module format, and what the version magic and CRC checks protect.

User space and kernel space are two privilege levels and two address ranges; code in one reaches the other only through system calls, faults and interrupts.

Run code in the child between fork and exec with CommandExt::pre_exec, learn which calls are async-signal-safe, and see how errors propagate to spawn.

Stop passing raw i32 descriptors around. Use OwnedFd to close on drop and BorrowedFd to lend a descriptor safely, with the AsFd trait, since Rust 1.63.

Use the nix crate to call POSIX functions like pipe, fork, waitpid and kill from Rust with typed arguments, Result errors and no raw unsafe libc calls.

Match on io::ErrorKind to handle NotFound, PermissionDenied and read-only filesystems from Rust std::fs, and use File::try_lock to detect a locked file.

The SysRq commands that matter for kernel debugging, each with what it does and when not to use it, plus how to enable them and the REISUB sequence.

Rust's standard library does not talk to the kernel directly on Linux. It calls libc, which issues the syscall. See the layers from File::open down to openat.

Read the kernel ring buffer with dmesg and the journal with journalctl -k, filter by level and time, follow new messages and avoid clock and permission traps.