本文主要是介绍[IMX6ULL]移植lf-v2022.04 U-boot,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
移植lf-v2022.04 U-boot
文章目录
- 移植lf-v2022.04 U-boot
- 1 下载 NXP uboot
- 2 编译 NXP uboot
- 2.1 编译命令
- 2.2 编译错误
- 3 烧写NXP uboot
- 4 适配正点原子alpha板子
- 4.1 添加配置文件
- 4.2 添加设备树文件
- 4.2.1 添加板级设备树文件
- 4.2.2 根据板子原理图裁剪和修改设备树内容
- 4.3 将alpha开发板添加进编译uboot的编译选项(menuconfig)
- 4.4 编译alpha-uboot
- 4.5 添加网卡支持
- 4.6 添加alpha7寸屏幕支持
- 4.7 测试引导Linux内核
1 下载 NXP uboot
git clone https://github.com/nxp-imx/uboot-imx.git
git checkout lf_v2022.04
GitHub 地址:nxp-imx/uboot-imx
2 编译 NXP uboot
2.1 编译命令
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mx6ull_14x14_evk_emmc_defconfig
make V=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16
2.2 编译错误
- bison: not found
HOSTCC scripts/basic/fixdepHOSTCC scripts/kconfig/conf.oYACC scripts/kconfig/zconf.tab.c
/bin/sh: 1: bison: not found
make[1]: *** [scripts/Makefile.lib:224:scripts/kconfig/zconf.tab.c] 错误 127
make: *** [Makefile:574:mx6ull_14x14_evk_emmc_defconfig] 错误 2
解决方法:
sudo apt-get install bison -y
- flex: not found
YACC scripts/kconfig/zconf.tab.cLEX scripts/kconfig/zconf.lex.c
/bin/sh: 1: flex: not found
make[1]: *** [scripts/Makefile.lib:216:scripts/kconfig/zconf.lex.c] 错误 127
make: *** [Makefile:574:mx6ull_14x14_evk_emmc_defconfig] 错误 2
解决方法:
sudo apt-get install flex -y
- Your GCC is older than 6.0 and is not supported
*** Your GCC is older than 6.0 and is not supported
make: *** [arch/arm/config.mk:74:checkgcc6] 错误 1
解决方法:
安装版本更新的arm-linux-gnueabihf , 安装步骤参考正点原子文档4.3章节。
3 烧写NXP uboot
./tools/imxdownload u-boot.bin /dev/sdb
记得选择SD启动
4 适配正点原子alpha板子
4.1 添加配置文件
- 板级defconfig文件
cp configs/mx6ull_14x14_evk_emmc_defconfig configs/mx6ull_14x14_alpha_emmc_defconfig
修改内容为:
# 将下面config修改为
CONFIG_TARGET_MX6ULL_14X14_ALPHA=y
CONFIG_DEFAULT_DEVICE_TREE="imx6ull-14x14-alpha-emmc"
- 板级头文件
cp ./include/configs/mx6ullevk.h ./include/configs/mx6ullalpha.h
修改内容为:
// 修改点1:修改头文件标识
#ifndef __MX6ULLALPHA_CONFIG_H
#define __MX6ULLALPHA_CONFIG_H//修改点2:根据board_name和board_rev选择alpha的dtb文件"findfdt="\"if test $fdt_file = undefined; then " \"if test $board_name = ULZ-EVK && test $board_rev = 14X14; then " \"setenv fdt_file imx6ulz-14x14-evk.dtb; fi; " \"if test $board_name = EVK && test $board_rev = 9X9; then " \"setenv fdt_file imx6ull-9x9-evk.dtb; fi; " \"if test $board_name = EVK && test $board_rev = 14X14; then " \"setenv fdt_file imx6ull-14x14-evk.dtb; fi; " \"if test $board_name = ALPHA && test $board_rev = 14X14; then " \"setenv fdt_file imx6ull-14x14-alpha-emmc.dtb; fi; " \ "if test $fdt_file = undefined; then " \"echo WARNING: Could not determine dtb to use; " \"fi; " \"fi;\0" \
- 创建alpha板级配置文件目录
cp -r ./board/freescale/mx6ullevk ./board/freescale/mx6ullalpha
cd ./board/freescale/mx6ullalpha
mv mx6ullevk.c mx6ullalpha.c
修改mx6ullalpha.c
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGenv_set("board_name", "ALPHA");if (is_mx6ull_9x9_evk())env_set("board_rev", "9X9");elseenv_set("board_rev", "14X14");if (is_cpu_type(MXC_CPU_MX6ULZ)) {env_set("board_name", "ULZ-EVK");env_set("usb_net_cmd", "usb start");}
#endifint checkboard(void)
{if (is_mx6ull_9x9_evk())puts("Board: MX6ULL 9x9 EVK\n");else if (is_cpu_type(MXC_CPU_MX6ULZ))puts("Board: MX6ULZ 14x14 EVK\n");elseputs("Board: MX6ULL 14x14 ALPHA\n"); //uboot的打印信息return 0;
}
修改imximage.cfg
#ifdef CONFIG_USE_IMXIMG_PLUGIN
/*PLUGIN plugin-binary-file IRAM_FREE_START_ADDR*/
PLUGIN board/freescale/mx6ullalpha/plugin.bin 0x00907000
#else
修改Kconfig
if TARGET_MX6ULL_14X14_ALPHAconfig SYS_BOARDdefault "mx6ullalpha"config SYS_VENDORdefault "freescale"config SYS_CONFIG_NAMEdefault "mx6ullalpha"config IMX_CONFIGdefault "board/freescale/mx6ullalpha/imximage.cfg"config SYS_TEXT_BASEdefault 0x87800000
endif
修改MAINTAINERS
MX6ULLALPHA BOARD
M: Peng Fan <peng.fan@nxp.com>
S: Maintained
F: board/freescale/mx6ullalpha/
F: include/configs/mx6ullalpha.h
F: configs/mx6ull_14x14_alpha_emmc_defconfig
修改Makefile
obj-y := mx6ullalpha.o
4.2 添加设备树文件
4.2.1 添加板级设备树文件
cp ./arch/arm/dts/imx6ull-14x14-evk-emmc.dts ./arch/arm/dts/imx6ull-14x14-alpha-emmc.dts
cp ./arch/arm/dts/imx6ull-14x14-evk.dts ./arch/arm/dts/imx6ull-14x14-alpha.dts
cp ./arch/arm/dts/imx6ul-14x14-evk.dtsi ./arch/arm/dts/imx6ul-14x14-alpha.dtsi
cp ./arch/arm/dts/imx6ul-14x14-evk-u-boot.dtsi ./arch/arm/dts/imx6ul-14x14-alpha-u-boot.dtsi
修改imx6ull-14x14-alpha-emmc.dts
#include "imx6ull-14x14-alpha.dts"&usdhc2 {pinctrl-names = "default", "state_100mhz", "state_200mhz";pinctrl-0 = <&pinctrl_usdhc2_8bit>;pinctrl-1 = <&pinctrl_usdhc2_8bit_100mhz>;pinctrl-2 = <&pinctrl_usdhc2_8bit_200mhz>;bus-width = <8>;non-removable;status = "okay";
};
修改imx6ull-14x14-alpha.dts
#include "imx6ull.dtsi"
#include "imx6ul-14x14-alpha.dtsi"
#include "imx6ul-14x14-alpha-u-boot.dtsi"/ {model = "i.MX6 ULL 14x14 ALPHA Board";compatible = "fsl,imx6ull-14x14-alpha", "fsl,imx6ull";
};
修改arch/arm/dts/Makefile, 添加alpha板子
dtb-$(CONFIG_MX6ULL) += \imx6ull-14x14-ddr3-val.dtb \imx6ull-14x14-ddr3-val-epdc.dtb \imx6ull-14x14-ddr3-val-emmc.dtb \imx6ull-14x14-ddr3-val-gpmi-weim.dtb \imx6ull-14x14-ddr3-val-tsc.dtb \imx6ull-14x14-evk.dtb \imx6ull-14x14-evk-emmc.dtb \imx6ull-14x14-alpha-emmc.dtb \imx6ull-14x14-evk-gpmi-weim.dtb \imx6ull-9x9-evk.dtb \imx6ull-colibri.dtb \imx6ull-colibri-emmc.dtb \imx6ull-myir-mys-6ulx-eval.dtb \imx6ull-seeed-npi-imx6ull-dev-board.dtb \imx6ull-phytec-segin-ff-rdk-emmc.dtb \imx6ull-dart-6ul.dtb \imx6ull-somlabs-visionsom.dtb \imx6ulz-14x14-evk.dtb \imx6ulz-14x14-evk-emmc.dtb \imx6ulz-14x14-evk-gpmi-weim.dtb
4.2.2 根据板子原理图裁剪和修改设备树内容
4.3 将alpha开发板添加进编译uboot的编译选项(menuconfig)
修改arch/arm/mach-imx/mx6/Kconfig
config TARGET_MX6ULL_14X14_ALPHAbool "Support mx6ull_14x14_alpha"depends on MX6ULLselect BOARD_LATE_INITselect DMselect DM_THERMALselect IMX_MODULE_FUSEselect OF_SYSTEM_SETUPimply CMD_DMsource "board/freescale/mx6ullalpha/Kconfig"
4.4 编译alpha-uboot
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mx6ull_14x14_alpha_emmc_defconfig
make V=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16
烧录
./tools/imxdownload u-boot-dtb.imx /dev/sdb
或者
sudo dd if=u-boot-dtb.imx of=/dev/sdb bs=1k seek=1 conv=fsync
4.5 添加网卡支持
- 修改imx6ul-14x14-alpha.dtsi
- 向追加iomuxc_snvs两个phy的RST引脚定义
- 分别修改fec1、fec2的复位引脚初始化电平以及持续时间
- 修改ethphy的地址
&fec2 {pinctrl-names = "default";pinctrl-0 = <&pinctrl_enet2 &pinctrl_eth2rst>;phy-mode = "rmii";phy-handle = <ðphy1>;phy-reset-gpios = <&gpio5 8 GPIO_ACTIVE_LOW>;phy-reset-duration = <100>;status = "okay";mdio {#address-cells = <1>;#size-cells = <0>;ethphy1: ethernet-phy@1 {reg = <1>;micrel,led-mode = <1>;clocks = <&clks IMX6UL_CLK_ENET2_REF>;clock-names = "rmii-ref";};};};...spi4 {compatible = "spi-gpio";pinctrl-names = "default";pinctrl-0 = <&pinctrl_spi4>;status = "disable";pinctrl-assert-gpios = <&gpio5 8 GPIO_ACTIVE_LOW>;gpio-sck = <&gpio5 11 0>;gpio-mosi = <&gpio5 10 0>;cs-gpios = <&gpio5 7 0>;num-chipselects = <1>;#address-cells = <1>;#size-cells = <0>;gpio_spi: gpio@0 {compatible = "fairchild,74hc595";gpio-controller;#gpio-cells = <2>;reg = <0>;registers-number = <1>;registers-default = /bits/ 8 <0x57>;spi-max-frequency = <100000>;};};
- 修改drivers/net/phy/phy.c
int genphy_update_link(struct phy_device *phydev)
{unsigned int mii_reg;#ifdef CONFIG_PHY_SMSCstatic int lan8720_flag = 0;int bmcr_reg = 0;if (lan8720_flag == 0){bmcr_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);while(phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR) & 0X8000){udelay(100);}phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, bmcr_reg);lan8720_flag = 1;}
#endif
...
}
- 修改mx6ull_14x14_alpha_emmc_defconfig
CONFIG_PHYLIB=y
CONFIG_PHY_SMSC=y
CONFIG_NET_RANDOM_ETHADDR=y
#CONFIG_PHY_MICREL=y
#CONFIG_PHY_MICREL_KSZ8XXX=y
测试:
setenv eth1addr 32:34:46:78:9A:DD
setenv serverip 192.168.3.7
setenv ipaddr 192.168.3.34
setenv gatewayip 192.168.3.1
setenv netmask 255.255.255.0
saveenv
tip: u-boot的环境变量是设置在MMC中的,不会随着UBoot重新编译而清除,如果修改乱了可以使用如下命令恢复默认:
(或者格式化mmc设备)
env default -a // 恢复默认设置
saveenv // 将改变覆盖到MMC
4.6 添加alpha7寸屏幕支持
- 修改设备树arch/arm/dts/imx6ul-14x14-alpha.dtsi
将ALPHA 板子的7寸1024x600的屏幕参数替换到lcdif节点
&lcdif {pinctrl-names = "default";pinctrl-0 = <&pinctrl_lcdif_dat&pinctrl_lcdif_ctrl>;display = <&display0>;status = "okay";display0: display@0 {bits-per-pixel = <24>;bus-width = <24>;display-timings {native-mode = <&timing0>;timing0: timing0 {clock-frequency = <51200000>;hactive = <1024>;vactive = <600>;hfront-porch = <160>;hback-porch = <140>;hsync-len = <20>;vback-porch = <20>;vfront-porch = <12>;vsync-len = <3>;hsync-active = <0>;vsync-active = <0>;de-active = <1>;pixelclk-active = <0>;};};};
};
ALPHA 开发板上的 LCD 接口用了三个 SGM3157 模拟开关,为了防止模拟开关影响到网络,因此这里需要降低 LCD 数据线的驱动能力, 将0x79改为0x49
pinctrl_lcdif_dat: lcdifdatgrp {fsl,pins = <MX6UL_PAD_LCD_DATA00__LCDIF_DATA00 0x49MX6UL_PAD_LCD_DATA01__LCDIF_DATA01 0x49MX6UL_PAD_LCD_DATA02__LCDIF_DATA02 0x49MX6UL_PAD_LCD_DATA03__LCDIF_DATA03 0x49MX6UL_PAD_LCD_DATA04__LCDIF_DATA04 0x49MX6UL_PAD_LCD_DATA05__LCDIF_DATA05 0x49MX6UL_PAD_LCD_DATA06__LCDIF_DATA06 0x49MX6UL_PAD_LCD_DATA07__LCDIF_DATA07 0x49MX6UL_PAD_LCD_DATA08__LCDIF_DATA08 0x49MX6UL_PAD_LCD_DATA09__LCDIF_DATA09 0x49MX6UL_PAD_LCD_DATA10__LCDIF_DATA10 0x49MX6UL_PAD_LCD_DATA11__LCDIF_DATA11 0x49MX6UL_PAD_LCD_DATA12__LCDIF_DATA12 0x49MX6UL_PAD_LCD_DATA13__LCDIF_DATA13 0x49MX6UL_PAD_LCD_DATA14__LCDIF_DATA14 0x49MX6UL_PAD_LCD_DATA15__LCDIF_DATA15 0x49MX6UL_PAD_LCD_DATA16__LCDIF_DATA16 0x49MX6UL_PAD_LCD_DATA17__LCDIF_DATA17 0x49MX6UL_PAD_LCD_DATA18__LCDIF_DATA18 0x49MX6UL_PAD_LCD_DATA19__LCDIF_DATA19 0x49MX6UL_PAD_LCD_DATA20__LCDIF_DATA20 0x49MX6UL_PAD_LCD_DATA21__LCDIF_DATA21 0x49MX6UL_PAD_LCD_DATA22__LCDIF_DATA22 0x49MX6UL_PAD_LCD_DATA23__LCDIF_DATA23 0x49>;};
ALPHA 板子不同于NXP的EVK开发板,它的LCD RESET使用的是硬件上电复位,所以不需要使用软件复位,即不需要单独的Pin去reset,所以注释EVK用到的lcd reset, 节约引脚(软件上,在LCD时序也需要注释掉它调用reset脚的时序点,在下面有讲到)
pinctrl_lcdif_ctrl: lcdifctrlgrp {fsl,pins = <MX6UL_PAD_LCD_CLK__LCDIF_CLK 0x79MX6UL_PAD_LCD_ENABLE__LCDIF_ENABLE 0x79MX6UL_PAD_LCD_HSYNC__LCDIF_HSYNC 0x79MX6UL_PAD_LCD_VSYNC__LCDIF_VSYNC 0x79/*alpha board use hardware reset, so do not need software reset*//* used for lcd reset *//*MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09 0x79*/>;};
- 修改board/freescale/mx6ullalpha/mx6ullalpha.c
软件上,在LCD时序也需要注释掉它调用reset脚的时序点
static int setup_lcd(void)
{enable_lcdif_clock(LCDIF1_BASE_ADDR, 1);imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));/*alpha board use hardware reset, so do not need software reset*//* Reset the LCD */// gpio_request(IMX_GPIO_NR(5, 9), "lcd reset");// gpio_direction_output(IMX_GPIO_NR(5, 9) , 0);// udelay(500);// gpio_direction_output(IMX_GPIO_NR(5, 9) , 1);/* Set Brightness to high */gpio_request(IMX_GPIO_NR(1, 8), "backlight");gpio_direction_output(IMX_GPIO_NR(1, 8) , 1);return 0;
}
#else
static inline int setup_lcd(void) { return 0; }
#endif
4.7 测试引导Linux内核
这篇关于[IMX6ULL]移植lf-v2022.04 U-boot的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!