Introduction: How to Add User Files to Buildroot Image on OK3562 With Linux 5.10.198
This article provides a method to include files, programs, applications, libraries, etc. required by user products into the source code and then compile them into the image. This can avoid the operation of separately copying programs to the development board after flashing the image.
Step 1: Method 1: Directly Put Into Source Code for Compilation
Placement Path Explanation:
User programs can be copied to the directory
/OK3562linuxsource/buildroot/board/forlinx/ok3562/fsoverlay/usr/bin.
Configuration files can be copied to the directory
/OK3562linuxsource/buildroot/board/forlinx/ok3562/fsoverlay/etc.
Library files can be copied to the directory
/OK3562linuxsource/buildroot/board/forlinx/ok3562/fsoverlay/lib.
Users can also create their own folders in the
/OK3562linuxsource/buildroot/board/forlinx/ok3562/fsoverlay/ directory to store their files.
Take the example of copying the compressed package
aarch64buildrootlinuxgnu_sdkbuildroot.tar.gz:
(1) Copy the file to the specified path
Create a directory named test under the path
/OK3562linuxsource/buildroot/board/forlinx/ok3562/fsoverlay/, and put the compressed package aarch64buildrootlinuxgnu_sdkbuildroot.tar.gz into this directory.
(2) Compile the source code
Execute the fullcompilation command ./build.sh all. After compilation, you can see that the test directory is generated in OK3562linuxfs/rootfs, which contains the compressed package.
(3) Verification on the development board
After booting the development board with the compiled update.img, it is found that the test directory exists in the file system.
In conclusion, the test is successful.
This method is permanently effective. You only need to perform the operation once. Later, when you modify the device tree or driver configuration in the source code and recompile the image, the added files will still be included.
(4) Deleting the added files
When deleting, note that in addition to deleting the files added in /OK3562linuxsource/buildroot/board/forlinx/ok3562/fsoverlay/, you also need to check if there are any remaining files in /OK3562linuxsource/buildroot/output. For example, during the compilation of the abovementioned compressed package,
test/aarch64buildrootlinuxgnu_sdkbuildroot.tar.gz is also created in /OK3562linuxsource/buildroot/output/OK3562_Linux/target/, and these files also need to be deleted manually.
Recompilation is required after deletion.
Step 2: Method 2: Mount Rootfs.ext2
If the source code has been compiled, or you only want to temporarily add files to a single image, you can use the method of mounting rootfs.ext2.
Path of rootfs.ext2: OK3562linuxsource/buildroot/output/OK3562_Linux/images
(1) Mount rootfs.ext2 and transfer files into it
In conclusion, files can be directly added to the compiled image.
Note: The default size of rootfs.ext2 is 1.7G. If you use this method to add files that are too large, you will get an error: cp: Error writing './aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz' : No space on device. You can expand rootfs.ext2 using the following commands before adding files. Note that you need to unmount rootfs.ext2 before executing these commands:
(2) Update the image
(3) Verification on the development board
Development board verification





