iMX6 - filesystem as RAMdisk

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

iMX6 - filesystem as RAMdisk

5,378 Views
andreapizzato
Contributor II

Hello,

on my custom board with iMX6, I'm trying to launch a Linux filesystem from on-board MMC to RAM-disk; MMC if formatted as below:

   Units = sectors of 1 * 512 = 512 bytes

   Device Boot               Start           End        Blocks    Id    System

   /dev/mmcblk0p1       40960      655359        307200    83    Linux

   /dev/mmcblk0p2     655360    1064959        204800    83    Linux

   /dev/mmcblk0p3   1064960   30535679    14735360    83    Linux

U-boot and kernel are stored in /dev/mmcblk0

The rootfs.ext2.gz and rootfs.ext2.gz.uboot files was created with LTIB with this configuration:

   General setup > initial ram filesystem and ram disk support --> CONFIG_BLK_DEV_INITRD=y, CONFIG_RD_GZIP=y

   Device drivers > block devices > ram block device support --> CONFIG_BLK_DEV_RAM=y, CONFIG_BLK_DEV_RAM_COUNT=16, CONFIG_BLK_DEV_RAM_SIZE=4096

The rootfs.ext2.gz was copied in MMC in the second partition, using the command:

   dd if=rootfs.ext2.gz of=/dev/mmcblk0p2 conv=fsync

thus it is stored at address 655360, that is 0xA0000.

Then, I changed the U-boot parameters:

   setenv bootcmd_mmc 'run bootargs_base bootargs_mmc; mmc dev 3; mmc read ${loadaddr} 0x2000 0x2000; mmc read 0x13000000 0xA0000 0xC000; bootm'

      (the compressed rootfs is read from MMC starting from 0xA0000 and stored in memory at 0x13000000)

   setenv bootargs_mmc 'setenv bootargs ${bootargs} root=/dev/ram0 rw initrd=0x13000000,200M'

      (the root device is /dev/ram0; the compressed rootfs is read starting from address 0x13000000; 200MB was allocated for ram-file-system)

Executing the boot, the kernel is correctly launched but, at time to mount the file-system, these messages are displayed on the console:

   RAMDISK: gzip image found

   Uncompression error

   VFS: mounted root (ext2 filesystem) on device 1:0

   EXT2-fs (ram0): error: ... ...

   Kernel panic ...

After this, I repeated the same procedure using the file rootfs.ext2.gz.uboot (instead of rootfs.ext2.gz); in this case, executing the boot, on console appear

   RAMDISK: Couldn't find valid RAM disk image

   Kernel panic ...

Any suggestions?

Thank you very much!

Andrea

Labels (1)
0 Kudos
Reply
3 Replies

2,228 Views
andreapizzato
Contributor II

Problem solved.

The error is in setenv bootargs_mmc 'setenv bootargs ${bootargs} root=/dev/ram0 rw initrd=0x13000000,200M'

I need to define how much memory (in kB) to allocate for /dev/ram0 in order to hold all the uncompressed filesystem: for this, I need to add ramdisk_size=200000

Moreover, the second parameter passed to the initrd is the size, in MB, of compressed filesystem, that is (in my case) about 25MB.

Summary, the correct string is setenv bootargs_mmc 'setenv bootargs ${bootargs} root=/dev/ram0 ramdisk_size=200000 rw initrd=0x13000000,25M'

In this way, my system load the filesystem in RAM.

0 Kudos
Reply

2,228 Views
rja
Contributor II

Hi, 

I know this post is really old but I was wondering if you could list what you have in your bootargs variable when you include it at the beginning of your setenv bootargs command.

Thanks

Ryan

0 Kudos
Reply

2,228 Views
ottawa-imx6
Contributor IV

I 'think' that the bootm command needs to know where the ramdisk is too..

for example...

bootcmd=tftp 0x10800000 uImage; tftp 0x12000000 ramdisk; bootm 0x10800000 0x12000000

0 Kudos
Reply