NXP i.MX6ULL 最新系统移植

0. 前提说明

WeChat:15713642125

操作系统:ubuntu 20.04

实验环境:韦东山IMX6ULL EMMC, 野火IMX6ULL NAND, 米尔科技IMX6ULL NAND

分别介绍旧系统和最新系统的移植,注意有些路径为我自己的本地路径,以$开头为linux指令。其余的为配置信息。请不要直接复制指令,建议根据实际情况填写指令。后期我会完善一些过程。

1. 交叉编译器

https://releases.linaro.org/components/toolchain/binaries/

Linaro下载最新版本,并解压

$ wget https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
$ tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz

配置环境变量

$ vim ~/.bashrc
export PATH=$PATH:/home/bohao/Nand/tool/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
$ source ~/.bashrc

查看版本信息

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Linaro GCC 7.5-2019.12) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GNU Toolchain | GNU-A Downloads – Arm Developer

None下载最新版本,并解压

$ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf.tar.xz
$ tar xvf gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf.tar.xz

配置环境变量

$ vim ~/.bashrc
export PATH=$PATH:/home/bohao/Nand/tool//home/bohao/Nand/tool/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabihf-
$ source ~/.bashrc

查看版本信息

arm-none-linux-gnueabihf-gcc --version
arm-none-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 10.3.1 20210621
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

安装相关工具 

$ sudo apt install bc build-essential git libncurses5-dev lzop perl libssl-dev bison flex

2. U-boot

https://source.codeaurora.org/external/imx/uboot-imx/

2016 -下载最旧版本

请参考:基于imx6ull原厂代码移植uboot - 知乎

$ git clone https://source.codeaurora.org/external/imx/uboot-imx -b nxp/imx_v2016.03_4.1.15_2.0.0_ga

IMX6ULL - EMMCLAN8720  2016

复制配置文件,并修改部分内容

$ cp configs/mx6ull_14x14_evk_emmc_defconfig configs/100zzu_defconfig

CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/100zzu/imximage.cfg,MX6ULL_EVK_EMMC_REWORK"
CONFIG_ARM=y
CONFIG_ARCH_MX6=y
CONFIG_TARGET_100ZZU=y
CONFIG_CMD_GPIO=y
CONFIG_LOCALVERSION_AUTO=n

复制头文件,并修改部分内容 

$ cp include/configs/mx6ullevk.h include/configs/100zzu.h

#ifndef __100ZZU_CONFIG_H
#define __100ZZU_CONFIG_H

CONFIG_EXTRA_ENV_SETTINGS
"ethaddr=00:04:9f:04:d2:35\0" \
"ipaddr=192.168.0.121\0" \
"netmask=255.255.255.0\0" \
"gatewayip=192.168.0.1\0" \
"bootargs=console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw\0" \

CONFIG_BOOTCOMMAND
"mmc dev 1;" \
"fatload mmc 1:1 0x80800000 zImage;" \
"fatload mmc 1:1 0x83000000 100zzu.dtb;" \
"bootz 0x80800000 - 0x83000000;"


#ifdef CONFIG_CMD_NET
#define CONFIG_CMD_PING
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_MII
#define CONFIG_FEC_MXC
#define CONFIG_MII
#define CONFIG_FEC_ENET_DEV		0

#if (CONFIG_FEC_ENET_DEV == 0)
#define IMX_FEC_BASE			ENET_BASE_ADDR
#define CONFIG_FEC_MXC_PHYADDR          0x0
#define CONFIG_FEC_XCV_TYPE             RMII
#elif (CONFIG_FEC_ENET_DEV == 1)
#define IMX_FEC_BASE			ENET2_BASE_ADDR
#define CONFIG_FEC_MXC_PHYADDR		0x1
#define CONFIG_FEC_XCV_TYPE		RMII
#endif
#define CONFIG_ETHPRIME			"FEC"

#define CONFIG_PHYLIB
#define CONFIG_PHY_SMSC
#endif

复制板级文件夹,修改部分文件中的内容

$ cp board/freescale/mx6ullevk/ board/freescale/100zzu -rf
$ mv board/freescale/100zzu/mx6ullevk.c board/freescale/100zzu/100zzu.c

PLUGIN	board/freescale/100zzu/plugin.bin 0x00907000

PLUGIN	board/freescale/100zzu/plugin.bin 0x00907000

if TARGET_100ZZU

config SYS_BOARD
	default "100zzu"

config SYS_VENDOR
	default "freescale"

config SYS_CONFIG_NAME
	default "100zzu"

endif

100ZZU BOARD
M:	Peng Fan 
S:	Maintained
F:	board/freescale/100zzu/
F:	include/configs/100zzu.h
F:	configs/100zzu_defconfig

obj-y  := 100zzu.o

extra-$(CONFIG_USE_PLUGIN) :=  plugin.bin
$(obj)/plugin.bin: $(obj)/plugin.o
	$(OBJCOPY) -O binary --gap-fill 0xff $< $@

 修改Kconfig文件,在相应位置添加部分内容

$ vim arch/arm/cpu/armv7/mx6/Kconfig

config TARGET_100ZZU
	bool "Support 100ZZU"
	select MX6ULL
	select DM
	select DM_THERMAL

source "board/freescale/100zzu/Kconfig"

修改网络驱动,针对LAN8720-PHY

$ vim board/freescale/100zzu/100zzu.c

...
#define IOX_OE IMX_GPIO_NR(5, 8)
#define ENET1_RESET IMX_GPIO_NR(5, 9)
#define ENET2_RESET IMX_GPIO_NR(5, 6)

...
MX6_PAD_ENET1_RX_EN__ENET1_RX_EN | MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_SNVS_TAMPER9__GPIO5_IO09 | MUX_PAD_CTRL(NO_PAD_CTRL),

...
MX6_PAD_ENET2_RX_ER__ENET2_RX_ER | MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_SNVS_TAMPER6__GPIO5_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL),

if (fec_id == 0){
		imx_iomux_v3_setup_multiple_pads(fec1_pads,
						 ARRAY_SIZE(fec1_pads));
		gpio_direction_output(ENET1_RESET, 1);
		gpio_set_value(ENET1_RESET, 0);
		mdelay(20);
		gpio_set_value(ENET1_RESET, 1);
	}
else{
		imx_iomux_v3_setup_multiple_pads(fec2_pads,
						 ARRAY_SIZE(fec2_pads));
		gpio_direction_output(ENET1_RESET, 1);
		gpio_set_value(ENET2_RESET, 0);
		mdelay(20);
		gpio_set_value(ENET2_RESET, 1);
}


$ vim drivers/net/phy/phy.c
#ifdef CONFIG_PHY_SMSC
    static 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) & BMCR_RESET) {
            udelay(100);           
        }
        phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, bmcr_reg); 
        lan8720_flag = 1;
    }
#endif

结果如下

U-Boot 2016.03+ (Oct 22 2021 - 18:03:47 -0700)

CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 43C
Reset cause: POR
Board: MX6ULL 14x14 EVK
I2C:   ready
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment

Display: TFT43AB (480x272)
Video: 480x272x24
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc1(part 0) is current device
Net:   FEC0
Normal Boot
Hit any key to stop autoboot:  0
=> ping 192.168.0.1
FEC0 Waiting for PHY auto negotiation to complete... done
Using FEC0 device
host 192.168.0.1 is alive


IMX6ULL - NAND - KSZ8081   2016

复制配置文件,并修改部分内容

$ cp configs/mx6ull_14x14_evk_nand_defconfig configs/200zzu_defconfig

CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/200zzu/imximage.cfg,SYS_BOOT_NAND,DDR_SIZE=512"
CONFIG_ARM=y
CONFIG_ARCH_MX6=y
CONFIG_TARGET_200ZZU=y
CONFIG_CMD_GPIO=y
CONFIG_LOCALVERSION_AUTO=n

复制头文件,并修改部分内容 

$ cp include/configs/mx6ullevk.h include/configs/200zzu.h

#ifndef __200ZZU_CONFIG_H
#define __200ZZU_CONFIG_H

#ifdef CONFIG_TARGET_MX6ULL_9X9_EVK
#define PHYS_SDRAM_SIZE		SZ_256M
#define CONFIG_BOOTARGS_CMA_SIZE   "cma=96M "
#else
#if (CONFIG_DDR_SIZE == 512)
#define PHYS_SDRAM_SIZE		SZ_512M
#elif (CONFIG_DDR_SIZE == 256)
#define PHYS_SDRAM_SIZE		SZ_256M
#endif
#define CONFIG_BOOTARGS_CMA_SIZE   ""
/* DCDC used on 14x14 EVK, no PMIC */
#undef CONFIG_LDO_BYPASS_CHECK
#endif

#ifdef CONFIG_SYS_BOOT_NAND
#define CONFIG_MFG_NAND_PARTITION "mtdparts=gpmi-nand:5m(boot),1m(env),10m(kernel),1m(dtb),-(rootfs) "
#else
#define CONFIG_MFG_NAND_PARTITION ""
#endif

#define CONFIG_EXTRA_ENV_SETTINGS \
	CONFIG_MFG_ENV_SETTINGS \
	"panel=TFT43AB\0" \
	"ethaddr=00:04:9f:04:d2:35\0" \
	"ipaddr=192.168.0.121\0" \
	"netmask=255.255.255.0\0" \
	"gatewayip=192.168.0.1\0" \
	"fdt_addr=0x83000000\0" \
	"fdt_high=0xffffffff\0"	  \
	"console=ttymxc0\0" \
	"bootargs=console=ttymxc0,115200 ubi.mtd=4 "  \
		"root=ubi0:rootfs rootfstype=ubifs "		     \
		CONFIG_BOOTARGS_CMA_SIZE \
		"mtdparts=gpmi-nand:5m(boot),1m(env),10m(kernel),1m(dtb),-(rootfs)\0"\
	"bootcmd=nand read 0x80800000 0x600000 0xA00000;"\
		"nand read 0x83000000 0x1000000 0x100000;"\
		"bootz 0x80800000 - 0x83000000\0"

复制板级文件夹,修改部分文件中的内容

$ cp board/freescale/mx6ullevk/ board/freescale/200zzu -rf
$ mv board/freescale/200zzu/mx6ullevk.c board/freescale/200zzu/200zzu.c

PLUGIN	board/freescale/200zzu/plugin.bin 0x00907000

PLUGIN	board/freescale/200zzu/plugin.bin 0x00907000

if TARGET_200ZZU

config SYS_BOARD
	default "200zzu"

config SYS_VENDOR
	default "freescale"

config SYS_CONFIG_NAME
	default "200zzu"

endif

200ZZU BOARD
M:	Peng Fan 
S:	Maintained
F:	board/freescale/200zzu/
F:	include/configs/200zzu.h
F:	configs/200zzu_defconfig

obj-y  := 200zzu.o

 修改Kconfig文件,在相应位置添加部分内容

$ vim arch/arm/cpu/armv7/mx6/Kconfig

config TARGET_200ZZU
	bool "Support 200ZZU"
	select MX6ULL
	select DM
	select DM_THERMAL

source "board/freescale/200zzu/Kconfig"

编译烧录,结果如下

U-Boot 2016.03+ (Oct 22 2021 - 18:40:30 -0700)

CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 43C
Reset cause: POR
Board: MX6ULL 14x14 EVK
I2C:   ready
DRAM:  512 MiB
NAND:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment

Display: TFT43AB (480x272)
Video: 480x272x24
In:    serial
Out:   serial
Err:   serial
Net:   FEC1
Normal Boot
Hit any key to stop autoboot:  0
=> ping 192.168.0.1
Using FEC1 device
host 192.168.0.1 is alive


https://source.codeaurora.org/external/imx/uboot-imx/

2020 -下载最新版本

$ git clone https://source.codeaurora.org/external/imx/uboot-imx -b imx_v2020.04_5.4.70_2.3.0

IMX6ULL - NAND - KSZ8081   2020

复制配置文件,并修改部分内容

$ cp configs/mx6ull_14x14_evk_nand_defconfig configs/200zzu_defconfig

CONFIG_TARGET_200ZZU=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/200zzu/imximage.cfg"
CONFIG_DEFAULT_DEVICE_TREE="200zzu"
CONFIG_LOCALVERSION_AUTO=n
CONFIG_NET_RANDOM_ETHADDR=y

复制头文件,并修改部分内容 

$ cp include/configs/mx6ullevk.h include/configs/100zzu.h

#ifndef __200ZZU_CONFIG_H
#define __200ZZU_CONFIG_H

#ifdef CONFIG_NAND_BOOT
#define MFG_NAND_PARTITION "mtdparts=gpmi-nand:5m(boot),10m(kernel),1m(dtb),-(rootfs)"
#else
#define MFG_NAND_PARTITION ""
#endif

#define CONFIG_EXTRA_ENV_SETTINGS \
	CONFIG_MFG_ENV_SETTINGS \
	TEE_ENV \
	"splashimage=0x8c000000\0" \
	"fdt_addr=0x83000000\0" \
	"fdt_high=0xffffffff\0"	  \
	"tee_addr=0x84000000\0" \
	"console=ttymxc0\0" \
	"ethaddr=00:04:9f:04:d2:35\0" \
	"ipaddr=192.168.0.121\0" \
	"netmask=255.255.255.0\0" \
	"gatewayip=192.168.0.1\0" \
	"bootargs=console=ttymxc0,115200 ubi.mtd=nandrootfs "  \
		"root=ubi0:rootfs rootfstype=ubifs "		     \
		BOOTARGS_CMA_SIZE \
		MFG_NAND_PARTITION \
		"\0" \
	"bootcmd=nand read 0x80800000 0x500000 0xA00000;"\
		"nand read 0x83000000 0x1000000 0x100000;"\
		"bootz 0x80800000 - 0x83000000;" \

复制板级文件夹,修改部分文件中的内容

$ cp board/freescale/mx6ullevk/ board/freescale/200zzu -rf
$ mv board/freescale/200zzu/mx6ullevk.c board/freescale/200zzu/200zzu.c

$ vim board/freescale/200zzu/imximage_lpddr2.cfg
PLUGIN	board/freescale/200zzu/plugin.bin 0x00907000

$ vim board/freescale/200zzu/imximage.cfg
PLUGIN	board/freescale/200zzu/plugin.bin 0x00907000

$ vim board/freescale/200zzu/Kconfig
if TARGET_200ZZU

config SYS_BOARD
	default "200zzu"

config SYS_VENDOR
	default "freescale"

config SYS_CONFIG_NAME
	default "200zzu"

config SYS_TEXT_BASE
	default 0x87800000
endif


$ vim board/freescale/200zzu/MAINTAINERS
200ZZU BOARD
M:	Peng Fan 
S:	Maintained
F:	board/freescale/200zzu/
F:	include/configs/200zzu.h
F:	configs/200zzu_defconfig

$ vim board/freescale/200zzu/Makefile
obj-y  := 200zzu.o

 修改Kconfig文件,在相应位置添加部分内容

$ vim arch/arm/mach-imx/mx6/Kconfig

config TARGET_200ZZU
	bool "Support 200zzu"
	select BOARD_LATE_INIT
	select DM
	select DM_THERMAL
	select MX6ULL
	imply CMD_DM

source "board/freescale/200zzu/Kconfig"

复制设备树文件

$ cp arch/arm/dts/imx6ull-14x14-evk-gpmi-weim.dts arch/arm/dts/200zzu.dts

$ vim arch/arm/dts/Makefile

dtb-$(CONFIG_MX6ULL) += \
    ... ...
	imx6ull-14x14-evk-gpmi-weim.dtb \
	200zzu.dtb \
    ... ...

编译烧录,结果如下

U-Boot 2020.04+ (Oct 22 2021 - 20:39:22 -0700)

CPU:   i.MX6ULL rev1.1 792 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 42C
Reset cause: POR
Model: i.MX6 ULL 14x14 EVK Board
Board: MX6ULL 14x14 EVK
DRAM:  512 MiB
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Loading Environment from NAND... *** Warning - bad CRC, using default environment

[*]-Video Link 0 (480 x 272)
        [0] lcdif@21c8000, video
In:    serial
Out:   serial
Err:   serial
Net:   Get shared mii bus on ethernet@2188000
eth1: ethernet@20b4000, eth0: ethernet@2188000 [PRIME]
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
=> ping 192.168.0.1
Using ethernet@2188000 device
host 192.168.0.1 is alive

IMX6ULL - EMMCLAN8720   2020

复制配置文件,并添加部分内容

$ cp configs/mx6ull_14x14_evk_emmc_defconfig configs/100zzu_defconfig

CONFIG_ENV_SIZE=0x4000
CONFIG_TARGET_100ZZU=y
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/100zzu/imximage.cfg"
CONFIG_DEFAULT_DEVICE_TREE="100zzu"
CONFIG_LOCALVERSION_AUTO=n
CONFIG_NET_RANDOM_ETHADDR=y

复制头文件,并修改部分内容 

$ cp include/configs/mx6ullevk.h include/configs/100zzu.h

#ifndef __100ZZU_CONFIG_H
#define __100ZZU_CONFIG_H

CONFIG_EXTRA_ENV_SETTINGS
"ethaddr=00:04:9f:04:d2:35\0" \
"ipaddr=192.168.0.121\0" \
"netmask=255.255.255.0\0" \
"gatewayip=192.168.0.1\0" \
"bootargs=console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw\0" \

CONFIG_BOOTCOMMAND
"mmc dev 1;" \
"fatload mmc 1:1 0x80800000 zImage;" \
"fatload mmc 1:1 0x83000000 100zzu.dtb;" \
"bootz 0x80800000 - 0x83000000;"

复制板级文件夹,修改部分文件中的内容

$ cp board/freescale/mx6ullevk/ board/freescale/100zzu -rf
$ mv board/freescale/100zzu/mx6ullevk.c board/freescale/100zzu/100zzu.c

$ vim board/freescale/100zzu/imximage_lpddr2.cfg
PLUGIN	board/freescale/100zzu/plugin.bin 0x00907000

$ vim board/freescale/100zzu/imximage.cfg
PLUGIN	board/freescale/100zzu/plugin.bin 0x00907000

$ vim board/freescale/100zzu/Kconfig
if TARGET_100ZZU

config SYS_BOARD
	default "100zzu"

config SYS_VENDOR
	default "freescale"

config SYS_CONFIG_NAME
	default "100zzu"

config SYS_TEXT_BASE
	default 0x87800000
endif

$ vim board/freescale/100zzu/MAINTAINERS
100ZZU BOARD
M:	Peng Fan 
S:	Maintained
F:	board/freescale/100zzu/
F:	include/configs/100zzu.h
F:	configs/100zzu_defconfig

$ vim board/freescale/100zzu/Makefile
obj-y  := 100zzu.o

 修改Kconfig文件,在相应位置添加部分内容

$ vim arch/arm/mach-imx/mx6/Kconfig

config TARGET_100ZZU
	bool "Support 100zzu"
	select BOARD_LATE_INIT
	select DM
	select DM_THERMAL
	select MX6ULL
	imply CMD_DM

source "board/freescale/100zzu/Kconfig"

复制设备树文件,并修改网络驱动

$ cp arch/arm/dts/imx6ull-14x14-evk-emmc.dts arch/arm/dts/100zzu.dts

$ vim arch/arm/dts/Makefile

dtb-$(CONFIG_MX6ULL) += \
    ... ...
	imx6ull-14x14-evk-emmc.dtb \
	100zzu.dtb \
    ... ...

$ vim arch/arm/dts/imx6ul-14x14-evk.dtsi

pinctrl_enet1: enet1grp {
		fsl,pins = <
			...
			MX6UL_PAD_ENET1_TX_CLK__ENET1_REF_CLK1	0x4001b009

			MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09 0x10B0 
		>;
	};

pinctrl_enet2: enet2grp {
		fsl,pins = <
			...
			MX6UL_PAD_ENET2_TX_CLK__ENET2_REF_CLK2	0x4001b009

			MX6UL_PAD_SNVS_TAMPER6__GPIO5_IO06 0x10B0 
		>;
	};

pinctrl_lcdif_ctrl: lcdifctrlgrp {
		fsl,pins = <
			...
			MX6UL_PAD_LCD_VSYNC__LCDIF_VSYNC    0x79
			/* used for lcd reset 
			MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09  0x79
			*/
		>;
    };

&fec1 {
	...
	phy-handle = <ðphy0>;
	phy-reset-gpios = <&gpio5 9 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <200>;
	status = "okay";
};

&fec2 {
	...
	phy-handle = <ðphy1>;
	phy-reset-gpios = <&gpio5 6 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <200>;
	status = "okay";

	mdio {
		#address-cells = <1>;
		#size-cells = <0>;

		ethphy0: ethernet-phy@0 {
			reg = <0>;
			smsc,led-mode = <1>;
			clocks = <&clks IMX6UL_CLK_ENET_REF>;
			clock-names = "rmii-ref";
		};

		ethphy1: ethernet-phy@1 {
			reg = <1>;
			smsc,led-mode = <1>;
			clocks = <&clks IMX6UL_CLK_ENET2_REF>;
			clock-names = "rmii-ref";
		};
	};
};

$ vim drivers/net/phy/phy.c
int genphy_config_aneg(struct phy_device *phydev)
{
	int result;

	phy_reset(phydev); 

	...
}

编译烧录,结果如下


U-Boot 2020.04+ (Oct 22 2021 - 19:14:59 -0700)

CPU:   i.MX6ULL rev1.1 792 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 39C
Reset cause: POR
Model: i.MX6 ULL 14x14 EVK Board
Board: MX6ULL 14x14 EVK
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

[*]-Video Link 0 (480 x 272)
        [0] lcdif@21c8000, video
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc1(part 0) is current device
flash target is MMC:1
Net:   Get shared mii bus on ethernet@2188000
Could not get PHY for FEC1: addr 0
eth1: ethernet@20b4000Get shared mii bus on ethernet@2188000
, eth0: ethernet@2188000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
=> ping 192.168.0.1
Using ethernet@2188000 device
host 192.168.0.1 is alive

3. Kernel

https://source.codeaurora.org/external/imx/linux-imx

5.4.70 - 下载最新版本

$ git clone https://source.codeaurora.org/external/imx/linux-imx -b imx_5.4.70_2.3.0

IMX6ULL - NAND - KSZ8081   5.4.70

复制配置文件

$ cp arch/arm/configs/imx_v7_defconfig arch/arm/configs/200zzu_defconfig

CONFIG_LOCALVERSION_AUTO=n

 复制设备树

$ cp arch/arm/boot/dts/imx6ull-14x14-evk-gpmi-weim.dts arch/arm/boot/dts/200zzu.dts

编译并烧录,网络可用 

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.4.70+ (bohao@ubuntu) (gcc version 7.5.0 (Linaro GCC 7.5-2019.12)) #1 SMP Fri Oct 22 23:13:02 PDT 2021
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Freescale i.MX6 ULL 14x14 EVK Board
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] efi: Getting EFI parameters from FDT:


/ # ifconfig eth1 192.168.0.121 netmask 255.255.255.0
/ # route add default gw 192.168.0.1
/ # ping www.baidu.com
PING www.baidu.com (104.193.88.77): 56 data bytes
64 bytes from 104.193.88.77: seq=0 ttl=49 time=165.796 ms
64 bytes from 104.193.88.77: seq=1 ttl=49 time=165.259 ms
64 bytes from 104.193.88.77: seq=2 ttl=49 time=165.165 ms

IMX6ULL - EMMC - LAN8720   5.4.70

复制配置文件

$ cp arch/arm/configs/imx_v7_defconfig arch/arm/configs/200zzu_defconfig

CONFIG_LOCALVERSION_AUTO=n

 复制并修改设备树

$ cp arch/arm/boot/dts/imx6ull-14x14-evk-gpmi-weim.dts arch/arm/boot/dts/200zzu.dts

$ vim arch/arm/boot/dts/imx6ul-14x14-evk.dtsi

pinctrl_enet1: enet1grp {
		fsl,pins = <
			...
			MX6UL_PAD_ENET1_TX_CLK__ENET1_REF_CLK1	0x4001b031

			MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09 0x10B0 
		>;
	};

pinctrl_enet2: enet2grp {
		fsl,pins = <
			...
			MX6UL_PAD_ENET2_TX_CLK__ENET2_REF_CLK2	0x4001b031

			MX6UL_PAD_SNVS_TAMPER6__GPIO5_IO06 0x10B0 
		>;
	};

pinctrl_lcdif_ctrl: lcdifctrlgrp {
		fsl,pins = <
			...
			/* used for lcd reset 
			MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09  0x79
			*/
		>;
	};

&fec1 {
	...
	phy-handle = <ðphy0>;
	phy-reset-gpios = <&gpio5 9 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <200>;
	status = "okay";
};

&fec2 {
	...
	phy-handle = <ðphy1>;
	phy-reset-gpios = <&gpio5 6 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <200>;
	status = "okay";

	mdio {
		#address-cells = <1>;
		#size-cells = <0>;

		ethphy0: ethernet-phy@0 {
			reg = <0>;
			smsc,led-mode = <1>;
			clocks = <&clks IMX6UL_CLK_ENET_REF>;
			clock-names = "rmii-ref";
		};

		ethphy1: ethernet-phy@1 {
			reg = <1>;
			smsc,led-mode = <1>;
			clocks = <&clks IMX6UL_CLK_ENET2_REF>;
			clock-names = "rmii-ref";
		};
	};
};

编译并烧录,网络可用 

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.4.70+ (bohao@ubuntu) (gcc version 7.5.0 (Linaro GCC 7.5-2019.12)) #1 SMP PREEMPT Fri Oct 22 23:35:54 PDT 2021
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Freescale i.MX6 ULL 14x14 EVK Board
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] Reserved memory: created CMA memory pool at 0x96000000, size 160 MiB
[    0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[    0.000000] percpu: Embedded 15 pages/cpu s32076 r8192 d21172 u61440
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129920

/ # ifconfig eth1 192.168.0.121 netmask 255.255.255.0
/ # route add default gw 192.168.0.1
/ # ping www.baidu.com
PING www.baidu.com (104.193.88.77): 56 data bytes
64 bytes from 104.193.88.77: seq=0 ttl=49 time=165.168 ms
64 bytes from 104.193.88.77: seq=1 ttl=49 time=165.095 ms
64 bytes from 104.193.88.77: seq=2 ttl=49 time=165.100 ms

4. 根文件系统

https://busybox.net/

wget https://busybox.net/downloads/busybox-1.34.1.tar.bz2

你可能感兴趣的:(网关,linux)