一、主机环境
主机:Windows10 64bit
VMware虚拟机软件版本:12.5.8
Ubuntu版本:14.04.5 64bit
开发板:I.MX6-PIANO , CPU: I.MX6DL
I.MX6 bsp infomation:
Bsp version:fsl-yocto-L4.1.15_2.0.0-ga ;
Yocto Project version: 2.1 ;
Linux Kernel version: 4.1 ;
U-Bboot version: 2016.03-r0
二、U-boot移植修改步骤
yocto编译完成后,我们需要找到源码目录:fsl-release-bsp/
1.拷贝board文件
cp -R board/freescale/mx6sabresd board/freescale/mx6dlpiano
2.修改文件名字
(1)
==>:
(2)
==>:
(3)修改mx6dlpiano.cfg文件
PLUGIN board/freescale/mx6sabresd/plugin.bin 0x00907000
==>:
PLUGIN board/freescale/mx6dlpiano/plugin.bin 0x00907000
3.复制板级配置头文件
cp include/configs/mx6sabresd.h include/configs/mx6dlpiano.h
4.在
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx6dlpiano/mx6dlpiano.cfg,MX6DL"
CONFIG_ARM=y
CONFIG_TARGET_MX6DLPIANO=y
CONFIG_SYS_MALLOC_F=y
CONFIG_SYS_MALLOC_F_LEN=0x400
CONFIG_DM=y
CONFIG_DM_THERMAL=y
5.修改
obj-y := mx6sabresd.o ==> obj-y := mx6dlpiano.o
6.修改Kconfig:
(1)修改板级配置文件的Kconfig,文件路径:
if TARGET_MX6SABRESD
config SYS_BOARD
default "mx6sabresd"
config SYS_VENDOR
default "freescale"
config SYS_CONFIG_NAME
default "mx6sabresd"
endif
==>:
if TARGET_MX6DLPIANO
config SYS_BOARD
default "mx6dlpiano"
config SYS_VENDOR
default "freescale"
config SYS_CONFIG_NAME
default "mx6dlpiano"
endif
(2)修改架构配置下的Kconfig,文件路径:
增加一个目标板配置项,需要注意的是:该Kconfig文件中的TARGET_XXX项要和
config TARGET_MX6DLPIANO
bool "Support mx6dlpiano"
select DM
select DM_THERMAL
source "board/freescale/mx6dlpiano/Kconfig"
7.在根目录下创建一个uboot编译脚本build_u-boot.sh,先去导入交叉编译工具链(toolchain)的环境变量(环境变量文件路径根据自己的toolchain安装目录选择),再去make对应的目标板配置,脚本信息如下:
#!/bin/bash
. /opt/fsl-imx-wayland/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
make distclean;
make mx6dlpiano_defconfig
make
8.去运行build_u-boot.sh,查看编译信息,是否有错误,运行编译脚本命令如下:
sh build_u-boot.sh
9.根据板子的硬件去修改代码适配,基本的修改就是上面copy出来的板子基础配置文件。主要要修改的地方以及步骤如下(硬件配置不同修改的也不同):
(1).修改串口配置:若板子的串口和官方板的串口不一样,则需要修改。本文使用的开发板的串口为UART1,引脚为SD3_DAT6和SD3_DAT7,修改步骤如下:
static 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_DAT7__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
MX6_PAD_SD3_DAT6__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
};
#define CONFIG_MXC_UART_BASE UART1_BASE
#define CONFIG_CONSOLE_DEV "ttymxc0"
(2).配置SD卡和eMMC接口:找到mx6dlpiano.c中的int board_mmc_init(bd_t *bis)函数,该函数默认是初始化了3个mmc,这里使用的板子是只有使用了USDHC3(SD卡)和USDHC4(eMMC)两个接口,根据代码去修改管脚配置。
#define USDHC2_CD_GPIO IMX_GPIO_NR(2, 2)
// #define USDHC3_CD_GPIO IMX_GPIO_NR(2, 0)
#define USDHC3_CD_GPIO IMX_GPIO_NR(3, 31)
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 */
MX6_PAD_EIM_D31__GPIO3_IO31 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
};
static iomux_v3_cfg_t const usdhc4_pads[] = {
MX6_PAD_SD4_CLK__SD4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_CMD__SD4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT0__SD4_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT1__SD4_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT2__SD4_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT3__SD4_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT4__SD4_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT5__SD4_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT6__SD4_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD4_DAT7__SD4_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
};
(3).修改打印的板子名称,找到如下函数进行修改:
int checkboard(void)
{
puts("Board: MX6DL-PIANO\n");
return 0;
}
(4).配置DDR参数:找到
10.编译和烧写:修改完毕基本的串口配置后,U-boot就可以正常的打印了,编译之后烧写,烧写命令示例:
sudo dd if=
此处我的SD卡插入在ubuntu下,输入命令ls -l /dev/sd*,查看到插入后多了一个dev/sdc,故烧录命令为:
sudo dd if=u-boot.imx of=/dev/sdc bs=512 seek=2 conv=fsync
11.验证:将板子的BOOT开关切换到SD启动,上电查看UART打印,部分log如下:
U-Boot 2016.03-imx_v2016.03_4.1.15_2.0.0_ga+ga57b13b (Apr 22 2018 - 04:02:27 -0700)
CPU: Freescale i.MX6DL rev1.3 996 MHz (running at 792 MHz)
CPU: Commercial temperature grade (0C to 95C) at 48C
Reset cause: POR
Board: MX6DL-PIANO
I2C: ready
DRAM: 1 GiB
PMIC: PFUZE100 ID=0x11
MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
三、编译总结
1.编译错误信息总结
(1)错误信息如下:
In file included from ./include/common.h:18:0:
include/config.h:8:22: fatal error: configs/.h: No such file or directory
compilation terminated.
make[1]: *** [include/autoconf.mk] Error 1
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/uboot.release'. Stop.
错误原因:Kconfig文件的配置相关错误,主要是在
解决办法:
比对两个Kconfig文件中的TARGET_XXX是否一致,查看