Refer to https://blog.csdn.net/hushui/article/details/97771341
for RK3288/Linux
Update for RK3399/Linux/202004
1. tools for mkupdate/unpack
https://github.com/rockchip-linux/tools.git
2. RK3399 branch
[lake@localhost tools]$ git checkout remotes/origin/rk3399
Note: checking out 'remotes/origin/rk3399'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 059959f... rk3399: update tools to 20180418
[lake@localhost tools]$ cd linux/Linux_Pack_Firmware/rockdev/
[lake@localhost Linux_Pack_Firmware]$ ls
rockdev.zip
[lake@localhost Linux_Pack_Firmware]$ unzip rockdev.zip
Archive: rockdev.zip
creating: rockdev/
inflating: rockdev/mkupdate.sh
inflating: rockdev/package-file
inflating: rockdev/unpack.sh
inflating: rockdev/readme.txt
inflating: rockdev/afptool
inflating: rockdev/rkImageMaker
creating: rockdev/Image/
[lake@localhost Linux_Pack_Firmware]$
[lake@localhost Linux_Pack_Firmware]$ ls
rockdev rockdev.zip
[lake@localhost Linux_Pack_Firmware]$ cd rockdev/
[lake@localhost rockdev]$ ls -l
total 1708
-rwxr-xr-x. 1 lake lake 1398134 Apr 2 2018 afptool
drwxr-xr-x. 2 lake lake 4096 Apr 9 2018 Image
-rwxr-xr-x. 1 lake lake 537 Apr 9 2018 mkupdate.sh
-rwxr-xr-x. 1 lake lake 620 Apr 8 2018 package-file
-rwxr-xr-x. 1 lake lake 407 Apr 9 2018 readme.txt
-rwxr-xr-x. 1 lake lake 325822 Jan 22 2018 rkImageMaker
-rwxr-xr-x. 1 lake lake 470 Apr 2 2018 unpack.sh
[lake@localhost rockdev]$
3. AIO-3399C-UBUNTU18.04-GPT-20190304-1225.img.tar.gz
$tar zxf AIO-3399C-UBUNTU18.04-GPT-20190304-1225.img.tar.gz
[lake@localhost Rockchip]$ ls -l pack/
total 2354136
-rw-rw-r--. 1 lake lake 2410611160 Mar 4 2019 AIO-3399C-UBUNTU18.04-GPT-20190304-1225.img
drwxrwxr-x. 4 lake lake 4096 Mar 4 2019 AndroidTool
drwxrwxr-x. 2 lake lake 4096 Mar 4 2019 commit
drwxrwxr-x. 2 lake lake 4096 Mar 4 2019 Linux_Upgrade_Tool
-rw-rw-r--. 1 lake lake 1009 Mar 4 2019 README.txt
[lake@localhost Rockchip]$
4. unpack
[lake@localhost rockdev]$ ln -s ~/Rockchip/pack/AIO-3399C-UBUNTU18.04-GPT-20190304-1225.img update.img
[lake@localhost rockdev]$ ls -l
total 1716
-rwxr-xr-x. 1 lake lake 1398134 Apr 2 2018 afptool
drwxr-xr-x. 2 lake lake 4096 Apr 9 2018 Image
-rwxr-xr-x. 1 lake lake 537 Apr 9 2018 mkupdate.sh
-rwxr-xr-x. 1 lake lake 620 Apr 8 2018 package-file
-rwxr-xr-x. 1 lake lake 407 Apr 9 2018 readme.txt
-rwxr-xr-x. 1 lake lake 325822 Jan 22 2018 rkImageMaker
-rwxr-xr-x. 1 lake lake 470 Apr 2 2018 unpack.sh
lrwxrwxrwx. 1 lake lake 68 Apr 19 21:20 update.img -> /home/lake/Rockchip/pack/AIO-3399C-UBUNTU18.04-GPT-20190304-1225.img
[lake@localhost rockdev]$ ./unpack.sh
start to unpack update.img...
********RKImageMaker ver 1.66********
Unpacking image, please wait...
Exporting boot.bin
Exporting firmware.img
Unpacking image success.
Android Firmware Package Tool v1.62
Check file... OK
------- UNPACK ------
package-file 0x0000000000000800 0x00000000000000F3
Image/MiniLoaderAll.bin 0x0000000000001000 0x000000000004394E
Image/parameter.txt 0x0000000000045000 0x0000000000000188
Image/trust.img 0x0000000000045800 0x0000000000400000
Image/uboot.img 0x0000000000445800 0x0000000000400000
Image/boot.img 0x0000000000845800 0x000000000137B800
Image/rootfs.img 0x0000000001BC1000 0x000000008DEEB800
Unpack firmware OK!
------ OK ------
Unpacking update.img OK.
Press any key to quit:
[lake@localhost rockdev]$
[lake@localhost rockdev]$ ls -l output/
total 284
drwxrwxr-x. 2 lake lake 4096 Apr 19 21:20 Image
-rw-rw-r--. 1 lake lake 276814 Apr 19 21:20 MiniLoaderAll.bin
-rw-rw-r--. 1 lake lake 243 Apr 19 21:20 package-file
-rw-rw-r--. 1 lake lake 392 Apr 19 21:20 parameter.txt
[lake@localhost rockdev]$ ls -l output/Image/
total 2353572
-rw-rw-r--. 1 lake lake 20428800 Apr 19 21:20 boot.img
-rw-rw-r--. 1 lake lake 2381232128 Apr 19 21:20 rootfs.img
-rw-rw-r--. 1 lake lake 4194304 Apr 19 21:20 trust.img
-rw-rw-r--. 1 lake lake 4194304 Apr 19 21:20 uboot.img
5. mkupdate.sh
Note default rockdev/package-file is for Android, NOT for Linux.
[lake@localhost rockdev]$ mv output/package-file .
[lake@localhost rockdev]$ mv output/MiniLoaderAll.bin output/parameter.txt output/Image/* Image/
[lake@localhost rockdev]$ ls
afptool Image mkupdate.sh package-file readme.txt rkImageMaker unpack.sh
[lake@localhost rockdev]$ ls -l Image/
total 2353848
-rw-rw-r--. 1 lake lake 20428800 Apr 19 21:20 boot.img
-rw-rw-r--. 1 lake lake 276814 Apr 19 21:20 MiniLoaderAll.bin
-rw-rw-r--. 1 lake lake 392 Apr 19 21:20 parameter.txt
-rw-rw-r--. 1 lake lake 2381232128 Apr 19 21:20 rootfs.img
-rw-rw-r--. 1 lake lake 4194304 Apr 19 21:20 trust.img
-rw-rw-r--. 1 lake lake 4194304 Apr 19 21:20 uboot.img
5.1 Replace boot.img/new build
[lake@localhost rockdev]$ cp ~/Rockchip/boot.img Image/
[lake@localhost rockdev]$ ./mkupdate.sh
start to make update.img...
Android Firmware Package Tool v1.62
------ PACKAGE ------
Add file: ./package-file
Add file: ./Image/MiniLoaderAll.bin
Add file: ./Image/parameter.txt
Add file: ./Image/trust.img
Add file: ./Image/uboot.img
Add file: ./Image/boot.img
Add file: ./Image/rootfs.img
Add CRC...
Make firmware OK!
------ OK ------
********RKImageMaker ver 1.66********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
Making update.img OK.
[lake@localhost rockdev]$
5.2 mkupdate
[lake@localhost rockdev]$ ./mkupdate.sh
start to make update.img...
Android Firmware Package Tool v1.62
------ PACKAGE ------
Add file: ./package-file
Add file: ./Image/MiniLoaderAll.bin
Add file: ./Image/parameter.txt
Add file: ./Image/trust.img
Add file: ./Image/uboot.img
Add file: ./Image/boot.img
Add file: ./Image/rootfs.img
Add CRC...
Make firmware OK!
------ OK ------
********RKImageMaker ver 1.66********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
Making update.img OK.
[lake@localhost rockdev]$
5.3 resize2fs rootfs.img to get more space for docker app inside
[lake@localhost Image]$ e2fsck -f rootfs.img
e2fsck 1.42.9 (28-Dec-2013)
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: 95977/97696 files (0.3% non-contiguous), 2321326/2325422 blocks
[lake@localhost Image]$ resize2fs -p rootfs.img 2511497
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on rootfs.img to 2511497 (1k) blocks.
Begin pass 2 (max = 12)
Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 284)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on rootfs.img is now 2511497 blocks long.
[lake@localhost Image]$ sudo mount rootfs.img /mnt/loop/
[lake@localhost Image]$ cd /mnt/loop/
[lake@localhost loop]$ sudo tar zxf ~/Rockchip/ubuntu18-arm64-rk3399-docker.tgz
[lake@localhost loop]$ df |grep loop
/dev/loop0 2496525 2473847 0 100% /mnt/loop
[lake@localhost loop]$
[lake@localhost loop]$ cd -
/home/lake/Rockchip/tools/linux/Linux_Pack_Firmware/rockdev/Image
[lake@localhost Image]$ sudo umount /mnt/loop
[lake@localhost Image]$ cd ..
[lake@localhost rockdev]$ ./mkupdate.sh
start to make update.img...
Android Firmware Package Tool v1.62
------ PACKAGE ------
Add file: ./package-file
Add file: ./Image/MiniLoaderAll.bin
Add file: ./Image/parameter.txt
Add file: ./Image/trust.img
Add file: ./Image/uboot.img
Add file: ./Image/boot.img
Add file: ./Image/rootfs.img
Add CRC...
Make firmware OK!
------ OK ------
********RKImageMaker ver 1.66********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
Making update.img OK.
[lake@localhost rockdev]$ mv Image/update.img ~/Rockchip/AIO-3399C-UBUNTU18.04-GPT-20190419-docker.img
[lake@localhost rockdev]$