您尚未登录。

楼主 # 2023-10-29 22:04:22

a1211762993
会员
注册时间: 2020-03-07
已发帖子: 22
积分: 52

T113 AWboot 编译指南

twzy大佬的原帖地址:https://whycan.com/p_85107.html

按照大佬的步骤,完整的实现了AWboot的编译过程,写了一个编译流程文档分享给大家参考。

配置AWboot编译环境

AWboot需要用到arm-none-eabi-的交叉编译工具,我们首先进行环境配置:
# 1. 进入交叉编译器目录下
cd gcc-arm-none-eabi-10.3-2021.10-x86_64-linux/
# 2. 创建目录
sudo mkdir /usr/local/arm-none-eabi
# 3. 将该目录下的所有文件复制到新建的目录下
sudo cp -rd * /usr/local/arm-none-eabi/
# 4. 最后需要添加该工具链的环境变量使其可以在任何目录下执行,使用bash -c命令在文件/etc/profile末尾添加”PATH=$PATH:/usr/local/arm-none-eabi/bin”
sudo bash -c 'echo "export PATH=\$PATH:/usr/local/arm-none-eabi/bin" >> /etc/profile'
# 5. 添加完毕,使路径立即生效可以使用如下命令
source /etc/profile
# 6. 接下来在终端输入
arm-none-eabi-
# 8. 按两次tab键进行验证

#cd gcc-arm-none-eabi-10.3-2021.10/
#sudo mkdir /usr/local/arm-none-eabi
#sudo cp -rd * /usr/local/arm-none-eabi/
#sudo bash -c 'echo "export PATH=\$PATH:/usr/local/arm-none-eabi/bin" >> /etc/profile'
#source /etc/profile
#arm-none-eabi-
arm-none-eabi-addr2line			arm-none-eabi-gdb
arm-none-eabi-ar					arm-none-eabi-gdb-add-index
arm-none-eabi-as					arm-none-eabi-gdb-add-index-py
arm-none-eabi-c++				arm-none-eabi-gdb-py
arm-none-eabi-c++filt				arm-none-eabi-gprof
arm-none-eabi-cpp				arm-none-eabi-ld
arm-none-eabi-elfedit				arm-none-eabi-ld.bfd
arm-none-eabi-g++				arm-none-eabi-lto-dump
arm-none-eabi-gcc					arm-none-eabi-nm
arm-none-eabi-gcc-10.3.1			arm-none-eabi-objcopy
arm-none-eabi-gcc-ar				arm-none-eabi-objdump
arm-none-eabi-gcc-nm				arm-none-eabi-ranlib
arm-none-eabi-gcc-ranlib			arm-none-eabi-readelf
arm-none-eabi-gcov				arm-none-eabi-size
arm-none-eabi-gcov-dump			arm-none-eabi-strings
arm-none-eabi-gcov-tool			arm-none-eabi-strip
#
编译AWboot

# 1. 制作编译工具
cd awboot/tools/
gcc mksunxi.c -o mksunxi

# 2. 编译 awboot
cd ..
Make
如果文件夹下awboot下生成了:awboot-boot-sd.bin则表示工作正常了。

# 3. 烧录 bin文件到SD卡进行验证(若无串口打印信息请看下一章节)
sudo dd if=awboot-boot-sd.bin of=/dev/sdb bs=1024 seek=8
此处为在SD卡进行验证,若需要在其他介质上启动可以参考:
FEL memory boot:
xfel write 0x30000 awboot-fel.bin
xfel exec 0x30000

FEL SPI NOR boot:
make spi-boot.img
xfel spinor
xfel spinor write 0 spi-boot.img
xfel reset   

FEL SPI NAND boot:
make spi-boot.img
xfel spi_nand
xfel spi_nand write 0 spi-boot.img
xfel reset

# 4. awboot支持MBR或者GPT分区,内核和设备树文件需要放置在一个偏移量至少为4M的FAT32分区,其中bin文件的偏移量:
MBR分区: 8KB (sector 16)
GPT分区: 128KB (sector 256)
拷贝zlmage文件和.dtb文件到FAT32分区

#cd ..
#cd awboot/tools/
#gcc mksunxi.c -o mksunxi
#cd ..
#make
#ls
Arch					awboot-fel.bin		build				main.c
awboot-boot.bin		awboot-fel.elf		include				main.h
awboot-boot.elf		awboot-fel.map	lib					Makefile
awboot-boot.map		board.c			linux					README.md
awboot-boot-sd.bin	board.h			linux-6.0-bootlog.txt	tools
awboot-boot-spi.bin	board-v851s.c		linux-6.0-v851s.txt
#sudo dd if=awboot-boot-sd.bin of=/dev/sdb bs=1024 seek=8
修改调试串口,设备树和运行灯GPIO口

1.打开awboot目录下的board.h文件
修改USART_DBG宏定义可以修改调试串口

#define USART_DBG usart3_dbg

修改CONFIG_DTB_FILENAME宏定义可以修改设备树文件名

#define CONFIG_DTB_FILENAME "sun8i-t113-mangopi-dual.dtb"

2.具体的串口定义可以在board.c文件中修改
打开awboot目录下的board.c文件,根据硬件进行配置,串口对应基地址和外设复用号可以查看本文档附录,也可以查看《T113-S3_User_Manual_V1.6.pdf》中的“GPIO Multiplex Function”章节。

sunxi_usart_t usart5_dbg = {
    .base    = 0x02501400,
    .id      = 5,
    .gpio_tx = {GPIO_PIN(PORTB, 4), GPIO_PERIPH_MUX7},
    .gpio_rx = {GPIO_PIN(PORTB, 5), GPIO_PERIPH_MUX7},
};

sunxi_usart_t usart0_dbg = {
    .base    = 0x02500000,
    .id      = 0,
    .gpio_tx = {GPIO_PIN(PORTE, 2), GPIO_PERIPH_MUX7},
    .gpio_rx = {GPIO_PIN(PORTE, 3), GPIO_PERIPH_MUX7},
};

sunxi_usart_t usart3_dbg = {
    .base    = 0x02500c00,
    .id      = 3,
    .gpio_tx = {GPIO_PIN(PORTG, 8), GPIO_PERIPH_MUX5},
    .gpio_rx = {GPIO_PIN(PORTG, 9), GPIO_PERIPH_MUX5},
};

3.板载运行灯在board.c文件中led_blue变量定义处修改:

static gpio_t led_blue = GPIO_PIN(PORTD, 22);
附录

T113-S3串口号基地址和复用号表格(格式:Tx/Rx)此处省略,可以查看附件内容


资源地址:

AWboot GitHub地址:
https://github.com/szemzoa/awboot

gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 地址:
https://developer.arm.com/downloads/-/gnu-rm



awboot编译指南.zip

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn