前言
在博文 https://blog.csdn.net/wenhao_ir/article/details/145547974 中,我们利用官方提供的BSP(FSL Yocto Project Community BSP)构建了写到SD卡中的完整镜像,然后启动后发现存在不少问题,首要的问题就是u-boot不能识别网卡,在这篇博文中,我们就找到FSL Yocto Project Community BSP
用到的u-boot源码,然后进行修改适配。
配置gcc交叉编译器
由于后面我们要自己去对自己修改后的u-boot进行编译,所以需要有gcc交叉编译器。
Buildroot在构建完之后能生成gcc交叉编译器,详情见 https://blog.csdn.net/wenhao_ir/article/details/145470042 【搜索“生成交叉编译工具链”】。
Ycoto在构建时也能生成,但是由于这里在配置时没有配置生成gcc交叉编译器,所以这里就只有自己去手动操作了。
为了减少这篇博文的长度,所以具体的gcc交叉编译器的下载和配置见下面博文:https://blog.csdn.net/wenhao_ir/article/details/145649698
找到u-boot源码
从博文https://blog.csdn.net/wenhao_ir/article/details/145547974构建的完整的SD卡镜像的运行情况来看,公板MCIMX6ULL-EVK(imx6ull14x14evk)的u-boot是不适应百问网的板子,主要就是网卡有问题,我们需要进行修改…
我们需要在FSL Yocto Project Community BSP
中找到u-boot源码…
我们需要在在FSL Yocto Project Community BSP
中找到对应的仓库地址,然后拉取到本地。
具体方法如下:
由于我们之前的镜像选择的是imx-image-multimedia
,Yocto对应的层如下面这个列表:
所以我们需要在目录/imx-yocto-bsp/sources/meta-imx/
中去找其对应的仓库地址信息。打开下面这个文件:
/imx-yocto-bsp/sources/meta-imx/meta-bsp/recipes-kernel/linux/linux-imx_5.4.bb
我们能找到meta-imx
层对应的liunx的源码仓库地址:
git://source.codeaurora.org/external/imx/linux-imx.git
据此,我们可以推断出其u-boot源码的仓库地址为:
https://source.codeaurora.org/external/imx/uboot-imx
如果这个源还有效的话,运行下面的命令就能将u-boot的源码下载下来了:
git clone https://source.codeaurora.org/external/imx/uboot-imx
但很可惜这个源已经无效了,证据如下:
curl https://source.codeaurora.org/
上面的截图是美国的服务器上运行的,说明是真失效了,那就只有用百问网提供的之前通过仓库地址下载好的u-boot源码了。百度网盘下载链接:https://pan.baidu.com/s/1YgJPge5JMOf2HkKm_gQB7Q?pwd=ytut
下载好之后,先放在那里备用。
编译找到的u-boot源码
将上一步得到的u-boot的源码复制到Ubuntu中:
然后解压出来:
终端中进入目录/home/book/mybuild/uboot-imx
cd /home/book/mybuild/uboot-imx
不妨先执行一次清除命令:
make distclean
然后给文件check-config.sh
添加执行权限
chmod +x ./scripts/check-config.sh
接着我们需要去查看下有哪些配置文件,配置文件在目录/uboot-imx/configs
下:
可以看到文件非常多,不妨搜索一下关键词mx6ull_14x14_evk*
上面截图中的几个配置文件介绍如下:
- mx6ull_14x14_evk_defconfig:imx6ullevk公板默认的配置文件,默认只支持SD卡启动。
- mx6ull_14x14_evk_emmc_defconfig:支持eMMC启动方式启动的配置文件。
- mx6ull_14x14_evk_nand_defconfig:支持NAND启动方式启动的配置文件。
- mx6ull_14x14_evk_optee_defconfig:支持 optee 系统的配置文件。
- mx6ull_14x14_evk_plugin_defconfig:支持扩展功能的配置文件,主要是烧写功能。
- mx6ull_14x14_evk_qspi1_defconfig:支持 qspi 启动方式启动的配置文件。
我们这里选择支持eMMC启动方式的配置文件: mx6ull_14x14_evk_emmc_defconfig
,运行下面的命令选择这个配置文件:
make mx6ull_14x14_evk_emmc_defconfig
然后执行下面的命令开始构建编译:
make -j4
命令中的4
代表使用4个线程进行编译,当然,如果你的CPU资源够多,可以调大,比如调到6
或8
。
编译很快就结束了,u-boot毕竟只是很短的代码。
从上面的运行结果来看,已经生成了我们想要的u-boot镜像文件u-boot-dtb.imx
,现在我们把它写入到eMMC中,然后通eMMC方式来运行u-boot。
镜像文件u-boot-dtb.imx
的位置就是在u-boot的根目录下:
u-boot镜像文件烧写到eMMC中
参考下面这篇博文把生成的u-boot镜像文件u-boot-dtb.imx
烧写到eMMC中:
https://blog.csdn.net/wenhao_ir/article/details/145653414
运行烧写到eMMC中的u-boot并分析运行结果
烧写完成后关闭开发板电源,
烧写完成后关闭开发板电源,
烧写完成后关闭开发板电源,
然后设置开发板为eMMC启动方式,打开串口即可看到终端有u-boot的运行信息了。
u-boot的运行信息如下:
U-Boot 2020.04-dirty (Feb 15 2025 - 16:43:33 +0800)
CPU: i.MX6ULL rev1.1 792 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 31C
Reset cause: POR
Model: i.MX6 ULL 14x14 EVK Board
Board: MX6ULL 14x14 EVK
DRAM: 512 MiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment
[*]-Video Link 0 (480 x 272)
[0] lcdif@21c8000, video
In: serial
Out: serial
Err: serial
switch to partitions #0, OK
mmc1(part 0) is current device
flash target is MMC:1
Net: Could not get PHY for FEC1: addr 1
Could not get PHY for FEC1: addr 1
Get shared mii bus on ethernet@2188000
Could not get PHY for FEC1: addr 2
Get shared mii bus on ethernet@2188000
undefined instruction
pc : [<00000084>] lr : [<9ef9bdaf>]
reloc pc : [<e8888084>] lr : [<87823daf>]
sp : 9df6d6b8 ip : 00000020 fp : 87800020
r10: 9df955c0 r9 : 9df75ed0 r8 : 9df774b8
r7 : 9df77458 r6 : 00000006 r5 : 00000004 r4 : 9df78748
r3 : 00000048 r2 : 00000006 r1 : 00000004 r0 : 9df78748
Flags: nzCv IRQs off FIQs off Mode SVC_32
Code: 00000000 00000000 00000000 00000011 (79706f43)
Resetting CPU ...
resetting ...
U-Boot 2020.04-dirty (Feb 15 2025 - 16:43:33 +0800)
CPU: i.MX6ULL rev1.1 792 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 32C
Reset cause: POR
Model: i.MX6 ULL 14x14 EVK Board
Board: MX6ULL 14x14 EVK
DRAM: 512 MiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment
[*]-Video Link 0 (480 x 272)
[0] lcdif@21c8000, video
In: serial
Out: serial
Err: serial
switch to partitions #0, OK
mmc1(part 0) is current device
flash target is MMC:1
Net:
Error: ethernet@20b4000 address not set.
Error: ethernet@20b4000 address not set.
Error: ethernet@20b4000 address not set.
FEC: can't find phy-handle
Error: ethernet@20b4000 address not set.
Could not get PHY for FEC0: addr 2
Error: ethernet@20b4000 address not set.
FEC: can't find phy-handle
Error: ethernet@20b4000 address not set.
Could not get PHY for FEC0: addr 2
No ethernet found.
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc1(part 0) is current device
switch to partitions