How to modify content of the existing rootfs?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to modify content of the existing rootfs?

No ratings

How to modify content of the existing rootfs?

The below steps describe how to modify the content of the existing rootfs.

Steps are explained using LX2160ARDB board, however, the steps are applicable to all Layerscape devices and boards.

  1. Extract and modify contents of cpio.gz archive
  2. Generate .itb image
  3. Set up Ethernet connection between TFTP server and Layerscape board
  4. Boot the Linux kernel using new .itb image

Step1: Extract and modify contents of cpio.gz archive

  1. Create a temporary directory for extracting the contents of the cpio.gz archive image. For example: mkdir temp_folder. 

  2. Extract the contents of the cpio.gz archive in the temporary folder.

    For example: gunzip -c rootfs_lsdk2012_yocto_tiny_arm64.cpio.gz | sh -c 'cd temp_folder/&& cpio -i'

  3. The temporary folder lists the filesystem as follows: 
    bin boot dev etc home init lib media mnt proc run sbin sys tmp usr var
  4. Make changes to the filesystem in the temporary folder. For example: copy a 'HelloWorld' file in the filesystem using the following command: cp <path>/HelloWorld .
  5. Repack the filesystem into a new cpio.gz archive. For example: use the following command: sh -c 'cd temp_folder/ && find . | cpio -H newc -o' | gzip -9 > new_rootfs_lsdk2012_yocto_tiny_arm64.cpio.gz

 

Step2: Generate .itb image

  1. Change the path for new rootfs (new_rootfs_lsdk2012_yocto_tiny_arm64.cpio.gz) in linux_arm64_LS.its using gedit editor.
    For example: 
    Change directory to flexbuild_lsdk<version>/configs/linux.
    gedit linux_arm64_LS.its
    Update path as follows: 
    data = /incbin/("../../packages/rfs/initrd/new_rootfs_lsdk2012_yocto_tiny_arm64.cpio.gz");
  2. Generate .itb image using the following command:

    For example: flex-builder -i mkitb -r yocto:tiny

    This generates lsdk2012_yocto_tiny_LS_arm64.itb image.

  3. Copy the .itb image to the TFTP server.

Step 3 - Set up Ethernet connection between TFTP server and Layerscape board

Set up Ethernet connection between the board (for example, LX2160ARDB) and host machine on which you have configured the TFTP server.

  1. Boot the board to U-Boot prompt. U-Boot prints a list of enabled Ethernet interfaces. For example, LX2160ARDB U-Boot prints following Ethernet interfaces.

    DPMAC2@xlaui4, DPMAC3@xgmii, DPMAC4@xgmii, DPMAC5@25g-aui, DPMAC6@25g-aui, DPMAC17@rgmii-id, DPMAC18@rgmii-id 

  2. Set server IP address to the IP address of the host machine on which you have configured the TFTP server.

    => setenv serverip <ipaddress1>

  3. Set ethact and ethprime as the ethernet interface connected to the TFTP server.

    See LX2160ARDB Ethernet Port Mapping for the mapping of Ethernet port names appearing on the chassis front panel with the port names in U-Boot and Linux.

    => setenv ethprime <name of interface connected to TFTP server>

    For example:

    => setenv ethprime DPMAC3@xgmii

    => setenv ethact <name of interface connected to TFTP server>

    For example:

    => setenv ethact DPMAC3@xgmii

  4. Set IP address of the board. You can set a static IP address or, if the board can connect to a dhcp server, you can use the dhcp command. 

    Static IP address assignment:
    => setenv ipaddr <ipaddress2>
    => setenv netmask <subnet mask>

    Dynamic IP address assignment:
    => dhcp

  5. Save the settings.

    => saveenv

  6. Check the connection between the board and the TFTP server.

    => ping $serverip

    Using DPMAC3@xgmii device

    host 192.168.2.1 is alive

Step4: Boot the Linux kernel using new .itb image

  1. Load the .itb image from TFTP server to DDR memory of the board.

    => tftp 0xa0000000 <itb_file_name>

    For example: => tftp 0xa0000000 lsdk2012_yocto_tiny_LS_arm64.itb

  2. Boot the kernel with .itb image as follows:

    => bootm 0xa0000000#<board_name>

    For example: => bootm 0xa0000000#lx2160ardb

    Let the board boots to Tiny Linux.

  3. List the filesystem.
    NXP LSDK tiny 2012 (based on Yocto)
    TinyLinux login: root
    root@TinyLinux:~# ls
    root@TinyLinux:~# cd /
    root@TinyLinux:/# ls
    HelloWorld boot etc init media new_rootfs_lsdk2012_yocto_tiny_arm64.cpio.gz root sbin tmp var
    bin dev home lib mnt proc run sys usr
    root@TinyLinux:/#

    You will observe the HelloWorld file available in the filesystem.

Version history
Revision #:
9 of 9
Last update:
‎08-01-2021 10:52 PM
Updated by: