Linux解压编译Tfa/bootloader

码农天地 -
Linux解压编译Tfa/bootloader

https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1546225257...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...
https://xueqiu.com/1875027149...:https://www.100ask.net/index(课程观看)
论  坛:http://bbs.100ask.net/(学术答疑)
开 发 板:https://100ask.taobao.com/ (淘宝)
     https://weidongshan.tmall.com/(天猫)
交流群一:QQ群:869222007(鸿蒙开发/Linux/嵌入式/驱动/资料下载)
交流群二:QQ群:536785813(单片机-嵌入式)
公 众 号:百问科技

版本

日期

作者

说明

V1

2020

韦东山

摘自《嵌入式Linux应用开发完全手册》

1.解压编译Tfa1.1 Tfa 介绍

Trusted Firmware-A(TF-A)是用于 Arm A-Profile 体系结构(Armv8-A 和 Armv7-A)的安全世界软件的参考实现,其中包括 Exception Level 3(EL3)安全监视器。它为在 AArch32 或 AArch64 执行状态下的安全世界启动和运行时固件产品化提供了一个合适的起点。

TF-A 实施 Arm 接口标准,包括:

电源状态协调接口(PSCI)受信任的板引导要求客户端(TBBR-CLIENT)SMC呼叫约定系统控制和管理界面(SCMI)软件委托异常接口(SDEI)

TF-a官方代码仓库地址: https://github.com/ARM-software/arm-trusted-firmware
TF-a官方参考文档资料: https://trustedfirmware-a.readthedocs.io/en/latest/
Arm官方参考资料:
https://developer.arm.com/tools-and-software/open-source-software/firmware/trusted-firmware
100ask_stm32mp157开发板TFA源码:https://gitee.com/weidongshan/stm32mp15xc-tf-a.git

1.2 Tfa 编译

于STM32MP157全功能版,Tfa的编译过程如下(编译Tfa前必须先配置好工具链等开发环境,这里我们使用的交叉编译工具链为Buildroot GCC 8.4版本)。
设置交叉编译,并执行编译命令。

`book@100ask:~$ export ARCH=arm
book@100ask:~$ export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
book@100ask:~$ export PATH=$PATH:/home/book/100ask_stm32mp157_pro-sdk/ToolChain/
arm-buildroot-linux-gnueabihf_sdk-buildroot/bin
book@100ask:~/100ask_stm32mp157_pro-sdk/Tfa-v2.2$ make -f $PWD/./Makefile.sdk all` 

*   1
*   2
*   3
*   4
*   5

编译完成后生成的文件在…/build/trusted/ 目录下,如下图所示。

编译完成之后生成tf-a-stm32mp157c-100ask-512d-v1.stm32,可以用于TF卡启动和EMMC启动,可以将此文件拷贝至资料光盘 02_ImagesFlashlayout 目录下,以备后续更新操作使用。

1.3 更新 Tfa1.3.1 烧写工具更新 trust 版本 uboot 镜像使用STM32CubeProgrammer烧写工具更新
请参考章节《7.3.1 单独更新tfa方法》。1.3.2 开发板系统上更新 trust 版本 uboot 镜像Emmc 文件系统内更新 uboot 镜像。
通过nfs网络挂载或者ssh等方式吧把上述编译好的tf-a-stm32mp157c-100ask-512d-v1.stm32 镜像文件拷贝到开发板文件系统任意目录,之后执行如下命令来更新tf-a-stm32mp157c-100ask-512d-v1.stm32。
`root@100ask:~$ echo 0 > /sys/class/block/mmcblk2boot0/force_ro
root@100ask:~$ echo 0 > /sys/class/block/mmcblk2boot1/force_ro
root@100ask:~$ dd if=tf-a-stm32mp157c-100ask-512d-v1.stm32 of=/dev/mmcblk2/boot0 conv=fsync > 
/dev/null 2>&1
root@100ask:~$ dd if=tf-a-stm32mp157c-100ask-512d-v1.stm32 of=/dev/mmcblk2/boot1 conv=fsync > 
/dev/null 2>&1
root@100ask:~$ echo 1 > /sys/class/block/mmcblk2boot0/force_ro
root@100ask:~$ echo 1 > /sys/class/block/mmcblk2boot1/force_ro` 

*   1
*   2
*   3
*   4
*   5
*   6
*   7
*   8

2.解压编译 bootloader2.1 Bootloader 介绍

Bootloader是在操作系统运行之前运行的一段代码,用于引导操作系统。通常每个操作系统都有一组专属的引导加载程序。引导加载程序通常可以通过多种方式引导操作系统内核,还有各种命令用于调试或修改内核运行环境。

U-Boot是一个开源的主引导加载程序,用于引导设备的操作系统内核,并含有多种命令以便调试系统。它适用于多种计算机体系结构,包括68k,ARM,Blackfin,MicroBlaze,MIPS,Nios,SuperH,PPC,RISC- V和x86。

U-boot官网 https://www.denx.de/wiki/U-Boot
ST源码下载页面 https://github.com/STMicroelectronics/u-boot.git
100ask_stm32mp157开发板Git仓库地址 https://gitee.com/weidongshan/stm32mp15xc-uboot.git
uboot更多使用讲解请参考页面 http://wiki.100ask.org/Category:Uboot

注意:我们使用的版本针对板子进行过修改,u-boot官网下载的源码不能直接使用。

2.2 编译 u-boot 镜像

不同的开发板对应不同的配置文件,配置文件位于 u-boot源码的configs/ 目录。

编译uboot前必须先配置好工具链等开发环境,这里我们使用的交叉编译工具链为Buildroot GCC 8.4
版本。

设置交叉编译,并执行编译命令。

`book@100ask:~$ export ARCH=arm
book@100ask:~$ export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
book@100ask:~$ export PATH=$PATH:/home/book/100ask_stm32mp157_pro-sdk/ToolChain/
arm-buildroot-linux-gnueabihf_sdk-buildroot/bin` 

*   1
*   2
*   3
*   4

2.2.1 编译 trust 版本 uboot:

对于STM32MP157全功能版,u-boot的编译配置过程如下:

`book@100ask:~/100ask_stm32mp157_pro-sdk/Uboot-2020.02$ make stm32mp15_trusted_defconfig
book@100ask:~/100ask_stm32mp157_pro-sdk/Uboot-2020.02$ make DEVICE_TREE=stm32mp157c-100ask-
512d-v1 all -j4` 

*   1
*   2
*   3

如下为具体的执行步骤:

编译完成后生成的文件如下图所示。

编译完成之后生成u-boot.stm32,可以用于TF卡启动和EMMC启动, 可以将此文件拷贝至资料光盘02_ImagesFlashlayout 目录下,以备后续更新操作使用。

2.3 更新 uboot 镜像2.3.1.烧写工具更新 trust 版本 uboot 镜像使用STM32CubeProgrammer烧写工具更新
请参考章节《7.3.2 单独更新Trust uboot方法》2.3.2.开发板系统上更新 trust 版本 uboot 镜像Emmc 文件系统内更新 uboot 镜像。
通过 nfs 网络挂载或者 ssh 等方式吧把上述编译好的 u-boot.stm32 镜像文件拷贝到开发板文件系统任意目录,之后执行如下命令来更新 uboot。
$ dd if=u-boot.stm32 of=/dev/mmcblk2p1 conv=fsync > /dev/null 2>&1
root@100ask:~$ sync
特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。

Tags 标签

加个好友,技术交流

1628738909466805.jpg