Bundle a core-image-tiny-initramfs to a core-image-minimal .wic image file in my "zeus" yocto-Linux project

cancel
Showing results for 
Search instead for 
Did you mean: 

Bundle a core-image-tiny-initramfs to a core-image-minimal .wic image file in my "zeus" yocto-Linux project

Jump to solution
1,968 Views
fbre
Contributor III

Hi,

I have problems to get an initramfs work which should be bundled to the kernel via INITRAMFS_IMAGE_BUNDLE.

I switched to "zeus" as yocto version to be able to work with .wic files. I have an i.MX8mm evalboard where I boot Linux from SD card.

That's why I configured the build with: DISTRO=fsl-imx-wayland MACHINE=imx8mmevk source imx-setup-release.sh -b build which results to the following variables in local.conf:

MACHINE  ??= 'imx8mmevk'

DISTRO ?= 'fsl-imx-wayland'

The rest is as it comes by default.

What did I do?:

  1. First, I added the following lines to my yocto/build/conf/local.conf of yocto:

    INITRAMFS_IMAGE = "core-image-tiny-initramfs"

    INITRAMFS_IMAGE_BUNDLE = "1"

    VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"

  2. Second, for a fast trial, I also changed a line in yocto/sources/poky/meta/recipes-core/images/core-image-tiny-initramfs.bb to add aarch64 support:

    COMPATIBLE_HOST = "(i.86|x86_64|aarch64).*-linux"

  3. and I commented out a line in yocto/sources/meta-imx/meta-bsp/conf/layer.conf this way:

    #IMAGE_CLASSES += "image_types_create_sdcard_symlink"

  4. Now I was able to build the whole thing with bitbake core-image-minimal without errors. I think, the resulting key files in yocto/build/tmp/deploy/images/imx8mmevk are the following, and I also extracted the wic.bz2 already here:

    core-image-minimal-imx8mmevk-[timestamp].rootfs.wic.bz2     42,3 MiB

    core-image-minimal-imx8mmevk-[timestamp].rootfs.wic         271,2 MiB
    core-image-tiny-initramfs.imx8mmevk-[timestamp].rootfs.cpio.gz 11,8 MiB
    core-image-tiny-initramfs.imx8mmevk.cpio.gz    (link to file above)
  5. Next I wrote that .wic file to my SD card with dd (as described in the NXP docs).
  6. I plugged that SD card into my eval board, switched on and typed on u-boot command line this one:

    setenv mmcroot /dev/ram0 rootwait rw

    boot
  7. Now the Linux boots properly but hangs with: Waiting for root device /dev/ram0...

  8. When I keep the mmcroot in u-boot to /dev/mmcblk1p2, Linux boots without problems! But in that case I cannot see it boots via initramfs. It uses the common rootfs of core-image-minimal.

It seems to me a core-image-minimal image without bundled initramfs image is just 200KB smaller. So I suspect the bundling does not properly work.

What goes wrong? What must be changed to let the Linux kernel use the bundled initramfs RAM filesystem??? Is there a problem with the scripts which bundle the initramfs to the wic file?

The actual thing I want to do is to setup my Linux with an overlayfs over the whole rootfs, and I can see core-image-tiny-initramfs is exactly doing that as it is configured so via its yocto/sources/poky/meta/recipes-core/initrdscripts/files/init-live.sh.

Thanx in advance for your help.

Tags (2)
0 Kudos
1 Solution
1,807 Views
fbre
Contributor III

Meanwhile I found out I also have to do 2 things more to really boot with that bundled initramfs:

  1. It is also necessary to add this IMAGE_BOOT_FILES_append = " ${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin" to conf/local.conf. This let the build system put the file Image-initramfs-imx8mmevk.bin to the boot partition of the SD card also. Now we have 2 kernel images, Image is the default one and that new Image-initramfs-imx8mmevk.bin which is the kernel with the bundled initramfs.
  2. Now when I stop in u-boot on command line I have to call the following command to tell u-boot to use the other Linux kernel on boot:     setenv image Image-initramfs-imx8mmevk.bin

Well, now it boots the kernel with the bundled initramfs but stops now here:

[    3.806081] mmc1: new ultra high speed SDR104 SDHC card at address 0001
[    3.813856] mmcblk1: mmc1:0001 EB1QT 29.8 GiB
[    3.820328]  mmcblk1: p1 p2
[    4.131276] imx6q-pcie 33800000.pcie: Phy link never came up
[    4.136983] imx6q-pcie 33800000.pcie: failed to initialize host
[    4.142921] imx6q-pcie 33800000.pcie: unable to add pcie port.
[    4.161500] Freeing unused kernel memory: 40640K
[    4.166205] Run /init as init process
Starting version 243.2+
Waiting for removable media...

I've searched the internet for this problem and found this one: Waiting for removable media ... 

So the cool thing is I realise my core-image-tiny-initramfs has started up. :-) I just need to tweak the script recipes-core/initrdscripts/files/init-live.sh a bit, and I must remove the script part with the loop of waiting for plugging in a live-CD to get over that hang on "Waiting for removable media". I must set my own /dev/mmcblk1p2 partition to be the lower layer for the overlayfs. Just look at script function mount_and_boot() in init-live.sh...

I hope this answer may help other people, too. It took me lots of hours, and I have to thank the yocto guys at freenode chat irc for their incredible help to solve this problem.

-- Cheers, F.B.

View solution in original post

0 Kudos
4 Replies
114 Views
fbre
Contributor III

OK, in the end I switched to yocto-version "dunfell" and it works there pretty easy with these settings:

INITRAMFS_IMAGE = "core-image-tiny-initramfs"
INITRAMFS_IMAGE_BUNDLE = "1"
INITRAMFS_KERNEL_IMAGE="${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin"
VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
IMAGE_BOOT_FILES_append = " ${INITRAMFS_KERNEL_IMAGE};${KERNEL_IMAGETYPE}"

 

0 Kudos
1,808 Views
fbre
Contributor III

Meanwhile I found out I also have to do 2 things more to really boot with that bundled initramfs:

  1. It is also necessary to add this IMAGE_BOOT_FILES_append = " ${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin" to conf/local.conf. This let the build system put the file Image-initramfs-imx8mmevk.bin to the boot partition of the SD card also. Now we have 2 kernel images, Image is the default one and that new Image-initramfs-imx8mmevk.bin which is the kernel with the bundled initramfs.
  2. Now when I stop in u-boot on command line I have to call the following command to tell u-boot to use the other Linux kernel on boot:     setenv image Image-initramfs-imx8mmevk.bin

Well, now it boots the kernel with the bundled initramfs but stops now here:

[    3.806081] mmc1: new ultra high speed SDR104 SDHC card at address 0001
[    3.813856] mmcblk1: mmc1:0001 EB1QT 29.8 GiB
[    3.820328]  mmcblk1: p1 p2
[    4.131276] imx6q-pcie 33800000.pcie: Phy link never came up
[    4.136983] imx6q-pcie 33800000.pcie: failed to initialize host
[    4.142921] imx6q-pcie 33800000.pcie: unable to add pcie port.
[    4.161500] Freeing unused kernel memory: 40640K
[    4.166205] Run /init as init process
Starting version 243.2+
Waiting for removable media...

I've searched the internet for this problem and found this one: Waiting for removable media ... 

So the cool thing is I realise my core-image-tiny-initramfs has started up. :-) I just need to tweak the script recipes-core/initrdscripts/files/init-live.sh a bit, and I must remove the script part with the loop of waiting for plugging in a live-CD to get over that hang on "Waiting for removable media". I must set my own /dev/mmcblk1p2 partition to be the lower layer for the overlayfs. Just look at script function mount_and_boot() in init-live.sh...

I hope this answer may help other people, too. It took me lots of hours, and I have to thank the yocto guys at freenode chat irc for their incredible help to solve this problem.

-- Cheers, F.B.

View solution in original post

0 Kudos
1,807 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello F B,

Have you tried to generate the core-image-minimal-initramfs? The image is used for minimal RAM based rootfs. Let me know more details about the issue - how it can be reproduced ?

Regards

0 Kudos
1,807 Views
fbre
Contributor III

Yes, I also tried INITRAMFS_IMAGE = core-image-minimal-initramfs instead of INITRAMFS_IMAGE = core-image-tiny-initramfs. Also here, I had to add aarch64 to the .bb file of this image. But in the end I get a strange bitbake error on generating the rootfs:

"Some packages could not be installed....

The following packages have unmet dependencies:

initramfs-module-install : Depends: grub but it is not installable"

I haven't tried to go this path further since my actual aim was to have that overlayfs stuff of init-live.sh which is not in the scripts of core-image-minimal-initramfs, you know.

This all can be reproduced with a fresh git checkout of the current zeus branch. Just follow the instructions of https://www.nxp.com/docs/en/user-guide/IMX_YOCTO_PROJECT_USERS_GUIDE.pdf A.1Quick Start, and additionally do the things described in this posting.

0 Kudos