# tspi_pack
**Repository Path**: bai_ke/tspi_pack
## Basic Information
- **Project Name**: tspi_pack
- **Description**: 基于立创泰山派的项目的主干打包环境
- **Primary Language**: C
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2024-01-18
- **Last Updated**: 2025-05-29
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
### 1、开发前的准备工作
#### 1.1、安装编译工具链
```shell
cd toolchain/
./install_toolchain.sh #将编译工具链安装在 toolchain/aarch64-none-linux-gnu目录
export PATH=$(pwd)/aarch64-none-linux-gnu/bin:$PATH
```
如果要永久添加PATH,把安装路径导出的命令添加到/home/nx666/.bashrc文件中.
任意路径执行 aarch64-none-linux-gnu-gcc --version 有如下输出,证明编译工具链安装完成
```shell
aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 10.3.1 20210621
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
#### 1.2、模块编译
编译模块使用fastbuild工具,在编译之前要先执行如下命令,
```shell
cd fastbuild
source .fastbuidrc
```
镜像打包依赖的模块信息记录在dependInfo.xml文件里,如编译kernel可在根目录下执行如下命令:
```shell
fastbuild kernel
```
也可以直接进入fastbuild目录,执行编译,如:
```shell
cd fastbuild
make kernel
```
如果没有python需要先安装python
```shell
sudo apt update
sudo apt install python3
```
fastbuild工具将模块的源码统一放在fastbuild/modules目录,当执行make kernel时,fastbuild会解析dependInfo.xml得到kernel模块的信息,其中就包括了模块的url路径、编译命令和产物,如果fastbuild/modules目录下没有待编译的模块源码,bastbuild会colne一份下来,然后执行编译命令,最后把编译产物拷贝到打包环境。
***编译kernel和uboot时可能会有依赖的库没有安装,笔者就有如下库需要安装:***
```shell
sudo apt-get install device-tree-compiler
sudo apt install python2
sudo apt install bison flex
```
#### 1.3、镜像打包
##### 1.3.1、根文件系统打包
打包环境根目录下执行 make rootfs
#### 1.4、镜像烧录
***目前需要的镜像已经都放到dist目录,可直接烧录,如有库需要更新直接替换即可***
windows下解压tools/win里的DriverAssitant_v5.11.zip和RKDevTool_Release_v2.92.zip,执行DriverAssitant_v5.11里的可执行程序安装驱动,然后打开RKDevTool_Release_v2.92里的工具就可以开始烧录了。
##### 1.4.1、导入配置项
##### 1.4.2、选择分区进行烧写
首先按住板子的REC按键不放然后按下RST键,等到打印不动了松开REC,设备启动过程中检查到REC键被按下就会进入LOADER模式,烧录软件识别到后会显示"发现一个LOADER设备",此时就可以用烧录软件升级了;然后按图示步骤选择分区、选择镜像,点击执行就可以触发一个分区的升级。更多烧录相关信息可查看[【下载】镜像烧入 - 飞书云文档 (feishu.cn)](https://lceda001.feishu.cn/wiki/GXdUwyGlZimkHHkpdMmcusSPnrf)
### 2、uboot相关
#### 2.1、编译
```shell
tar -xvf ./tspi_linux_sdk_20230916.tar.gz Release/build.sh Release/device Release/envsetup.sh Release/IMAGE/TSPI-RK3566-USER-V10-LINUX_20230914.1209_RELEASE_TEST Release/kernel Release/Makefile Release/mkfirmware.sh Release/prebuilts Release/rkbin Release/rkflash.sh Release/rockdev Release/.rootfs Release/tools Release/u-boot
./make.sh rk3566 $UBOOT_COMPILE_COMMANDS CROSS_COMPILE=aarch64-none-linux-gnu-
UBOOT_COMPILE_COMMANDS="\
${RK_TRUST_INI_CONFIG:+../rkbin/RKTRUST/$RK_TRUST_INI_CONFIG} \
${RK_SPL_INI_CONFIG:+../rkbin/RKBOOT/$RK_SPL_INI_CONFIG} \
${RK_UBOOT_SIZE_CONFIG:+--sz-uboot $RK_UBOOT_SIZE_CONFIG} \
${RK_TRUST_SIZE_CONFIG:+--sz-trust $RK_TRUST_SIZE_CONFIG}"
UBOOT_COMPILE_COMMANDS="$(echo $UBOOT_COMPILE_COMMANDS)"
export PATH=/home/nx666/codes/tspi_pack/toolchain/aarch64-none-linux-gnu/bin:$PATH
./make.sh rk3566 CROSS_COMPILE=aarch64-none-linux-gnu-
sudo apt-get install device-tree-compiler
sudo apt install python2
```
### 2.2、打包
### 3、kernel相关
```shell
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- rockchip_linux_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- tspi-rk3566-user-v10-linux.img -j 12
rkbin/scripts/mk-fitimage.sh boot.img rkbin/config/boot.its
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt install bison flex
https://zhuanlan.zhihu.com/p/645477595
```
### 4、rootfs相关
编译busybox
```shell
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- menuconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu-
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- install CONFIG_PREFIX=/home/nx666/codes/tspi_pack/image/rootfs
cp /home/nx666/codes/tspi_pack/toolchain/aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc/usr/lib/*.so* /home/nx666/codes/tspi_pack/image/rootfs/usr/lib/ -d
cp /home/nx666/codes/tspi_pack/toolchain/aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc/usr/lib64/*.so* /home/nx666/codes/tspi_pack/image/rootfs/usr/lib64/ -d
cp /home/nx666/codes/tspi_pack/toolchain/aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc/lib/*.so* /home/nx666/codes/tspi_pack/image/rootfs/lib/ -d
cp /home/nx666/codes/tspi_pack/toolchain/aarch64-none-linux-gnu/aarch64-none-linux-gnu/libc/lib64/*.so* /home/nx666/codes/tspi_pack/image/rootfs/lib64/ -d
mkdir tempfs
dd if=/dev/zero of=rootfs.img bs=1M count=128
mkfs.ext4 rootfs.img
sudo mount rootfs.img tempfs/
sudo cp -rfp rootfs/* tempfs/
sudo umount tempfs/
e2fsck -p -f rootfs.img
resize2fs -M rootfs.img
ls -l rootfs.img
dd if=/dev/zero of=rootfs.img bs=1M count=128;mkfs.ext4 rootfs.img;fakeroot;sudo mount rootfs.img tempfs/;sudo cp -rfp romfs/* tempfs/;sudo umount tempfs/;exit;e2fsck -p -f rootfs.img;resize2fs -M rootfs.img
```
### 3、分区表
位于sdk路径device/rockchip/rk356x/parameter*文件
```shell
0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00020000@0x00028000(recovery),0x00010000@0x00048000(backup),0x00c00000@0x00058000(rootfs),0x00040000@0x00c58000(oem),-@0x00c98000(userdata:grow)
partitions=uuid_disk=${uuid_gpt_disk};name=uboot,start=8MB,size=4MB,uuid=${uuid_gpt_loader2};name=trust,size=4M,uuid=${uuid_gpt_atf};name=misc,size=4MB,uuid=${uuid_gpt_misc};name=resource,size=16MB,uuid=${uuid_gpt_resource};name=kernel,size=32M,uuid=${uuid_gpt_kernel};name=boot,size=32M,bootable,uuid=${uuid_gpt_boot};name=recovery,size=32M,uuid=${uuid_gpt_recovery};name=backup,size=112M,uuid=${uuid_gpt_backup};name=cache,size=512M,uuid=${uuid_gpt_cache};name=system,size=2048M,uuid=${uuid_gpt_system};name=metadata,size=16M,uuid=${uuid_gpt_metadata};name=vendor,size=32M,uuid=${uuid_gpt_vendor};name=oem,size=32M,uuid=${uuid_gpt_oem};name=frp,size=512K,uuid=${uuid_gpt_frp};name=security,size=2M,uuid=${uuid_gpt_security};name=userdata,size=-,uuid=${uuid_gpt_userdata};
```