Difference between revisions of "APITestPage/zh"
From FriendlyELEC WiKi
(→安装自编译的内核与uboot) |
|||
Line 8: | Line 8: | ||
! 交叉编译器 | ! 交叉编译器 | ||
! 分区类型 | ! 分区类型 | ||
− | ! | + | ! 构建脚本 |
! 内核代码分支 | ! 内核代码分支 | ||
! 内核配置 | ! 内核配置 | ||
Line 14: | Line 14: | ||
! uboot配置 | ! uboot配置 | ||
|- | |- | ||
− | | | + | | buildroot |
− | | rowspan=" | + | | rowspan="2" | linux v4.19.y |
− | | rowspan=" | + | | rowspan="7" | u-boot <br />v2017.09 |
− | | rowspan=" | + | | rowspan="7" | 11.3-aarch64 |
− | | rowspan=" | + | | rowspan="2" | [https://github.com/friendlyarm/sd-fuse_rk3568/blob/kernel-4.19/prebuilt/parameter.template GPT] |
− | | rowspan=" | + | | rowspan="2" | [https://github.com/friendlyarm/sd-fuse_rk3568/tree/kernel-4.19 sd-fuse] |
− | | rowspan=" | + | | rowspan="2" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi4-v4.19.y nanopi4-v4.19.y] |
− | | rowspan=" | + | | rowspan="2" | nanopi4_linux_defconfig |
− | | rowspan=" | + | | rowspan="7" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi5-v2017.09 nanopi5-v2017.09] |
− | | rowspan=" | + | | rowspan="7" | rk3288_defconfig |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| buildroot | | buildroot | ||
− | | rowspan=" | + | | rowspan="10" | linux v5.10.y |
− | | rowspan=" | + | | rowspan="10" | u-boot <br />v2017.09 |
− | | rowspan=" | + | | rowspan="10" | 11.3-aarch64 |
− | | rowspan=" | + | | rowspan="10" | [https://github.com/friendlyarm/sd-fuse_rk3568/blob/master/prebuilt/parameter.template GPT] |
− | | rowspan=" | + | | rowspan="10" | [https://github.com/friendlyarm/sd-fuse_rk3568/tree/master sd-fuse] |
− | | rowspan=" | + | | rowspan="10" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi5-v5.10.y_opt nanopi5-v5.10.y_opt] |
− | | rowspan=" | + | | rowspan="6" | nanopi5_linux_defconfig |
− | | rowspan=" | + | | rowspan="10" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi5-v2017.09 nanopi5-v2017.09] |
− | | rowspan=" | + | | rowspan="10" | rk3568_defconfig |
|- | |- | ||
− | | | + | | friendlycore-focal-arm64 |
|- | |- | ||
| debian-bullseye-core-arm64 | | debian-bullseye-core-arm64 | ||
Line 50: | Line 44: | ||
| debian-bullseye-minimal-arm64 | | debian-bullseye-minimal-arm64 | ||
|- | |- | ||
− | | | + | | debian-buster-desktop-arm64 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| friendlywrt21 | | friendlywrt21 | ||
− | | rowspan="4" | | + | | rowspan="4" | nanopi5_linux_defconfig<br /> friendlywrt.config |
|- | |- | ||
| friendlywrt21-docker | | friendlywrt21-docker | ||
Line 83: | Line 61: | ||
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH | export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * sd- | + | * sd-fuse构建脚本可以用于快速编译kernel和uboot、重新打包sd卡固件与卡刷固件等 |
− | + | ====编译内核linux-v5.10.y==== | |
− | + | ||
− | ====编译内核linux- | + | |
本节内容适用于如下OS: | 本节内容适用于如下OS: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | | | + | | buildroot |
− | + | | friendlycore-focal-arm64 | |
− | + | ||
− | | friendlycore- | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
| debian-bullseye-core-arm64 | | debian-bullseye-core-arm64 | ||
| debian-bullseye-desktop-arm64 | | debian-bullseye-desktop-arm64 | ||
| debian-bullseye-minimal-arm64 | | debian-bullseye-minimal-arm64 | ||
− | |- | + | | debian-buster-desktop-arm64 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
| friendlywrt21 | | friendlywrt21 | ||
| friendlywrt21-docker | | friendlywrt21-docker | ||
| friendlywrt22 | | friendlywrt22 | ||
| friendlywrt22-docker | | friendlywrt22-docker | ||
− | | friendlycore-lite-focal | + | | friendlycore-lite-focal-arm64 |
|} | |} | ||
下载源代码并编译: | 下载源代码并编译: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b | + | git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi5-v5.10.y_opt kernel-rockchip |
cd kernel-rockchip | cd kernel-rockchip | ||
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH | export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH | ||
touch .scmversion | touch .scmversion | ||
+ | # 配置内核 | ||
+ | # option1: 加载Linux系统配置 | ||
+ | make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig | ||
+ | # option2: 加载FriendlyWrt系统配置 | ||
+ | # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig friendlywrt.config | ||
+ | # 启动配置界面 | ||
+ | # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig | ||
# 编译内核 | # 编译内核 | ||
− | make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 | + | make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5-images -j$(nproc) |
− | + | ||
− | + | ||
# 编译驱动模块 | # 编译驱动模块 | ||
mkdir -p out-modules && rm -rf out-modules/* | mkdir -p out-modules && rm -rf out-modules/* | ||
Line 220: | Line 100: | ||
[ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER} | [ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER} | ||
(cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded) | (cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
完成后会得到如下文件: | 完成后会得到如下文件: | ||
Line 240: | Line 106: | ||
| kernel.img | | kernel.img | ||
| resource.img | | resource.img | ||
+ | | <del>boot.img (此img弃用)</del> | ||
| 驱动模块位于out-modules目录 | | 驱动模块位于out-modules目录 | ||
|} | |} | ||
安装内核: <br> | 安装内核: <br> | ||
− | 请参考 [[# | + | 请参考 [[#下载uboot与内核到目标板]]<br> |
====编译u-boot v2017.09==== | ====编译u-boot v2017.09==== | ||
本节内容适用于如下OS: | 本节内容适用于如下OS: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | | | + | | buildroot |
+ | | friendlycore-focal-arm64 | ||
| debian-bullseye-core-arm64 | | debian-bullseye-core-arm64 | ||
| debian-bullseye-desktop-arm64 | | debian-bullseye-desktop-arm64 | ||
| debian-bullseye-minimal-arm64 | | debian-bullseye-minimal-arm64 | ||
− | |- | + | | debian-buster-desktop-arm64 |
− | | | + | | friendlywrt21 |
− | | friendlycore-lite-focal | + | | friendlywrt21-docker |
− | + | | friendlywrt22 | |
− | + | | friendlywrt22-docker | |
+ | | friendlycore-lite-focal-arm64 | ||
|} | |} | ||
下载源代码并编译: | 下载源代码并编译: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b | + | git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b nanopi5 |
− | git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b | + | git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi5-v2017.09 |
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH | export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH | ||
cd uboot-rockchip/ | cd uboot-rockchip/ | ||
− | ./make.sh | + | ./make.sh nanopi5 |
</syntaxhighlight> | </syntaxhighlight> | ||
编译完成后会生成如下文件: | 编译完成后会生成如下文件: | ||
Line 270: | Line 139: | ||
|- | |- | ||
| uboot.img | | uboot.img | ||
− | | | + | | rk356x_spl_loader_v1.15.112.bin (打包时改名为MiniLoaderAll.bin) |
− | + | ||
|} | |} | ||
安装u-boot: <br /> | 安装u-boot: <br /> | ||
− | 请参考 [[# | + | 请参考 [[#下载uboot与内核到目标板]]<br> |
====下载uboot与内核到目标板==== | ====下载uboot与内核到目标板==== | ||
=====下载至已安装的系统===== | =====下载至已安装的系统===== | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
======GPT分区====== | ======GPT分区====== | ||
本节内容适用于如下OS: | 本节内容适用于如下OS: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | | | + | | buildroot |
+ | | friendlycore-focal-arm64 | ||
| debian-bullseye-core-arm64 | | debian-bullseye-core-arm64 | ||
| debian-bullseye-desktop-arm64 | | debian-bullseye-desktop-arm64 | ||
| debian-bullseye-minimal-arm64 | | debian-bullseye-minimal-arm64 | ||
− | |- | + | | debian-buster-desktop-arm64 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
| friendlywrt21 | | friendlywrt21 | ||
| friendlywrt21-docker | | friendlywrt21-docker | ||
| friendlywrt22 | | friendlywrt22 | ||
| friendlywrt22-docker | | friendlywrt22-docker | ||
+ | | friendlycore-lite-focal-arm64 | ||
|} | |} | ||
− | + | dd image文件至相应的分区即可(注意image的大小不要越界),在操作时需要注意存储设备的节点: | |
* SD/TF Card设备节点为 /dev/mmcblk0 <br /> | * SD/TF Card设备节点为 /dev/mmcblk0 <br /> | ||
* eMMC设备节点为 /dev/mmcblk2 <br /> | * eMMC设备节点为 /dev/mmcblk2 <br /> | ||
Line 337: | Line 188: | ||
8 147MB 31.0GB 30.9GB ext4 rootfs | 8 147MB 31.0GB 30.9GB ext4 rootfs | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | resource分区的序号为4, kernel分区的序号为5,对应的设备节点为/dev/mmcblk2p4和/dev/mmcblk2p5, dd命令如下: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dd if=resource.img of=/dev/mmcblk2p4 bs=1M | dd if=resource.img of=/dev/mmcblk2p4 bs=1M | ||
dd if=kernel.img of=/dev/mmcblk2p5 bs=1M | dd if=kernel.img of=/dev/mmcblk2p5 bs=1M | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | 如果要更新uboot: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
dd if=boot.img of=/dev/mmcblk2p1 bs=1M | dd if=boot.img of=/dev/mmcblk2p1 bs=1M | ||
Line 357: | Line 208: | ||
|- | |- | ||
! 内核版本 | ! 内核版本 | ||
− | ! | + | ! 构建脚本 |
|- | |- | ||
− | | linux | + | | linux v5.10.y |
− | | [https://github.com/friendlyarm/sd- | + | | [https://github.com/friendlyarm/sd-fuse_rk3568/tree/master<br /> sd-fuse_rk3568] |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|} | |} | ||
=====线刷===== | =====线刷===== | ||
− | + | ======Linux系统====== | |
+ | 用upgrade_tool工具烧写uboot与内核, 命令如下所示: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo upgrade_tool ul MiniLoaderAll.bin | sudo upgrade_tool ul MiniLoaderAll.bin | ||
sudo upgrade_tool di -p parameter.txt | sudo upgrade_tool di -p parameter.txt | ||
sudo upgrade_tool di uboot uboot.img | sudo upgrade_tool di uboot uboot.img | ||
− | |||
sudo upgrade_tool di resource resource.img | sudo upgrade_tool di resource resource.img | ||
sudo upgrade_tool di kernel kernel.img | sudo upgrade_tool di kernel kernel.img | ||
Line 380: | Line 225: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
注:upgrade_tool是Rockchip提供的Linux下的命令行工具(Linux_Upgrade_Tool) | 注:upgrade_tool是Rockchip提供的Linux下的命令行工具(Linux_Upgrade_Tool) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 14:13, 29 March 2023
Contents
1 Linux系统编译
1.1 各个OS对应的内核与u-boot版本
操作系统 | 内核版本 | uboot版本 | 交叉编译器 | 分区类型 | 构建脚本 | 内核代码分支 | 内核配置 | uboot代码分支 | uboot配置 |
---|---|---|---|---|---|---|---|---|---|
buildroot | linux v4.19.y | u-boot v2017.09 |
11.3-aarch64 | GPT | sd-fuse | nanopi4-v4.19.y | nanopi4_linux_defconfig | nanopi5-v2017.09 | rk3288_defconfig |
buildroot | linux v5.10.y | u-boot v2017.09 |
11.3-aarch64 | GPT | sd-fuse | nanopi5-v5.10.y_opt | nanopi5_linux_defconfig | nanopi5-v2017.09 | rk3568_defconfig |
friendlycore-focal-arm64 | |||||||||
debian-bullseye-core-arm64 | |||||||||
debian-bullseye-desktop-arm64 | |||||||||
debian-bullseye-minimal-arm64 | |||||||||
debian-buster-desktop-arm64 | |||||||||
friendlywrt21 | nanopi5_linux_defconfig friendlywrt.config | ||||||||
friendlywrt21-docker | |||||||||
friendlywrt22 | |||||||||
friendlywrt22-docker |
- 内核源代码仓库地址:https://github.com/friendlyarm/kernel-rockchip
- u-boot源代码仓库地址:https://github.com/friendlyarm/uboot-rockchip
- 交叉编译工具链存放在如下路径: /opt/FriendlyARM/toolchain/,使用前需导出到PATH环境变量,例如需要使用11.3-aarch64版本的编译器,使用如下命令:
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
- sd-fuse构建脚本可以用于快速编译kernel和uboot、重新打包sd卡固件与卡刷固件等
1.2 编译内核linux-v5.10.y
本节内容适用于如下OS:
buildroot | friendlycore-focal-arm64 | debian-bullseye-core-arm64 | debian-bullseye-desktop-arm64 | debian-bullseye-minimal-arm64 | debian-buster-desktop-arm64 | friendlywrt21 | friendlywrt21-docker | friendlywrt22 | friendlywrt22-docker | friendlycore-lite-focal-arm64 |
下载源代码并编译:
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi5-v5.10.y_opt kernel-rockchip cd kernel-rockchip export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH touch .scmversion # 配置内核 # option1: 加载Linux系统配置 make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig # option2: 加载FriendlyWrt系统配置 # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig friendlywrt.config # 启动配置界面 # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig # 编译内核 make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5-images -j$(nproc) # 编译驱动模块 mkdir -p out-modules && rm -rf out-modules/* make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc) make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules_install KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease) [ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER} (cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
完成后会得到如下文件:
kernel.img | resource.img | |
驱动模块位于out-modules目录 |
安装内核:
请参考 #下载uboot与内核到目标板
1.3 编译u-boot v2017.09
本节内容适用于如下OS:
buildroot | friendlycore-focal-arm64 | debian-bullseye-core-arm64 | debian-bullseye-desktop-arm64 | debian-bullseye-minimal-arm64 | debian-buster-desktop-arm64 | friendlywrt21 | friendlywrt21-docker | friendlywrt22 | friendlywrt22-docker | friendlycore-lite-focal-arm64 |
下载源代码并编译:
git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b nanopi5 git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi5-v2017.09 export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH cd uboot-rockchip/ ./make.sh nanopi5
编译完成后会生成如下文件:
uboot.img | rk356x_spl_loader_v1.15.112.bin (打包时改名为MiniLoaderAll.bin) |
安装u-boot:
请参考 #下载uboot与内核到目标板
1.4 下载uboot与内核到目标板
1.4.1 下载至已安装的系统
1.4.1.1 GPT分区
本节内容适用于如下OS:
buildroot | friendlycore-focal-arm64 | debian-bullseye-core-arm64 | debian-bullseye-desktop-arm64 | debian-bullseye-minimal-arm64 | debian-buster-desktop-arm64 | friendlywrt21 | friendlywrt21-docker | friendlywrt22 | friendlywrt22-docker | friendlycore-lite-focal-arm64 |
dd image文件至相应的分区即可(注意image的大小不要越界),在操作时需要注意存储设备的节点:
- SD/TF Card设备节点为 /dev/mmcblk0
- eMMC设备节点为 /dev/mmcblk2
下面将演示如何将内核更新到eMMC:
使用parted命令查看分区布局:
parted /dev/mmcblk2 print
得到如下输出:
Model: MMC A3A551 (sd/mmc) Disk /dev/mmcblk2: 31.0GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 8389kB 12.6MB 4194kB uboot 2 12.6MB 16.8MB 4194kB misc 3 16.8MB 21.0MB 4194kB dtbo 4 21.0MB 37.7MB 16.8MB resource 5 37.7MB 79.7MB 41.9MB kernel 6 79.7MB 113MB 33.6MB boot 7 113MB 147MB 33.6MB recovery 8 147MB 31.0GB 30.9GB ext4 rootfs
resource分区的序号为4, kernel分区的序号为5,对应的设备节点为/dev/mmcblk2p4和/dev/mmcblk2p5, dd命令如下:
dd if=resource.img of=/dev/mmcblk2p4 bs=1M dd if=kernel.img of=/dev/mmcblk2p5 bs=1M
如果要更新uboot:
dd if=boot.img of=/dev/mmcblk2p1 bs=1M
如果要更新内核驱动模块,将新驱动模块目录上传并替换以下目录下的文件即可:/lib/modules。
1.4.2 打包新的SD卡启动固件或者SD-to-eMMC卡刷固件
sd-fuse 提供一些工具和脚本, 用于制作SD卡固件, 具体用途如下:
- 制作分区镜像文件, 例如将rootfs目录打包成rootfs.img
- 将多个分区镜像文件打包成可直接写SD卡的单一镜像文件
- 简化内核和uboot的编译, 一键编译内核、第三方驱动, 并更新rootfs.img中的内核模块
请根据所用的内核版本点击对应的链接了解详细的使用方法:
内核版本 | 构建脚本 |
---|---|
linux v5.10.y | sd-fuse_rk3568 |
1.4.3 线刷
1.4.3.1 Linux系统
用upgrade_tool工具烧写uboot与内核, 命令如下所示:
sudo upgrade_tool ul MiniLoaderAll.bin sudo upgrade_tool di -p parameter.txt sudo upgrade_tool di uboot uboot.img sudo upgrade_tool di resource resource.img sudo upgrade_tool di kernel kernel.img sudo upgrade_tool RD
注:upgrade_tool是Rockchip提供的Linux下的命令行工具(Linux_Upgrade_Tool)