Last active
August 28, 2020 02:06
-
-
Save mariotpc/b63577e57bfc2a66c962734bda5b4465 to your computer and use it in GitHub Desktop.
Creating the root file system to use with Kernel 4.9.13-MarioTPC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mariotpc@fedora31 boot]$ ls | |
bootp compressed dts Image install.sh Makefile zImage | |
1.- Create the rootfs | |
********************************************************************************* | |
[mariotpc@fedora31 boot]$ mkdir ~/rootfs | |
[mariotpc@fedora31 boot]$ cd ~/rootfs | |
[mariotpc@fedora31 rootfs]$ mkdir bin dev etc home lib proc sbin sys tmp usr var | |
[mariotpc@fedora31 rootfs]$ mkdir usr/bin usr/lib usr/sbin | |
[mariotpc@fedora31 rootfs]$ mkdir -p var/log | |
[mariotpc@fedora31 rootfs]$ ls | |
bin dev etc home lib proc sbin sys tmp usr var | |
[mariotpc@fedora31 rootfs]$ tree -d | |
. | |
├── bin | |
├── dev | |
├── etc | |
├── home | |
├── lib | |
├── proc | |
├── sbin | |
├── sys | |
├── tmp | |
├── usr | |
│ ├── bin | |
│ ├── lib | |
│ └── sbin | |
└── var | |
└── log | |
15 directories | |
2.- Move the rootfs and change everything to root:root | |
********************************************************************************* | |
[mariotpc@fedora31 rootfs]$ cd ~/rootfs | |
[mariotpc@fedora31 rootfs]$ sudo chown -R root:root * | |
[sudo] password for mariotpc: | |
3.- I am copying the files from busybox to my rootfs | |
[mariotpc@fedora31 rootfs]$ ~/Downloads/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-readelf -a ../Downloads/busybox-1.27.2/busybox | grep "inter" | |
[Requesting program interpreter: /lib/ld-linux-armhf.so.3] | |
[mariotpc@fedora31 rootfs]$ ~/Downloads/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-readelf -a ../Downloads/busybox-1.27.2/busybox | grep "Shared" | |
0x00000001 (NEEDED) Shared library: [libm.so.6] | |
0x00000001 (NEEDED) Shared library: [libc.so.6] | |
[mariotpc@fedora31 rootfs]$ ls lib/ -ltrah | |
total 24M | |
lrwxrwxrwx 1 mariotpc mariotpc 12 Mar 21 2019 libm.so.6 -> libm-2.28.so | |
-rwxr-xr-x 1 mariotpc mariotpc 6.2M Mar 21 2019 libm-2.28.so | |
lrwxrwxrwx 1 mariotpc mariotpc 12 Mar 21 2019 libc.so.6 -> libc-2.28.so | |
-rwxr-xr-x 1 mariotpc mariotpc 16M Mar 21 2019 libc-2.28.so | |
lrwxrwxrwx 1 mariotpc mariotpc 10 Mar 21 2019 ld-linux-armhf.so.3 -> ld-2.28.so | |
-rwxr-xr-x 1 mariotpc mariotpc 1.3M Mar 21 2019 ld-2.28.so | |
drwxrwxr-x 13 mariotpc mariotpc 4.0K Aug 24 18:47 .. | |
drwxrwxr-x 2 root root 4.0K Aug 24 19:31 . | |
4.- MKNOD to create the console and null | |
*************************************************************************** | |
only two nodes to boot BusyBox: console and null . | |
console only needs to be accessible by root , the owner of the device node, so the access permissions are 600 . | |
[mariotpc@fedora31 rootfs]$ cd ~/rootfs | |
[mariotpc@fedora31 rootfs]$ sudo mknod -m 666 dev/null c 1 3 | |
[mariotpc@fedora31 rootfs]$ sudo mknod -m 600 dev/console c 5 1 | |
[mariotpc@fedora31 rootfs]$ ls -ltra dev | |
total 8 | |
drwxrwxr-x 13 mariotpc mariotpc 4096 Aug 24 18:47 .. | |
crw-rw-rw- 1 root root 1, 3 Aug 24 19:35 null | |
crw------- 1 root root 5, 1 Aug 24 19:35 console | |
drwxrwxr-x 2 root root 4096 Aug 24 19:35 . | |
5.- Mount the proc and sys pseudofilesystems | |
# mount -t proc proc /proc | |
# mount -t sysfs sysfs /sys | |
Something bad occurs here | |
[mariotpc@fedora31 rootfs]$ sudo mount -t proc proc /proc | |
mount: /proc: proc already mounted on /proc. | |
[mariotpc@fedora31 rootfs]$ mount -t sysfs sysfs /sys | |
mount: only root can use "--types" option | |
[mariotpc@fedora31 rootfs]$ sudo mount -t sysfs sysfs /sys | |
mount: /sys: sysfs already mounted on /sys. | |
Tranfer the rootfs to the initram | |
*************************************************************************************** | |
1.- Enter to the rootfs | |
******************************************* | |
cd ~/rootfs | |
2.- create the file initramfs.cpio | |
******************************************* | |
[mariotpc@fedora31 rootfs]$ sudo find . | cpio -H newc -ov --owner root:root > ../initramfs.cpio | |
. | |
./tmp | |
./usr | |
./usr/lib | |
./usr/bin | |
./usr/sbin | |
./var | |
./var/log | |
./sys | |
./lib | |
./lib/libc.so.6 | |
./lib/libm-2.28.so | |
./lib/ld-linux-armhf.so.3 | |
./lib/libc-2.28.so | |
./lib/ld-2.28.so | |
./lib/libm.so.6 | |
./bin | |
./dev | |
./dev/console | |
./dev/null | |
./proc | |
./etc | |
./sbin | |
./home | |
47471 blocks | |
[mariotpc@fedora31 rootfs]$ | |
3.- compress it in gzip format | |
************************************ | |
cd .. | |
ls -ltr | |
drwxrwxr-x 13 mariotpc mariotpc 4096 Aug 24 18:47 rootfs | |
-rw-rw-r-- 1 mariotpc mariotpc 7662314 Aug 24 19:39 initramfs.cpio.gz | |
4.- Try with the previously created kernel | |
*************************************************** | |
my pwd | |
/home/mariotpc/Downloads/Embedded/linux-4.9.13/arch/arm/boot | |
qemu-system-arm -m 256M -nographic -M vexpress-a9 -kernel zImage -append "console=ttyAMA0,115200 \ | |
selinux=0 panic=1" -dtb ./dts/vexpress-v2p-ca9.dtb -initrd /home/mariotpc/initramfs.cpio.gz | |
At least my Kernel Works | |
*********************************************** | |
qemu-system-arm -M vexpress-a9 -kernel zImage -dtb ./dts/vexpress-v2p-ca9.dtb -initrd initrd.img-3.2.0-4-vexpress -drive if=sd,file=debian_wheezy_armhf_standard.qcow2 -append "root=/dev/mmcblk0p2" | |
https://people.debian.org/~aurel32/qemu/armhf/ | |
I wanto to try again to create the initrd image...!!! | |
It finally Works !!!! | |
************************************************ | |
qemu-system-arm -m 256 -M versatilepb -cpu arm926 -dtb /boot/dtbs/4.9.13-MarioTPC/versatile-pb.dtb -kernel zImage -append "console=ttyAMA0,115200 rdinit=/bin/sh" -initrd ./test3/initramfs.gz | |
/ # uname -a | |
Linux (none) 4.9.13-MarioTPC #1 Thu Aug 27 10:19:00 CST 2020 armv5tejl GNU/Linux | |
/ # busybox | |
BusyBox v1.22.0-MarioTPC (2020-08-27 19:41:26 CST) multi-call binary. | |
BusyBox is copyrighted by many authors between 1998-2012. | |
Licensed under GPLv2. See source distribution for detailed | |
copyright notices. | |
Last steps | |
***************************** | |
1.- Mount the proc pseudodevice | |
mount -t proc proc /proc | |
/ # mount -t proc proc /proc | |
/ # ps | |
PID USER TIME COMMAND | |
1 root 0:01 /bin/sh | |
2 root 0:00 [kthreadd] | |
3 root 0:00 [ksoftirqd/0] | |
5 root 0:00 [kworker/0:0H] | |
6 root 0:00 [kworker/u2:0] | |
7 root 0:00 [lru-add-drain] | |
8 root 0:00 [netns] | |
9 root 0:00 [oom_reaper] | |
10 root 0:00 [writeback] | |
11 root 0:00 [kcompactd0] | |
12 root 0:00 [crypto] | |
13 root 0:00 [bioset] | |
14 root 0:00 [kblockd] | |
15 root 0:00 [rpciod] | |
16 root 0:01 [kworker/0:1] | |
17 root 0:00 [xprtiod] | |
18 root 0:00 [kswapd0] | |
19 root 0:00 [nfsiod] | |
26 root 0:00 [bioset] | |
27 root 0:00 [bioset] | |
28 root 0:00 [bioset] | |
29 root 0:00 [bioset] | |
30 root 0:00 [bioset] | |
31 root 0:00 [bioset] | |
32 root 0:00 [bioset] | |
33 root 0:00 [bioset] | |
34 root 0:00 [bioset] | |
35 root 0:00 [bioset] | |
36 root 0:00 [bioset] | |
37 root 0:00 [bioset] | |
38 root 0:00 [bioset] | |
39 root 0:00 [bioset] | |
40 root 0:00 [bioset] | |
41 root 0:00 [bioset] | |
42 root 0:00 [kworker/0:2] | |
43 root 0:00 [kworker/u2:1] | |
68 root 0:00 ps | |
/ # cat /proc/cpu | |
cpu/ cpuinfo | |
/ # cat /proc/cpuinfo | |
processor : 0 | |
model name : ARM926EJ-S rev 5 (v5l) | |
BogoMIPS : 944.53 | |
Features : swp half thumb fastmult vfp edsp java | |
CPU implementer : 0x41 | |
CPU architecture: 5TEJ | |
CPU variant : 0x0 | |
CPU part : 0x926 | |
CPU revision : 5 | |
Hardware : ARM-Versatile (Device Tree Support) | |
Revision : 0000 | |
Serial : 0000000000000000 | |
/ # | |
2.- Mount the sys pseudodevice | |
********************************** | |
/ # mount -t sysfs sysfs /sys | |
/ # ls /sys | |
block class devices fs module | |
bus dev firmware kernel power | |
/ # | |
NOTES: | |
Kernel was compiled using: | |
gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf | |
Busybox was compiled using: | |
cross-compiler-armv6l | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment