全志v3s学习笔记(2)——u-boot编译与烧录

本文档详细介绍了如何在Linux环境下为Lichee Pi Zero交叉编译U-Boot,并提供了不同屏幕配置的编译选项。编译完成后,通过sunxi-fel工具将U-Boot烧录到RAM或SPI闪存中,同时展示了烧录过程和启动信息。
摘要由CSDN通过智能技术生成

一、编译

1、安装交叉编译环境

我是直接用的之前Linux-ARM开发的环境:
参考:arm-linux-gnueabihf 交叉编译工具链安装


2、获取uboot(不同版本uboot)

//普通
git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current
//支持spi flash
git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-spi-experimental

uboot的基本结构:

├── api                存放uboot提供的API接口函数
├── arch               平台相关的部分我们只需要关心这个目录下的ARM文件夹
│   ├──arm
│   │   └──cpu
│   │   │   └──armv7
│   │   └──dts
│   │   │   └──*.dts 存放设备的dts,也就是设备配置相关的引脚信息
├── board              对于不同的平台的开发板对应的代码
├── cmd                顾名思义,大部分的命令的实现都在这个文件夹下面。
├── common             公共的代码
├── configs            各个板子的对应的配置文件都在里面,我们的Lichee配置也在里面
├── disk               对磁盘的一些操作都在这个文件夹里面,例如分区等。
├── doc                参考文档,这里面有很多跟平台等相关的使用文档。
├── drivers            各式各样的驱动文件都在这里面
├── dts                一种树形结构(device tree)这个应该是uboot新的语法
├── examples           官方给出的一些样例程序
├── fs                 文件系统,uboot会用到的一些文件系统
├── include            头文件,所有的头文件都在这个文件夹下面
├── lib                一些常用的库文件在这个文件夹下面
├── Licenses           这个其实跟编译无关了,就是一些license的声明
├── net                网络相关的,需要用的小型网络协议栈
├── post              上电自检程序
├── scripts           编译脚本和Makefile文件
├── spl               second program loader,即相当于二级uboot启动。
├── test              小型的单元测试程序。
└── tools             里面有很多uboot常用的工具。

3、编译uboot

cd u-boot

//不同屏幕不同配置(配置文件在configs文件夹下)--------------------------------------
//默认
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_defconfig 
//4.3寸屏
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_480x272LCD_defconfig
//5寸屏
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_800x480LCD_defconfig 

//配置和编译-----------------------------------------------------------------------
make ARCH=arm menuconfig
time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 | tee build.log

在uboot顶层Makefile的248行,添加默认编译器,就可以直接用make编译了。

# set default to nothing for native builds
ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?= 
endif

ARCH  ?= arm
CROSS_COMPILE ?= arm-linux-gnueabihf-

KCONFIG_CONFIG	?= .config
export KCONFIG_CONFIG

编译成功:
在这里插入图片描述
【问题解决】报错:SyntaxError: Missing parentheses in call to ‘print‘. Did you mean print(result)?
【问题解决】报错:Your dtc is too old, please upgrade to dtc 1.4 or newer


二、烧录

1、进入 fel 模式使用 sunxi-fel 工具烧录

详细步骤参考:全志sunxi-tools烧录工具安装和使用

//检查是否可以探测到芯片信息:
sudo sunxi-fel -l
//确认是否成功进入fel模式:
sudo sunxi-fel ver

在这里插入图片描述

有两种方式进行程序下载:

  • 烧录到RAM中去执行,以 uboot file-with-spl形式进行(单次运行,测试时个人推荐)
sudo sunxi-fel uboot u-boot-sunxi-with-spl.bin

//或者执行烧录地址
sudo sunxi-fel -p write 0x40000000 u-boot-sunxi-with-spl.bin
sudo sunxi-fel exec 0x40000000
  • 烧录到 spi-flash (开机自启)
sunxi-fel -p spiflash-write 0 u-boot-sunxi-with-spl.bin

注意:如果烧录到 spi-flash ,需要修改 include/configs/sun8i.h ,从flash引导系统


uboot启动信息:

U-Boot SPL 2017.01-rc2-00057-g32ab1804cd (Jan 16 2021 - 12:28:54)
DRAM: 64 MiB
Trying to boot from FEL

U-Boot 2017.01-rc2-00057-g32ab1804cd (Jan 16 2021 - 12:28:54 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
MMC:   SUNXI SD/MMC: 0
Card did not respond to voltage select!
*** Warning - MMC init failed, using default environment

In:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000
Net:   No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot:  0 
Card did not respond to voltage select!
starting USB...
No controllers found
USB is stopped. Please issue 'usb start' first.
starting USB...
No controllers found
No ethernet found.
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-sunxi
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
starting USB...
No controllers found
No ethernet found.
No ethernet found.
=>

2、烧录到TF/SD卡

TF卡中的系统镜像一般分为三个区:

  • boot区或者引导区 - 该部分没有文件系统而是直接将二进制的bootloader(uboot)文件直接写入。
  • linux内核区 - fat文件系统,存放linux内核、内核参数文件还有设备数dtb文件。
  • rootfs分区 - 用来存放根文件系统和用户数据等,一般是ext4文件分区格式。
//插入TF卡前后查询,确认设备名称
ls /dev/sd*

//删除TF/SD的分区信息
sudo dd if=/dev/zero of=/dev/sdb bs=512K count=1

//烧录到TF卡(`u-boot-sunxi-with-spl.bin`在uboot根目录下)
sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8

在这里插入图片描述
在这里插入图片描述

uboot启动信息:

U-Boot 2017.01-rc2-00057-g32ab1804cd-dirty (Jan 16 2021 - 22:48:52 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

Setting up a 480x272 lcd console (overscan 0x0)
dotclock: 10000kHz = 10000kHz: (1 * 3MHz * 20) / 6
In:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000
Net:   No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot:  0 
** Invalid partition 1 **
** Invalid partition 1 **
=> 

三、启动成功后显示界面:

1、直接烧录到RAM启动(USB):

在这里插入图片描述

2、烧录到TF启动:

注意TF卡要插在靠近USB的那个接口:
在这里插入图片描述

参考:荔枝派Zero V3s开发板入坑记录 (TF/SD卡启动)(主线Linux,主线u-boot)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值