xref: /freebsd/stand/kboot/README (revision 02e9120893770924227138ba49df1edb3896112a)
1So to make a Linux initrd:
2
3(1) mkdir .../initrd
4(2) mkdir -p .../initrd/boot/defaults
5(3) cd src/stand; make install DESTDIR=.../initrd
6(4) Copy kernel to .../initrd/boot/kernel
7(5) cd .../initrd
8(6) cp boot/loader.kboot init
9(7) find . | sort | cpio -o -H newc | gzip > /tmp/initrd.cpio
10(8) download or build your linux kernel
11(9) qemu-system-x86_64 -kernel ~/vmlinuz-5.19.0-051900-generic \
12	-initrd /tmp/initrd.cpio \
13	-m 256m -nographic \
14	-monitor telnet::4444,server,nowait -serial stdio \
15	-append "console=ttyS0"
16    (though you may need more than 256M of ram to actually boot FreeBSD and do
17     anything interesting with it and the serial console to stdio bit hasn't
18     been the most stable recipe lately).
19
20Notes:
21For #6 you might need to strip loader.kboot if you copy it directly and don't
22	use make install.
23For #7 the sort is important, and you may need LC_ALL=C for its invocation
24For #7 gzip is but one of many methods, but it's the simplest to do.
25For #9, this means we can automate it using methods from
26	src/tools/boot/rootgen.sh when the time comes.
27#9 also likely generalizes to other architectures
28For #8, see https://kernel.ubuntu.com/~kernel-ppa/mainline/ to download
29	a kernel suitable for testing... For arm, I've been using the
30	non 64k page kernels and 5.19 seems to not suck.
31
32aarch64:
33qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt \
34	-kernel ~/linuxboot/arm64/kernel/boot/vmlinuz-5.19.0-051900-generic \
35	-initrd ~/linuxboot/arm64/initrd.img -m 256m -nographic \
36	-monitor telnet::4444,server,nowait -serial stdio \
37	-append "console=ttyAMA0"
38
39General
40
41Add -g -G to have gdb stop and wait for the debugger. This is useful for
42debugging the trampoline (hbreak will set a hardware break that's durable across
43code changes).  If you set the breakpoint for the trampoline and it never hits,
44then there's likely no RAM there and you got the PA to load to wrong. When
45debugging the trampiline and up to that, use gdb /boot/loader. When debugging
46the kernel, use kernel.full to get all the debugging. hbreak panic() is useful
47on the latter since you'll see the original panic, not the panic you get from
48there not being an early console.
49