[ROC-RK3568-PC] 手把手教你打包能使用Etcher或dd命令烧写的Ubuntu系统固件

Posted Neutionwei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ROC-RK3568-PC] 手把手教你打包能使用Etcher或dd命令烧写的Ubuntu系统固件相关的知识,希望对你有一定的参考价值。

📢 ROC-RK3568-PC入门篇连载进程:

[ROC-RK3568-PC] 手把手教你把出厂的Android系统烧写为Ubuntu系统
[ROC-RK3568-PC] 手把手教你制作Ubuntu系统TF卡启动盘
[ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Ubuntu系统固件
[ROC-RK3568-PC] 手把手教你解包Ubuntu系统固件
[ROC-RK3568-PC] 手把手教你在Linux下解包与打包Ubuntu系统固件


在前面我带领大家如何通过编译Linux_SDK从而打包出自己的Ubuntu系统固件:

[ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Ubuntu系统固件

但是这种生成的固件并不是Raw固件,它是由Rockchip官方自定义的一种打包方式(不开源)固件,在烧写的时候只能使用Rockchip相关工具进行烧写!

那我想打包成Raw固件该怎么办?别急,这篇给大家揭晓!

1、准备工具

工欲善其事,必先利其器,为了尽可能避免发生奇怪的错误,我在这里列举一下大家需要用到的工具:

  • balenaEtcher (Linux/Windows/Mac)、或dd命令 (Linux)、或其他第三方工具
  • 良好的TF卡与读卡器

2、Raw固件打包

(1)选择板卡配置文件:

neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh device/rockchip/rk356x/roc-rk3568-pc-ubuntu.mk
processing option: device/rockchip/rk356x/roc-rk3568-pc-ubuntu.mk

(2)查看build.sh脚本帮助信息:

neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh -h
Usage: build.sh [OPTIONS]
Available options:
*.mk               -switch to specified board config
launch              -list current SDK boards and switch to specified board config
uboot              -build uboot
spl                -build spl
loader             -build loader
kernel             -build kernel
modules            -build kernel modules
toolchain          -build toolchain
extboot            -build extlinux boot.img, boot from EFI partition
rootfs             -build default rootfs, currently build buildroot as default
buildroot          -build buildroot rootfs
ramboot            -build ramboot image
multi-npu_boot     -build boot image for multi-npu board
yocto              -build yocto rootfs
debian             -build debian9 stretch rootfs
distro             -build debian10 buster rootfs
openwrt            -build openwrt rootfs
pcba               -build pcba
recovery           -build recovery
all                -build uboot, kernel, rootfs, recovery image
cleanall           -clean uboot, kernel, rootfs, recovery
firmware           -pack all the image we need to boot up system
updateimg          -pack update image
rawimg             -pack raw image
otapackage         -pack ab update otapackage image (update_ota.img)
sdpackage          -pack update sdcard package image (update_sdcard.img)
save               -save images, patches, commands used to debug
allsave            -build all & firmware & updateimg & save
check              -check the environment of building
info               -see the current board building information
app/<pkg>          -build packages in the dir of app/*
external/<pkg>     -build packages in the dir of external/*

Default option is 'allff'.

(3)相关信息:

rawimg             -pack raw image

(4)打包Raw固件:

neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh rawimg
processing option: rawimg
File name is  ROC-RK3568-PC-UBUNTU20.04-GPT-RAW 
Rename the file? [N|y]n
==========Start building recovery==========
TARGET_RECOVERY_CONFIG=
========================================
config is 
use prebuilt rk356x-recovery-arm64-raw.cpio.gz for CPIO image
found kernel image
pack recovery.img...fdt 
kernel 
ramdisk 
resource 
FIT description: U-Boot FIT source file for arm
Created:         Sat Dec 25 09:48:41 2021
 Image 0 (fdt)
  Description:  unavailable
  Created:      Sat Dec 25 09:48:41 2021
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    132152 Bytes = 129.05 KiB = 0.13 MiB
  Architecture: AArch64
  Load Address: 0xffffff00
  Hash algo:    sha256
  Hash value:   6f764a41c90575ca782da50a9c589b38da80dc9305e98d6c64baf1fb18fb7644
 Image 1 (kernel)
  Description:  unavailable
  Created:      Sat Dec 25 09:48:41 2021
  Type:         Kernel Image
  Compression:  uncompressed
  Data Size:    24119304 Bytes = 23554.01 KiB = 23.00 MiB
  Architecture: AArch64
  OS:           Linux
  Load Address: 0xffffff01
  Entry Point:  0xffffff01
  Hash algo:    sha256
  Hash value:   ddb92470653ae4c95753d9c4eb281c353c1b69db170b2ea811afb2c68d1de22d
 Image 2 (ramdisk)
  Description:  unavailable
  Created:      Sat Dec 25 09:48:41 2021
  Type:         RAMDisk Image
  Compression:  uncompressed
  Data Size:    7249770 Bytes = 7079.85 KiB = 6.91 MiB
  Architecture: AArch64
  OS:           Linux
  Load Address: 0xffffff02
  Entry Point:  unavailable
  Hash algo:    sha256
  Hash value:   dde187df2b1fda6c230aee1e8a8763dddfd9a994cb81f899cb77c8d6894d4439
 Image 3 (resource)
  Description:  unavailable
  Created:      Sat Dec 25 09:48:41 2021
  Type:         Multi-File Image
  Compression:  uncompressed
  Data Size:    390656 Bytes = 381.50 KiB = 0.37 MiB
  Hash algo:    sha256
  Hash value:   98addd4af52aef2cb7b65d440a0cd16b453d68dd631e48336b4bf882712b3cc7
 Default Configuration: 'conf'
 Configuration 0 (conf)
  Description:  unavailable
  Kernel:       kernel
  Init Ramdisk: ramdisk
  FDT:          fdt
done.
you take 0:01.20 to build recovery
====Build recovery ok!====
Running build_recovery succeeded.
Make raw.img
Generate raw image : raw.img !
Resize rootfs partition size
dumpe2fs 1.44.1 (24-Mar-2018)
0+0 records in
0+0 records out
0 bytes copied, 1.6412e-05 s, 0.0 kB/s
./mkrawimg.sh: line 76: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
EXPAND
./mkrawimg.sh: line 90: parted: command not found
./mkrawimg.sh: line 107: gdisk: command not found
568+0 records in
568+0 records out
290816 bytes (291 kB, 284 KiB) copied, 0.015737 s, 18.5 MB/s
uboot Image/uboot.img 0x00004000
8192+0 records in
8192+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.150549 s, 27.9 MB/s
misc Image/misc.img 0x00006000
96+0 records in
96+0 records out
49152 bytes (49 kB, 48 KiB) copied, 0.0717786 s, 685 kB/s
boot Image/boot.img 0x00008000
65444+0 records in
65444+0 records out
33507328 bytes (34 MB, 32 MiB) copied, 0.547018 s, 61.3 MB/s
recovery Image/recovery.img 0x00028000
62297+0 records in
62297+0 records out
31896064 bytes (32 MB, 30 MiB) copied, 0.71566 s, 44.6 MB/s
rootfs Image/rootfs.img 0x00058000
^C4932577+0 records in
4932576+0 records out
2525478912 bytes (2.5 GB, 2.4 GiB) copied, 72.2584 s, 35.0 MB/s

(5)缺少某些命令:

./mkrawimg.sh: line 76: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
./mkrawimg.sh: line 93: parted: command not found
EXPAND
./mkrawimg.sh: line 90: parted: command not found
./mkrawimg.sh: line 107: gdisk: command not found

(5)安装缺少命令:

neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ sudo apt-get install parted
neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ sudo apt-get install gdisk

(6)重新打包:

neutionwei@32b7b9ddcaab:~/project/rk356x_linux_release_20211019$ ./build.sh rawimg
processing option: rawimg
File name is  ROC-RK3568-PC-UBUNTU20.04-GPT-RAW 
Rename the file? [N|y]n
==========Start building recovery==========
TARGET_RECOVERY_CONFIG=
========================================
config is 
use prebuilt rk356x-recovery-arm64-raw.cpio.gz for CPIO image
found kernel image
pack recovery.img...fdt 
kernel 
ramdisk 
resource 
FIT description: U-Boot FIT source file for arm
Created:         Sat Dec 25 10:45:53 2021
 Image 0 (fdt)
  Description:  unavailable
  Created:      Sat Dec 25 10:45:53 2021
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    132152 Bytes = 129.05 KiB = 0.13 MiB
  Architecture: AArch64
  Load Address: 0xffffff00
  Hash algo:    sha256
  Hash value:   6f764a41c90575ca782da50a9c589b38da80dc9305e98d6c64baf1fb18fb7644
 Image 1 (kernel)
  Description:  unavailable
  Created:      Sat Dec 25 10:45:53 2021
  Type:         Kernel Image
  Compression:  uncompressed
  Data Size:    24119304 Bytes = 23554.01 KiB = 23.00 MiB
  Architecture: AArch64
  OS:           Linux
  Load Address: 0xffffff01
  Entry Point:  0xffffff01
  Hash algo:    sha256
  Hash value:   ddb92470653ae4c95753d9c4eb281c353c1b69db170b2ea811afb2c68d1de22d
 Image 2 (ramdisk)
  Description:  unavailable
  Created:      Sat Dec 25 10:45:53 2021
  Type:         RAMDisk Image
  Compression:  uncompressed
  Data Size:    7249770 Bytes = 7079.85 KiB = 6.91 MiB
  Architecture: AArch64
  OS:           Linux
  Load Address: 0xffffff02
  Entry Point:  unavailable
  Hash algo:    sha256
  Hash value:   dde187df2b1fda6c230aee1e8a8763dddfd9a994cb81f899cb77c8d6894d4439
 Image 3 (resource)
  Description:  unavailable
  Created:      Sat Dec 25 10:45:53 2021
  Type:         Multi-File Image
  Compression:  uncompressed
  Data Size:    390656 Bytes = 381.50 KiB = 0.37 MiB
  Hash algo:    sha256
  Hash value:   98addd4af52aef2cb7b65d440a0cd16b453d68dd631e48336b4bf882712b3cc7
 Default Configuration: 'conf'
 Configuration 0 (conf)
  Description:  unavailable
  Kernel:       kernel
  Init Ramdisk: ramdisk
  FDT:          fdt
done.
you take 0:01.22 to build recovery
====Build recovery ok!====
Running build_recovery succeeded.
Make raw.img
Generate raw image : raw.img !
Resize rootfs partition size
dumpe2fs 1.44.1 (24-Mar-2018)
0+0 records in
0+0 records out
0 bytes copied, 3.2098e-05 s, 0.0 kB/s
EXPAND
Warning: The resulting partition is not properly aligned for best performance.
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): 
Expert command (? for help): Partition number (1-7): Enter the partition's new unique GUID ('R' to randomize): New GUID is 614E0000-0000-4B53-8000-1D28000054A9

Expert command (? for help): 
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to raw.img.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
568+0 records in
568+0 records out
290816 bytes (291 kB, 284 KiB) copied, 0.014064 s, 20.7 MB/s
uboot Image/uboot.img 0x00004000
8192+0 records in
8192+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.121891 s, 34.4 MB/s
misc Image/misc.img 0x00006000
96+0 records in
96+0 records out
49152 bytes (49 kB, 48 KiB) copied, 0.0802251 s, 613 kB/s
boot Image/boot.img 0x00008000
65444+0 records in
65444+0 records out
33507328 bytes (34 MB, 32 MiB) copied, 0.572347 s, 58.5 MB/s
recovery Image/recovery.img 0x00028000
62297+0 records in
62297+0 records out
31896064 bytes (32 MB, 30 MiB) copied, 0.380661 s, 83.8 MB/s
rootfs Image/rootfs.img 0x00058000
5481086+0 records in
5481086+0 records out
2806316032 bytes (2.8 GB, 2.6 GiB) copied, 68.9483 s, 40.7 MB/s
Make raw image ok!
 /home/neutionwei/project/rk356x_linux_release_20211019/rockdev/pack/ROC-RK3568-PC-UBUNTU20.04-GPT-RAW-20211226-1045.img 

(7)最终生成固件位于目录:

/home/neutionwei/project/rk356x_linux_release_20211019/rockdev/pack/ROC-RK3568-PC-UBUNTU20.04-GPT-RAW-20211226-1045.img 

3、烧写Raw固件

3.1 balenaEtcher工具烧写

(1)把TF卡插进读卡器,并把读卡器插入电脑的USB接口中;
(2)打开balenaEtcher,点击Flash from file选择Ubuntu固件:

(3)点击Select target,选择刚刚插入电脑的移动存储设备:

(4)点击Flash,等待烧写完毕:

3.2 Linux dd命令烧写

使用dd命令烧写务必要确认你的移动存储设备在Linux下所识别成的设备,例如我的被识别成sdc,则烧写命令如下:

$ sudo dd if=ROC-RK3568-PC-UBUNTU20.04-GPT-RAW-20211225-1045.img of=/dev/sdc conv=notrunc

以上是关于[ROC-RK3568-PC] 手把手教你打包能使用Etcher或dd命令烧写的Ubuntu系统固件的主要内容,如果未能解决你的问题,请参考以下文章

[ROC-RK3568-PC] 手把手教你打包能使用Etcher或dd命令烧写的Ubuntu系统固件

[ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Ubuntu系统固件

[ROC-RK3568-PC] 手把手教你解包Ubuntu系统固件

[ROC-RK3568-PC] 手把手教你编译与打包Android 11系统固件

[ROC-RK3568-PC] 手把手教你编译Linux_SDK并打包Buildroot系统固件

[ROC-RK3568-PC] 手把手教你制作Ubuntu系统TF卡启动盘