一. 获取源码

https://github.com/mtk-openwrt/u-boot

二. 编译步骤

编译环境为ubuntu 18.04。交叉编译工具链我用的是openwrt编译生成的工具链,并设置到环境变量,如下:

export PATH=$PATH:/root/mt8976/BPI-R3-OPENWRT-V21.02.3-main/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/bin
export STAGING_DIR=/root/mt8976/BPI-R3-OPENWRT-V21.02.3-main/staging_dir

1. 配置

make mt7986a_bpir3_sd_defconfig。

由命令可知,该uboot被配置了用于烧写在SD卡中,还可以选择编译烧写在SPI-NOR,SPI-NAND和eMMC,如下:

[root@ u-boot-mtksoc]#ls configs/ | grep 7986
mt7986a_bpir3_emmc_defconfig
mt7986a_bpir3_sd_defconfig
mt7986a_emmc_rfb_defconfig
mt7986a_emmc_sb_rfb_defconfig
mt7986a_sd_rfb_defconfig
mt7986b_emmc_rfb_defconfig
mt7986b_sd_rfb_defconfig
mt7986_nmbm_snfi_nand_sb_rfb_defconfig
mt7986_rfb_defconfig
mt7986_snfi_nand_rfb_defconfig
mt7986_spim_nand_rfb_defconfig
mt7986_spim_nand_sb_rfb_defconfig
mt7986_spim_nor_rfb_defconfig

2. 编译代码

make CROSS_COMPILE=aarch64-openwrt-linux- V=1

V=1:可以看到具体的编译命令是什么,便于查看编译问题的具体原因。

PS:编译过程中可能会报如下错误:

tools/sunxi_toc0.o: In function `toc0_verify_header':
sunxi_toc0.c:(.text+0x4f5): undefined reference to `RSA_set0_key'
sunxi_toc0.c:(.text+0x50c): undefined reference to `RSA_get0_n'
sunxi_toc0.c:(.text+0x52a): undefined reference to `RSA_get0_e'
sunxi_toc0.c:(.text+0x5f0): undefined reference to `RSA_set0_key'
sunxi_toc0.c:(.text+0x702): undefined reference to `RSA_set0_key'
sunxi_toc0.c:(.text+0x719): undefined reference to `RSA_get0_n'
sunxi_toc0.c:(.text+0x726): undefined reference to `RSA_get0_n'
sunxi_toc0.c:(.text+0x743): undefined reference to `RSA_get0_e'
sunxi_toc0.c:(.text+0x750): undefined reference to `RSA_get0_e'
tools/sunxi_toc0.o: In function `toc0_set_header':
sunxi_toc0.c:(.text+0xaa5): undefined reference to `RSA_get0_d'
sunxi_toc0.c:(.text+0xafe): undefined reference to `RSA_get0_d'
sunxi_toc0.c:(.text+0xd81): undefined reference to `RSA_get0_n'
sunxi_toc0.c:(.text+0xda9): undefined reference to `RSA_get0_e'
sunxi_toc0.c:(.text+0xde9): undefined reference to `RSA_get0_n'
sunxi_toc0.c:(.text+0xe11): undefined reference to `RSA_get0_e'
sunxi_toc0.c:(.text+0xf14): undefined reference to `RSA_get0_n'
sunxi_toc0.c:(.text+0xf29): undefined reference to `BN_bn2binpad'
sunxi_toc0.c:(.text+0xf3b): undefined reference to `RSA_get0_e'
sunxi_toc0.c:(.text+0xf50): undefined reference to `BN_bn2binpad'
tools/lib/ecdsa/ecdsa-libcrypto.o: In function `prepare_ctx':
ecdsa-libcrypto.c:(.text+0xcd): undefined reference to `OPENSSL_init_ssl'
ecdsa-libcrypto.c:(.text+0x185): undefined reference to `EC_GROUP_order_bits'
tools/lib/ecdsa/ecdsa-libcrypto.o: In function `ecdsa_check_signature.isra.3':
ecdsa-libcrypto.c:(.text+0x3ad): undefined reference to `ECDSA_SIG_set0'
tools/lib/ecdsa/ecdsa-libcrypto.o: In function `ecdsa_sign':
ecdsa-libcrypto.c:(.text+0x497): undefined reference to `ECDSA_SIG_get0'
ecdsa-libcrypto.c:(.text+0x4ae): undefined reference to `BN_bn2binpad'
ecdsa-libcrypto.c:(.text+0x4c0): undefined reference to `BN_bn2binpad'
tools/lib/ecdsa/ecdsa-libcrypto.o: In function `ecdsa_add_verify_data':
ecdsa-libcrypto.c:(.text+0x68d): undefined reference to `EC_GROUP_order_bits'
ecdsa-libcrypto.c:(.text+0x6d3): undefined reference to `EC_POINT_get_affine_coordinates'
tools/lib/rsa/rsa-sign.o: In function `rsa_sign':
rsa-sign.c:(.text+0x524): undefined reference to `OPENSSL_init_ssl'
tools/lib/rsa/rsa-sign.o: In function `rsa_get_params':
rsa-sign.c:(.text+0x973): undefined reference to `RSA_get0_key'
rsa-sign.c:(.text+0x9c0): undefined reference to `RSA_get0_key'
tools/lib/rsa/rsa-sign.o: In function `rsa_add_verify_data':
rsa-sign.c:(.text+0xe21): undefined reference to `EVP_PKEY_get0_RSA'
collect2: error: ld returned 1 exit status
scripts/Makefile.host:104: recipe for target 'tools/dumpimage' failed
make[1]: *** [tools/dumpimage] Error 1
Makefile:1916: recipe for target 'tools' failed
make: *** [tools] Error 2

编译sunxi_toc0.c缺少openssl库,也可能是因为openssl版本低导致的。这里我手动编译安装了openssl-1.1.1n版本的库,具体步骤如下:

cd openssl-1.1.1n
./configure
make && make install
ldconfig

3. 取出uboot     

uboot编译成功结果如下:

[root@ u-boot-mtksoc]#make CROSS_COMPILE=aarch64-openwrt-linux- UPD     include/generated/timestamp_autogenerated.hENVC    include/generated/env.txtENVP    include/generated/env.inENVT    include/generated/environment.hCC      cmd/version.oAR      cmd/built-in.oCC      env/common.oAR      env/built-in.oLD      u-bootOBJCOPY u-boot.srecOBJCOPY u-boot-nodtb.binRELOC   u-boot-nodtb.binCAT     u-boot-dtb.binCOPY    u-boot.binSYM     u-boot.symMKIMAGE u-boot-mtk.binCFGCHK  u-boot.cfgOFCHK   .config

u-boot:代码编译的最原始的uboot,包含符号信息,debug信息等等。

u-boot-nodtb.bin:u-boot通过objcopy,留下了必要的段,所以大小较u-boot小非常多。

u-boot-dtb.bin:是在u-boot-nodtb.bin的基础上,追加了dts/dt.dtb文件。

u-boot.bin:是u-boot-dtb.bin的副本。

u-boot.sym:u-boot的符号表信息。

u-boot-mtk.bin:u-boot.bin文件通过mkimage命令处理过的文件。用于最终烧写的文件。

三. 总结

编译BPI-R3开发板uboot用的交叉编译工具链是编译openwrt产生的,编译过程中可能会报openssl相关错误,可以安装openssl-1.1.1n解决,记得安装完openssl就运行ldconfig,uboot编译完,烧写u-boot-mtk.bin文件。

BPI-R3开发板 - uboot编译相关推荐

  1. Nuvoton NK-980IOT开发板 u-boot 编译

    前言 最近搭建了 Nuvoton NK-980IOT开发板 的开发编译环境,记录一下 u-boot 的 编译流程 Nuvoton NK-980IOT开发板 资源还是比较的丰富的,可以用于 嵌入式Lin ...

  2. 基于TI AM335x创龙开发板U-Boot编译

    分享一下基于广州创龙TL335x-IDK开发板的U-Boot编译.希望能帮助上你. 板子特点如下:  基于 TI AM335x ARM Cortex-A8 CPU,主频可高达 1GHz,运算能力可高 ...

  3. 天嵌TQ2440 ARM开发板Uboot移植

    TQ2440 ARM开发板Uboot移植 移植环境 主    机:VMWare--Fedora 10 Kernel:2.6.34  开发板:TQ2440--256MB Nand 编译器:arm-lin ...

  4. 【迅为iMX6Q】开发板 u-boot 2020.04 RTL8211E 以太网驱动适配

    相关参考 [迅为iMX6Q]开发板 u-boot 2015.04 SD卡 启动 [迅为iMX6Q]开发板 u-boot 2020.04 SD卡 启动 [迅为iMX6Q]开发板 u-boot 2022. ...

  5. 全志A33开发板vstar编译环境搭建

    全志A33开发板vstar编译环境搭建 安装系统 全志提供的vstar的SDK使用内核linux-3.4.39, 在编译过程中,要用到一个文件gen_check_code,位于linux-3.4/ar ...

  6. OK6410开发板Uboot学习总结----(三)从SD卡启动分析

    前面讲了Uboot启动流程和如何修改调试串口,相信大家对Uboot已经有了初步的了解,今天来进行更深一点的分析.上篇文章 OK6410开发板Uboot学习总结----(二)修改调试打印串口 遗留一个问 ...

  7. 安信可 ESP8266机智云开发板:编译与烧录

    安信可 ESP8266机智云开发板:编译与烧录 编译:1.SDK 开发环境搭建见 安信可ESP系列一体化开发环境搭建                        下载地址:http://pan.ba ...

  8. Arduino UNO R3开发板+MQ-2烟雾浓度传感器+火焰传感器+舵机+无源蜂鸣器+风扇+步进电机+WIFI模块+RGB三色LED灯+SIM900A所构成的室内安全报警模块

    该系统模块主要由Arduino UNO R3开发板+MQ-2烟雾浓度传感器+火焰传感器+舵机+无源蜂鸣器+风扇+步进电机+WIFI模块+RGB三色LED灯+SIM900A所组成,MQ-2烟雾浓度传感器 ...

  9. 基于OK6410开发板Uboot源码简单分析

    2018-04-07 OK6410开发板是基于三星S3C6410芯片设计的一款开发板,资源比较丰富,可是想要使用这些资源就需要编写相应的启动引导程序,即BootLoader.当然,想要自己凭空写出Bo ...

最新文章

  1. 链表问题13——删除无序单链表中值重复出现的节点(方法二)
  2. 分布式架构探索 - 2. WebService RPC框架之Apache CXF
  3. This version of MySQL doesn't yet support 'LIMIT IN/ALL/ANY/SOME subquery'
  4. easiest approach for improving writing skills for ielts
  5. QT读写Sqlite数据库三种方式
  6. libnids校验和引起回放包不能正常捕捉
  7. Win-MASM64汇编语言-NEG指令
  8. 服务器 消息 208,在MSSQL2000里边 对象名 'sys.servers' 无效 服务器: 消息 208,级别 16,状态 1,行 1...
  9. 软考计算机硬件知识,软考程序员考点计算机硬件基础知识之存储器简介
  10. linux开发板挂载nfs服务
  11. 31个惊艳的数据可视化作品,让你感受“数据之美”!
  12. 安卓游戏广告加速插件_Pokemon Go游戏加速器 安卓/IOS客户端 使用方法
  13. QQ一键登录助手_DedeCMS插件_适合FOR V55 V56 V57_GBK.zip
  14. 一键安装java程序_一键配置java环境工具
  15. GoLang之使用sync.Cond
  16. spark进行数据清洗时,如何读取xlsx表格类型文件
  17. 中国式IT运维,趟出自己的“长期主义”河流
  18. 计算机英语冯敏课后题答案,英语人教版五年级下册Unit 6 Work quietly人教版五年级冯敏.docx...
  19. 使用树莓派4b和OpenCV做机械臂夹取
  20. ALC声卡选择建议2014

热门文章

  1. Redis:缓存雪崩,缓存击穿,缓存穿透,缓存预热
  2. 计算机视觉 立体视觉极简一览
  3. 一种简单的,适合单片机的,数据加密解密方法,仅需要调用两个函数即可完成数据的加密解密
  4. flot 自定义显示日期
  5. eclipse修改配置
  6. python3.85在Windows10中安装报错Could not create system restore point, error: 0x80070422. Continuing...
  7. git的初始化+常见bug解决方案
  8. 微信小程序 数据请求 GET请求和POST请求
  9. db2 日期英式写法_英文日期格式的正确写法
  10. mosquitto安装与使用