参照:http://blog.csdn.net/girlkoo/article/details/45420977
文档参照:
- 《i.MX BSP Porting Guide-2015/12, Rev.0》---------uboot porting steps
- 《E9_TQIMX6Q_V1_20131031.pdf》------------------E9 schematics
- 《E9_User_Manual-V3.1.0》---------------------------Burned methods
BSP版本:L3.14.52.1.1.0
Step1:创建单板board目录,这里选择mx6sabresd作为参考
$cp -R board/freescale/mx6sabresd/ board/freescale/mx6q_tqE9/
Step2:创建board配置config文件,这里面设定了dtb文件名称,Stack/Heap大小,DDR大小,zImage装载地址
$cp include/configs/mx6sabresd.h include/configs/mx6q_tqE9.h
Step3:<UBOOT_DIR>/configs/目录,创建config选项配置文件, 复制mx6qsabresd_defconfig --> mx6q_tqE9_defconfig, 然后修改为:
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6q_tqE9.cfg,MX6Q"
CONFIG_ARM=y
CONFIG_TARGET_MX6Q<customer_board>=y
CONFIG_SYS_MALLOC_F=y
CONFIG_SYS_MALLOC_F_LEN=0x400
CONFIG_DM=y
CONFIG_DM_THERMAL=y
Step4:文件重命名
board/freescale/mx6q_tqE9/mx6sabresd.c --> board/freescale/mx6q_tqE9/mx6q_tqE9.c
board/freescale/mx6q_tqE9/mx6qp.cfg --> board/freescale/mx6q_tqE9/mx6q_tqE9.cfg
Step5: 修改board/freescale/mx6q_tqE9目录的Makefile
obj-y:= mx6sabresd.o --> obj-y := mx6q_tqE9.o
Step6: 修改Kconfig
- arch/arm/Kconfig
添加:
config TARGET_MX6Q_TQE9
bool "Support mx6q_tqE9"
select CPU_V7
source "board/freescale/mx6q_tqE9/Kconfig"
- board/freescale/mx6q_tqE9/Kconfig
修改为:
if TARGET_MX6Q_TQE9 config SYS_BOARD
default "mx6q_tqE9" config SYS_VENDOR
default "freescale" config SYS_SOC
default "mx6" config SYS_CONFIG_NAME
default "mx6q_tqE9" endif
Step7:创建编译脚本
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=/opt/Embedsky/gcc-4.6.-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/bin/arm-fsl-linux-gnueabi-
make distclean;
make mx6q_tqE9_defconfig
make
Step8:参照@girlkoo:
1. 定制DDR,目录为board/freescale/mx6q_tqE9/mx6q_tqE9.cfg
DATA , 0x020e0798, 0x000C0000
DATA , 0x020e0758, 0x00000000
DATA , 0x020e0588, 0x00000030
DATA , 0x020e0594, 0x00000030
DATA , 0x020e056c, 0x00000030
DATA , 0x020e0578, 0x00000030
DATA , 0x020e074c, 0x00000030
DATA , 0x020e057c, 0x00000030
DATA , 0x020e058c, 0x00000000
DATA , 0x020e059c, 0x00000030
DATA , 0x020e05a0, 0x00000030
DATA , 0x020e078c, 0x00000030
DATA , 0x020e0750, 0x00020000
DATA , 0x020e05a8, 0x00000018
DATA , 0x020e05b0, 0x00000018
DATA , 0x020e0524, 0x00000018
DATA , 0x020e051c, 0x00000018
DATA , 0x020e0518, 0x00000018
DATA , 0x020e050c, 0x00000018
DATA , 0x020e05b8, 0x00000018
DATA , 0x020e05c0, 0x00000018
DATA , 0x020e0774, 0x00020000
DATA , 0x020e0784, 0x00000018
DATA , 0x020e0788, 0x00000018
DATA , 0x020e0794, 0x00000018
DATA , 0x020e079c, 0x00000018
DATA , 0x020e07a0, 0x00000018
DATA , 0x020e07a4, 0x00000018
DATA , 0x020e07a8, 0x00000018
DATA , 0x020e0748, 0x00000018
DATA , 0x020e05ac, 0x00000018
DATA , 0x020e05b4, 0x00000018
DATA , 0x020e0528, 0x00000018
DATA , 0x020e0520, 0x00000018
DATA , 0x020e0514, 0x00000018
DATA , 0x020e0510, 0x00000018
DATA , 0x020e05bc, 0x00000018
DATA , 0x020e05c4, 0x00000018
DATA , 0x021b0800, 0xa1390003
DATA , 0x021b080c, 0x001F001F
DATA , 0x021b0810, 0x001F001F
DATA , 0x021b480c, 0x001F001F
DATA , 0x021b4810, 0x001F001F
DATA , 0x021b083c, 0x43270338
DATA , 0x021b0840, 0x03200314
DATA , 0x021b483c, 0x431A032F
DATA , 0x021b4840, 0x03200263
DATA , 0x021b0848, 0x4B434748
DATA , 0x021b4848, 0x4445404C
DATA , 0x021b0850, 0x38444542
DATA , 0x021b4850, 0x4935493A
DATA , 0x021b081c, 0x33333333
DATA , 0x021b0820, 0x33333333
DATA , 0x021b0824, 0x33333333
DATA , 0x021b0828, 0x33333333
DATA , 0x021b481c, 0x33333333
DATA , 0x021b4820, 0x33333333
DATA , 0x021b4824, 0x33333333
DATA , 0x021b4828, 0x33333333
DATA , 0x021b08b8, 0x00000800
DATA , 0x021b48b8, 0x00000800
DATA , 0x021b0004, 0x00020036
DATA , 0x021b0008, 0x09444040
DATA , 0x021b000c, 0x8A8F7955
DATA , 0x021b0010, 0xFF328F64
DATA , 0x021b0014, 0x01FF00DB
DATA , 0x021b0018, 0x00001740
DATA , 0x021b001c, 0x00008000
DATA , 0x021b002c, 0x000026d2
DATA , 0x021b0030, 0x008F1023
DATA , 0x021b0040, 0x00000047
DATA , 0x021b0000, 0x841A0000
DATA , 0x021b001c, 0x04088032
DATA , 0x021b001c, 0x00008033
DATA , 0x021b001c, 0x00048031
DATA , 0x021b001c, 0x09408030
DATA , 0x021b001c, 0x04008040
DATA , 0x021b0020, 0x00005800
DATA , 0x021b0818, 0x00011117
DATA , 0x021b4818, 0x00011117
DATA , 0x021b0004, 0x00025576
DATA , 0x021b0404, 0x00011006
DATA , 0x021b001c, 0x00000000 /* set the default clock gate to save power */
DATA , 0x020c4068, 0x00C03F3F
DATA , 0x020c406c, 0x0030FC03
DATA , 0x020c4070, 0x0FFFC000
DATA , 0x020c4074, 0x3FF00000
DATA , 0x020c4078, 0x00FFF300
DATA , 0x020c407c, 0x0F0000F3
DATA , 0x020c4080, 0x000003FF /* enable AXI cache for VDOA/VPU/IPU */
DATA , 0x020e0010, 0xF00000CF
/* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */
DATA , 0x020e0018, 0x007F007F
DATA , 0x020e001c, 0x007F007F
2. 定制board端子,board/freescale/mx6q_tqE9/mx6q_tqE9.c
<1>.修改串口如下:
iomux_v3_cfg_t const uart1_pads[] = {
// MX6_PAD_CSI0_DAT10__UART1_TXD | MUX_PAD_CTRL(UART_PAD_CTRL),
// MX6_PAD_CSI0_DAT11__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL),
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),
};
<2>.修改SD卡端子:
iomux_v3_cfg_t const usdhc2_pads[] = {
MX6_PAD_SD2_CLK__USDHC2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_CMD__USDHC2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT0__USDHC2_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT1__USDHC2_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT2__USDHC2_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT3__USDHC2_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_NANDF_D4__USDHC2_DAT4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_NANDF_D5__USDHC2_DAT5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_NANDF_D6__USDHC2_DAT6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_NANDF_D7__USDHC2_DAT7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_NANDF_D2__GPIO_2_2 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
}; iomux_v3_cfg_t const usdhc3_pads[] = {
MX6_PAD_SD3_CLK__USDHC3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_CMD__USDHC3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT0__USDHC3_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT1__USDHC3_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT2__USDHC3_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT3__USDHC3_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT4__USDHC3_DAT4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT5__USDHC3_DAT5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_SD3_DAT6__USDHC3_DAT6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
// MX6_PAD_SD3_DAT7__USDHC3_DAT7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_NANDF_D0__GPIO_2_0 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
};
<3>.定制Card Detect端子,否则SD卡插入会检测不到
#define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4)
Step9: 编译
./build_uboot.sh
Step10: 烧写,下载:
烧写SD卡:
sudo dd if=u-boot.imx of=/dev/sdc bs= seek=
sync
更改E9为SD卡启动:
Jumper为1~7: 1 0 0 0 0 0 1.
输出log:
U-Boot 2015.04-imx_v2015.04_3..52_1..0_ga+g6cf684a (Oct - ::) CPU: Freescale i.MX6Q rev1. at MHz
CPU: Temperature - C
Reset cause: POR
Board: MX6-TQE9
I2C: ready
DRAM: GiB
Can't find PMIC:PFUZE100
initcall sequence 8ff93570 failed at call 178036e8 (err=-)
### ERROR ### Please RESET the board ###
Issue1:
这里遇到一个问题就是串口管脚的修改,E9的管脚UART1_TXD(SD3_DAT7)和UART1_RXD(SD3_DAT6),所以需要修改,而原有在sabresd板子中配置为MX6_PAD_CSI0_DAT10__UART1_TX_DATA和MX6_PAD_CSI0_DAT11__UART1_RX_DATA,使用grep并找不到定义,所以也就找不到此版本下SD3_DAT7和SD3_DAT6应该怎么表示,刚开始修改不对,uboot打印一直不出现。
后来通过mx6q_tqE9.c包含头文件找到arch/arm/include/asm/arch-mx6/mx6q_pins.h:851:
MX6_PAD_DECL(SD3_DAT7__UART1_TX_DATA, 0x0690, 0x02A8, , 0x0000, , )
而在arch/arm/include/asm/arch-mx6/mx6-pins.h中有这样定义:
#elif defined(CONFIG_MX6Q)
enum {
#define MX6_PAD_DECL(name, pco, mc, mm, sio, si, pc) \
MX6_PAD_DECLARE(MX6_PAD_,name, pco, mc, mm, sio, si, pc),
#include "mx6q_pins.h"
};
进而有同样在arch/arm/include/asm/arch-mx6/mx6-pins.h:
#define MX6_PAD_DECLARE(prefix, name, pco, mc, mm, sio, si, pc) \
prefix##name = IOMUX_PAD(pco, mc, mm, sio, si, pc)
这样也就有了串口MX6_PAD_SD3_DAT7__UART1_TX_DATA的定义。
Issue2:
从上述的log中可以看出,虽然有打印,但是uboot并未被正常执行,提示Can't find PMIC:PFUZE100错误,于是参照fsl社区的答疑,https://community.nxp.com/message/651335, 按照FAE说的加#undef CONFIG_LDO_BYPASS_CHECK并没有解决问题,看上去pmic_probe函数仍然被执行了;于是按照用户的答案,disable pmic代码,/drivers/power/power_i2c.c 屏蔽pmic_probe函数内容,于是通过了,最终输出log如下:
U-Boot 2015.04-imx_v2015.04_3..52_1..0_ga+g6cf684a (Oct - ::) CPU: Freescale i.MX6Q rev1. at MHz
CPU: Temperature - C
Reset cause: POR
Board: MX6-TQE9
I2C: ready
DRAM: GiB
PMIC: PFUZE100 ID=0x8ffa132f
Not supported, id=
MMC: FSL_SDHC: , FSL_SDHC: , FSL_SDHC:
*** Warning - bad CRC, using default environment No panel detected: default to Hannstar-XGA
Display: Hannstar-XGA (1024x768)
In: serial
Out: serial
Err: serial
switch to partitions #, OK
mmc0 is current device
Net: Phy not found
PHY reset timed out
FEC [PRIME]
Error: FEC address not set. Normal Boot
Hit any key to stop autoboot:
switch to partitions #, OK
mmc0 is current device
** No partition table - mmc **
** No partition table - mmc **
Booting from net ...
*** ERROR: `ethaddr' not set
*** ERROR: `ethaddr' not set
Bad Linux ARM zImage magic!
=>
这样看上去uboot已经移植成功了!以前没有做过类似的事情,还是费了不少周折,后面抽时间看看源码。
推荐博文:
1.uboot启动过程完全分析(uboot启动启动2个阶段分析)
http://blog.csdn.net/hanchaoman/article/details/9282947
2.uboot的两个启动过程和第二阶段的board_init_f/board_init_r
http://tscsh.blog.163.com/blog/static/200320103201312645149965/
问题:
1. SD卡格式化
mkfs.ext4 /dev/sdc
2. 格式化完后分区
3. 以上的编译使用的工具链还是较老的工具链,E9光盘安装,并没有更新
4. 为什么uboot启动要分为两个阶段?
个人理解,可以试想一下,如果只有1个阶段,片内固化ROM代码将uboot代码直接拷贝到片内RAM然后执行,uboot大小可能超过片内RAM,直接拷贝到DDR,又会有DDR还没有初始化,也就是不可以这么做。所以只可以在uboot分为两段启动,第一段运行在片内RAM,初始化DDR,第二段运行在DDR中,搬运内核,跳转。