How to compile and run an ARMLinux kernel
1. Purpose
Through this experiment, learn how to compile an ARM version of the kernel image and run it on the QEMU virtual machine.
2. Experimental steps
In order to speed up the development process, ARM provides the VersatileExpress development platform. Customers can develop product prototypes based on the VersatileExpress platform. As an individual learner, there is no need to purchase the VersatileExpress development platform or other ARM development boards. You can use QEMU to simulate the development platform linux and develop arm, which can also achieve the purpose of learning.
(1) Planning tools
Download the following code package.
(2) Compile the minimum file system
First use busybox to manually compile a minimal file system.
$ cd busybox $ export ARCH=arm $ export CROSS_COMPILE=arm-linux-gnueabi- $ make menuconfig
After entering menuconfig, configure it to static compilation.
Busybox Settings ---> Build Options ---> [*] Build BusyBox as a static binary (no shared libs)
After make&&makeinstall is compiled, there will be an "_install" directory in the root directory of busybox, which stores some command sets required by the compiled file system.
Copy the _install directory to the linux-4.0 directory. Step into the _install directory and first create etc, dev and other directories.
#mkdir etc #mkdir dev #mkdir mnt #mkdir –p etc/init.d/
Create a new rcS file in the _install/etc/init.d/ directory and write the following content.
mkdir –p /proc mkdir –p /tmp mkdir -p /sys mkdir –p /mnt /bin/mount -a mkdir -p /dev/pts mount -t devpts devpts /dev/pts echo /sbin/mdev > /proc/sys/kernel/hotplug mdev –s
Changing the _install/etc/init.d/rcS file requires executable permissions, which can be achieved by using the chmod command, such as "chmod x_install/etc/init.d/rcS".
Create a new fstab file in the _install/etc directory and write the following content.
proc /proc proc defaults 0 0 tmpfs /tmp tmpfs defaults 0 0 sysfs /sys sysfs defaults 0 0 tmpfs /dev tmpfs defaults 0 0 debugfs /sys/kernel/debug debugfs defaults 0 0
Create a new inittab file in the _install/etc directory and write the following content.
::sysinit:/etc/init.d/rcS ::respawn:-/bin/sh ::askfirst:-/bin/sh ::ctrlaltdel:/bin/umount -a –r
Create the following device node in the _install/dev directoryLinux development arm, this time requires root permissions.
$ cd _install/dev/ $ sudo mknod console c 5 1 $ sudo mknod null c 1 3
(3) Compile kernel
$ cd linux-4.0 $ export ARCH=arm $ export CROSS_COMPILE=arm-linux-gnueabi- $ make vexpress_defconfig $ make menuconfig
配置initramfs,在initramfssourcefile中填入_install,并把Defaultkernelcommandstring清空。
General setup ---> [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support (_install) Initramfs source file(s) Boot options --> ()Default kernel command string
配置memorysplit为“3G/1Guser/kernelsplit”,并打开高档显存。
Kernel Features ---> Memory split (3G/1G user/kernel split) ---> [ *] High Memory Support
开始编译内核。
$ make bzImage –j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- $ make dtbs
(4)运行QEMU虚拟机
运行QEMU虚拟机来模拟4核Cortex-A9的VersatileExpress开发平台。
$ qemu-system-arm -M vexpress-a9 -smp 4 -m 200M -kernel arch/arm/boot/zImage -append "rdinit=/linuxrc console=ttyAMA0 loglevel=8" -dtb arch/arm/boot/dts/vexpress-v2p-ca9.dtb -nographic
运行结果与实验3相同。
The above is the detailed content of Versatile virtual machine product prototype development experiment purpose: learn how to compile through this experiment. For more information, please follow other related articles on the PHP Chinese website!