1

I've installed Petalinux 2014.4 on my Zynq board, but the NAND flash is not mounted when I boot up the board. I'm wondering if it's possible to change rootfs.cpio by extracting the package and then do changes to fstab and so make a cpio arhcive back. If yes, is it enough to just run petalinux-build after that?

Thanks :)

user2466860
  • 67
  • 1
  • 2
  • 13

3 Answers3

2

If you have access to the ramdisk image file, then yes, you can modify its contents. I assume that your image file is compressed using gzip. Furthermore I assume that you use U-Boot and your compressed ramdisk image has a U-Boot preamble.

First you need to strip the U-Boot header:

dd bs=64 skip=1 if=uramdisk.cpio.gz of=ramdisk.cpio.gz

Next, we decompress:

gunzip ramdisk.cpio.gz

Finally we extract the CPIO archive:

mkdir ramdisk && cd ramdisk
cpio -i -F ../ramdisk.cpio

Either you execute the latter command as root or you change the file ownership back to root before archiving again. This is necessary for your init program to start. After your modifications you can create your image file again:

find . | cpio -o -H newc | gzip -9 > ../ramdisk_new.cpio.gz
mkimage -A arm -T ramdisk -C gzip -d ramdisk_new.cpio.gz uramdisk.image.gz

Notice that the mkimage tool is part of U-Boot and is located in the respective sources in the tools directory.

I am not familiar with PetaLinux so I don't know whether this general answer suits your needs and expectations.

sven
  • 371
  • 2
  • 11
2

Using cpio package tools is OK. But it needs to be done every time you updates rootfs.

You can also use PetaLinux built-in tool to accomplish this. It doesn't need extra steps once you set it up.

Create the app:

petalinux-create -t apps -n fstab_mount_sd --template install --enable

In the created components/apps/fstab_mount_sd directory, modify the Makefile to append contents to current fstab file or replace the original fstab with your version of fstab file.

Here's an example of the fstab_mount_sd Makefile:

install:    
    $(TARGETINST) -a "/dev/mmcblk0p1       /media/card          auto           defaults,sync,noauto      0  0" /etc/fstab

$(TARGETINST) -a means append the following text to the destination file.

Note: commands in makefile should start with Tab. Replace the spaces before $(TARGETINST) in previous code block with a Tab.

You can read the help of the $(TARGETINST) command by going to PetaLinux install directory and run components/rootfs/targetroot-inst.sh

Ricky Su
  • 51
  • 5
0

More convenient while development is using any standard distribution. Petalinux can be used to create the kernel, u-boot files. Then install a Linux of your favor on the sd card and boot it up. You can use the standard tools apt for example to install packages.

akira hinoshiro
  • 393
  • 2
  • 15