I am following the book "Mastering Embedded Linux Programming - Second Edition" trying to boot up the Linux kernel mounting a ramdisk.
I have U-boot 2020.01 working and the Linux kernel image made. I have made a file system on my computer where I have added busybox and the libraries required by it manually as so files. Here is summarized copy of tree in my filesystem.
├── bin │ ├── arch -> busybox ... │ ├── busybox │ ├── cat -> busybox ... ├── dev ├── etc ├── home ├── lib │ ├── ld-2.30.so │ ├── ld-linux-armhf.so.3 -> ld-2.30.so │ ├── libc-2.30.so │ ├── libc.so.6 -> libc-2.30.so │ ├── libm-2.30.so │ ├── libm.so.6 -> libm-2.30.so │ ├── libresolv-2.30.so │ └── libresolv.so.2 -> libresolv-2.30.so ├── linuxrc -> bin/busybox ├── proc ├── sbin │ ├── acpid -> ../bin/busybox ... ├── sys ├── tmp ├── usr │ ├── bin │ │ ├── [ -> ../../bin/busybox ... │ ├── lib │ └── sbin │ ├── addgroup -> ../../bin/busybox ... └── var └── log
I have created my ramdisk image following the snippet:
cd ~/rootfs find . | cpio -H newc -ov --owner root:root > ../initramfs.cpio cd .. gzip initramfs.cpio mkimage -A arm -O linux -T ramdisk -d initramfs.cpio.gz uRamdisk
I have placed all the needed files in the SD card and in u-boot in the Beaglebone black tried to boot as:
fatload mmc 0:1 0x80200000 zImage fatload mmc 0:1 0x80f00000 am335x-boneblack.dtb fatload mmc 0:1 0x81000000 uRamdisk setenv bootargs console=ttyO0,115200 rdinit=/bin/sh bootz 0x80200000 0x81000000 0x80f00000
The problem is after the bootz it complains about my ramdisk image being wrong.
=> fatload mmc 0:1 0x80200000 zImage 7109016 bytes read in 464 ms (14.6 MiB/s) => fatload mmc 0:1 0x80f00000 am335x-boneblack.dtb 34220 bytes read in 5 ms (6.5 MiB/s) => fatload mmc 0:1 0x81000000 uRamdisk 2828897 bytes read in 185 ms (14.6 MiB/s) => setenv bootargs console=ttyO0,115200 rdinit=/bin/sh => bootz 0x80200000 0x81000000 0x80f00000 Wrong Ramdisk Image Format Ramdisk image is corrupt or invalid
As I am starting with Linux on embedded devices I am completely out of ideas on how to solve the issue. I have found the reason is that the filesystem image has been created wrong. I have tried to use mkimage with
-c none to no avail. I have tried using the mkimage inside my u-boot copy instead of the one that you can install in Ubuntu (with sudo apt-get install u-boot-tools).
Before mkimage is called initramfs.cpio.gz looks as as follow:
Am I missing some folders/files in my filesystem? Is it a problem my computer has ext4 but the boot partition uses fat32? Do I need to use a different mkimage toolset? What could be the problem?