Yocto initramfs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Yocto initramfs

47,879 Views
saurabh206
Senior Contributor III

Hi,

How to prepare initramfs RAMDisk image using Yocto build?

Labels (1)
Tags (1)
18 Replies

23,844 Views
karthikeyanraju
Contributor III

Finally i got zImage with Initramfs file (zImage***.bin file) ... Can anyone tell me how to use this .bin file ? Is it possible to use this file instead of zImage ? or else tell me how to flash ? 

0 Kudos
Reply

23,844 Views
michaelwesley
Contributor I

Hi Karthikeyan Raju,

    I haven't seen any conversation for last one week on this thread. I'll share my thoughts & findings regarding the same, hope you get an idea. Your initramfs bin file(zImage***.bin file) was combined with zImage + initramfs cpio archive file, but i didn't used this combined file in my board instead of that i'm loading individualy(like zImage, dtb and initramfs file, not a combined bin file).

-> Is it possible to use this file instead of zImage?
    Yes, ofcourse. you could may use complete bin file instead of initramfs but my suggestion for you to better load the files individually.

-> Why we need to load individually?
    If you are working on multiple operating system, better you use seperate files for precision & linearity. It really helps while development.

Hope it helps.

0 Kudos
Reply

23,844 Views
georgechiao
Contributor II

Hi,

Do you know or could you guide me through briefly how to use the complete bin file?

Thanks

0 Kudos
Reply

23,844 Views
patrickphilp
Contributor II

After trying the above suggestions with limited success, I found a different solution.

In your .../conf directory, create a file (mine is named initramfs.conf ) and add the following to the file:

INITRAMFS_IMAGE = "core-image-base"

INITRAMFS_IMAGE_BUNDLE = "1"

IMAGE_FSTYPES = "cpio.gz"

Then to build the initramfs based on the core-image-base recipe, execute the following bitbake command:

     bitbake -R conf/initramfs.conf core-image-base

When it completes, there will be a kernel + initramfs file in the .../tmp/deploy/images/..../  directory.

To build an initramfs image for a recipe other than core-image-base, just modify the initramfs.conf file and specify the image name in the INITRAMFS_IMAGE variable, and then include the image name on the bitbake command line.

23,844 Views
amarnathpujari1
Contributor I

hi patrick,
can you please guide me for, how i can confirm that the kernel is getting build with initramfs ?
we have the entry called CONFIG_INITRAMFS_SOURCE in kernel's .config file, so is it expected that we should get the path of initramfs.cpio.gz file in the .config file for CONFIG_INITRAMFS_SOURCE entry ?

I tried the solution you mentioned above, but i am not getting the path for initramfs in the CONFIG_INITRAMFS_SOURCE, it is still blank.
Please suggest if I need to check any other fields.

regards,
/amar

0 Kudos
Reply

23,844 Views
larslarsen
Contributor I

hi Patrick

A question...  perhaps a little off-topic, but if you have any comments I'll be glad

I managed to  build an image, following your recipe : 

resulting in bzImage-initramfs-genericx86.bin

but I'm having trouble getting it  to boot on my target.

I'm using syslinux

in syslinux.cfg I have 

ALLOWOPTIONS 1
SERIAL 0 115200
DEFAULT boot
TIMEOUT 50
PROMPT 1

LABEL boot
KERNEL /bzImage-initramfs-genericx86.bin
APPEND LABEL=boot root=/dev/ram0

before  when I was building 'normally'  I had 

LABEL boot
KERNEL /vmlinuz
APPEND initrd=/initrd LABEL=boot root=/dev/ram0

-Lars

0 Kudos
Reply

23,844 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Have you tried to generate the core-image-minimal-initramfs? The image is used for minimal RAM based rootfs.

Regards,

Alejandro

0 Kudos
Reply

23,844 Views
chenabner
Contributor I

Hi Sir,

I base on FSL YOCTO 3.14.28_1.0.1 code to run core-image-minimal-initramfs function.

But it still has some error message.

Which file I need to update ?

bitbake core-image-minimal-initramfs

Loading cache: 100% |###########################################| ETA:  00:00:00

Loaded 2524 entries from dependency cache.

NOTE: Resolving any missing task queue dependencies

ERROR: Nothing RPROVIDES 'initramfs-live-install' (but /home/abner/fsl-imx6-yacto/sources/poky/meta/recipes-core/images/core-image-minimal-initramfs.bb RDEPENDS on or otherwise requires it)

ERROR: initramfs-live-install was skipped: incompatible with host arm-poky-linux-gnueabi (not in COMPATIBLE_HOST)

NOTE: Runtime target 'initramfs-live-install' is unbuildable, removing...

Missing or unbuildable dependency chain was: ['initramfs-live-install']

ERROR: Required build target 'core-image-minimal-initramfs' has no buildable providers.

Missing or unbuildable dependency chain was: ['core-image-minimal-initramfs', 'initramfs-live-install']

0 Kudos
Reply

23,844 Views
michaelwesley
Contributor I

Hi,

I'm also getting the same error in my freescale development board based on imx6, BTW, initramfs live is not compatible for arm architectures by the recipe file.

Like live-boot, i'm adding the machine architecture in the COMPATIBLE version/label like below,

-> initramfs-live-install_1.0.bb and initramfs-live-install-efi_1.0.bb

From,

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

To,

COMPATIBLE_MACHINE = "${MACHINE_ARCH}"

Here, MACHINE_ARCH represents your arm board.

Now, i'm getting cpio.gz files in /tmp/deploy/images/<board_name>/

0 Kudos
Reply

23,844 Views
kbingham
Contributor II

Did anyone get anywhere with this?

I'm also trying to create an initramfs for freescale (wandboard)

0 Kudos
Reply

23,843 Views
kbingham
Contributor II

Not to worry - Managed to do this by creating a new -initramfs.bb image, and adding

include original-image.bb

IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"

PACKAGE_INSTALL = "${IMAGE_INSTALL}"

And then in conf/local.conf

INITRAMFS_IMAGE = "image-initramfs"   ### < image-initramfs is the .bb file above

INITRAMFS_IMAGE_BUNDLE = "1"

23,843 Views
adc1
Contributor IV

Hi Kieran,

I tried to modify my image recipe (a generic image recipe similar to core-image-minimal) as your hints suggest. I obtain a cpio.gz file but, using it as my INITRAMFS_SOURCE, kernel boot show me some "mount: you must be root" messages and than hangs. What could they means? Have I to configure something else into my recipe file?

thanks

Andrea

0 Kudos
Reply

23,844 Views
kbingham
Contributor II

Hi Andrea,

Difficult to say for sure without seeing your logs or knowing what your process was.

When I built my initramfs image, I didn't have to use it as my INITRAMFS_SOURCE manually - it is all done automatically by setting

in conf/local.conf

INITRAMFS_IMAGE = "wandboard-initramfs"

INITRAMFS_IMAGE_BUNDLE = "1"

Then running my usual 'bitbake wandboard-image'

This causes the kernel build to be run separately and creates the zImage-initramfs-wandboard.bin which is now a kernel and filesystem in one binary that I loaded over tftpboot.

23,844 Views
adc1
Contributor IV

Hi Kieran,

thank you for the reply. I've tried, as you suggest, configuring directly local.conf file without manually setup kernel INITRAMFS_SOURCE and, in this way, I can load and run output image without any problem. But, if I would to extract cpio filesystem to update it adding some configuration or files, the only way I see to bundle it into my kernel image is to configure INITRAMFS_SOURCE. Why if I do that do I not obtain the same output? Why, in this way, are devfs not loaded and I have to add manually /dev/console and /dev/tty0? What could differ?

Has someone any hints?

regards

Andrea

0 Kudos
Reply

23,844 Views
kbingham
Contributor II

Hi Andrea,

Good to hear you can get an image booted and running with initramfs as you desire. It sounds like now its just a case of customising the image that is created for the initramfs. I think as you are already using a recipe to get this far - it wouldn't make sense to then pull out the filesystem and start making manual changes.

I would suggest that your configuration and files should be provided by a recipe included in your $(yourimage)-initramfs.bb.

You could add to the packages that go into just the initramfs by adding them to the package install line ...

for example:

PACKAGE_INSTALL = "${IMAGE_INSTALL} dropbear i2c-tools"

Of course - you don't even have to pull in the normal IMAGE_INSTALL rules, you could subset from there too ... I chose to do that as I wanted the whole system to run from initramfs.

0 Kudos
Reply

23,844 Views
adc1
Contributor IV

Hi Kieran,

thank you for your suggestions. anyway my problems were connected with an error extracting cpio package.

now my output image work as Yocto bundle image.

regards

Andrea

0 Kudos
Reply

23,843 Views
marcus123
Contributor I

Hi Kieran,

Could you explain what the above changes do to make the build work?

Regards

Marcus

0 Kudos
Reply

23,843 Views
kbingham
Contributor II

Hi Marcus,

I have created a separate image.bb file for my target. Its based on wandboard, but I'm sure your's will be whatever you want.

I have a wandboard-image.bb which contains a minimal image inherited from core-image and my own application.

file wandboard-image.bb:

<pre>

DESCRIPTION = "A wandboard base image"<br/>

IMAGE_INSTALL = "packagegroup-core-boot packagegroup-machine-base ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${my_extra_application}"<br/>

inherit core-image<br/>

</pre>

I can use this wandboard-image to create a working image that I use to write to SD card successfully. I would expect you would have your own variant of this perhaps.

Then to create a separate binary which puts all of that into one kernel which contains the root filesystem as an initramfs:

file wandboard-image-initramfs.bb:  ## Comments added with 2 ##

<pre>

include wandboard-image.bb          ## This pulls in the above tested image to define my filesystem<br>

DESCRIPTION = "An Initramfs wandboard image..."<br>

IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"     ## This is required to make an initramfs filesystem<br>

PACKAGE_INSTALL = "${IMAGE_INSTALL}" ## This is defined in the included image, and duplicates my original image into the initramfs.<br>

</pre>

So that  defines how the initramfs image should be created for my image.

Then to actually ask it to be built (it is created as a separate binary in the tmp/deploy/images/ directory) you need to provide the reference in the conf/local.conf

0 Kudos
Reply