我imx6ull使用的是正点原子的alpha开发板。我将我的SD卡分成了两个分区,第一个分区格式化为fat,用来存放zImage和dtb;第二个分区格式化为EXT4格式,这个分区作为根文件系统。
遇到的问题是:我编译好kernel后,尝试通过UBoot的fatload或load命令将fat分区中的boot/zImage和boot/my-i6ull.dtb文件载入内存,但是每次载入zImage的时候都无法读取这个文件,再次读取时就报找不到分区表:
U-Boot 2016.03-gc221d3f (Oct 14 2019 - 12:40:04 +0800)
CPU: Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 49C
Reset cause: POR
Board: MX6ULL 14x14 EVK
I2C: ready
DRAM: 256 MiB
NAND: 512 MiB
MMC: FSL_SDHC: 0
*** Warning - bad CRC, using default environment
Display: ATK-LCD-4.3-480x272 (480x272)
Video: 480x272x24
NAND read: device 0 offset 0x420000, size 0x100000
1048576 bytes read: OK
Error: no valid bmp image at 88000000
In: serial
Out: serial
Err: serial
Net: FEC1
Error: FEC1 address not set.
Normal Boot
Hit any key to stop autoboot: 0
=> mmc part
Partition Map for MMC device 0 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
1 2048 204800 8bb1460b-01 0e Boot
2 206848 772096 8bb1460b-02 83
=> fatls mmc 0:1 boot
./
../
5583352 zimage
36274 my-i6ull.dtb
2 file(s), 2 dir(s)
=> fatload mmc 0:1 80800000 boot/zImage
reading boot/zImage
Error reading cluster
** Unable to read file boot/zImage **
=>
=> fatload mmc 0:1 80800000 boot/zImage
** Can't read partition table on 0:0 **
** Invalid partition 1 **
=>
=> mmc part
Partition Map for MMC device 0 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
** Can't read partition table on 0:0 **
=>
令我感到神奇的是boot/my-iu6ull.dtb文件虽然大多数时候也是读取失败,但偶尔也能成功读到内存中去。等boot/my-i6ull.dtb读完后仍能通过 mmc part 看到分区表,但这时,如果尝试读zImage,仍然是失败:
U-Boot 2016.03-gc221d3f (Oct 14 2019 - 12:40:04 +0800)
CPU: Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 50C
Reset cause: POR
Board: MX6ULL 14x14 EVK
I2C: ready
DRAM: 256 MiB
NAND: 512 MiB
MMC: FSL_SDHC: 0
*** Warning - bad CRC, using default environment
Display: ATK-LCD-4.3-480x272 (480x272)
Video: 480x272x24
NAND read: device 0 offset 0x420000, size 0x100000
1048576 bytes read: OK
Error: no valid bmp image at 88000000
In: serial
Out: serial
Err: serial
Net: FEC1
Error: FEC1 address not set.
Normal Boot
Hit any key to stop autoboot: 0
=> mmc part
Partition Map for MMC device 0 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
1 2048 204800 8bb1460b-01 0e Boot
2 206848 772096 8bb1460b-02 83
=> fatls mmc 0:1 boot
./
../
5583352 zimage
36274 my-i6ull.dtb
2 file(s), 2 dir(s)
=> fatload mmc 0:1 83000000 boot/my-i6ull.dtb
reading boot/my-i6ull.dtb
36274 bytes read in 22 ms (1.6 MiB/s)
=>
=> fatload mmc 0:1 80800000 boot/zImage
reading boot/zImage
Error reading cluster
** Unable to read file boot/zImage **
=>
=> fatload mmc 0:1 80800000 boot/zImage
** Can't read partition table on 0:0 **
** Invalid partition 1 **
=>
=>
后来我重新使用正点原子提供的nand和emmc的配置文件对UBoot进行编译(刚开始我一直用的是nand中的UBoot),然后调整boot到卡启动模式,这个问题仍然存在。我更换过使用的SD卡,仍无法解决。我不得不怀疑是否是厂家在修改UBoot的时候误操作了什么地方,接着我又使用nxp的uboot-imx-rel_imx_4.1.15_2.1.0_ga.tar.bz2源码包,使用mx6ull_14x14_evk_defconfig配置文件进行编译。我想大厂的总该没问题了吧!可惜的是,这个问题仍然存在。。。看来官方提供的UBoot可能真的有些bug
各种抓狂之下去UBoot的分ftp站点重新下载了一个版本,第一次下的是u-boot-2016.03.tar.bz2,结果却发现该版本只合并到mx6ul,重新下了u-boot-2017.03.tar.bz2,发现支持到了mx6ull,编译的时候提示我:Your dtc is too old, please upgrade to dtc 1.4 or newer ,执行:apt-get install device-tree-compiler 后再次使用mx6ull_14x14_evk_defconfig配置进行编译:
... 省略 ...
DTC arch/arm/dts/imx6dl-icore.dtb
DTC arch/arm/dts/imx6dl-icore-rqs.dtb
DTC arch/arm/dts/imx6q-icore.dtb
DTC arch/arm/dts/imx6q-icore-rqs.dtb
DTC arch/arm/dts/imx6sx-sabreauto.dtb
DTC arch/arm/dts/imx6ul-geam-kit.dtb
SHIPPED dts/dt.dtb
CAT u-boot-dtb.bin
CFGS board/freescale/mx6ullevk/imximage.cfg.cfgtmp
MKIMAGE u-boot-dtb.imx
OBJCOPY u-boot.srec
COPY u-boot.bin
SYM u-boot.sym
COPY u-boot.dtb
CFGCHK u-boot.cfg
cat: u-boot.cfg: No such file or directory
root@hope-VirtualBox:/home/hope/work/uboot/u-boot-2017.03# ls u-boot*
u-boot u-boot.dtb u-boot-dtb.imx.log u-boot-nodtb.bin
u-boot.bin u-boot-dtb.bin u-boot.lds u-boot.srec
u-boot.cfg.configs u-boot-dtb.imx u-boot.map u-boot.sym
烧写测试:
U-Boot 2017.03 (Aug 13 2020 - 10:05:02 +0800)
CPU: Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 45C
Reset cause: WDOG
Model: Freescale i.MX6 ULL 14x14 EVK Board
Board: MX6ULL 14x14 EVK
DRAM: 512 MiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: CPU Net Initialization Failed
No ethernet found.
Hit any key to stop autoboot: 0
=> fatload mmc 0:1 80800000 boot/zImage
reading boot/zImage
5583352 bytes read in 346 ms (15.4 MiB/s)
=> fatload mmc 0:1 83000000 boot/my-i6ull.dtb
reading boot/my-i6ull.dtb
36274 bytes read in 23 ms (1.5 MiB/s)
=>
这下终于美滋滋了~~~~~~~load命令和fatload命令屡试不爽!kernel也能正常启动
老实说,起初我怀疑是mmc驱动有问题,但一看UBoot是能正确识别到sd卡的并且fatls命令输出的结果也正确,这意味着不太可能是驱动的问题。难不成是文件系统有bug???具体原因我还没来得及去细究,今天先记录下这个问题,等有时间的时候再去看看这令我抓狂的虫子到底在哪!有知道的朋友还望赐教~~