飞思卡尔提供了imx6q的移植手册i.MX_BSP_Porting_Guide.pdf。
1.准备源码:
$cd /opt/fsl-yocto-L4.1.15_1.0.0-ga/fsl-release-bsp/
source fsl-setup-release.sh -b build-x11
构建u-boot-imx.
$bitbake u-boot-imx
$cp tmp/work/imx6qsabresd-poky-linux-gnueabi/u-boot-imx/2015.04-r0/git /opt/fsl-yocto-L4.1.15_1.0.0-ga/u-boot-imx-2015-04-r0/ -rfd
$cd /opt/fsl-yocto-L4.1.15_1.0.0-ga/u-boot-imx-2015-04-r0/
$mkdir board/EmbedSky
$cp -R board/freescale/common board/EmbedSky/common
$cp -R board/freescale/mx6sabresd/ board/EmbedSky/mx6q_tqe9/
$cp include/configs/mx6sabresd.h include/configs/mx6q_tqe9.h
$cp configs/mx6qsabresd_defconfig configs/mx6q_tqe9_defconfig
修改mx6q_tqe9_defconfig如下(红色为修改部分):
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/EmbedSky/mx6q_tqe9/mx6q_4x_mt41j128.cfg,MX6Q,SYS_USE_SPINOR"
CONFIG_ARM=y
CONFIG_TARGET_MX6Q_TQE9=y
CONFIG_DM=y
CONFIG_DM_THERMAL=y
$mv board/EmbedSky/mx6q_tqe9/mx6sabresd.c board/EmbedSky/mx6q_tqe9/mx6q_tqe9.c
把board/EmbedSky/mx6q_tqe9/Makefile中的下面一行
obj-y := mx6sabresd.o
改成如下一行
obj-y := mx6q_tqe9.o
修改board/EmbedSky/mx6q_tqe9/Kconfig(红色部分)
if TARGET_MX6Q_TQE9
config SYS_BOARD
default "mx6q_tqe9"
config SYS_VENDOR
default "EmbedSky"
config SYS_SOC
default "mx6"
config SYS_CONFIG_NAME
default "mx6q_tqe9"
endif
修改arch/arm/Kconfig,在TARGET_MX6SABRESD下面增加TARGET_MX6Q_TQE9的配置(红色部分):
config TARGET_MX6SABRESD
bool "Support mx6sabresd"
select CPU_V7
select SUPPORT_SPL
config TARGET_MX6Q_TQE9
bool "Support mx6q_tqe9"
select CPU_V7
select SUPPORT_SPL
source "board/EmbedSky/mx6q_tqe9/Kconfig"
编写创建镜像脚本build_u-boot.sh:
#!/bin/bash
export ARCH=arm export CROSS_COMPILE=/opt/fsl-imx-x11/4.1.15-1.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
make distclean
make mx6q_tqe9_defconfig
make
执行build_u-boot.sh 若出现找不到 -lgcc 之类的错误 可尝试source environment-setup-xxxx.sh脚本建立环境再次执行build_u-boot.sh脚本.
若能正常生成镜像则说明移植代码可用。
接下来修改我们板子的DCD,天嵌提供的uboot源码是基于1.3.4版本,DCD是在板目录的flash_header.S中配置,我们的uboot版本中DCD是以xxxx.cfg配置文件的形式存在的,而天嵌只给出了一个module,这里当然可以直接反汇编出会汇编源码,然后修改我们的uboot,但这里还是采用飞思卡尔的工具配置DCD,一下步骤在windows上操作。
首先下载DDR_Stress_Tester_V1.0.3.zip和I.MX6DQSDL DDR3 Script Aid V0.10.xlsx两个工具,解压DDR_Stress_Tester_V1.0.3.zip到c盘根下,把I.MX6DQSDL DDR3 Script Aid V0.10.xlsx放到C:\DDR_Stress_Tester_V1.0.3\Binary,打I.MX6DQSDL DDR3 Script Aid V0.10.xlsx,根据板子上的DDR3芯片的芯片手册配置Register Configuration标签页,如下图:
此时RealView .inc标签页将生成相应的配置信息。
切换到RealView .inc页,另存为,文件类型选择 文本文件(制表符分隔)(*.txt),文件名V0.10.txt(可为其他),存到C:\DDR_Stress_Tester_V1.0.3\Binary目录。
打开V0.10.txt注掉setmem /16 0x020bc000 =0x30一行:
//setmem /16 0x020bc000 = 0x30
保存。
把板子拨码开关拨到USB下载模式。
打开cmd依次输入以下指令:
>cd c:\DDR_Stress_Tester_V1.0.3\Binary\
>DDR_Stress_Tester.exe -t mx6x -df V0.10.txt
进入DDR_Stress_Tester.exe软件指令界面。
输入数字1,选择ARM工作核心为800MHz;
输入数字0,选择2GB容量;
输入'y',选择DDR工作频率528MHz;
输入'y',运行write leveling calibration;
输入 V0.10.txt中MR1寄存器值得高四个十六进制位0004;
此时得到write leveling calibration的调校结果:
MMDC_MPWLDECTRL0 ch0 after write level cal: 0x00150009
MMDC_MPWLDECTRL1 ch0 after write level cal: 0x00220015
MMDC_MPWLDECTRL0 ch1 after write level cal: 0x0013002C
MMDC_MPWLDECTRL1 ch1 after write level cal: 0x0009002A
用以上四个值修改V0.10.txt:
// For target board, may need to run write leveling calibration to fine tune these settings.
setmem /32 0x021b080c =0x00150009
setmem /32 0x021b0810 =0x00220015
setmem /32 0x021b480c =0x0013002C
setmem /32 0x021b4810 =0x0009002A
输入'y'继续后三项调校,这个将会等上3分钟左右,然后得到结果如下:
Read DQS Gating calibration
MPDGCTRL0 PHY0 (0x021b083c) = 0x03340348
MPDGCTRL1 PHY0 (0x021b0840) = 0x03340328
MPDGCTRL0 PHY1 (0x021b483c) = 0x034C0358
MPDGCTRL1 PHY1 (0x021b4840) = 0x03480308
Read calibration
MPRDDLCTL PHY0 (0x021b0848) = 0x48383C38
MPRDDLCTL PHY1 (0x021b4848) = 0x423E3844
Write calibration
MPWRDLCTL PHY0 (0x021b0850) = 0x3A38423E
MPWRDLCTL PHY1 (0x021b4850) = 0x4A304840
用以上结果修改V0.10.txt,
////Read DQS Gating calibration
setmem /32 0x021b083c =0x03340348// MPDGCTRL0 PHY0
setmem /32 0x021b0840 =0x03340328// MPDGCTRL1 PHY0
setmem /32 0x021b483c =0x034C0358// MPDGCTRL0 PHY1
setmem /32 0x021b4840 =0x03480308// MPDGCTRL1 PHY1
//Read calibration
setmem /32 0x021b0848 =0x48383C38// MPRDDLCTL PHY0
setmem /32 0x021b4848 =0x423E3844// MPRDDLCTL PHY1
//Write calibration
setmem /32 0x021b0850 =0x3A38423E// MPWRDLCTL PHY0
setmem /32 0x021b4850 =0x4A304840// MPWRDLCTL PHY1
回到linux系统,把官方sabresd中的cfg文件操被一份作为我们的cfg基础
$cp board/EmbedSky/mx6q_tqe9/mx6q_4x_mt41j128.cfg board/EmbedSky/mx6q_tqe9/mx6q_tqe9_ddr3.cfg
根据V0.10.txt修改我们的mx6q_tqe9_ddr3.cfg。
修改configs/mx6q_tqe9_defconfig文件:
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/EmbedSky/mx6q_tqe9/mx6q_tqe9_ddr3.cfg,MX6Q,SYS_USE_SPINOR"
CONFIG_ARM=y
CONFIG_TARGET_MX6Q_TQE9=y
CONFIG_DM=y
CONFIG_DM_THERMAL=y
E9的串口终端IO跟sabresd不太一样,使用了SD3_DAT7、SD3_DAT分别作UART1_TXD、UART1_RXD,所以这里需要做相应的改变。
修改board/EmbedSky/mx6q_tqe9/mx6q_tqe9.c :
static iomux_v3_cfg_t const uart1_pads[] = {
MX6_PAD_SD3_DAT7__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
MX6_PAD_SD3_DAT6__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
};
由于MX6_PAD_SD3_DAT7、MX6_PAD_SD3_DAT6已经被USDHC3占用,继续修改board/EmbedSky/mx6q_tqe9/mx6q_tqe9.c :
static iomux_v3_cfg_t const usdhc3_pads[] = {
MX6_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_NANDF_D0__GPIO2_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
};
E9的sd卡槽使用的是USDHC2控制器,并且与sabresd不同的是该SD CARD电路的CD引脚使用的是GPIO_4,继续修改board/EmbedSky/mx6q_tqe9/mx6q_tqe9.c :
引脚配置:
// MX6_PAD_NANDF_D2__GPIO2_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
MX6_PAD_GPIO_4__GPIO1_IO04 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
#define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4)
编译uboot,烧写sd卡
$./build_u-boot.sh
$sudo dd if=u-boot.imx of=/dev/sdc bs=512 seek=2 conv=fsync
运行开发板报错:
Can't find PMIC:PFUZE100
天嵌这块板子没有使用sabresd官方使用的PFUZE100,故要关掉相应驱动。
include/configs/mx6q_tqe9.h +:
/* PMIC */
/*************************************
#define CONFIG_POWER
#define CONFIG_POWER_I2C
#define CONFIG_POWER_PFUZE100
#define CONFIG_POWER_PFUZE100_I2C_ADDR 0x08
**************************************/
board/EmbedSky/mx6q_tqe9/mx6q_tqe9.c +973:
使用#if 0/#endif 注掉static struct pmic *pfuze;和int power_init_board(void)
./include/configs/mx6_common.h +48:
/* #define CONFIG_LDO_BYPASS_CHECK */
重新编译烧写u-boot
$./build_u-boot.sh
$sudo dd if=u-boot.imx of=/dev/sdc bs=512 seek=2 conv=fsync
启动板子打印如下:
U-Boot 2015.04-imx_v2015.04_4.1.15_1.0.0_ga+gd7d7c43 (May 20 2016 - 00:41:18)这里命令行提示符为"=> ",可以将之改为正式些的形式,修改include/config_fallbacks.h 行79:
#define CONFIG_SYS_PROMPT "TQE9>> "
最后修改下board/EmbedSky/mx6q_tqe9.c :
int checkboard(void)
{
puts("Board: MX6Q_TQE9\n");
return 0;
}
最后重新编译运行目标,至此u-boot移植初步完成 ,接下来将移植TQE9的网卡。