Using a statically compiled C file as rootfs

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

Using a statically compiled C file as rootfs

912 Views
nabilb
Contributor I

Hello guys !

I want to boot my imx53-qsb board using not a normal rootfs but a statically compiled hello_world.c file in other words a hello_s.out.

To achieve that, I wrote a hello_world.c file cross compiled it statically to get my hello_s.out I put it in the mmcblk0p1 ext4 partition of my sd card. I put my uImage and my u-boot.imx in the mmcblk0.

I set after that my u-boot environment variables like this :

setenv bootargs_base 'setenv bootargs console=ttymxc0,115200'

setenv bootargs_mmc root=/dev/mmcblk0p1 rw rootfstype=ext4 init=/hello_s.out

setenv bootcmd_mmc 'run bootargs_base bootargs_mmc;mmc dev 0;mmc read ${loadaddr} 0x800 0x4000;bootm'

setenv bootcmd 'run bootcmd_mmc'

saveenv

run bootcmd

But the board boots and i got an error :

Please append a correct "root=" boot option; here are the available partitions:

b300         3872256 mmcblk0 driver: mmcblk

  b301         3868160 mmcblk0p1

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

Any solution please ?

Thanks

0 Kudos
3 Replies

862 Views
Yuri
NXP Employee
NXP Employee

Please check if Your kernel supports ext4.


Have a great day,
Yuri

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

862 Views
EricNelson
Senior Contributor II

Hi Nabil,

You need a root filesystem in order for the kernel to locate your init program, and it will need to be named according to conventions (usually /init).

You even hinted at this in your question:

     "I put it in the mmcblk0p1 ext4 partition..."

For this use case (highly specialized userspace), you'd normally want to use a RAM disk and have your boot loader load the ram disk and hand it off to the kernel. When doing this, you won't need a kernel command-line parameter specifying the root because it will be handed to the kernel by the boot loader.

0 Kudos

862 Views
nabilb
Contributor I

Hello Eric,

Thanks for your response.

But is it related to the version of the kernel that i am using ? Or to the board ?

Because I already did this with a beaglebone black and I didn't need the use of a ramdisk. I put the .out file directry in the partition and it worked.

0 Kudos