Export device system

When the user has completed the deployment of the working environment on one device, the current environment needs to be exported completely to deploy to other devices in batches. The current development environment can be backed up by exporting the device file system.

Exporting the device system is divided into two steps:

  1. Export the Ubuntu root file system rootfs on the device;

  2. Repackage the complete firmware, combine Ubuntu rootfs with other partitions where the firmware is released, complete the secondary packaging, and generate a new complete firmware.

Export device rootfs

Note that the following operations are all performed on the device side.

  1. In the Ubuntu environment of the device, install fireflydev:

    sudo apt update
    sudo apt install fireflydev
    
  2. After installing fireflydev, you can use the ff_export_rootfs script to export the root file system

    • It is recommended to use a mobile hard disk with a larger capacity

    • The exporter does things like apt clean to reduce the filesystem size

    • Export the root file system, for example, to the /media/firefly/AC91-C4AE/ directory (it takes a while):

    ff_export_rootfs /media/firefly/AC91-C4AE/
    
    • Compress the file system, delete unnecessary blank space to reduce memory resource usage:

    # Some customers said that the size of the exported rootfs is 3.3G, but actually only 3G is used, because the rootfs is not compressed
    e2fsck -p -f Firefly_Ubuntu_18.04.6_rootfs.img
    resize2fs -M Firefly_Ubuntu_18.04.6_rootfs.img
    

Second package complete firmware

Note that the following operations are all performed on the PC (x86-64 architecture).

  1. Install the necessary packages: sudo apt-get install lib32stdc++6

  2. Download the secondary packaging tool: firefly-linux-repack

  3. Unzip the secondary packaging tool:

    tar -xzf firefly-linux-repack.tgz
    cd firefly-linux-repack
    

    The directory is as follows:

    firefly-linux-repack
        ├── bin
        │   ├── afptool
        │   └── rkImageMaker
        ├── pack.sh # packaging script
        ├── Readme_en.md
        ├── Readme.md
        └── unpack.sh # unpack script
    
  4. Unpacking operation: Copy the official Ubuntu firmware to the firefly-linux-repack root directory, rename it to update.img, and execute the unpacking script unpack.sh. After the unpacking is complete, the partition files are in the output directory.

    mv /path/to/ROC-RK3566-PC_Ubuntu18.04-r21156_v1.2.4a_220519.img update.img
    ./unpack.sh
    
  5. Packaging operation: Keep the current directory structure and file name unchanged, connect the mobile hard disk to the PC, replace output/Image/rootfs.img with the Ubuntu rootfs exported earlier, and then execute the packaging script pack.sh .

    cp /media/customer/1878-4615/Firefly_Ubuntu_18.04.6_rootfs.img /path/to/firefly-linux-repack/output/Image/rootfs.img
    ./pack.sh
    
  6. The new full firmware is new_update.img in the current directory.