OK3562 Buildroot: Two Methods to Add User Files to the Image

This technical guide provides professional methods for integrating user product files, applications, and shared libraries into the OK3562-linux-source. By leveraging the Buildroot fs-overlay mechanism, you can compile custom assets directly into the system image, which effectively avoids the need to separately copy programs to the OK3562-C ARM development board after burning the firmware.

Modification Method

Method 1: Compile directly into the source code

Location path:

User programs can be copied to the/OK3562-linux-source/build root/board/forlinx/ok3562/fs-overlay/usr/bin directory.

The configuration file can be copied to the/OK3562-linux-source/build root/board/forlinx/ok3562/fs-overlay/etc directory.

The library file can be copied to the/OK3562-linux-source/buildroot/board/forlinx/ok3562/fs-overlay/lib directory.

You can also create your own folders in the/OK3562-linux-source/buildroot/board/forlinx/ok3562/fs-overlay/directory to store their own files.

This article takes copying aarch64-buildroot-linux-gnu _ sdk-buildroot. tar. gz compressed package as an example.

1. Copy the file to the specified path

Create a directory called test at/OK3562-linux-source/buildroot/board/forlinx/ok3562/fs-overlay/. Place the aarch64-buildroot-linux-gnu _ SDK-buildroot. tar. gz archive in this directory:

Directory structure showing aarch64-buildroot-linux-gnu _ SDK-buildroot. tar. gz placed in the fs-overlay test folder

2. Source Code Compilation

Execute the full compilation command

./build. sh all
After compilation, you can see the generated test directory in OK3562-linux-fs/rootfs, which contains the compressed package:


Terminal file listing showing the test directory and SDK package in the target rootfs after compilation

3. Development Board Verification

Using the update.img generated by compilation, boot the device. You can see a directory named test exists in the file system.

Development board serial console confirming the test folder exists in the live root file system

In summary, the test was successful.

This configuration is a one-time setup. The added files will be automatically included in all future image compilations, even after modifications to the source code’s device tree or drivers.

4. Removing the Added Files

When deleting, in addition to the files added in
OK3562-linux-source/buildroot/board/forlinx/ok3562/fs-overlay/,
you also need to search whether there are any in
OK3562-linux-source/buildroot/output.
For example, when compiling the above compressed package,
test/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz was also created in
OK3562-linux-source/buildroot/output/OK3562_Linux/target/,
and this also needs to be manually deleted.

After deleting, a recompilation is required.

Method 2: Mounting rootfs.ext2

Once the source code is compiled, or for temporarily adding files to a single image instance, you can directly mount the rootfs.ext2 file.

rootfs.ext2 path:OK3562-linux-source/buildroot/output/OK3562_Linux/images

1. After mounting rootfs.ext2, transfer files into it

forlinx@ubuntu:~/work/OK3562-linux-source$ cd buildroot/output/OK3562_Linux/images
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ ls
rootfs.cpio rootfs.cpio.gz rootfs.ext2 rootfs.ext4 rootfs.squashfs rootfs.tar
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ mkdir rootfs
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ sudo mount rootfs.ext2 rootfs
[sudo] forlinx password:
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ cd rootfs/
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images/rootfs$ ls
bin busybox.fragment dev etc home info lib lib64 linuxrc lost+found media mnt oem opt proc root run sbin sys test tmp userdata usr var
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images/rootfs$ sudo cp /mnt/hgfs/share/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz ./
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images/rootfs$ cd ..
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ sudo umount rootfs

In summary, the file can be directly placed into the image generated by compilation.

Note: The default size of rootfs.ext2 is 1.7G. If you place files that are too large using this method, an error will occur: cp: Error writing './aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz': No space left on device. You can expand rootfs.ext2 using the following commands before placing files. Make sure to unmount rootfs.ext2 before executing these commands:

forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ dd if=/dev/zero bs=1M count=0 seek=2000 of=rootfs.ext2 // This command does not write any data to rootfs.ext2; it only expands the file size to 2G.
0+0 write in
0+0 write out
0 bytes copied, 0.000348683 s, 0.0 kB/s
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ e2fsck -f rootfs.ext2
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
rootfs: 9137/70128 files (0.1% non-contiguous), 249143/280320 blocks
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ resize2fs rootfs.ext2
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on rootfs.ext2 to 512000 blocks (4k per block).
The filesystem on rootfs.ext2 is now 512000 blocks (4k per block).
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ ls -lh
Total 3.5G
drwxrwxr-x 2 forlinx forlinx 4.0K January 7 09:30 rootfs
-rw-r--r-- 1 forlinx forlinx 906M January 7 11:13 rootfs.cpio
-rw-r--r-- 1 forlinx forlinx 385M January 7 11:15 rootfs.cpio.gz
-rw-r--r-- 1 forlinx forlinx 2.0G January 7 11:21 rootfs.ext2
lrwxrwxrwx 1 forlinx forlinx 11 January 7 11:15 rootfs.ext4 -> rootfs.ext2
drwxrwxr-x 2 forlinx forlinx 4.0K January 7 10:02 rootfs_old
-rw-r--r-- 1 forlinx forlinx 383M January 7 11:15 rootfs.squashfs
-rw-r--r-- 1 forlinx forlinx 920M January 7 11:16 rootfs.tar
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ sudo mount rootfs.ext2 rootfs
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ cd rootfs/
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images/rootfs$ sudo cp /mnt/hgfs/share/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz ./
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images/rootfs$ cd ..
forlinx@ubuntu:~/work/OK3562-linux-source/buildroot/output/OK3562_Linux/images$ sudo umount rootfs

2. Image Updates

forlinx@ubuntu:~/work/OK3562-linux-source$ ./build.sh updateimg

3. Development Board Verification

Development Board Verification

Verification of the aarch64 SDK archive on the development board after using Method 2 and flashing the image

In summary, the test was successful.

Note: This method only takes effect for the current build. The modifications will be overwritten if the source code is recompiled, requiring the process to be repeated.




Contact Sales Team

Our sales team will connect you with FAE engineers for one-on-one technical support.

Talk to Our Engineers

Get a Quote

Get pricing and project evaluation support from our team.

Request a Quote

Apply for Samples

Submit your request to receive product samples for evaluation.

Get Samples

Join Facebook Group

Get Forlinx technical updates and hands-on sharing from our experts.

Join Now