针对已搭建好的 IM6Q yocto平台进行uboot编译,我买的开发板是天嵌的E9开发板,不是为了做广告,主要是比较下,感觉这个开发板还比较便宜,而且发现别人写的博客,参考地址:http://blog.csdn.net/girlkoo?viewmode=contents,我的移植也是参考这个地址,我先按照这位博主移植了uboot-v2013.04_3.10.17_ga,然后,按照官方手册和之前的移植经验,进行uboot v2014.04_3.14.28_1.0.0_ga移植.
我的资源地址imx6q 针对E9平台移植资料
下载uboot也可以通过:git clone git://git.freescale.com/imx/uboot-imx.git 直接下载
下面开始uboot的移植了:
(1)进入源码目录
进入你搭建好的yocto平台,然后进入build-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/u-boot-imx/2014.04-r0/git,这是我的路径,你的可能会稍有不同,可以找到.
(2)查看并创建自己的分支
git branch -a
git checkout -b imx6q_v2014.04_3.14.28_1.0.0_ga remotes/origin/imx_v2014.04_3.14.28_1.0.0_ga
我的分支名称叫:imx6q_v2014.04_3.14.28_1.0.0_ga,使用远程库:remotes/origin/imx_v2014.04_3.14.28_1.0.0_ga
这个版本与freescale 官方提供版本移植
(2)针对开发板进行移植
①查找参考平台
你可以像手册一样重新定义自己的平台的名称,我就偷个懒直接使用源码中的例程了.我的平台使用
参考uboot根目录下的boards.cfg文件,查找你参考的平台
我使用的平台:mx6qsabresd
②定制DDR配置
参数如下,至于解释参考:http://blog.csdn.net/girlkoo/article/details/45420977
进入/board/freescale/imx/ddr修改mx6q_4x_mt41j128.cfg,我的全部代码如下:
/*
* Copyright (C) 2011-2014 Freescale Semiconductor, Inc.
* Jason Liu
*
* SPDX-License-Identifier: GPL-2.0+
*
* Refer doc/README.imximage for more details about how-to configure
* and create imximage boot image
*
* The syntax is taken as close as possible with the kwbimage
*/
#define __ASSEMBLY__
#include
/* image version */
IMAGE_VERSION 2
/*
* Boot Device : one of spi, sd, sata
* the board has no nand and eimnor
* spinor: flash_offset: 0x0400
* sata: flash_offset: 0x0400
* sd/mmc: flash_offset: 0x0400
*/
/* the same flash_offset as sd */
BOOT_FROM sd
#ifdef CONFIG_USE_PLUGIN
/*PLUGIN plugin-binary-file IRAM_FREE_START_ADDR*/
PLUGIN board/freescale/mx6sabresd/plugin.bin 0x00907000
#else
#ifdef CONFIG_SECURE_BOOT
CSF 0x2000
#endif
/*
* Device Configuration Data (DCD)
*
* Each entry must have the format:
* Addr-type Address Value
*
* where:
* Addr-type register length (1,2 or 4 bytes)
* Address absolute address of the register
* value value to be stored in the register
*/
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
/*
* Setup CCM_CCOSR register as follows:
*
* cko1_en = 1 --> CKO1 enabled
* cko1_div = 111 --> divide by 8
* cko1_sel = 1011 --> ahb_clk_root
*
* This sets CKO1 at ahb_clk_root/8 = 132/8 = 16.5 MHz
*/
DATA 4, 0x020c4060, 0x000000fb
#endif
E9开发板使用uart1作为输出
进入目录:build-x11/tmp/work/imx6qsabresd-poky-linux-gnueabi/u-boot-imx/2014.04-r0/git/board/freescale/mx6sabresd
修改mx6sabresd.c文件,共4处
第1处,uart1引脚配置
iomux_v3_cfg_t const uart1_pads[] = {
//MX6_PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
//MX6_PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
MX6_PAD_SD3_DAT6__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
MX6_PAD_SD3_DAT7__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
};
第2处,修改SD卡端子
iomux_v3_cfg_t const usdhc2_pads[] = {
MX6_PAD_SD2_CLK__SD2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_CMD__SD2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT1__SD2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT2__SD2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD2_DAT3__SD2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
//MX6_PAD_NANDF_D4__SD2_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
//MX6_PAD_NANDF_D5__SD2_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
//MX6_PAD_NANDF_D6__SD2_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
//MX6_PAD_NANDF_D7__SD2_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
//MX6_PAD_NANDF_D2__GPIO2_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
};
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 */
};
第4处,定制cd(card detect)端子
//#define USDHC2_CD_GPIO IMX_GPIO_NR(2, 2)
#define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4)
#define USDHC3_CD_GPIO IMX_GPIO_NR(2, 0)
vi build.sh
#!/bin/sh
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
make distclean
make mx6qsabresd_config
make
其中mx6qsabresd为我的平台名称
然后chmod +x build.sh
./build.sh即可进行平台编译.
(4)SD卡烧写脚本
vi flash_sd.sh
#!/bin/sh
sudo dd if=u-boot.imx of=/dev/sdb bs=512 seek=2
其中/dev/sdb为我的sd的设备名称
chmod +x flash_sd.sh
./flash_sd.sh即可进行SD镜像安装
(5)配置板子从SD开启动,串口打印信息如下:
U-Boot 2014.04-08650-g5b983bd-dirty (Oct 05 2015 - 21:39:03)
CPU: Freescale i.MX6Q rev1.2 at 792 MHz
CPU: Temperature 31 C, calibration data: 0x5384a769
Reset cause: POR
Board: MX6-SabreSD
I2C: ready
DRAM: 1 GiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
*** Warning - bad CRC, using default environment
No panel detected: default to Hannstar-XGA
Display: Hannstar-XGA (1024x768)
In: serial
Out: serial
Err: serial
mmc0 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
mmc0 is current device
** No partition table - mmc 0 **
** No partition table - mmc 0 **
Booting from net ...
*** ERROR: `ethaddr' not set
*** ERROR: `ethaddr' not set
Bad Linux ARM zImage magic!
=>