Difference between revisions of "APITestPage"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
 
(94 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] build toolset can be used to quickly compile the kernel and u-boot, as well as repackaging SD card image and SD-to-eMMC image.
 
====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>
 
You will get the following file:
 
{| 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====
+
{{BurnLinuxToExtDrive-Rockchip/zh|NanoPC-T4}}
=====Download to the installed system=====
+
{{BurnLinuxToExtDrive-Rockchip|NanoPC-T4}}
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 09:58, 29 October 2024

1 安装系统到M.2或USB硬盘

可以通过使用TF卡启动eFlasher系统,将引导和系统分别安装到不同存储设备,但是由于CPU不支持直接从M.2和USB设备引导,所以虽然系统可以安装到M.2和USB设备,但是引导仍然需要安装到eMMC或者TF卡。
操作步骤如下:

  • 准备一张32G或以上容量的TF卡;
  • 访问此处的下载地址下载文件名为XXXX-eflasher-multiple-os-YYYYMMDD-30g.img.gz的固件(位于"01_系统固件/02_SD卡刷机固件(SD-to-eMMC)"目录);
  • 将固件写入TF卡,在NanoPC-T4上连接好存储设备,插入TF卡上电开机,接下来要在界面上操作,如果没有显示设备,可以使用VNC代替,请参考使用VNC操作eFlasher;
  • 在eFlasher界面上,首先选择要安装的OS,然后选择引导安装的目的地 (通常选eMMC),以及选择系统安装的目的地(可以选eMMC,M.2硬盘,USB存储设备等),如下图所示:

Eflasher-select-boot-and-system-device.png

  • 没有eMMC时可使用TF卡作为引导,方法是将另一个TF卡通过USB读卡器插入USB端口,然后选择USB设备作为引导安装目的地,从而实现从TF卡引导,但系统存放在M.2或USB硬盘的目的;
  • 烧写完成后,从NanoPC-T4弹出SD卡,引导在eMMC的情况下,NanoPC-T4会自动重启至你刚刚烧写的系统,如果引导安装在TF卡,则需要拨掉电源,插入TF引导卡再上电开机;
  • 更详细的安装指南请参考此处;

2 Installing the System to M.2 or USB Drive

You can use a TF card to boot the eFlasher system, allowing the boot and system to be installed on different storage devices. However, since the CPU doesn’t support booting directly from M.2 and USB devices, the system can be installed on M.2 and USB devices, but the boot must still be installed on eMMC or a TF card.
Steps are as follows:

  • Prepare a TF card with a capacity of 32GB or larger.
  • Visit [the download link here](http://download.friendlyelec.com/APITestPage) to download the firmware file named XXXX-eflasher-multiple-os-YYYYMMDD-30g.img.gz (located in the “01_Official images/02_SD-to-eMMC images” directory).
  • Flash the firmware to the TF card, connect the storage device you intend to use on NanoPC-T4, insert the TF card and power on, we need to perform the operations in the eFlasher GUI. If your NanoPC-T4 does not have a display interface, you can use VNC; refer to Using VNC to Operate eFlasher.
  • In the eFlasher GUI, select the OS to install, and in the OS settings interface, choose the destination for boot installation (typically eMMC), then choose the destination for system installation (options include eMMC, M.2 hard drive, USB storage, etc.), as shown below:

Eflasher-select-boot-and-system-device.png

  • If no eMMC is available, the TF card can serve as the boot by inserting another TF card into the USB port via a USB card reader and selecting it as the boot destination, enabling booting from the TF card with the system stored on the M.2 or USB drive.
  • After flashing, eject the SD card from NanoPC-T4. If booting from eMMC, NanoPC-T4 will automatically restart into the newly flashed system. If boot installation is on a TF card, power off, insert the boot TF card, and power on again.
  • For a more detailed installation guide, please refer to this link.