Since few days, I am working on a little project in order to discover the kernel programming. However, I read a lot on the internet and asked a question before about kernel
Good work please document the work and post it on git / blog lot of tweaking required to get linux kernel compile on mac OS X.
Now to answer your question.
I hope I have answered you.
Buildroot
https://buildroot.org/
Buildroot is an awesome way to do this.
In very few commands it:
For aarch64 the commands are:
git clone https://github.com/buildroot/buildroot
cd buildroot
git checkout 2018.02
make qemu_aarch64_virt_defconfig
printf '
BR2_CCACHE=y
BR2_PACKAGE_HOST_QEMU=y
BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE=n
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
BR2_PACKAGE_HOST_QEMU_VDE2=y
' >>.config
make olddefconfig
time make BR2_JLEVEL="$(nproc)" HOST_QEMU_OPTS='--enable-sdl --with-sdlabi=2.0'
./output/host/usr/bin/qemu-system-aarch64 \
-M virt \
-cpu cortex-a57 \
-nographic \
-smp 1 \
-kernel output/images/Image \
-append "root=/dev/vda console=ttyAMA0" \
-netdev user,id=eth0 \
-device virtio-net-device,netdev=eth0 \
-drive file=output/images/rootfs.ext4,if=none,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
;
You are now left on a shell and you can login with username root
(no password).
The QEMU boot command is documented in Buildroot itself at: https://github.com/buildroot/buildroot/blob/2018.02/board/qemu/aarch64-virt/readme.txt
Then to use your own Linux kernel source, you basically just have to use LINUX_OVERRIDE_SRCDIR
as explained at: How to modify the source of Buildroot packages for package development?
And then basically for free you also get a way to:
I have automated and documented all of those things on this GitHub repo. To make kernel development even better, that:
Other ISAs mentioned at: https://cirosantilli.com/linux-kernel-module-cheat/#buildroot-hello-world
Tested in Ubuntu 18.04.