前段时间就开始学习I.MX6Q了,但是最近工作实在是忙,间断了一些时间了。为了提高移植效率,还是考虑移植Freescale维护的3.10版本的内核。
源码获取
Freescale维护的3.10的内核是使用git管理的,但是直接使用git下载代码会比较慢,下面是我下载好的uboot和kernel:
I.MX6Q BSP源码(Freescale官方维护)
代码下载好后,先将u-boot解压到工作目录,然后在终端下切换到uboot根目录。由于这个版本的bsp是使用git管理的,因此,需要切换到指定分支。执行指令:
git branch -a
可以查看freescale维护的uboot的各个分支,我们checkout的分支是“remotes/origin/imx_v2013.04_3.10.17_1.0.0_ga”,执行指令:
git checkout -b tqimx6q imx_v2013.04_3.10.17_1.0.0_ga
这样,就在本地创建的分支tqimx6q并将远程分支imx_v2013.04_3.10.17_1.0.0_ga上的代码checkout到这个本地分支。我们之后的修改在tqimx6q分支进行即可。
U-Boot移植
新版U-Boot移植也不麻烦,主要是freescale给出了详细的官方手册"i.MX 6 BSP Porting Guide",具体的移植步骤如下:
Step1. 创建board目录。由于imx6q的很多代码是共通的,跟之前的移植一样,可以参考mx6qsabresd进行的,执行指令:
cp board/freescale/mx6qsabresd/ board/freescale/mx6q_tqimx6q -r
Step2. 修改board相关文件的名称:
cp board/freescale/mx6q_tqimx6q/mx6qsabresd.c board/freescale/mx6q_tqimx6q/mx6q_tqimx6q.c
Step3. 修改Makefile中的文件名。打开board/freescale/Makefile,将mx6qsabresd替换为mx6q_tqimx6q.c。
cp include/configs/mx6qsabresd.h include/configs/mx6q_tqimx6q.h
Step5. 添加编译选项。打开文件boards.cfg,找到配置项"mx6qsabresd"(如果没有改动的话,在277行),复制该行配置并添加在下面,然后修改为如下内容:
mx6q_tqimx6q arm armv7 mx6q_tqimx6q freescale mx6 mx6qsabresd:IMX_CONFIG=board/freescale/mx6q_tqimx6q/mx6q_tqimx6q_ddr.cfg,MX6Q,DEFAULT_FDT_FILE="imx6q-tqimx6q.dtb",DDR_MB=1024,SYS_USE_SPINOR
Step6. 定制DDR配置。其实DDR相关的参数在之前的移植文章中已经有了。
cp board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg board/freescale/mx6q_tqimx6q/mx6q_tqimx6q_ddr.cfg
然后修改文件mx6q_tqimx6q_ddr.cfg,修改后的文件内容如下:
DATA 4, 0x020e0798, 0x000C0000
DATA 4, 0x020e0758, 0x00000000
DATA 4, 0x020e0588, 0x00000030
DATA 4, 0x020e0594, 0x00000030
DATA 4, 0x020e056c, 0x00000030
DATA 4, 0x020e0578, 0x00000030
DATA 4, 0x020e074c, 0x00000030
DATA 4, 0x020e057c, 0x00000030
DATA 4, 0x020e058c, 0x00000000
DATA 4, 0x020e059c, 0x00000030
DATA 4, 0x020e05a0, 0x00000030
DATA 4, 0x020e078c, 0x00000030
DATA 4, 0x020e0750, 0x00020000
DATA 4, 0x020e05a8, 0x00000018
DATA 4, 0x020e05b0, 0x00000018
DATA 4, 0x020e0524, 0x00000018
DATA 4, 0x020e051c, 0x00000018
DATA 4, 0x020e0518, 0x00000018
DATA 4, 0x020e050c, 0x00000018
DATA 4, 0x020e05b8, 0x00000018
DATA 4, 0x020e05c0, 0x00000018
DATA 4, 0x020e0774, 0x00020000
DATA 4, 0x020e0784, 0x00000018
DATA 4, 0x020e0788, 0x00000018
DATA 4, 0x020e0794, 0x00000018
DATA 4, 0x020e079c, 0x00000018
DATA 4, 0x020e07a0, 0x00000018
DATA 4, 0x020e07a4, 0x00000018
DATA 4, 0x020e07a8, 0x00000018
DATA 4, 0x020e0748, 0x00000018
DATA 4, 0x020e05ac, 0x00000018
DATA 4, 0x020e05b4, 0x00000018
DATA 4, 0x020e0528, 0x00000018
DATA 4, 0x020e0520, 0x00000018
DATA 4, 0x020e0514, 0x00000018
DATA 4, 0x020e0510, 0x00000018
DATA 4, 0x020e05bc, 0x00000018
DATA 4, 0x020e05c4, 0x00000018
DATA 4, 0x021b0800, 0xa1390003
DATA 4, 0x021b080c, 0x001F001F
DATA 4, 0x021b0810, 0x001F001F
DATA 4, 0x021b480c, 0x001F001F
DATA 4, 0x021b4810, 0x001F001F
DATA 4, 0x021b083c, 0x43270338
DATA 4, 0x021b0840, 0x03200314
DATA 4, 0x021b483c, 0x431A032F
DATA 4, 0x021b4840, 0x03200263
DATA 4, 0x021b0848, 0x4B434748
DATA 4, 0x021b4848, 0x4445404C
DATA 4, 0x021b0850, 0x38444542
DATA 4, 0x021b4850, 0x4935493A
DATA 4, 0x021b081c, 0x33333333
DATA 4, 0x021b0820, 0x33333333
DATA 4, 0x021b0824, 0x33333333
DATA 4, 0x021b0828, 0x33333333
DATA 4, 0x021b481c, 0x33333333
DATA 4, 0x021b4820, 0x33333333
DATA 4, 0x021b4824, 0x33333333
DATA 4, 0x021b4828, 0x33333333
DATA 4, 0x021b08b8, 0x00000800
DATA 4, 0x021b48b8, 0x00000800
DATA 4, 0x021b0004, 0x00020036
DATA 4, 0x021b0008, 0x09444040
DATA 4, 0x021b000c, 0x8A8F7955
DATA 4, 0x021b0010, 0xFF328F64
DATA 4, 0x021b0014, 0x01FF00DB
DATA 4, 0x021b0018, 0x00001740
DATA 4, 0x021b001c, 0x00008000
DATA 4, 0x021b002c, 0x000026d2
DATA 4, 0x021b0030, 0x008F1023
DATA 4, 0x021b0040, 0x00000047
DATA 4, 0x021b0000, 0x841A0000
DATA 4, 0x021b001c, 0x04088032
DATA 4, 0x021b001c, 0x00008033
DATA 4, 0x021b001c, 0x00048031
DATA 4, 0x021b001c, 0x09408030
DATA 4, 0x021b001c, 0x04008040
DATA 4, 0x021b0020, 0x00005800
DATA 4, 0x021b0818, 0x00011117
DATA 4, 0x021b4818, 0x00011117
DATA 4, 0x021b0004, 0x00025576
DATA 4, 0x021b0404, 0x00011006
DATA 4, 0x021b001c, 0x00000000
/* set the default clock gate to save power */
DATA 4, 0x020c4068, 0x00C03F3F
DATA 4, 0x020c406c, 0x0030FC03
DATA 4, 0x020c4070, 0x0FFFC000
DATA 4, 0x020c4074, 0x3FF00000
DATA 4, 0x020c4078, 0x00FFF300
DATA 4, 0x020c407c, 0x0F0000F3
DATA 4, 0x020c4080, 0x000003FF
/* enable AXI cache for VDOA/VPU/IPU */
DATA 4, 0x020e0010, 0xF00000CF
/* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */
DATA 4, 0x020e0018, 0x007F007F
DATA 4, 0x020e001c, 0x007F007F
Step7. 定制board端子。其实有影响的端子在移植老版的uboot时已经知道,因此修改起来也是比较容易。
(1) 修改串口端子。具体修改内容如下:
iomux_v3_cfg_t const uart1_pads[] = {
// MX6_PAD_CSI0_DAT10__UART1_TXD | MUX_PAD_CTRL(UART_PAD_CTRL),
MX6_PAD_SD3_DAT7__UART1_TXD | MUX_PAD_CTRL(UART_PAD_CTRL),
// MX6_PAD_CSI0_DAT11__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL),
MX6_PAD_SD3_DAT6__UART1_RXD | 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 */
};
定制cd(card detect)端子,否则uboot将检测不到SD卡插入。打开board/freescale/mx6q_tqimx6q/mx6q_tqimx6q.c修改USDHC2_CD_GPIO:
#define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4)
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make mx6q_tqimx6q
其中,CROSS_COMPILE是交叉编译工具链的前缀,根据自己的实际情况修改。如果前面的步骤操作正确,uboot就可以顺利编译通过了。
烧写启动
经过前面的移植工作,uboot已经可以正常运行在tqimx6q开发板上了。这个版本的uboot与之前版本的uboot编译出的目标文件不同,具体的烧写指令如下:
sudo dd if=u-boot.imx of=/dev/sdb bs=512 seek=2
启动Log如下:
U-Boot 2013.04-04987-g98fdbdc-dirty (May 01 2015 - 23:15:34)
CPU: Freescale i.MX6Q rev1.2 at 792 MHz
CPU: Temperature 24 C, calibration data: 0x54e4bb69
Reset cause: POR
Board: MX6Q/SDL-SabreSD
I2C: ready
DRAM: 1 GiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
MMC: no card present
MMC init failed
Using default environment
No panel detected: default to Hannstar-XGA
Display: Hannstar-XGA (1024x768)
In: serial
Out: serial
Err: serial
MMC: no card present
mmc0(part 0) is current device
Net: Phy not found
PHY reset timed out
FEC [PRIME]
Warning: failed to set MAC address
Normal Boot
Hit any key to stop autoboot: 0
MMC: no card present
mmc0(part 0) is current device
MMC: no card present
Booting from net ...
*** ERROR: `ethaddr' not set
*** ERROR: `ethaddr' not set
Wrong Image Format for bootm command
ERROR: can't get kernel image!
U-Boot >
总结
本文链接:http://blog.csdn.net/girlkoo/article/details/45420977
本文作者:girlkoo