如何适配Embedfire I.MX6ULL-S1-NAND-MINI开发板到NXP官方最新的SDK

开发板资料请参考如下网址: https://doc.embedfire.com/products/link/zh/latest/linux/ebf_i.mx6ull.html

nxp 提供了丰富的软件sdk, 如果能利用NXP的提供的最新的sdk资源,搭配低成本的硬件方案,强强联合使产品更有竞争力,更方便爱好者学习使用,我们采用最新的SDK版本L6.1.36-2.1.0来做适配。

1.首先利用DDR压力测试工具生成ddr参数,可以参考之前的文档https://www.lijiandong.com.cn/?p=110

IMX6ULL DDR压力测试工具网址:

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/i-MX-6-7-DDR-Stress-Test-Tool/ta-p/1108221

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/i-MX-6-7-Series-DDR-Tool-Release/ta-p/1271415

压力测试生成的log文件如下,更新如下Calibration寄存器到uboot的代码里

MMDC registers updated from calibration
Write leveling calibration
MMDC_MPWLDECTRL0 ch0 (0x021b080c) = 0x00050003
MMDC_MPWLDECTRL1 ch0 (0x021b0810) = 0x00060006
Read DQS Gating calibration
MPDGCTRL0 PHY0 (0x021b083c) = 0x413C0140
MPDGCTRL1 PHY0 (0x021b0840) = 0x00000000
Read calibration
MPRDDLCTL PHY0 (0x021b0848) = 0x40402E34
Write calibration
MPWRDLCTL PHY0 (0x021b0850) = 0x40403430
Success: DDR calibration completed!!!

更新uboot-imx/board/freescale/mx6ullevk/imximage.cfg文件,根据log修改对应ddr寄存器的值如下:

DATA 4 0x021B080C 0x00050003
DATA 4 0x021B0810 0x00060006
DATA 4 0x021B083C 0x413C0140
DATA 4 0x021B0840 0x00000000
DATA 4 0x021B0848 0x40402E34
DATA 4 0x021B0850 0x40403430

如果更换的DDR3颗粒容量大小有变化,请修改如下两个寄存器,比如采用2Gb容量颗粒后

DATA 4 0x021B0040 0x00000047
DATA 4 0x021B0000 0x83180000

修改 source/meta-bsp/conf/machine/imx6ull14x14evk.conf,
配置编译nand版本image 默认编译的是sd image: UBOOT_CONFIG ??= “nand”

开发板自带4Gb Nand, 因为nand 都兼容ONFI标准,所以软件部分基本不用做修改,执行如下命令重新编译生成nand 版本uboot image

bitbake -c compile -f uboot-imx
bitbake uboot-imx

为了方便uuu烧写image工具修改如下文件:
source/meta-imx/meta-bsp/conf/machine/include/imx-base-extend.inc
修改默认生成的rootfs文件压缩格式为tar.bz2,增加tar.bz2
SOC_DEFAULT_IMAGE_FSTYPES = “wic.bmap wic.zst tar.zst tar.bz2

bitbake imx-image-core #生成新的tar.bz2压缩格式的文件系统, 参考sdk文档根据具体应用需求可以生成不同的文件系统,比如fsl-image-qt5.

uuu 烧写工具是新一代的量产烧写工具,相比于之前的mfgtools功能上有很多增强。工具网址:https://github.com/nxp-imx/mfgtools/wiki

uuu工具通过uboot的fastboot模式,通过usb口进行烧写image, 针对nand烧写,只通过uboot fastboot模式是不行的,需要加载linux ramfs文件系统才可以,参考如下说明:

What Firmware Need

What you wantFirmware Need
Download bootloaderN/A
Burn Image to eMMC/SDuboot with fastboot enable
Burn Image to qspi\spi\noruboot with fastboot enable
Burn Image into Nand flashuboot(1), linux kernel\initramfs\uboot\dtb
Need linux shell cmd such as fdiskuboot(1), linux kernel\initramfs\uboot\dtb
Boot linux kenrel with rootfs already in eMMCuboot with fastboot enable
Boot Linux kernel with nfs over USBuboot with fastboot enable, initramfs

执行如下命令生成uuu下载需要的文件: bitbake fsl-image-mfgtool-initramfs

参考uuu.pdf文件,uuu nand flash 烧写需要的脚本如下:

# Please replace below item with actual name
# @_flash_fw.bin | boot loader firmware, for i.MX8QM/QX, it's different from _flash.bin, for all other platforms, it's same as _flash.bin
# @_flash.bin | boot loader file burn to NAND
# @_Image | linux kernel image, zImage for arm32, Image for arm64
# @_board.dtb | board dtb file
# @_initramfs.cpio.gz.uboot | initramfs
# @_tee | optee image
# @_rootfs.tar.bz2 | rootfs
# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f u-boot-nand.imx
# This command will be run when ROM support stream mode
# i.MX8QXP, i.MX8QM
SDPS: boot -f u-boot-nand.imx
# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f u-boot-nand.imx -offset 0x57c00
SDPU: jump
# }
# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f u-boot-nand.imx -skipspl
SDPV: jump
# }
FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f zImage
FB: ucmd setenv fastboot_buffer ${fdt_addr}
FB: download -f imx6ul-14x14-evk-gpmi-weim.dtb
FB: ucmd setenv fastboot_buffer ${initrd_addr}
FB: download -f fsl-image-mfgtool-initramfs-imx6ulevk.cpio.zst.u-boot
FB: ucmd setenv bootargs ${bootargs} ${mtdparts}
#FB: ucmd setenv bootargs console=ttymxc3,115200 ${mtdparts}
FB: acmd ${kboot} ${loadaddr} ${initrd_addr} ${fdt_addr}
FBK: ucmd cat /proc/mtd
FBK: ucmd cat /proc/mtd | while read dev size erase name; do mtd=${dev:3}; mtd=${mtd%:}; name=${name%\"}; name=${name#\"}; echo export $name=$mtd >> /tmp/mtd.sh; done;
FBK: ucmd chmod 777 /tmp/mtd.sh
FBK: ucmd mount -t debugfs debugfs /sys/kernel/debug
# write boot loader
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandboot} 0 0
FBK: ucp u-boot-nand.imx t:/tmp/boot
FBK: ucmd source /tmp/mtd.sh; cd /tmp; if ! [[ `cat /sys/devices/soc0/soc_id` = *"MX8Q"* ]]; then pad="-x"; fi; kobs-ng init $pad -v --chip_0_device_path=/dev/mtd${nandboot} /tmp/boot
# burn FIT
FBK: ucmd if [[ `cat /tmp/mtd.sh` = *"nandfit"* ]]; then source /tmp/mtd.sh;flash_erase /dev/mtd${nandfit} 0 0; dd if=/tmp/boot of=/tmp/fit; nandwrite -p /dev/mtd${nandfit} -p /tmp/fit; fi
# burn kernel
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandkernel} 0 0
FBK: ucp zImage t:/tmp/img
FBK: ucmd source /tmp/mtd.sh; nandwrite -p /dev/mtd${nandkernel} -p /tmp/img
# burn dtb
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nanddtb} 0 0
FBK: ucp imx6ul-14x14-evk-gpmi-weim.dtb t:/tmp/dtb
FBK: ucmd source /tmp/mtd.sh; nandwrite -p /dev/mtd${nanddtb} -p /tmp/dtb
# burn uTee
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandtee} 0 0
FBK: ucp tee t:/tmp/tee
FBK: ucmd source /tmp/mtd.sh; nandwrite -p /dev/mtd${nandtee} -p /tmp/tee
# burn rootfs
FBK: ucmd source /tmp/mtd.sh; flash_erase /dev/mtd${nandrootfs} 0 0
FBK: ucmd source /tmp/mtd.sh; ubiattach /dev/ubi_ctrl -m ${nandrootfs}
FBK: ucmd source /tmp/mtd.sh; ubimkvol /dev/ubi0 -Nnandrootfs -m
FBK: ucmd source /tmp/mtd.sh; mkdir -p /mnt/mtd
FBK: ucmd source /tmp/mtd.sh; mount -t ubifs ubi0:nandrootfs /mnt/mtd
FBK: acmd export EXTRACT_UNSAFE_SYMLINKS=1; tar -jx -C /mnt/mtd
FBK: ucp rootfs.tar.bz2 t:-
FBK: sync
FBK: ucmd umount /mnt/mtd
FBK: done

注意脚本里要下载和烧写的image名称要与实际的image名称对应上。

如果更换不同容量的nand,比如修改为2G nand,需要修改nand分区,并修改image加载地址,参考如下uboot代码,

diff --git a/include/configs/mx6ul_14x14_evk.h b/include/configs/mx6ul_14x14_evk.h
index a89cea359d..b6deb8899d 100644
--- a/include/configs/mx6ul_14x14_evk.h
+++ b/include/configs/mx6ul_14x14_evk.h
@@ -39,7 +39,8 @@
 #endif
 #ifdef CONFIG_NAND_BOOT
-#define MFG_NAND_PARTITION "mtdparts=gpmi-nand:64m(nandboot),16m(nandkernel),16m(nanddtb),16m(nandtee),-(nandrootfs)"
+#define MFG_NAND_PARTITION "mtdparts=gpmi-nand:8m(nandboot),16m(nandkernel),1m(nanddtb),1m(nandtee),-(nandrootfs)"
+/*#define MFG_NAND_PARTITION "mtdparts=gpmi-nand:64m(nandboot),16m(nandkernel),16m(nanddtb),16m(nandtee),-(nandrootfs)"*/
 #else
 #define MFG_NAND_PARTITION ""
 #endif
@@ -64,14 +65,14 @@
 	"tee_addr=0x84000000\0" \
 	"console=ttymxc0\0" \
 	"bootargs=console=ttymxc0,115200 ubi.mtd=nandrootfs "  \
-		"root=ubi0:rootfs rootfstype=ubifs "		     \
+		"root=ubi0:nandrootfs rootfstype=ubifs "		     \
 		BOOTARGS_CMA_SIZE \
 		MFG_NAND_PARTITION \
 		"\0" \
-	"bootcmd=nand read ${loadaddr} 0x4000000 0xc00000;"\
-		"nand read ${fdt_addr} 0x5000000 0x100000;"\
+	"bootcmd=nand read ${loadaddr} 0x800000 0xc00000;"\
+		"nand read ${fdt_addr} 0x1800000 0x100000;"\
 		"if test ${tee} = yes; then " \
-			"nand read ${tee_addr} 0x6000000 0x400000;"\
+			"nand read ${tee_addr} 0x1900000 0x400000;"\
 			"bootm ${tee_addr} - ${fdt_addr};" \
 		"else " \
 			"bootz ${loadaddr} - ${fdt_addr};" \

执行 uuu -b 脚本名称 烧写nand image,烧写后系统可以正常启动。后续根据需要修改硬件外设设备树,使开发板外设可用。此mini板采用与nxp官方开发板相同的双百兆网口PHY硬件设计,所以网口可以直接使用。

发表评论

电子邮件地址不会被公开。