@@ -35,12 +35,98 @@ CMD /bin/bash
3535
3636
3737# -----------------------------------------------------------------------------
38+ # git clone -b v5.15 --depth=1 https://github.com/torvalds/linux
39+ # git clone -b 1_36_0 --depth=1 https://github.com/mirror/busybox
40+
3841# --- docker build ---
3942# docker build -t kbuilder --build-arg UID=$(id -u) --build-arg GID=$(id -g) .
4043
4144# --- run daemon mode ---
42- # docker run -it -d --name kbuilder_con --mount type=bind,src=/xxx,dst=/yyy kbuilder
45+ # docker run -it -d --name kbuilder_con \
46+ # --mount type=bind,src=/path/to/linux,dst=/home/builder/linux \
47+ # --mount type=bind,src=/path/to/busybox,dst=/home/builder/busybox \
48+ # kbuilder
4349
4450# docker exec -it kbuilder_con /bin/bash
4551# docker exec -it -u builder -w /home/builder kbuilder_con /bin/bash
4652
53+ # --- build kernel ---
54+ # cd linux
55+ # make defconfig
56+ # make menuconfig
57+ # Kernel hacking -> [*] Kernel debugging
58+ # Kernel hacking -> Compile-time checks and compiler options -> [*] Compile the kernel with debug info
59+ # Processor type and features -> [ ] EFI runtime service support
60+ # -> [ ] Build a relocatable kernel
61+ # time make -j $(nproc)
62+
63+ # --- create compile_commands.json at host ---
64+ # cd linux
65+ # ./scripts/clang-tools/gen_compile_commands.py
66+ # or
67+ # ./scripts/gen_compile_commands.py
68+
69+ # --- if need build busybox ---
70+ # cd busybox
71+ # make defconfig
72+ # make menuconfig
73+ # Settings -> [*] Build static binary (no shared libs)
74+ # make
75+ # make install
76+
77+ # --- create initramfs (busybox simple) at host ---
78+ # mkdir -p ramfs/{proc,bin,sbin,dev,sys}
79+ # cd ramfs/bin
80+ # curl -LOks https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox
81+ # chmod 755 ./busybox
82+ # ln -s busybox sh
83+ # ln -s busybox mount
84+ # cd ../sbin
85+ # cat <<EOF > init
86+ # > #!/bin/sh
87+ # > mount -t proc none /proc
88+ # > mount -t sysfs none /sys
89+ # > exec /bin/sh
90+ # > EOF
91+ # chmod 755 init
92+ # cd ../dev
93+ # sudo mknod console c 5 1
94+ # sudo mknod null c 1 3
95+ # cd ..
96+ # find ./ | cpio -o -H newc | gzip > initramfs.img
97+
98+ # --- launch qemu at host ---
99+ # qemu-system-x86_64 -kernel /path/to/bzImage -initrd /path/to/initramfs.img -append "console=ttyS0 rdinit=/sbin/init" -nographic
100+ # finish -> ctrl+a x
101+
102+ # --- create initramfs (busybox full) at host ---
103+ # mkdir -p ramfs/{proc,dev,sys,run,etc/init.d}
104+ # cp -pr /path/to/busybox/_install/* ramfs/
105+ # cd ramfs/dev
106+ # sudo mknod console c 5 1
107+ # sudo mknod null c 1 3
108+ # sudo mknod -m 666 tty c 5 0
109+ # sudo mknod ram b 1 0
110+ # cd ../etc/init.d
111+ # cat <<EOF > rcS
112+ # > #!/bin/sh
113+ # > mount -v --bind /dev /dev
114+ # > mount -v --bind /dev/pts /dev/pts
115+ # > mount -vt proc proc /proc
116+ # > mount -vt sysfs sysfs /sys
117+ # > mount -vt tmpfs tmpfs /run
118+ # > /sbin/mdev -s
119+ # > EOF
120+ # chmod 755 rcS
121+ # cd ../..
122+ # find ./ | cpio -o -H newc | gzip > initramfs.img
123+
124+ # --- launch qemu + gdb at host ---
125+ # qemu-system-x86_64 -kernel /path/to/bzImage -initrd /path/to/initramfs.img -append "console=ttyS0 rdinit=/sbin/init root=/dev/ram" -nographic -gdb tcp::12345 -S
126+ # gdb
127+ # target remote localhost:12345
128+ # symbol-file /path/to/linux/vmlinux
129+ # directory /path/to/linux
130+ # b start_kernel
131+ # layout split
132+ # c
0 commit comments