|
| 1 | +# Taishanpi-RK3566 板级支持包使用说明 |
| 2 | + |
| 3 | +中文页 | [English](./Taishanpi-RK3566_ZH.md) |
| 4 | + |
| 5 | +## 0. 说明 |
| 6 | + |
| 7 | +此文档使用的Commit: |
| 8 | +- `a1c642aa3a2848b47f2a1b52679dc4ee5156f2f4` |
| 9 | + |
| 10 | +在[原有文档](./README.md)基础上面进行了文档补充和步骤说明,丰富了一下原有内容。 |
| 11 | + |
| 12 | +## 1. 介绍 |
| 13 | + |
| 14 | +这份支持包使用说明是根据[泰山派1](https://wiki.lckfb.com/zh-hans/tspi-rk3566/)所写的一份使用指南。 |
| 15 | + |
| 16 | +[泰山派1中原理图、PCB文件和软件资料全部开源](https://wiki.lckfb.com/zh-hans/tspi-rk3566/open-source-hardware/) |
| 17 | + |
| 18 | +在本指南中会尽可能的详细介绍使用步骤和相关注意事项。 |
| 19 | + |
| 20 | +### 1.1. 芯片介绍 |
| 21 | + |
| 22 | +`Rockchip RK3566` 是中高端 `AIOT` 芯片: |
| 23 | + |
| 24 | +- 采用`22nm`制程工艺。 |
| 25 | +- `4`核`Cortex-A55`的`64`位CPU。 |
| 26 | +- 主频高达`1.8GHz`。 |
| 27 | +- 集成`ARM Mali-G52 GPU` |
| 28 | +- 集成`1Tops`算力的`AI`加速器`NPU`; |
| 29 | +- 支持`4K 60FPS`解码。 |
| 30 | +- 支持`1080P 60FPS`解码。 |
| 31 | +- 支持`5M ISP`和`HDR`。 |
| 32 | + |
| 33 | +### 1.2. 宿主机环境介绍 |
| 34 | + |
| 35 | +本次使用的是 `Ubuntu22.04.5 LTS Desktop` 运行在`VMware`中。 |
| 36 | + |
| 37 | +系统信息如下: |
| 38 | + |
| 39 | +```bash |
| 40 | +$ cat /etc/os-release |
| 41 | +PRETTY_NAME="Ubuntu 22.04.5 LTS" |
| 42 | +NAME="Ubuntu" |
| 43 | +VERSION_ID="22.04" |
| 44 | +VERSION="22.04.5 LTS (Jammy Jellyfish)" |
| 45 | +VERSION_CODENAME=jammy |
| 46 | +ID=ubuntu |
| 47 | +ID_LIKE=debian |
| 48 | +HOME_URL="https://www.ubuntu.com/" |
| 49 | +SUPPORT_URL="https://help.ubuntu.com/" |
| 50 | +BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" |
| 51 | +PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" |
| 52 | +UBUNTU_CODENAME=jammy |
| 53 | + |
| 54 | +``` |
| 55 | + |
| 56 | +```bash |
| 57 | +$ lsb_release -a |
| 58 | +No LSB modules are available. |
| 59 | +Distributor ID: Ubuntu |
| 60 | +Description: Ubuntu 22.04.2 LTS |
| 61 | +Release: 22.04 |
| 62 | +Codename: jammy |
| 63 | +``` |
| 64 | + |
| 65 | +`Python`版本如下: |
| 66 | +```bash |
| 67 | +$ python --version |
| 68 | +Python 3.10.12 |
| 69 | +``` |
| 70 | + |
| 71 | + |
| 72 | +## 2. 环境搭建 |
| 73 | + |
| 74 | +运行下面的命令安装相关的软件包: |
| 75 | + |
| 76 | +1. 必要工具: |
| 77 | +```bash |
| 78 | +sudo apt update && \ |
| 79 | +sudo apt install -y python3 python3-pip u-boot-tools device-tree-compiler |
| 80 | +``` |
| 81 | + |
| 82 | +2. 使用`pip`安装工具: |
| 83 | +```bash |
| 84 | +pip3 install --user tqdm scons |
| 85 | +``` |
| 86 | + |
| 87 | + |
| 88 | +3. 设定`python`版本: |
| 89 | +```bash |
| 90 | +sudo rm -rf /usr/bin/python && \ |
| 91 | +sudo ln -s /usr/bin/python3 /usr/bin/python |
| 92 | +``` |
| 93 | + |
| 94 | + |
| 95 | +4. 下载 `RT-Thread Smart` 工具链: |
| 96 | +```bash |
| 97 | +wget https://download.rt-thread.org/download/rt-smart/toolchains/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 |
| 98 | + |
| 99 | +``` |
| 100 | + |
| 101 | +5. 解压: |
| 102 | +```bash |
| 103 | +sudo tar -xf aarch64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 -C /opt |
| 104 | +``` |
| 105 | + |
| 106 | +5. 将工具链下载后,解压至`/opt`目录。并设置环境变量 |
| 107 | + |
| 108 | +> 直接复制全部,然后粘贴到命令行回车即可。 |
| 109 | +
|
| 110 | +```bash |
| 111 | +export RTT_CC="gcc" |
| 112 | +export RTT_EXEC_PATH="/opt/aarch64-linux-musleabi_for_x86_64-pc-linux-gnu/bin/" |
| 113 | +export RTT_CC_PREFIX="aarch64-linux-musleabi-" |
| 114 | +export PATH="$RTT_EXEC_PATH:$PATH" |
| 115 | +``` |
| 116 | + |
| 117 | +## 3. 编译 |
| 118 | + |
| 119 | +进入`rt-thread/bsp/rockchip/rk3566`目录下输入下面的命令: |
| 120 | + |
| 121 | +进入 `menuconfig` 后直接 保存退出,生成一个 `.config` 文件: |
| 122 | + |
| 123 | +```bash |
| 124 | +scons --menuconfig |
| 125 | +``` |
| 126 | + |
| 127 | +> 拉取`zlib`软件包,我们编译的时候需要用到。 |
| 128 | +
|
| 129 | +```bash |
| 130 | +source ~/.env/tools/scripts/pkgs --update |
| 131 | +``` |
| 132 | + |
| 133 | +开始编译: |
| 134 | + |
| 135 | +> 或者通过 `scons --exec-path="GCC工具链路径"` 命令,在指定工具链位置的同时直接编译。 |
| 136 | +
|
| 137 | +```bash |
| 138 | +scons -j$(nproc) |
| 139 | +``` |
| 140 | + |
| 141 | +可以看到在当前`rk3566`文件夹中正常生成`rtthread.elf`与`rtthread.bin`文件。 |
| 142 | + |
| 143 | +## 3. 运行 |
| 144 | + |
| 145 | +### 3.1. 为板子烧录镜像 |
| 146 | + |
| 147 | +因为我需要在 `Uboot` 环境中使用命令进行引导 `rtthread` 系统,所以需要烧录相关的文件。 |
| 148 | + |
| 149 | +这里我是用的内核是 [泰山派1](https://wiki.lckfb.com/zh-hans/tspi-rk3566/) 的 `Rockchip Linux5.10 SDK`: |
| 150 | + |
| 151 | +- `Github`:https://github.com/TaishanPi |
| 152 | + |
| 153 | +- 教程看 [宿主机构建方式](https://wiki.lckfb.com/zh-hans/tspi-rk3566/sdk-compilation/openkylin-sdk-compilation.html) |
| 154 | + |
| 155 | +编译完成之后会在 `rockdev/` 目录下生成我们所需要的文件 |
| 156 | + |
| 157 | +将板子的所有镜像全部擦除: |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | +然后使用`瑞芯微开发工具`烧录下面的`4`个文件: |
| 162 | + |
| 163 | +> > 注意: 因为我们的SDK是重新进行分区的,所以使用[泰山派1](https://wiki.lckfb.com/zh-hans/tspi-rk3566/)需要下面的`4`个文件,其他板子没有测试,可以自行尝试。 |
| 164 | +
|
| 165 | +- `MiniLoaderAll.bin` |
| 166 | +- `parameter.txt` |
| 167 | +- `uboot.img` |
| 168 | +- `boot.img` |
| 169 | + |
| 170 | +### 3.2. 格式化TF卡 |
| 171 | + |
| 172 | +我们需要准备一张 `TF` 卡,用来存放 `rtthread.bin` 文件。 |
| 173 | + |
| 174 | +下载 `Rufus`:https://rufus.org.cn/ |
| 175 | + |
| 176 | +设定为下列的模式,然后点击`开始`: |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | +### 3.3. 制作boot.scr |
| 182 | + |
| 183 | +> 这里可以直接使用当前目录下的 `boot.scr`,同样也是用下面的方式制作出来的,如果有需求可以根据下面的方法自己制作。 |
| 184 | +
|
| 185 | +前面我们已经安装过 `u-boot-tools` 所以直接使用即可。 |
| 186 | + |
| 187 | +创建 `boot.cmd`,并写入下面的内容: |
| 188 | + |
| 189 | +```bash |
| 190 | +fatload mmc 1:1 0x480000 rtthread.bin; |
| 191 | +fatload mmc 1:1 0x8300000 tspi-rk3566-user-v10-linux.dtb; |
| 192 | +booti 0x480000 - 0x8300000; |
| 193 | +``` |
| 194 | +> 系统启动需要`设备树文件DTB`,这里我们[泰山派1](https://wiki.lckfb.com/zh-hans/tspi-rk3566/)的`dtb`文件是`kernel/arch/arm64/boot/dts/rockchip/tspi-rk3566-user-v10-linux.dtb`,其他的文件有不同的名字,可以根据不同的开发板选择。不然`rtthread`就会无法启动,详情请看文档最后面的 `常见问题与解决办法` |
| 195 | +
|
| 196 | + |
| 197 | +运行生成`boot.scr` |
| 198 | + |
| 199 | +```bash |
| 200 | +mkimage -C none -A arm -T script -d boot.cmd boot.scr |
| 201 | +``` |
| 202 | + |
| 203 | +### 3.4. 复制文件到TF卡 |
| 204 | + |
| 205 | +将下面三个文件复制到TF中: |
| 206 | + |
| 207 | +- `boot.scr` |
| 208 | +- `tspi-rk3566-user-v10-linux.dtb` |
| 209 | +- `rtthread.bin` |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | +### 3.5. 运行 |
| 214 | + |
| 215 | +连接[开发板串口->MoBaXterm](https://wiki.lckfb.com/zh-hans/tspi-rk3566/tool-use/debug-tools-use.html): |
| 216 | + |
| 217 | +打开串口工具,选择对应串口,设置波特率为 `1500000` |
| 218 | + |
| 219 | +因为有 `boot.scr` 会自动引导启动`rtthread`: |
| 220 | + |
| 221 | +> 注意1:如果卡死在了 `[I/rtdm.ofw] Console: uart0 (fiq-debugger)` 那么看`常见问题与解决办法`。 |
| 222 | +
|
| 223 | +> 注意2:记得每次`rtthread`启动失败(在`uboot`中引导失败后),都应该将开发板完全断电然后在上电,清空内存。 |
| 224 | +
|
| 225 | +> 注意3:如果多次自动引导失败可以手动在`uboot`界面运行 `boot.cmd` 的内容,手动引导,如果还不行,那就要考虑其他的因素了,例如TF质量问题,传输到TF卡中的文件有损坏等等等。 |
| 226 | +
|
| 227 | +```bash |
| 228 | +Hit key to stop autoboot('CTRL+C'): 0 |
| 229 | +switch to partitions #0, OK |
| 230 | +mmc1 is current device |
| 231 | +Scanning mmc 1:1... |
| 232 | +Found U-Boot script /boot.scr |
| 233 | +reading /boot.scr |
| 234 | +197 bytes read in 3 ms (63.5 KiB/s) |
| 235 | +## Executing script at 00c00000 |
| 236 | +reading rtthread.bin |
| 237 | +1220848 bytes read in 104 ms (11.2 MiB/s) |
| 238 | +reading tspi-rk3566-user-v10-linux.dtb |
| 239 | +167469 bytes read in 17 ms (9.4 MiB/s) |
| 240 | +Fdt Ramdisk skip relocation |
| 241 | +No misc partition |
| 242 | +## Flattened Device Tree blob at 0x08300000 |
| 243 | + Booting using the fdt blob at 0x08300000 |
| 244 | + Using Device Tree in place at 0000000008300000, end 000000000832be2c |
| 245 | +No resource file: logo_kernel.bmp |
| 246 | +** Unable to read file logo_kernel.bmp ** |
| 247 | +Failed to do_load |
| 248 | +VP0 fail to load kernel logo |
| 249 | +vp0, plane_mask:0x3f, primary-id:4, curser-id:-1 |
| 250 | +vp1, plane_mask:0x0, primary-id:0, curser-id:-1 |
| 251 | +vp2, plane_mask:0x0, primary-id:0, curser-id:-1 |
| 252 | +## reserved-memory: |
| 253 | + drm-logo@00000000: addr=7df00000 size=ad000 |
| 254 | + drm-cubic-lut@00000000: addr=7ff00000 size=8000 |
| 255 | + ramoops@110000: addr=110000 size=f0000 |
| 256 | +Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000) |
| 257 | +Adding bank: 0x09400000 - 0x80000000 (size: 0x76c00000) |
| 258 | +board seed: Pseudo |
| 259 | +Total: 600.154/648.331 ms |
| 260 | + |
| 261 | +Starting kernel ... |
| 262 | + |
| 263 | +[I/rtdm.ofw] Booting RT-Thread on physical CPU 0x0 |
| 264 | +[I/rtdm.ofw] Machine model: lckfb tspi V10 Board |
| 265 | +[I/rtdm.ofw] Earlycon: uart8250 at MMIO/PIO 0x00000000fe660000 (options '') |
| 266 | +[I/rtdm.ofw] Memory node(1) ranges: 0x0000000000200000 - 0x0000000008400000 |
| 267 | +[I/rtdm.ofw] Memory node(1) ranges: 0x0000000009400000 - 0x0000000080000000 |
| 268 | +[I/mm.memblock] System memory: |
| 269 | +[I/mm.memblock] [0x0000000000200000, 0x0000000008400000] |
| 270 | +[I/mm.memblock] [0x0000000009400000, 0x0000000080000000] |
| 271 | +[I/mm.memblock] Reserved memory: |
| 272 | +[I/mm.memblock] [0x0000000000110000, 0x0000000000200000] |
| 273 | +[I/mm.memblock] [0x0000000000480000, 0x00000000006d0000] |
| 274 | +[I/mm.memblock] [0x00000000006d0000, 0x00000000046d0000] |
| 275 | +[I/mm.memblock] [0x00000000046d0000, 0x00000000048d0000] |
| 276 | +[I/mm.memblock] [0x00000000048d0000, 0x00000000048fa000] |
| 277 | +[I/mm.memblock] [0x0000000008300000, 0x000000000832a000] |
| 278 | +[I/mm.memblock] [0x000000007df00000, 0x000000007dfad000] |
| 279 | +[I/mm.memblock] [0x000000007ff00000, 0x000000007ff08000] |
| 280 | +[I/mm.memblock] physical memory region [0x0000000000200000-0x0000000000480000] installed to system page |
| 281 | +[I/mm.memblock] physical memory region [0x00000000048fa000-0x0000000008300000] installed to system page |
| 282 | +[I/mm.memblock] physical memory region [0x000000000832a000-0x0000000008400000] installed to system page |
| 283 | +[I/mm.memblock] physical memory region [0x0000000009400000-0x000000007df00000] installed to system page |
| 284 | +[I/mm.memblock] physical memory region [0x000000007dfad000-0x000000007ff00000] installed to system page |
| 285 | +[I/mm.memblock] physical memory region [0x000000007ff08000-0x0000000080000000] installed to system page |
| 286 | +[I/mm.memblock] 2055 MB memory installed to system page |
| 287 | +[I/osi.psci] Using PSCI v1.1 Function IDs |
| 288 | +[I/clk.rk3568] set cpu_freq to 1800000000 |
| 289 | +[I/rtdm.ofw] Console: uart0 (fiq-debugger) |
| 290 | + |
| 291 | + \ | / |
| 292 | +- RT - Thread Smart Operating System |
| 293 | + / | \ 5.2.1 build Jul 30 2025 08:58:40 |
| 294 | + 2006 - 2024 Copyright by RT-Thread team |
| 295 | +lwIP-2.1.2 initialized! |
| 296 | +[I/sal.skt] Socket Abstraction Layer initialize success. |
| 297 | +[I/utest] utest is initialize success. |
| 298 | +[I/utest] total utest testcase num: (5) |
| 299 | +[I/drivers.serial] Using /dev/ttyS0 as default console |
| 300 | +Press any key to stop init process startup ... 3 |
| 301 | +Press any key to stop init process startup ... 2 |
| 302 | +Press any key to stop init process startup ... 1 |
| 303 | +Starting init ... |
| 304 | +[E/DFS.fs] mount point (/proc) already mounted! |
| 305 | +[I/rtdm.mnt] File system initialization done |
| 306 | +Hi, this is RT-Thread!! |
| 307 | +msh />I/TC: Secondary CPU 1 initializing |
| 308 | +I/TC: Secondary CPU 1 switching to normal world boot |
| 309 | +o/[C3:2 mS[eIc/ocnpdua.raya 6C4P]U 2 inCiatlila lcipzui n1g |
| 310 | + n success |
| 311 | +I/TC: Secondary CPU 2 switching to normal world boot |
| 312 | +I/TC: Secondary CPU 3 initializing |
| 313 | +I/TC: Secondary CPU 3 switching to normal world boot |
| 314 | +[I/cpu.aa64] Call cpu 2 on success |
| 315 | +[I/cpu.aa64] Call cpu 3 on success |
| 316 | + |
| 317 | +msh /> |
| 318 | +msh /> |
| 319 | +``` |
| 320 | +
|
| 321 | +## 常见问题与解决办法 |
| 322 | +
|
| 323 | +### Could not find a valid device tree |
| 324 | +
|
| 325 | +我们没有加载 `.dtb` 设备树文件直接启动就会出现这样的情况: |
| 326 | +
|
| 327 | +```bash |
| 328 | +Hit key to stop autoboot('CTRL+C'): 0 |
| 329 | +=> <INTERRUPT> |
| 330 | +=> <INTERRUPT> |
| 331 | +=> <INTERRUPT> |
| 332 | +=> <INTERRUPT> |
| 333 | +=> <INTERRUPT> |
| 334 | +=> fatload mmc 1:1 0x480000 rtthread.bin |
| 335 | +reading rtthread.bin |
| 336 | +1220848 bytes read in 104 ms (11.2 MiB/s) |
| 337 | +=> booti 0x480000 - 0x8300000 |
| 338 | +Fdt Ramdisk skip relocation |
| 339 | +No misc partition |
| 340 | +ERROR: Did not find a cmdline Flattened Device Tree |
| 341 | +Could not find a valid device tree |
| 342 | +=> |
| 343 | +``` |
| 344 | +
|
| 345 | +> 注意:记得每次`rtthread`启动失败(在`uboot`中引导失败后),都应该将开发板完全断电然后在上电,清空内存。 |
| 346 | +
|
| 347 | +然后将 `kernel/arch/arm64/boot/dts/rockchip/` 文件夹中编译之后的`.dtb`文件转移到TF卡中,然后使用 `fatload`从TF卡中加载到`0x8300000`地址然后再次跳转即可。 |
| 348 | +
|
| 349 | +
|
| 350 | +### 卡在 `[I/rtdm.ofw] Console: uart0 (fiq-debugger)` 无法启动 |
| 351 | +
|
| 352 | +大概率和你的设备树有关系,在设备树中有一个参数很重要,需要被读取: |
| 353 | +
|
| 354 | +> 这里我贴出我的参数,我的`Debug`串口硬件是`uart2m0` |
| 355 | +
|
| 356 | +> 这个`chosen` 是重要的,如果不清楚,可以参照我这么写。 |
| 357 | +
|
| 358 | +```ini |
| 359 | + chosen: chosen { |
| 360 | + bootargs = "earlycon=uart8250,mmio32,0xfe660000 console=ttyFIQ0"; |
| 361 | + }; |
| 362 | + |
| 363 | + fiq-debugger { |
| 364 | + compatible = "rockchip,fiq-debugger"; |
| 365 | + rockchip,serial-id = <2>; |
| 366 | + rockchip,wake-irq = <0>; |
| 367 | + /* If enable uart uses irq instead of fiq */ |
| 368 | + rockchip,irq-mode-enable = <1>; |
| 369 | + rockchip,baudrate = <1500000>; /* Only 115200 and 1500000 */ |
| 370 | + interrupts = <GIC_SPI 252 IRQ_TYPE_LEVEL_LOW>; |
| 371 | + pinctrl-names = "default"; |
| 372 | + pinctrl-0 = <&uart2m0_xfer>; |
| 373 | + status = "okay"; |
| 374 | + }; |
| 375 | +``` |
0 commit comments