Others: New toy – Rock Pi 4A

非常感谢hipboi及radxa.com赠送的Rock Pi 4A单板计算机,这也是我当前接触到的性能最强的单板计算机。

官网:http://rockpi.org/

惯例:学习官方的相关文档,重新编译bootloader, 重新编译 kernel。。。

也许,再跑个Android Q

 

  • 串口log

这里必须提一下,它使用的串口波特率为1500000 bps (1.5Mbps),与传统的115200波特率稍有不同。由于传输数据的波特率很高,官方建议选一根好点的串口线,值得庆幸的是我这条使用pl2303芯片的串口线也可以正常工作。

串口线的接法(图片来自https://wiki.radxa.com/Rockpi4/dev/serial-console):

  • 相关源代码下载

相关的文档可以参考这里: https://wiki.radxa.com/Rockpi4/dev/u-boot

linux BSP的源代码可以从这里下载:https://github.com/radxa/rockchip-bsp

该项目包启了build, kernel, rkbin, rootfs, u-boot等源代码,只有master及stable-4.4-rockips这两个分支。使用master分支的代码来编译kernel 及uboot的源代码可能会有问题。

这里将不直接通过rockchip-bsp下载代码而是通过git命令直接下载下面相关子模块代码, 建立相关的目录结构:

rock-pi-4
+-- boot
|   `-- cmd.sh
+-- build
+-- kernel
+-- rkbin
+-- rootfs
`-- u-boot

build 使用 commit id:

commit 3a40904a60e07ad4d8996cb888369d338dd64dd6
Author: Stephen <stephen@vamrs.com>
Date:   Thu Jul 18 20:27:16 2019 +0800

    mk-uboot.sh: fix building of rockpis board
    
    Signed-off-by: Stephen <stephen@vamrs.com>

kernel使用origin/rockpi-release-4.4分支, commit id

commit 52e2fa1fd3cdf5491e31e68008a24e2fe01ef0e5
Author: stephen <stephen@radxa.com>
Date:   Tue Dec 11 19:36:39 2018 +0800

    add support for the TP-Link UE300 ethernet adapter
    
    Signed-off-by: stephen <stephen@radxa.com>

rkbin使用commit id:

commit eabbf3960e94897d552a15bf5ec7eac2858bbe02
Merge: 38e2fab 36fd29d
Author: Jack Ma <jack@vamrs.com>
Date:   Mon Jul 8 18:02:10 2019 +0800

    Merge remote-tracking branch 'rockchip/master'
    
    Signed-off-by: Jack Ma <jack@vamrs.com>

rootfs使用commit id:

commit 56f7c80573ace91bad13ed15756d9366116d9ad8
Author: Jack Ma <jack@radxa.com>
Date:   Mon Dec 3 11:14:18 2018 +0800

    Add ap6256 wfi/bt firmware
    
    Some version info from the binary:
    
    BCM4345C5 - Ampak_CL1.5 UART 37.4 MHz BT 5.0 [Baseline: 0021]
    
    fw_bcm43456c5*.bin - version: 7.45.96.0 CRC: 1d0e37c2 Date:
    Fri 2017-06-16 12:39:23 CST Ucode Ver: 1043.2070 FWID: 01-1813af84
    
    nvram_ap6256.txt - AP6256_NVRAM_V1.1_08252017
    
    Tested on ROCK Pi 4 model B.
    
    Signed-off-by: Jack Ma <jack@radxa.com>

u-boot使用origin/stable-4.4-rockpi4分支,commit id:

commit 0568348e2db0cc32657ef40e274e6b39d855d5fc
Author: Stephen <stephen@vamrs.com>
Date:   Thu May 30 11:09:51 2019 +0800

    force pcie power on for rockpi4 board
    
    Signed-off-by: Stephen <stephen@vamrs.com>
  • u-boot编译

在rock-pi-4/boot下执行cmd.sh命令,会在当前目录下生成rk3399_loader_v1.12.112.bin, idbloader.img, trust.img 及 uboot.img, 同时会在spi目录下生成idbloader-spi.imgrk3399_loader_spinor_v1.15.114.bin及uboot-trust-spi.img。

rpck-pi-4/boot/cmd.sh脚本的内容如下:

#! /bin/bash
set -e

pushd ../u-boot

ARCH=arm64 CROSS_COMPILE=/data/PUB-pie-9.0.0_r8/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-androidkernel- \
    make rock-pi-4b-rk3399_defconfig

ARCH=arm64 CROSS_COMPILE=/data/PUB-pie-9.0.0_r8/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-androidkernel- \
    make $*

popd


../rkbin/tools/loaderimage --pack --uboot ../u-boot/u-boot-dtb.bin uboot.img 0x200000 --size 1024 1

../u-boot/tools/mkimage -n rk3399 -T rksd -d ../rkbin/bin/rk33/rk3399_ddr_800MHz_v1.22.bin idbloader.img
cat ../rkbin/bin/rk33/rk3399_miniloader_v1.19.bin >> idbloader.img

cp ../rkbin/bin/rk33/rk3399_loader_v1.12.112.bin .

cat > trust.ini << EOF
[VERSION]
MAJOR=1
MINOR=0
[BL30_OPTION]
SEC=0
[BL31_OPTION]
SEC=1
PATH=../rkbin/bin/rk33/rk3399_bl31_v1.28.elf
ADDR=0x10000
[BL32_OPTION]
SEC=0
[BL33_OPTION]
SEC=0
[OUTPUT]
PATH=trust.img
EOF

../rkbin/tools/trust_merger --size 1024 1 trust.ini


# SPI
[ -d spi ] || mkdir spi
../u-boot/tools/mkimage -n rk3399 -T rkspi -d ../rkbin/bin/rk33/rk3399_ddr_800MHz_v1.22.bin spi/idbloader-spi.img
cat ../rkbin/bin/rk33/rk3399_miniloader_spinor_v1.14.bin >> spi/idbloader-spi.img

cp ../rkbin/bin/rk33/rk3399_loader_spinor_v1.15.114.bin spi/

cat > spi/spi.ini << EOF
[System]
FwVersion=18.08.03
BLANK_GAP=1
FILL_BYTE=0
[UserPart1]
Name=IDBlock
Flag=0
Type=2
File=../../rkbin/bin/rk33/rk3399_ddr_800MHz_v1.22.bin,../../rkbin/bin/rk33/rk3399_miniloader_spinor_v1.14.bin
PartOffset=0x40
PartSize=0x7C0
[UserPart2]
Name=uboot
Type=0x20
Flag=0
File=../uboot.img
PartOffset=0x1000
PartSize=0x800
[UserPart3]
Name=trust
Type=0x10
Flag=0
File=../trust.img
PartOffset=0x1800
PartSize=0x800
EOF

../rkbin/tools/firmwareMerger -P spi/spi.ini spi/

mv spi/Firmware.img spi/uboot-trust-spi.img
mv spi/Firmware.md5 spi/uboot-trust-spi.img.md5

 

  • 官方linux镜像分区表

官方使用的是GPT分区表,由于loader1的偏移为32KB, GPT的分区表会比通常的GPT分区表较为特殊一点。

| Part Number | Offset | Name    | Description                |
| ----------- | ------ | ------- | -------------------------- |
| 1           | 32KB   | loader1 | First stage loader         |
| 2           | 8MB    | loader2 | U-boot image               |
| 3           | 12MB   | trust   | ATF                        |
| 4           | 16MB   | boot    | Kernel partition, bootable |
| 5           | 128MB  | rootfs  | Rootfs                     |

(来自:https://wiki.radxa.com/Rockpi4/partitions)

  • 通过USB接口更新固件

相关的文档请看这里: https://wiki.radxa.com/Rockpi4/dev/usb-install

可以通过rkdeveloptool 将相关文件写入到TF卡,eMMC或者是SPI flash中:

$ sudo rkdeveloptool db rk3399_loader_*.bin
$ sleep 1
$ sudo rkdeveloptool wl 64 idbloader.img
$ sudo rkdeveloptool wl 16384 uboot.img
$ sudo rkdeveloptool wl 24576 trust.img
$ sudo rkdeveloptool wl 32768 boot.img
$ sudo rkdeveloptool wl 262144 rootfs.img

注意:

1。在使用rkdeveloptool 下载bootloader(rk3399_loader_*.bin)之后,需要等待1秒之后,再执行后面的操作,个人猜想是在执行这个命令时,会重新初始化USB控制器。在使用脚本下载的时候,要特别注意。

2。rkbin中也包含了这个工具,可以不通过源代码编译。

rkdeveloptool工具的源代码可以从这里下载:https://wiki.radxa.com/Rockpi4/dev/spi-install

相关的介绍文档在这里: http://opensource.rock-chips.com/wiki_Rkdeveloptool

$ rkdeveloptool/rkdeveloptool 

---------------------Tool Usage ---------------------
Help:			-h or --help
Version:		-v or --version
ListDevice:		ld
DownloadBoot:		db <Loader>
UpgradeLoader:		ul <Loader>
ReadLBA:		rl  <BeginSec> <SectorLen> <File>
WriteLBA:		wl  <BeginSec> <File>
WriteLBA:		wlx  <PartitionName> <File>
WriteGPT:		gpt <gpt partition table>
WriteParameter:		prm <parameter>
PrintPartition:		ppt 
EraseFlash:		ef 
TestDevice:		td
ResetDevice:		rd [subcode]
ReadFlashID:		rid
ReadFlashInfo:		rfi
ReadChipInfo:		rci
ReadCapability:		rcb
PackBootLoader:		pack
UnpackBootLoader:	unpack <boot loader>
TagSPL:			tagspl <tag> <U-Boot SPL>
-------------------------------------------------------

从这里可以看到,这个工具只能将文件写入到存储卡的某个特定的位置,不能将文件下载到内存运行。个人认为这样用来调试bootloader (u-boot)或者是kernel会比较麻烦一些。

OTHERS: Rock Pi 4A – 固件下载

  • 相关的参考文档

1。https://wiki.radxa.com/Rockpi4/dev/serial-console

2。https://wiki.radxa.com/Rockpi4/dev/u-boot

3。https://wiki.radxa.com/Rockpi4/dev/spi-install

4。https://github.com/radxa/rockchip-bsp/tree/stable-4.4-rockpis

发表评论

电子邮件地址不会被公开。 必填项已用*标注