Difference between revisions of "APITestPage/zh"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
 
(67 intermediate revisions by the same user not shown)
Line 1: Line 1:
===How to compile custom kernel and u-boot===
 
====Kernel and u-boot versions for each OS====
 
{| class="wikitable"
 
|-
 
! Operating System
 
! Kernel Version
 
! U-boot version
 
! Cross-compiler
 
! Partition type
 
! Build toolset
 
! Kernel code branch
 
! Kernel configuration
 
! U-boot code branch
 
! u-boot configuration
 
|-
 
| buildroot
 
| rowspan="10" | linux v5.10.y
 
| rowspan="10" | u-boot <br />v2017.09
 
| rowspan="10" | 11.3-aarch64
 
| rowspan="10" | [https://github.com/friendlyarm/sd-fuse_rk3568/blob/master/prebuilt/parameter.template GPT]
 
| rowspan="10" | [https://github.com/friendlyarm/sd-fuse_rk3568/tree/master sd-fuse]
 
| rowspan="10" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi5-v5.10.y_opt nanopi5-v5.10.y_opt]
 
| rowspan="6" | nanopi5_linux_defconfig
 
| rowspan="10" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi5-v2017.09 nanopi5-v2017.09]
 
| rowspan="10" | rk3568_defconfig
 
|-
 
| friendlycore-focal-arm64
 
|-
 
| debian-bullseye-core-arm64
 
|-
 
| debian-bullseye-desktop-arm64
 
|-
 
| debian-bullseye-minimal-arm64
 
|-
 
| debian-buster-desktop-arm64
 
|-
 
| friendlywrt21
 
| rowspan="4" | nanopi5_linux_defconfig<br />friendlywrt.config
 
|-
 
| friendlywrt21-docker
 
|-
 
| friendlywrt22
 
|-
 
| friendlywrt22-docker
 
|}
 
* Kernel source code repository:https://github.com/friendlyarm/kernel-rockchip
 
* u-boot source code repository:https://github.com/friendlyarm/uboot-rockchip
 
* The cross-compile toolchain is located in the path: /opt/FriendlyARM/toolchain/. Using the toolchain is as simple as adding the toolchain’s bin directory in your PATH, such as:
 
<syntaxhighlight lang="bash">
 
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
 
</syntaxhighlight>
 
* The [https://github.com/friendlyarm/sd-fuse_rk3568/tree/master sd-fuse] is a bunch of scripts to build bootable SD card images.
 
====Compile kernel linux-v5.10.y====
 
Download the source code and compile as follows:
 
<syntaxhighlight lang="bash">
 
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
 
# Configuring the Kernel
 
# Option1: Load Linux system configuration
 
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig
 
# Option2: Load FriendlyWrt system configuration
 
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig friendlywrt.config
 
# Launch configuration interface
 
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig
 
# Compiling Kernel
 
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5-images -j$(nproc)
 
# Compiling the driver modules
 
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)
 
</syntaxhighlight>
 
After compilation there will be some files in corresponding folder named as:
 
{| class="wikitable"
 
|-
 
| kernel.img
 
| resource.img
 
| <del>boot.img This img is deprecated</del>
 
| The kernel modules are located in the out-modules directory
 
|}
 
Installing the kernel: <br>
 
Please click on [[#Download u-boot and the kernel to the target board]]<br>
 
====Compile u-boot v2017.09====
 
Download the source code and compile as follows:
 
<syntaxhighlight lang="bash">
 
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
 
</syntaxhighlight>
 
After the compilation, the following files will be generated:
 
{| class="wikitable"
 
|-
 
| uboot.img
 
| rk356x_spl_loader_v1.15.112.bin (Before packaging, you need to rename it to MiniLoaderAll.bin)
 
|}
 
Installing the u-boot: <br>
 
Please click on [[#Download u-boot and the kernel to the target board]]<br>
 
  
====Download u-boot and the kernel to the target board====
+
{{RockchipUnbrick/zh|NanoPC-T6}}
=====Download to the installed system=====
+
Since the RK3568's OS uses GPT partitions by default, you can use the dd command to write the image file to the partition, the device nodes for SD card and eMMC are shown below:
+
* The SD/TF Card device node: /dev/mmcblk0 <br />
+
* The eMMC device node: /dev/mmcblk2 <br />
+
The following is an example of how to update the kernel to eMMC:<br />
+
Use the 'parted' command to view the partition layout:
+
<syntaxhighlight lang="bash">
+
parted /dev/mmcblk2 print
+
</syntaxhighlight>
+
You should get output similar to the following:
+
<syntaxhighlight lang="bash">
+
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
+
</syntaxhighlight>
+
as shown above, the resource partition is located at 4 and the kernel partition is located at 5. Use the dd command to write the resource.img and kernel.img files to these partitions, the commands are as follows:
+
<syntaxhighlight lang="bash">
+
dd if=resource.img of=/dev/mmcblk2p4 bs=1M
+
dd if=kernel.img of=/dev/mmcblk2p5 bs=1M
+
</syntaxhighlight>
+
If you want to update u-boot:
+
<syntaxhighlight lang="bash">
+
dd if=boot.img of=/dev/mmcblk2p1 bs=1M
+
</syntaxhighlight>
+
To update new driver modules, copy the newly compiled driver modules to the appropriate directory under /lib/modules.
+
 
+
=====How to create a new OS image file=====
+
To create a new OS image file, you need to use the "sd-fuse" packaging tool.<br />
+
<br />
+
"sd-fuse" is a collection of scripts that can be used to create bootable SD card images for FriendlyElec boards. Its main features include:<br />
+
* Creation of root filesystem images from a directory <br />
+
* Building of bootable SD card images<br />
+
* Simple compilation of kernel, U-Boot, and third-party drivers<br />
+
Please click on the following link to find out more:
+
{| class="wikitable"
+
|-
+
! Kernel version
+
! Build toolset
+
|-
+
| linux v5.10.y
+
| [https://github.com/friendlyarm/sd-fuse_rk3568/tree/master<br /> sd-fuse_rk3568]
+
|}
+
=====USB flashing=====
+
======Linux======
+
To flash U-Boot and kernel using the "upgrade_tool" tool, please use the following command:
+
<syntaxhighlight lang="bash">
+
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
+
</syntaxhighlight>
+
Note: "upgrade_tool" is a command-line tool provided by Rockchip for Linux operating systems (Linux_Upgrade_Tool).
+

Latest revision as of 07:13, 4 June 2024

1 救砖办法

如何固件没有正确安装,导致开发板变砖,而且可能没有机会通过SD卡重新安装固件,这时,就需要进入Maskrom模式,通过擦除存储设备的办法救砖。

1.1 Windows用户

1.1.1 下载所需文件

  • 获取所需工具:访问这里,在 05_Tools 目录中找到 RKDevTool_v3.19_for_window.zip, DriverAssitant_v5.12.zip 下载到本地
  • 安装Rockchip USB驱动和RKDevTool: 解压 DriverAssitant_v5.12.zip 安装Rockchip USB驱动, 解压 RKDevTool_v3.19_for_window.zip 获得 Rockchip烧写工具 RKDevTool
  • 获取loader: 访问这里,进入CPU型号对应的tools目录,下载 MiniLoaderAll.bin

1.1.2 进入Maskrom模式擦除存储设备

  • 使用USB数据线将NanoPC-T6与电脑相连接
  • 在电脑上启动 RKDevTool
  • 将NanoPC-T6断开电源,按住 MASK 键,连接电源,当看到界面下方显示 Found One MASKROM Device 时松开按键, 如下图所示:

Rkdevtool found one maskrom device.png

  • RKDevTool 界面上点击 Advanced Function 选项卡
  • Boot 编辑框中选择 MiniLoaderAll.bin,然后点击 Download 按钮
  • 选中 EMMC,点 Switch Storage,再点击 ErashAll 按钮擦除eMMC

Rkdevtool erase emmc.png

  • (可选): 如果你的NanoPC-T6上有SPI Nor Flash,选中 SPINOR, 点 Switch Storage,再点击 ErashAll 按钮擦除SPI Nor Flash

Rkdevtool erase spinorflash.png

  • 至此,NanoPC-T6恢复至初始状态,可以正常通过SD卡或eMMC引导系统了

1.2 Linux/Mac用户

1.2.1 下载所需文件

  • 获取所需工具:访问这里,在 05_Tools 目录中找到 upgrade_tool_v2.30_for_linux.tgz (或Mac用户选upgrade_tool_v2.25_for_mac.tgz) 下载到本地
  • 获取loader: 访问这里,进入CPU型号对应的tools目录,下载 MiniLoaderAll.bin

1.2.2 安装upgrade_tool工具

以下命令以Linux为例,Mac用户只有文件和目录名略有不同:

tar xzf upgrade_tool_v2.30_for_linux.tgz
cd upgrade_tool_v2.30_for_linux
sudo cp upgrade_tool /usr/local/sbin/
sudo chmod 755 /usr/local/sbin/upgrade_tool

1.2.3 进入Maskrom模式擦除存储设备

  • 使用USB数据线将NanoPC-T6与电脑相连接
  • 将NanoPC-T6断开电源,按住 MASK 键,连接电源,4秒后松开按键
  • 用如下命令检查连接:
upgrade_tool LD

显示类似 "DevNo=1 Vid=0x2207,Pid=0x350b,LocationID=13 Mode=Maskrom SerialNo=" 的内容表示已检测到设备。

  • 用如下命令擦除eMMC:
upgrade_tool EF MiniLoaderAll.bin
  • (可选): 如果你的NanoPC-T6上有SPI Nor Flash,用如下命令擦除SPI Nor Flash:
upgrade_tool DB MiniLoaderAll.bin
upgrade_tool SSD   #选5, SPINOR
dd if=/dev/zero of=zero.img bs=1M count=16   # 针对16M NOR FLASH
upgrade_tool WL 0 zero.img
  • 至此,NanoPC-T6恢复至初始状态,可以正常通过SD卡或eMMC引导系统了