Difference between revisions of "APITestPage/zh"

From FriendlyELEC WiKi
Jump to: navigation, search
(安装自编译的内核与uboot)
Line 8: Line 8:
 
! 交叉编译器
 
! 交叉编译器
 
! 分区类型
 
! 分区类型
! 构建工具集
+
! 构建脚本
 
! 内核代码分支
 
! 内核代码分支
 
! 内核配置
 
! 内核配置
Line 14: Line 14:
 
! uboot配置
 
! uboot配置
 
|-
 
|-
| lubuntu
+
| buildroot
| rowspan="4" | linux v4.4.y
+
| rowspan="2" | linux v4.19.y
| rowspan="4" | u-boot v2014.10
+
| rowspan="7" | u-boot <br />v2017.09
| rowspan="4" | 6.4-aarch64<br />
+
| rowspan="7" | 11.3-aarch64
| rowspan="4" | [https://github.com/friendlyarm/sd-fuse_rk3399/blob/master/prebuilt/parameter.template MBR]
+
| rowspan="2" | [https://github.com/friendlyarm/sd-fuse_rk3568/blob/kernel-4.19/prebuilt/parameter.template GPT]
| rowspan="4" | [https://github.com/friendlyarm/sd-fuse_rk3399/tree/master sd-fuse]
+
| rowspan="2" | [https://github.com/friendlyarm/sd-fuse_rk3568/tree/kernel-4.19 sd-fuse]
| rowspan="4" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi4-linux-v4.4.y nanopi4-linux-v4.4.y]
+
| rowspan="2" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi4-v4.19.y nanopi4-v4.19.y]
| rowspan="4" | nanopi4_linux_defconfig
+
| rowspan="2" | nanopi4_linux_defconfig
| rowspan="4" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi4-v2014.10_oreo nanopi4-v2014.10_oreo]
+
| rowspan="7" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi5-v2017.09 nanopi5-v2017.09]
| rowspan="4" | rk3399_defconfig
+
| rowspan="7" | rk3288_defconfig
|-
+
| friendlycore-arm64
+
|-
+
| friendlydesktop-arm64
+
|-
+
| eflasher
+
 
|-
 
|-
 
| buildroot
 
| buildroot
| rowspan="8" | linux v4.19.y
+
| rowspan="10" | linux v5.10.y
| rowspan="8" | u-boot <br />v2017.09
+
| rowspan="10" | u-boot <br />v2017.09
| rowspan="8" | 11.3-aarch64
+
| rowspan="10" | 11.3-aarch64
| rowspan="8" | [https://github.com/friendlyarm/sd-fuse_rk3399/blob/kernel-4.19/prebuilt/parameter.template GPT]
+
| rowspan="10" | [https://github.com/friendlyarm/sd-fuse_rk3568/blob/master/prebuilt/parameter.template GPT]
| rowspan="8" | [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-4.19 sd-fuse]
+
| rowspan="10" | [https://github.com/friendlyarm/sd-fuse_rk3568/tree/master sd-fuse]
| rowspan="8" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi4-v4.19.y nanopi4-v4.19.y]
+
| rowspan="10" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi5-v5.10.y_opt nanopi5-v5.10.y_opt]
| rowspan="7" | nanopi4_linux_defconfig
+
| rowspan="6" | nanopi5_linux_defconfig
| rowspan="8" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi4-v2017.09 nanopi4-v2017.09]
+
| rowspan="10" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi5-v2017.09 nanopi5-v2017.09]
| rowspan="8" | rk3399_defconfig
+
| rowspan="10" | rk3568_defconfig
 
|-
 
|-
| debian-buster-desktop-arm64
+
| friendlycore-focal-arm64
 
|-
 
|-
 
| debian-bullseye-core-arm64
 
| debian-bullseye-core-arm64
Line 50: Line 44:
 
| debian-bullseye-minimal-arm64
 
| debian-bullseye-minimal-arm64
 
|-
 
|-
| friendlycore-focal-arm64
+
| debian-buster-desktop-arm64
|-
+
| friendlycore-lite-focal-kernel4-arm64
+
|-
+
| friendlywrt21-kernel4
+
| nanopi4_linux_defconfig<br />+friendlywrt.config
+
|-
+
| friendlycore-lite-focal-kernel5-arm64
+
| rowspan="5" | linux v5.15.y
+
| rowspan="5" | u-boot <br />v2017.09
+
| rowspan="5" | 11.3-aarch64
+
| rowspan="5" | [https://github.com/friendlyarm/sd-fuse_rk3399/blob/kernel-5.15.y/prebuilt/parameter.template GPT]
+
| rowspan="5" | [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-5.15.y<br /> sd-fuse]
+
| rowspan="5" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi-r2-v5.15.y nanopi-r2-v5.15.y]
+
| nanopi4_linux_defconfig
+
| rowspan="5" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi4-v2017.09<br /> nanopi4-v2017.09]
+
| rowspan="5" | rk3399_defconfig
+
 
|-
 
|-
 
| friendlywrt21
 
| friendlywrt21
| rowspan="4" | nanopi4_linux_defconfig<br />+friendlywrt.config
+
| 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-fuse构建工具集可以用于快速编译kernel和uboot、重新打包sd卡固件与卡刷固件等
+
* sd-fuse构建脚本可以用于快速编译kernel和uboot、重新打包sd卡固件与卡刷固件等
* 点击表格中的MBR与GPT可查看各系统的分区布局(配置文件)
+
====编译内核linux-v5.10.y====
 
+
====编译内核linux-v4.4.y====
+
 
本节内容适用于如下OS:
 
本节内容适用于如下OS:
 
{| class="wikitable"  
 
{| class="wikitable"  
 
|-
 
|-
| lubuntu
+
| buildroot
| eflasher
+
| friendlycore-focal-arm64
| friendlydesktop-arm64
+
| friendlycore-arm64
+
|}
+
下载源代码并编译:
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip
+
cd kernel-rockchip
+
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
+
touch .scmversion
+
# 编译内核
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
+
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig  # 启动配置界面
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
+
# 编译驱动模块
+
mkdir -p out-modules
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
+
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
+
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
+
[ ! -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)
+
</syntaxhighlight>
+
编译完会生成如下文件:
+
{| class="wikitable"
+
|-
+
| kernel.img
+
| resource.img
+
| 驱动模块位于out-modules目录
+
|}
+
安装内核: <br>
+
请参考 [[#安装自编译的内核与uboot]]<br>
+
 
+
====编译u-boot v2014.10====
+
本节内容适用于如下OS:
+
{| class="wikitable"
+
|-
+
| lubuntu
+
| eflasher
+
| friendlydesktop-arm64
+
| friendlycore-arm64
+
|}
+
下载源代码并编译:
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2014.10_oreo
+
cd uboot-rockchip
+
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
+
make CROSS_COMPILE=aarch64-linux- rk3399_defconfig
+
make CROSS_COMPILE=aarch64-linux-
+
</syntaxhighlight>
+
编译完成后会生成如下文件:
+
{| class="wikitable"
+
|-
+
| uboot.img
+
| trust.img
+
| rk3399_loader_v1.22.119.bin
+
|}
+
安装u-boot: <br />
+
请参考 [[#安装自编译的内核与uboot]]<br>
+
 
+
====编译内核linux-v4.19.y====
+
本节内容适用于如下OS:
+
{| class="wikitable"
+
|-
+
| debian-buster-desktop-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
| friendlycore-focal-arm64
+
| friendlycore-lite-focal-kernel4-arm64
+
| friendlywrt21-kernel4
+
| buildroot
+
|}
+
下载源代码并编译:
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-v4.19.y kernel-rockchip
+
cd kernel-rockchip
+
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
+
touch .scmversion
+
# 编译内核
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
+
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig  # 启动配置界面
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
+
# 编译驱动模块
+
mkdir -p out-modules
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
+
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
+
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
+
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
+
[ ! -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)
+
</syntaxhighlight>
+
编译完会生成如下文件:
+
{| class="wikitable"
+
|-
+
| kernel.img
+
| resource.img
+
| 驱动模块位于out-modules目录
+
|}
+
安装内核: <br>
+
请参考 [[#安装自编译的内核与uboot]]<br>
+
====编译内核linux-v5.15.y====
+
本节内容适用于如下OS:
+
{| class="wikitable"
+
|-
+
 
| friendlywrt21
 
| friendlywrt21
 
| friendlywrt21-docker
 
| friendlywrt21-docker
 
| friendlywrt22
 
| friendlywrt22
 
| friendlywrt22-docker
 
| friendlywrt22-docker
| friendlycore-lite-focal-kernel5-arm64
+
| friendlycore-lite-focal-arm64
 
|}
 
|}
 
下载源代码并编译:
 
下载源代码并编译:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi-r2-v5.15.y kernel-rockchip
+
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 nanopi4_linux_defconfig
+
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5-images -j$(nproc)
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig  # 启动配置界面
+
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -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>
 
打包kernel.img与resource.img:
 
<syntaxhighlight lang="bash">
 
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/tools/mkkrnlimg && chmod 755 mkkrnlimg
 
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/tools/resource_tool && chmod 755 resource_tool
 
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/prebuilt/boot/logo.bmp
 
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/prebuilt/boot/logo_kernel.bmp
 
./mkkrnlimg arch/arm64/boot/Image kernel.img
 
mkdir kernel-dtbs
 
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev09.dtb
 
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev0a.dtb
 
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4se.dtb kernel-dtbs/rk3399-nanopi4-rev0b.dtb
 
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dtb kernel-dtbs/rk3399-nanopi4-rev00.dtb
 
./resource_tool --dtbname kernel-dtbs/*.dtb logo.bmp logo_kernel.bmp
 
 
</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>
+
请参考 [[#下载uboot与内核到目标板]]<br>
 
====编译u-boot v2017.09====
 
====编译u-boot v2017.09====
 
本节内容适用于如下OS:
 
本节内容适用于如下OS:
 
{| class="wikitable"  
 
{| class="wikitable"  
 
|-
 
|-
| debian-buster-desktop-arm64
+
| 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
| friendlycore-focal-arm64
+
| friendlywrt21
| friendlycore-lite-focal-kernel4-arm64
+
| friendlywrt21-docker
| friendlywrt21-kernel4
+
| friendlywrt22
| buildroot
+
| friendlywrt22-docker
 +
| friendlycore-lite-focal-arm64
 
|}
 
|}
 
下载源代码并编译:
 
下载源代码并编译:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b friendlyelec
+
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 nanopi4-v2017.09 -j$(nproc)
+
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 nanopi4
+
./make.sh nanopi5
 
</syntaxhighlight>
 
</syntaxhighlight>
 
编译完成后会生成如下文件:
 
编译完成后会生成如下文件:
Line 270: Line 139:
 
|-
 
|-
 
| uboot.img
 
| uboot.img
| trust.img
+
| rk356x_spl_loader_v1.15.112.bin (打包时改名为MiniLoaderAll.bin)
| rk3399_loader_v1.24.126.bin
+
 
|}
 
|}
 
安装u-boot: <br />
 
安装u-boot: <br />
请参考 [[#安装自编译的内核与uboot]]<br>
+
请参考 [[#下载uboot与内核到目标板]]<br>
  
 
====下载uboot与内核到目标板====
 
====下载uboot与内核到目标板====
 
=====下载至已安装的系统=====
 
=====下载至已安装的系统=====
======MBR分区======
 
本节内容适用于如下OS:
 
{| class="wikitable"
 
|-
 
| lubuntu
 
| eflasher
 
| friendlydesktop-arm64
 
| friendlycore-arm64
 
|}
 
目前只有linux v4.4内核使用mbr分区,需要参考此链接的[https://github.com/friendlyarm/sd-fuse_rk3399/blob/kernel-4.19/prebuilt/parameter.template partmap文件],计算各分区的偏移地址,用dd命令进行写入,例如parameter.template文件内容中"0x00014000@0x00014000(kernel)"表示kernel.img的位置位于0x00014000,转换成10进制就是81920, 所以dd命令如下:
 
<syntaxhighlight lang="bash">
 
dd if=kernel.img of=/dev/mmcblk0 seek=81920
 
</syntaxhighlight>
 
 
 
======GPT分区======
 
======GPT分区======
 
本节内容适用于如下OS:
 
本节内容适用于如下OS:
 
{| class="wikitable"  
 
{| class="wikitable"  
 
|-
 
|-
| debian-buster-desktop-arm64
+
| 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
| friendlycore-focal-arm64
+
| friendlycore-lite-focal-kernel4-arm64
+
| friendlywrt21-kernel4
+
| buildroot
+
|-
+
 
| friendlywrt21
 
| friendlywrt21
 
| friendlywrt21-docker
 
| friendlywrt21-docker
 
| friendlywrt22
 
| friendlywrt22
 
| friendlywrt22-docker
 
| friendlywrt22-docker
 +
| friendlycore-lite-focal-arm64
 
|}
 
|}
linux v4.19内核和linux v5.15内核的系统默认使用GPT分区, 更新GPT分区比较简单,直接dd image文件至相应的分区即可(注意image的大小不要越界),在操作时需要注意存储设备的节点:
+
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,用dd命令分别写入resource.img与kernel.img到这两个分区即可, 命令如下:
+
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,则命令为:
+
如果要更新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 v4.4.y
+
| linux v5.10.y
| [https://github.com/friendlyarm/sd-fuse_rk3399/tree/master sd-fuse]
+
| [https://github.com/friendlyarm/sd-fuse_rk3568/tree/master<br /> sd-fuse_rk3568]
|-
+
| linux v4.19.y
+
| [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-4.19<br /> sd-fuse]
+
|-
+
| linux v5.15.y
+
| [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-5.15.y<br /> sd-fuse]
+
 
|}
 
|}
 
=====线刷=====
 
=====线刷=====
不擦除flash的情况下只刷入编译生成的文件即可,需要注意的是uboot编译生成的rk3399_loader需要改名为MiniLoaderAll.bin,如下命令演示刷入uboot与内核,需要先加载parameter.txt,再刷入其他文件:
+
======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 trust trust.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)
 
===Android系统编译===
 
====编译Android10====
 
=====下载Android10源代码=====
 
有以下两种途径获取 Android10 的源代码,都需要联网:
 
* '''使用网盘里的git repo压缩包'''
 
网盘下载地址: [http://download.friendlyelec.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} 点击进入]<br />
 
文件位于网盘的以下路径:07_源代码/rk3399-android-10.git-YYYYMMDD.tar.xz (YYYYMMDD表示打包的日期)<br />
 
从网盘中获取的压缩包在解压之后,需要执行一下 sync.sh 脚本,会从gitlab上拉取最新的代码:
 
<syntaxhighlight lang="bash">
 
tar xf /path/to/netdisk/07_源代码/rk3399-android-10.git-YYYYMMDD.tar.xz
 
cd rk3399-android-10
 
./sync.sh
 
</syntaxhighlight>
 
注意: 如果遇到“error: unknown option `recurse-submodules'”,请升级git至v2.0.0或以上版本。
 
* '''直接克隆git仓库'''
 
{{{1}}} 源代码托管在 gitlab 上,使用以下命令进行下载:
 
<syntaxhighlight lang="bash">
 
git clone --recursive https://gitlab.com/friendlyelec/rk3399-android-10.git -b main
 
</syntaxhighlight>
 
 
=====编译并生成Image文件=====
 
编译Android 10建议使用普通用户登录,运行以下命令编译:
 
<syntaxhighlight lang="bash">
 
cd rk3399-android-10
 
./build-nanopc-t4.sh -F -M
 
</syntaxhighlight>
 
如果需要包含google apps,需要设置一个环境变量再编译,如下所示:
 
<syntaxhighlight lang="bash">
 
cd rk3399-android-10
 
export INSTALL_GAPPS_FOR_TESTING=yes
 
./build-nanopc-t4.sh -F -M
 
</syntaxhighlight>
 
 
=====编译OTA Packages=====
 
如果需要A/B (Seamless) System Updates的支持,需要先进行以下定制:<br />
 
a) 搭建自己的更新服务器<br />
 
b) 定制packages/apps/Updater使其适配自己的更新服务<br />
 
定制完成后,使用快速编译脚本参数-O或--ota可编译OTA Packages,如下所示:
 
<syntaxhighlight lang="bash">
 
cd rk3399-android-10
 
./build-nanopc-t4.sh -F -O -M
 
</syntaxhighlight>
 
编译成功完成后,OTA更新相关的包位于目录 rockdev/otapackage/ ,请保留此目录。<br />
 
当完成了某些修改后使用参数-O 再次编译将会生成ota-update-XXXXXXXX.zip,这是增量更新包。<br />
 
OTA Packages依赖BUILD_NUMBER, 只有它有变化才会生成增量更新包,缺省的生成规则请查看build-nanopc-t4.sh。<br />
 
修改 device/rockchip/rk3399/nanopc-t4/BoardConfig.mk 中 <br />
 
<syntaxhighlight lang="bash">
 
BOARD_USES_AB_IMAGE := false
 
</syntaxhighlight>
 
可禁用 A/B 特性,然后重新编译(包括u-boot和android)。<br />
 
=====更新系统为自已编译的Image=====
 
编译完成后,image文件会存放在Android10源代码目录的 rockdev/Image-nanopc_t4/ 子目录下,参考以下步骤更新到 {{{1}}}上: <br />
 
1) 将 EFlasher 启动SD卡 通过读卡器插入电脑,电脑上的Ubuntu系统会自动挂载 SD卡的分区; <br />
 
2) 我们需要将 rockdev/Image-nanopc_t4/ 子目录下的所有文件,拷贝并覆盖到 SD卡 FRIENDLYARM 分区里的 android10 目录; <br />
 
3) 将SD卡插入{{{1}}},重新烧写Andorid系统即可; <br />
 
也可参考这个github仓库的方法来更新:[https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
 
烧写Android 10时EFlasher 需要 v1.3 或以上版本,通过Type-C烧写时请使用rockchip提供的工具AndroidTool v2.71 或Linux_Upgrade_Tool v1.49 。
 
 
====编译Android8.1====
 
=====下载Android8.1源代码=====
 
有以下两种途径获取 Android8.1 的源代码,都需要联网:
 
* '''使用网盘里的git repo压缩包'''
 
网盘下载地址: [http://download.friendlyelec.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} 点击进入]<br />
 
文件位于网盘的以下路径:sources/rk3399-android-8.1.git-YYYYMMDD.tgz (YYYYMMDD表示打包的日期)<br />
 
从网盘中获取的压缩包在解压之后,需要执行一下 sync.sh 脚本,会从gitlab上拉取最新的代码:
 
<syntaxhighlight lang="bash">
 
tar xvzf /path/to/netdisk/sources/rk3399-android-8.1.git-YYYYMMDD.tgz
 
cd rk3399-android-8.1
 
./sync.sh
 
</syntaxhighlight>
 
* '''直接克隆git仓库'''
 
{{{1}}} 源代码托管在 gitlab 上,使用以下命令进行下载:
 
<syntaxhighlight lang="bash">
 
git clone https://gitlab.com/friendlyelec/rk3399-android-8.1 --depth 1 -b master
 
</syntaxhighlight>
 
 
=====编译并生成Image文件=====
 
使用以下命令编译:
 
<syntaxhighlight lang="bash">
 
cd rk3399-android-8.1
 
./build-nanopc-t4.sh -F -M
 
</syntaxhighlight>
 
 
=====更新系统为自已编译的Image=====
 
编译完成后,image文件会存放在Android8.1源代码目录的 rockdev/Image-nanopc_t4/ 子目录下,参考以下步骤更新到 {{{1}}}上: <br />
 
1) 将 EFlasher 启动SD卡 通过读卡器插入电脑,电脑上的Ubuntu系统会自动挂载 SD卡的分区; <br />
 
2) 我们需要将 rockdev/Image-nanopc_t4/ 子目录下的所有文件,拷贝并覆盖到 SD卡 FRIENDLYARM 分区里的 android8 目录; <br />
 
3) 将SD卡插入{{{1}}},重新烧写Andorid系统即可; <br />
 
也可参考这个github仓库的方法来更新:[https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
 
 
====编译Android7源代码====
 
=====下载Android7源代码=====
 
有以下两种途径获取 Android7 的源代码,都需要联网:
 
* '''使用网盘里的git repo压缩包'''
 
网盘下载地址: [http://download.friendlyelec.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}}  点击进入]<br />
 
文件位于网盘的以下路径:sources/rk3399-android-7.git-YYYYMMDD.tgz (YYYYMMDD表示打包的日期)<br />
 
从网盘中获取的 repo 压缩包在解压之后,需要执行一下 sync.sh 脚本,会从gitlab上拉取最新的代码:
 
<syntaxhighlight lang="bash">
 
tar xvzf /path/to/netdisk/sources/rk3399-android-7.git-20181228.tgz
 
cd rk3399-nougat
 
./sync.sh
 
</syntaxhighlight>
 
* '''直接克隆git仓库'''
 
{{{1}}} 源代码托管在 gitlab 上,使用以下命令进行下载:
 
<syntaxhighlight lang="bash">
 
git clone https://gitlab.com/friendlyelec/rk3399-nougat --depth 1 -b nanopc-t4-nougat
 
</syntaxhighlight>
 
 
=====编译并生成Image文件=====
 
使用以下命令编译:
 
<syntaxhighlight lang="bash">
 
cd rk3399-nougat
 
./build-nanopc-t4.sh -F -M
 
</syntaxhighlight>
 
 
=====更新系统为自已编译的Image=====
 
编译完成后,image文件会存放在Android7源代码目录的 rockdev/Image-nanopc_t4/ 子目录下,参考以下步骤更新到 {{{1}}}上: <br />
 
1) 将 EFlasher 启动SD卡 通过读卡器插入电脑,电脑上的Ubuntu系统会自动挂载 SD卡的分区; <br />
 
2) 我们需要将 rockdev/Image-nanopc_t4/ 子目录下的所有文件,拷贝并覆盖到 SD卡 FRIENDLYARM 分区里的  nougat 目录; <br />
 
3) 将SD卡插入{{{1}}},重新烧写Andorid系统即可; <br />
 
也可参考这个github仓库的方法来更新:[https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
 

Revision as of 14:13, 29 March 2023

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
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 boot.img (此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)