OK3568-C 5.10.160 Buildroot Rsync Synchronization of Development Board File System
Background
During product development, a software environment is often deployed on the development board. At this stage, it's essential to synchronize this environment with other devices. Due to the cumbersome deployment process, a more efficient synchronization method is needed.
The method provided in this document uses the rsync tool to directly synchronize the user-modified file system into the update.img image.
Note: When compiling the source code, a file system image named rootfs.img is generated. This rootfs.img is ultimately packaged into update.img. If, after modifying the file system on the development board, the size of the file system is smaller than rootfs.img, this method can be used directly. However, if the size of the file system on the development board exceeds that of rootfs.img, you will need to expand rootfs.img before proceeding. For the specific method, please refer to Section 2.3.3 File System Image Expansion.
2. Implementation Steps
2.1 Compiling Rsync via Buildroot
The rsync tool can be compiled using Buildroot. This requires adding the corresponding CONFIG options in the configuration file. There are two methods to add them:
Method 1: Modifying OK3568_defconfig
Modify the buildroot/configs/OK3568_defconfig configuration file by adding the corresponding CONFIG option for compilation. The content to add is as follows:
BR2_PACKAGE_POPT=y BR2_PACKAGE_RSYNC=y
Method 2: Menuconfig Graphical Configuration
The corresponding compilation options can also be added via the graphical configuration interface. First, it is necessary to modify the relevant compilation script.
Open the following file:
device/rockchip/common/scripts/mk-buildroot.sh
Comment out the line at approximately line 58.
Afterwards, navigate to the buildroot/output/OK3568 directory and execute a command to enter the graphical configuration interface.
forlinx@ubuntu:~/OK3568-linux-sdk5.10/buildroot/output/OK3568$ make menuconfig
Navigate to the following directory and check rsync.
Location: │-> Target packages │ -> Networking applications
Select <Save> to save and exit. The corresponding configuration will be saved in the .config file within the current directory.
After configuring using either of the methods described above, return to the top-level directory of the source code and execute the following command to compile Buildroot separately:
forlinx@ubuntu:~/OK3568-linux-sdk5.10$ ./build.sh buildroot
Note: For materials from version R6 and above, you need to remove or rename the rootfs.ext4 file located in the source/prebuilts/forlinx/OK3568/buildroot/ path. After doing this, execute ./build.sh buildroot to compile the file system.
After compilation is complete, you can find the corresponding executable files and dynamic libraries in the buildroot/output/OK3568/target directory. You can package the following files and directly copy and extract them into the development board’s file system.
buildroot/output/OK3568/target/bin/rsync buildroot/output/OK3568/target/usr/lib64/libz.so.1 buildroot/output/OK3568/target/usr/lib64/libpopt.so.0 buildroot/output/OK3568/target/usr/lib64/libc.so.6 buildroot/output/OK3568/target/usr/lib64/ld-linux-aarch64.so.1
Run the following command to package the relevant files:
forlinx@ubuntu:~/OK3568-linux-sdk5.10/buildroot/output/OK3568/target$ tar cvf rsync.tar \ bin/rsync \ usr/lib64/libz.so.1 \ usr/lib64/libpopt.so.0 \ usr/lib64/libc.so.6 \ usr/lib64/ld-linux-aarch64.so.1
2.2 Deploying Rsync to the Development Board
Copy the rsync.tar file compiled and packaged using the above method to the root directory of the development board and extract it there.
The copying process is omitted here, and you can copy the file using your preferred method.
After copying the file to the root directory of the development board, directly use the tar command to extract it in the development board’s command line terminal:
root@OK3568-buildroot:/# tar xvf rsync.tar
Check the rsync version to verify whether the port was successful.
root@OK3568-buildroot:/# rsync --version rsync version 3.2.3 protocol version 31 Copyright (C) 1996-2020 by Andrew Tridgell, Wayne Davison, and others. Web site: https://rsync.samba.org/ Capabilities: 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, no socketpairs, hardlinks, no hardlink-specials, symlinks, IPv6, atimes, batchfiles, inplace, append, no ACLs, xattrs, optional protect-args, iconv, symtimes, prealloc, stop-at, no crtimes Optimizations: no SIMD, no asm, no openssl-crypto Checksum list: md5 md4 none Compress list: zlibx zlib none rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public Licence for details.
2.3 Synchronizing the File System
2.3.1 Connecting the Development Board to the Development Environment via SSH
Next, perform incremental synchronization. First, ensure that the development board and the development environment are on the same local network and that the development board can use SSH to log into the development environment (if using a virtual machine, for example VMware, please enable the network’s bridge mode). A normal login will appear as shown below:
root@OK3568-buildroot:/# ssh [email protected] //SSH Log in to the virtual machine [email protected]'s password: //Enter password, no display Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s just raised the bar for easy, resilient and secure K8s cluster deployment. https://ubuntu.com/engage/secure-kubernetes-at-the-edge Expanded Security Maintenance for Applications is not enabled. 0 updates can be applied immediately. 5 additional security updates can be applied with ESM Apps. Learn more about enabling ESM Apps service at https://ubuntu.com/esm Last login: Tue Sep 3 11:00:07 2024 from 172.20.2.103
Potential issues:
root@OK3568-buildroot:/# rm ~/.ssh/known_hosts //Delete the.ssh/know _ hosts file under the current account root@OK3568-buildroot:/# ssh [email protected] The authenticity of host '172.20.2.103 (172.20.2.103)' can't be established. ED25519 key fingerprint is SHA256:yq1ON/V/lLhkzvFJ4u9xJ3//ckdKvep3m0RSukKOTG0. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes //Select yes for the first input.
If the followings appears, it indicates that root SSH login permissions are not enabled. Modify the virtual machine’s configuration file:
forlinx@ubuntu:~$ sudo vi /etc/ssh/sshd_config
At approximately line 33, change it to the option indicated in the box.
Then restart the SSH service or reboot the virtual machine
forlinx@ubuntu:~$ sudo service ssh restart //Restart the SSH service
2.3.2 File System Synchronization
Development Environment: Mounting the File System Image
forlinx@ubuntu:~/OK3568-linux-sdk5.10$ cd rockdev forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ mkdir test //Create a directory to mount the file system forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ sudo mount rootfs.img test/ //Mount the file system image to the 'test' directory [sudo] password for forlinx: forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ cd test/ forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev/test$ ls bin busybox.fragment data dev etc home info lib lib64 linuxrc lost+found //Mounted successfully media misc mnt oem opt proc rockchip-test root run sbin sdcard sys tmp udisk userdata usr var forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev/test$ pwd /home/forlinx/OK3568-linux-sdk5.10/rockdev/test //Copy the mount path, which you will need later.
Development board: synchronizing file systems into the development environment.
root@OK3568-buildroot:/# rsync -avx / [email protected]:/home/forlinx/OK3568-linux-sdk5.10/rockdev/test // The IP address here is the IP of the development environment, and the path is the mount path mentioned above. [email protected]'s password: //Enter password, no display sending incremental file list ./ .cache/QtExamples/matrix-browser/QtWebEngine/Default/Cache/ ... ... ... //The print information is too long and is omitted here. usr/lib/libpopt.so.0 usr/lib/libz.so.1 var/lib/random-seed sent 231,355 bytes received 19,619 bytes 33,463.20 bytes/sec total size is 761,390,000 speedup is 3,033.74 //Synchronization completed
To synchronize and delete unused files, you can add the following parameter. This will compare and delete files that have been removed on the development board, also deleting them in the development environment:
rsync -avx --delete --exclude="rootfs" / [email protected]:/home/forlinx/OK3568-linux-sdk5.10/rockdev/test
Unmount the file system and package the image in the development environment:
forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev/test$ cd .. forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ sudo umount test forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ rmdir test forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ cd .. forlinx@ubuntu:~/OK3568-linux-sdk5.10$ ./build.sh updateimg // Package the image and generate update.img
2.3.3 File System Image Expansion
If the file system runs out of space during synchronization as described above, you can expand it using the following method:
forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ sudo fsck.ext4 -f rootfs.img 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: 8872/90112 files (0.1% non-contiguous), 229543/345650 blocks forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ sudo resize2fs rootfs.img 1250000 resize2fs 1.46.5 (30-Dec-2021) Resizing the filesystem on rootfs.ext4 to 1250000 (4k) blocks. The filesystem on rootfs.ext4 is now 1250000 (4k) blocks long. forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ sudo mount rootfs.img test/ forlinx@ubuntu:~/OK3568-linux-sdk5.10/rockdev$ df -h Filesystem Size Used Avail Use% Mounted on tmpfs 990M 5.9M 985M 1% /run /dev/sda3 1.6T 1.3T 271G 83% / tmpfs 4.9G 0 4.9G 0% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock /dev/sda2 512M 6.1M 506M 2% /boot/efi tmpfs 990M 112K 990M 1% /run/user/1000 /dev/loop18 4.7G 808M 3.6G 19% /home/forlinx/OK3568-linux-sdk5.10/rockdev/test
Here is a dedicated explanation of the resize2fs command. Its basic usage format is as follows:
sudo resize2fs IMAGE SIZE
IMAGE is the name of the image to be modified.
SIZE is the number of blocks, where each block is 4K in size. For example:
| SIZE | Size (in K) | Size (in M, approximate) |
| 783770 | 783770*4=3135080 | About 3061 |
| 1250000 | 1250000*4=5000000 | About 4882 |
It is recommended to expand the image only to the necessary size, as increasing the file system image will also enlarge the corresponding generated update.img.


