(四)正点原子STM32MP135移植——u-boot移植

news2024/11/15 20:57:22

一、概述

        u-boot概述就不概述了,u-boot、kernel、dtb三件套,dddd

        

        经过国庆艰苦奋战,已经成功把所有功能移植好了

二、编译官方代码

        进入u-boot的目录

2.1 解压源码、打补丁

/* 解压源码 */
tar xf u-boot-stm32mp-v2022.10-stm32mp-r1-r0.tar.xz 

/* 进入源码目录 */
cd u-boot-stm32mp-v2022.10-stm32mp-r1/

/* 打补丁 */
for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

2.2 修改Makefile.sdk

        打开Makefile.sdk,把DEPLOYDIR目录改成这个:

DEPLOYDIR ?= $(SRC_PATH)/../../FIP_artifacts/u-boot

         然后第12行开始,我们把157的屏蔽掉,留下135

# Init default config settings
# UBOOT_CONFIGS += trusted
# UBOOT_DEFCONFIG_trusted += stm32mp15_defconfig
# UBOOT_BINARY_stm32mp15_defconfig ?= u-boot.dtb
# UBOOT_DEVICETREE_stm32mp15_defconfig ?=  stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2
# Init default config settings
UBOOT_CONFIGS += trusted
UBOOT_DEFCONFIG_trusted += stm32mp13_defconfig
UBOOT_BINARY_stm32mp13_defconfig ?= u-boot.dtb
UBOOT_DEVICETREE_stm32mp13_defconfig ?=  stm32mp135f-dk
DEVICETREE ?= stm32mp135f-dk

2.3 配置编译环境

/* 加载环境 */
source /opt/st/stm32mp1/4.2.1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
 
/* 配置环境变量 */
export FIP_DEPLOYDIR_ROOT=$PWD/../../FIP_artifacts

不要关了这个终端,它已经配置好了,关于这部分的配置,可以看上一篇关于TF-A的解释比较详细。

2.4 编译

make -f ../Makefile.sdk all

由于之前我们编译过了stm32mp135f-dk的TF-A和optee,这里编译完成之后,会直接调用fiptool工具给我们打包生成fip-stm32mp135-atk-optee.bin到FIP文件夹里。

[fiptool] Create fip-stm32mp135f-dk-optee.bin fip binary into 'FIP_DEPLOYDIR_FIP' folder...
[fiptool] Done

三、移植

3.1 复制官方文件

/* 进入设备树目录 */
cd arch/arm/dts/

cp stm32mp135f-dk.dts stm32mp135-atk.dts
cp stm32mp13-pinctrl.dtsi stm32mp13-pinctrl-atk.dtsi
cp stm32mp135f-dk-u-boot.dtsi stm32mp135-atk-u-boot.dtsi

/* 回到源码根目录 */
cd ../../../

3.2 修改头文件

        打开stm32mp135-atk.dts,把引脚头文件改成我们的

// #include "stm32mp13-pinctrl.dtsi"
#include "stm32mp13-pinctrl-atk.dtsi"

3.3 修改电源

        首先找到scmi_regu节点,把里面的内容删,但是节点别删,还得留下一个scmi_v1v8_periph

&scmi_regu {
	scmi_vddcpu: voltd-vddcpu {
		reg = <VOLTD_SCMI_STPMIC1_BUCK1>;
		regulator-name = "vddcpu";
	};
	scmi_vdd: voltd-vdd {
		reg = <VOLTD_SCMI_STPMIC1_BUCK3>;
		regulator-name = "vdd";
	};
	scmi_vddcore: voltd-vddcore {
		reg = <VOLTD_SCMI_STPMIC1_BUCK4>;
		regulator-name = "vddcore";
	};
	scmi_vdd_adc: voltd-vdd-adc {
		reg = <VOLTD_SCMI_STPMIC1_LDO1>;
		regulator-name = "vdd_adc";
	};
	scmi_vdd_usb: voltd-vdd-usb {
		reg = <VOLTD_SCMI_STPMIC1_LDO4>;
		regulator-name = "vdd_usb";
	};
	scmi_vdd_sd: voltd-vdd-sd {
		reg = <VOLTD_SCMI_STPMIC1_LDO5>;
		regulator-name = "vdd_sd";
	};
	scmi_v1v8_periph: voltd-v1v8-periph {
		reg = <VOLTD_SCMI_STPMIC1_LDO6>;
		regulator-name = "v1v8_periph";
	};
	scmi_v3v3_sw: voltd-v3v3-sw {
		reg = <VOLTD_SCMI_STPMIC1_PWR_SW2>;
		regulator-name = "v3v3_sw";
	};
};

修改过后如下:如果有大佬知道怎么解决麻烦底下留言帮帮忙

/* 这一段不知道怎么解决,不能删
删除之后,烧写到u-boot阶段,会被强行复位,但是使用分立电源又不行
*/
&scmi_regu {
	scmi_v1v8_periph: voltd-v1v8-periph {
		reg = <VOLTD_SCMI_STPMIC1_LDO6>;
		regulator-name = "v1v8_periph";
	};
};

笔者尝试过在根节点下加入对1.8V电源的描述,但是并不行,烧录的时候会直接被迫重启,刚学linux不久,大佬带带

/* 想用分立电源代替掉scmi_v1v8_periph,但是没有实现 */
	// v1v8: v1v8 {
    //     compatible = "regulator-fixed";
	// 	regulator-name = "v1v8_periph";
    //     regulator-min-microvolt = <1800000>;
    //     regulator-max-microvolt = <1800000>;
    //     regulator-off-in-suspend;
    //     regulator-always-on;
    // };

删除scmi电源之后,在根节点下面加入我们的电源描述,和之前的一样

vddcore: vddcore {
        compatible = "regulator-fixed";
        regulator-name = "vddcore";
        regulator-min-microvolt = <1200000>;
        regulator-max-microvolt = <1350000>;
        regulator-off-in-suspend;
        regulator-always-on;
	};

	vddcpu: vddcpu {
		compatible = "regulator-fixed";
		regulator-name = "vddcpu";
		regulator-min-microvolt = <1350000>;
		regulator-max-microvolt = <1350000>;
        regulator-off-in-suspend;
        regulator-always-on;
	};

	v3v3: v3v3 {
        compatible = "regulator-fixed";
        regulator-name = "v3v3";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-off-in-suspend;
        regulator-always-on;
    };

	vbus_otg: vbus_otg {
        compatible = "regulator-fixed";
        regulator-name = "vbus_otg";
        regulator-min-microvolt = <5000000>;
        regulator-max-microvolt = <5000000>;
        regulator-off-in-suspend;
		regulator-always-on;
    };

	vdd: vdd {
        compatible = "regulator-fixed";
        regulator-name = "vdd";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-off-in-suspend;
        regulator-always-on;
    };

	vdd_usb: vdd_usb {
        compatible = "regulator-fixed";
        regulator-name = "vdd_usb";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-off-in-suspend;
        regulator-always-on;
    };

3.4 删除无关节点

        可以删除(建议删除)的节点如下

1.        &i2c5全部

2.        &uart8 &usart1 &usart2三个串口

3.        根节点下的gpio-keys

4.        根节点下aliases里的几个串口,只留下串口4

5.        &dcmipp节点

6.        &spi5  &timer3  &timer4  &timer8  &timer14这几个都可以删了

3.5 修改USB OTG

        正点原子的OTG使用的是usbphyc_port1,而usbphyc_port0是host,找到&usbphyc_port1节点,只需要修改该它的电源即可。

&usbphyc_port1 {
 // phy-supply = <&scmi_vdd_usb>;    /* 删了原来的 */
	phy-supply = <&vdd_usb>;
	st,current-boost-microamp = <1000>;
	st,decrease-hs-slew-rate;
	st,tune-hs-dc-level = <2>;
	st,enable-hs-rftime-reduction;
	st,trim-hs-current = <11>;
	st,trim-hs-impedance = <2>;
	st,tune-squelch-level = <1>;
	st,enable-hs-rx-gain-eq;
	st,no-hs-ftime-ctrl;
	st,no-lsfs-sc;
};

 修改&usbotg_hs

&usbotg_hs {
	phys = <&usbphyc_port1 0>;
	phy-names = "usb2-phy";
	usb-role-switch;
	dr_mode = "otg";
	pinctrl-0 = <&usbotg_hs_pins_a>;
	pinctrl-names = "default";
	vbus-supply = <&vbus_otg>;
	status = "okay";
};

3.6 修改USB节点

        同OTG,先把电源改了,下面那个connector好像不要也行

&usbphyc_port0 {
 // phy-supply = <&scmi_vdd_usb>;    /* 删了原来的 */
	phy-supply = <&vdd_usb>;
	st,current-boost-microamp = <1000>;
	st,decrease-hs-slew-rate;
	st,tune-hs-dc-level = <2>;
	st,enable-hs-rftime-reduction;
	st,trim-hs-current = <11>;
	st,trim-hs-impedance = <2>;
	st,tune-squelch-level = <1>;
	st,enable-hs-rx-gain-eq;
	st,no-hs-ftime-ctrl;
	st,no-lsfs-sc;

    /*
	 * Hack to keep hub active if wakeup source is enabled
	 * otherwise the hub will wakeup the port0 as soon as the v3v3_sw is disabled
	 */
	connector {
		compatible = "usb-a-connector";
		vbus-supply = <&v3v3>;
	};
};

修改usbh_ehci节点:

&usbh_ehci {
	phys = <&usbphyc_port0>;
	status = "okay";
};

3.7 修改TF卡和emmc节点

这里,偷个懒,直接把原子的复制过来了,直接替换掉

&sdmmc1 {
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc1_b4_pins_a &sdmmc1_clk_pins_a>;
	pinctrl-1 = <&sdmmc1_b4_od_pins_a &sdmmc1_clk_pins_a>;
	pinctrl-2 = <&sdmmc1_b4_sleep_pins_a>;
	cd-gpios = <&gpiof 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
	disable-wp;
	st,neg-edge;
	no-1-8-v;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	status = "okay";
};

/* EMMC */
&sdmmc2 {
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc2_b4_pins_a &sdmmc2_b4_b7_pins_a &sdmmc2_clk_pins_a>;
	pinctrl-1 = <&sdmmc2_b4_od_pins_a &sdmmc2_b4_b7_od_pins_a &sdmmc2_clk_pins_a>;
	pinctrl-2 = <&sdmmc2_b4_sleep_pins_a &sdmmc2_b4_b7_sleep_pins_a>;
	non-removable;
	st,neg-edge;
	mmc-ddr-3_3v;
 	no-1-8-v;
	bus-width = <8>;
	vmmc-supply = <&v3v3>;
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";
};

3.8 修改ltdc

        在根节点下添加:

atk_pinctrl_lcd {
        gpior = <&gpioe 9 GPIO_ACTIVE_LOW>;
        gpiog = <&gpioa 15 GPIO_ACTIVE_LOW>;
        gpiob = <&gpioe 15 GPIO_ACTIVE_LOW>;
    };

        修改panel_rgb:panel-rgb,这里继续偷懒,直接复制粘贴了

panel_rgb: panel-rgb {
		compatible = "simple-panel";
		backlight = <&panel_backlight>;
		power-supply = <&v3v3>;
		status = "okay";

		port {
			panel_in_rgb: endpoint {
				remote-endpoint = <&ltdc_out_rgb>;
			};
		};

		display-timings {
			native-mode = <&timing0>; 			/* 时序信息 */
			timing0: timing0 { 					/* 7 寸 1024*600 分辨率 */
				clock-frequency = <51200000>; 	/* LCD 像素时钟,单位 Hz */
				hactive = <1024>; 				/* LCD X 轴像素个数 */
				vactive = <600>; 				/* LCD Y 轴像素个数 */
				hfront-porch = <160>; 			/* LCD hfp 参数 */
				hback-porch = <140>; 			/* LCD hbp 参数 */
				hsync-len = <20>; 				/* LCD hspw 参数 */
				vback-porch = <20>; 			/* LCD vbp 参数 */
				vfront-porch = <12>; 			/* LCD vfp 参数 */
				vsync-len = <3>; 				/* LCD vspw 参数 */
			};
		};
	};

        修改panel_backlight,ST用的是PE 12,正点原子用的是PD 13

panel_backlight: panel-backlight {
		compatible = "gpio-backlight";
		gpios = <&gpiod 13 GPIO_ACTIVE_HIGH>;
		default-on;
		status = "okay";
	};

        然后向pinctrl追加:

&pinctrl {
   gpio_r:gpio_r {
        pins {
            pinmux = <STM32_PINMUX('E', 9, GPIO)>; /* PE9.GPIO */
            bias-pull-up;
            drive-push-pull;
        };
    };

   gpio_g:gpio_g {
        pins {
            pinmux = <STM32_PINMUX('A', 15, GPIO)>; /* PA15.GPIO */
            bias-pull-up;
            drive-push-pull;
        };
    };

   gpio_b:gpio_b {
        pins {
            pinmux = <STM32_PINMUX('E', 15, GPIO)>; /* PE15.GPIO */
            bias-pull-up;
            drive-push-pull;
        };
    };
};

3.9 修改网络

        找到eth1和eth2两个节点,直接覆盖修改

&eth1 {
	status = "okay";
	pinctrl-0 = <&eth1_rgmii_pins_a>;
	pinctrl-1 = <&eth1_rgmii_sleep_pins_a>;
	pinctrl-names = "default", "sleep";
	phy-mode = "rgmii-id";
	max-speed = <1000>;
	phy-handle = <&phy0_eth1>;
	nvmem-cells = <&ethernet_mac1_address>;
	nvmem-cell-names = "mac-address";

	mdio1 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "snps,dwmac-mdio";
		phy0_eth1: ethernet-phy@1 {
            reg = <1>;
		};
	};
};

/* 需要用eth2就取消注释即可 */
// &eth2 {
// 	status = "okay";
// 	pinctrl-0 = <&eth2_rgmii_pins_a>;
// 	pinctrl-1 = <&eth2_rgmii_sleep_pins_a>;
// 	pinctrl-names = "default", "sleep";
// 	phy-mode = "rgmii-id";
// 	max-speed = <1000>;
// 	phy-handle = <&phy0_eth2>;
// 	phy-supply = <&v3v3>;
// 	nvmem-cells = <&ethernet_mac2_address>;
// 	nvmem-cell-names = "mac-address";

// 	mdio1 {
// 		#address-cells = <1>;
// 		#size-cells = <0>;
// 		compatible = "snps,dwmac-mdio";
// 		phy0_eth2: ethernet-phy@2 {
// 			reg = <2>;
// 		};
// 	};
// };

3.10 修改引脚

        偷个懒,直接照搬原子的引脚配置即可

// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
/*
 * Copyright (C) STMicroelectronics 2021 - All Rights Reserved
 * Author: Alexandre Torgue <alexandre.torgue@foss.st.com>
 */
#include <dt-bindings/pinctrl/stm32-pinfunc.h>

&pinctrl {
	eth1_rgmii_pins_a: eth1-rgmii-1 {
        pins1 {
            pinmux = <STM32_PINMUX('F', 12, AF11)>, /* ETH1_RGMII_CLK125 */
                 <STM32_PINMUX('C', 1, AF11)>, 	/* ETH1_RGMII_GTX_CLK */
                 <STM32_PINMUX('G', 13, AF11)>, /* ETH1_RGMII_TXD0 */
                 <STM32_PINMUX('G', 14, AF11)>, /* ETH1_RGMII_TXD1 */
                 <STM32_PINMUX('C', 2, AF11)>, 	/* ETH1_RGMII_TXD2 */
                 <STM32_PINMUX('E', 5, AF10)>, 	/* ETH1_RGMII_TXD3 */
                 <STM32_PINMUX('B', 11, AF11)>, /* ETH1_RGMII_TX_CTL */
                 <STM32_PINMUX('A', 2, AF11)>, 	/* ETH1_MDIO */
                 <STM32_PINMUX('G', 2, AF11)>; 	/* ETH1_MDC */
            bias-disable;
            drive-push-pull;
			slew-rate = <2>;
        };
        pins2 {
            pinmux = <STM32_PINMUX('C', 4, AF11)>, /* ETH1_RGMII_RXD0 */
                 <STM32_PINMUX('C', 5, AF11)>, /* ETH1_RGMII_RXD1 */
                 <STM32_PINMUX('B', 0, AF11)>, /* ETH1_RGMII_RXD2 */
                 <STM32_PINMUX('B', 1, AF11)>, /* ETH1_RGMII_RXD3 */
                 <STM32_PINMUX('A', 1, AF11)>, /* ETH1_RGMII_RX_CLK */
                 <STM32_PINMUX('A', 7, AF11)>; /* ETH1_RGMII_RX_CTL */
            bias-disable;
        };
    };

	eth1_rgmii_sleep_pins_a: eth1-rgmii-sleep-1 {
		pins1 {
            pinmux = <STM32_PINMUX('F', 12, ANALOG)>, /* ETH1_RGMII_CLK125 */
                 <STM32_PINMUX('C', 1, ANALOG)>, 	/* ETH1_RGMII_GTX_CLK */
                 <STM32_PINMUX('G', 13, ANALOG)>, 	/* ETH1_RGMII_TXD0 */
                 <STM32_PINMUX('G', 14, ANALOG)>, 	/* ETH1_RGMII_TXD1 */
                 <STM32_PINMUX('C', 2, ANALOG)>, 	/* ETH1_RGMII_TXD2 */
                 <STM32_PINMUX('E', 5, ANALOG)>, 	/* ETH1_RGMII_TXD3 */
                 <STM32_PINMUX('B', 11, ANALOG)>, 	/* ETH1_RGMII_TX_CTL */
                 <STM32_PINMUX('A', 2, ANALOG)>, 	/* ETH1_MDIO */
                 <STM32_PINMUX('G', 2, ANALOG)>, 	/* ETH1_MDC */
				 <STM32_PINMUX('C', 4, ANALOG)>, 	/* ETH1_RGMII_RXD0 */
                 <STM32_PINMUX('C', 5, ANALOG)>, 	/* ETH1_RGMII_RXD1 */
                 <STM32_PINMUX('B', 0, ANALOG)>, 	/* ETH1_RGMII_RXD2 */
                 <STM32_PINMUX('B', 1, ANALOG)>, 	/* ETH1_RGMII_RXD3 */
                 <STM32_PINMUX('A', 1, ANALOG)>, 	/* ETH1_RGMII_RX_CLK */
                 <STM32_PINMUX('A', 7, ANALOG)>; 	/* ETH1_RGMII_RX_CTL */
		};
	};

	eth2_rgmii_pins_a: eth2-rgmii-2 {
		pins1 {
			pinmux = <STM32_PINMUX('H', 2, AF13)>, /* ETH2_RGMII_CLK125 */
				 <STM32_PINMUX('F', 7, AF11)>, 	/* ETH2_RGMII_TXD0 */
				 <STM32_PINMUX('G', 11, AF10)>, /* ETH2_RGMII_TXD1 */
				 <STM32_PINMUX('G', 1, AF10)>, 	/* ETH2_RGMII_TXD2 */
				 <STM32_PINMUX('E', 6, AF11)>, 	/* ETH2_RGMII_TXD3 */
				 <STM32_PINMUX('G', 3, AF10)>, 	/* ETH2_RGMII_GTX_CLK */
				 <STM32_PINMUX('F', 6, AF11)>, 	/* ETH2_RGMII_TX_CTL */
				 <STM32_PINMUX('B', 2, AF11)>, 	/* ETH2_MDIO */
				 <STM32_PINMUX('G', 5, AF10)>; 	/* ETH2_MDC */
			bias-disable;
			drive-push-pull;
			slew-rate = <2>;
		};

		pins2 {
			pinmux = <STM32_PINMUX('F', 4, AF11)>, /* ETH2_RGMII_RXD0 */
				 <STM32_PINMUX('E', 2, AF10)>, 	/* ETH2_RGMII_RXD1 */
				 <STM32_PINMUX('H', 6, AF12)>, 	/* ETH2_RGMII_RXD2 */
				 <STM32_PINMUX('A', 8, AF11)>, 	/* ETH2_RGMII_RXD3 */
				 <STM32_PINMUX('H', 11, AF11)>, /* ETH2_RGMII_RX_CLK */
				 <STM32_PINMUX('G', 12, AF12)>; /* ETH2_RGMII_RX_CTL */
			bias-disable;
		};
	};

	eth2_rgmii_sleep_pins_a: eth2-rgmii-sleep-2 {
		pins1 {
			pinmux = <STM32_PINMUX('H', 2, ANALOG)>, /* ETH2_RGMII_CLK125 */
				 <STM32_PINMUX('F', 7, ANALOG)>, 	/* ETH2_RGMII_TXD0 */
				 <STM32_PINMUX('G', 11, ANALOG)>, 	/* ETH2_RGMII_TXD1 */
				 <STM32_PINMUX('G', 1, ANALOG)>, 	/* ETH2_RGMII_TXD2 */
				 <STM32_PINMUX('E', 6, ANALOG)>, 	/* ETH2_RGMII_TXD3 */
				 <STM32_PINMUX('G', 3, ANALOG)>, 	/* ETH2_RGMII_GTX_CLK */
				 <STM32_PINMUX('F', 6, ANALOG)>, 	/* ETH2_RGMII_TX_CTL */
				 <STM32_PINMUX('B', 2, ANALOG)>, 	/* ETH2_MDIO */
				 <STM32_PINMUX('G', 5, ANALOG)>, 	/* ETH2_MDC */
				 <STM32_PINMUX('F', 4, ANALOG)>, 	/* ETH2_RGMII_RXD0 */
				 <STM32_PINMUX('E', 2, ANALOG)>, 	/* ETH2_RGMII_RXD1 */
				 <STM32_PINMUX('H', 6, ANALOG)>, 	/* ETH2_RGMII_RXD2 */
				 <STM32_PINMUX('A', 8, ANALOG)>, 	/* ETH2_RGMII_RXD3 */
				 <STM32_PINMUX('H', 11, ANALOG)>, 	/* ETH2_RGMII_RX_CLK */
				 <STM32_PINMUX('G', 12, ANALOG)>; 	/* ETH2_RGMII_RX_CTL */
		};
	};

	ltdc_pins_a: ltdc-0 {
		pins {
			pinmux = <STM32_PINMUX('D',  9, AF13)>, /* LCD_CLK */
				 <STM32_PINMUX('H',  10, AF13)>, /* LCD_HSYNC */
				 <STM32_PINMUX('G',  4, AF11)>, /* LCD_VSYNC */ 
				 <STM32_PINMUX('H',  9, AF11)>, /* LCD_DE */
				 <STM32_PINMUX('E', 11, AF9)>,  /* LCD_R0 */
				 <STM32_PINMUX('D',  4, AF11)>, /* LCD_R1 */
				 <STM32_PINMUX('G',  7, AF14)>, /* LCD_R2 */
				 <STM32_PINMUX('B', 12, AF13)>, /* LCD_R3 */
				 <STM32_PINMUX('D', 14, AF14)>, /* LCD_R4 */
				 <STM32_PINMUX('E',  7, AF14)>, /* LCD_R5 */
				 <STM32_PINMUX('E', 13, AF14)>, /* LCD_R6 */
				 <STM32_PINMUX('E',  9, AF14)>, /* LCD_R7 */
				 <STM32_PINMUX('F',  5, AF9)>,  /* LCD_G0 */
				 <STM32_PINMUX('F',  1, AF14)>, /* LCD_G1 */
				 <STM32_PINMUX('H', 13, AF14)>, /* LCD_G2 */
				 <STM32_PINMUX('F',  3, AF14)>, /* LCD_G3 */
				 <STM32_PINMUX('E', 12, AF11)>, /* LCD_G4 */
				 <STM32_PINMUX('G',  0, AF14)>, /* LCD_G5 */
				 <STM32_PINMUX('A', 12, AF14)>, /* LCD_G6 */
				 <STM32_PINMUX('A', 15, AF11)>, /* LCD_G7 */
				 <STM32_PINMUX('D',  5, AF13)>, /* LCD_B0 */
				 <STM32_PINMUX('G',  8, AF7)>,  /* LCD_B1 */
				 <STM32_PINMUX('D', 10, AF14)>, /* LCD_B2 */
				 <STM32_PINMUX('F',  2, AF14)>, /* LCD_B3 */
				 <STM32_PINMUX('G', 15, AF11)>, /* LCD_B4 */
				 <STM32_PINMUX('D', 15, AF14)>, /* LCD_B5 */
				 <STM32_PINMUX('D',  1, AF11)>, /* LCD_B6 */
				 <STM32_PINMUX('E', 15, AF14)>; /* LCD_B7 */
			bias-disable;
			drive-push-pull;
			slew-rate = <1>;
		};
	};

	ltdc_sleep_pins_a: ltdc-sleep-0 {
		pins {
			pinmux = <STM32_PINMUX('D',  9, ANALOG)>, /* LCD_CLK */
				 <STM32_PINMUX('H',  10, ANALOG)>, /* LCD_HSYNC */
				 <STM32_PINMUX('G',  4, ANALOG)>, /* LCD_VSYNC */
				 <STM32_PINMUX('H',  9, ANALOG)>, /* LCD_DE */
				 <STM32_PINMUX('E', 11, ANALOG)>, /* LCD_R0 */
				 <STM32_PINMUX('D',  4, ANALOG)>, /* LCD_R1 */				 
				 <STM32_PINMUX('G',  7, ANALOG)>, /* LCD_R2 */
				 <STM32_PINMUX('B', 12, ANALOG)>, /* LCD_R3 */
				 <STM32_PINMUX('D', 14, ANALOG)>, /* LCD_R4 */
				 <STM32_PINMUX('E',  7, ANALOG)>, /* LCD_R5 */
				 <STM32_PINMUX('E', 13, ANALOG)>, /* LCD_R6 */
				 <STM32_PINMUX('E',  9, ANALOG)>, /* LCD_R7 */
				 <STM32_PINMUX('F',  5, ANALOG)>, /* LCD_G0 */
				 <STM32_PINMUX('F',  1, ANALOG)>, /* LCD_G1 */				 
				 <STM32_PINMUX('H', 13, ANALOG)>, /* LCD_G2 */
				 <STM32_PINMUX('F',  3, ANALOG)>, /* LCD_G3 */
				 <STM32_PINMUX('E', 12, ANALOG)>, /* LCD_G4 */
				 <STM32_PINMUX('G',  0, ANALOG)>, /* LCD_G5 */
				 <STM32_PINMUX('A', 12, ANALOG)>, /* LCD_G6 */
				 <STM32_PINMUX('A', 15, ANALOG)>, /* LCD_G7 */
				 <STM32_PINMUX('D',  5, ANALOG)>, /* LCD_B0 */
				 <STM32_PINMUX('G',  8, ANALOG)>, /* LCD_B1 */				 
				 <STM32_PINMUX('D', 10, ANALOG)>, /* LCD_B2 */
				 <STM32_PINMUX('F',  2, ANALOG)>, /* LCD_B3 */
				 <STM32_PINMUX('G', 15, ANALOG)>, /* LCD_B4 */
				 <STM32_PINMUX('D', 15, ANALOG)>, /* LCD_B5 */
				 <STM32_PINMUX('D',  1, ANALOG)>, /* LCD_B6 */
				 <STM32_PINMUX('E', 15, ANALOG)>; /* LCD_B7 */
		};
	};

	sdmmc1_b4_pins_a: sdmmc1-b4-0 {
		pins {
			pinmux = <STM32_PINMUX('C', 8, AF12)>, /* SDMMC1_D0 */
				 <STM32_PINMUX('C', 9, AF12)>, /* SDMMC1_D1 */
				 <STM32_PINMUX('C', 10, AF12)>, /* SDMMC1_D2 */
				 <STM32_PINMUX('C', 11, AF12)>, /* SDMMC1_D3 */
				 <STM32_PINMUX('D', 2, AF12)>; /* SDMMC1_CMD */
			slew-rate = <1>;
			drive-push-pull;
			bias-disable;
		};
	};

	sdmmc1_b4_od_pins_a: sdmmc1-b4-od-0 {
		pins1 {
			pinmux = <STM32_PINMUX('C', 8, AF12)>, /* SDMMC1_D0 */
				 <STM32_PINMUX('C', 9, AF12)>, /* SDMMC1_D1 */
				 <STM32_PINMUX('C', 10, AF12)>, /* SDMMC1_D2 */
				 <STM32_PINMUX('C', 11, AF12)>; /* SDMMC1_D3 */
			slew-rate = <1>;
			drive-push-pull;
			bias-disable;
		};
		pins2 {
			pinmux = <STM32_PINMUX('D', 2, AF12)>; /* SDMMC1_CMD */
			slew-rate = <1>;
			drive-open-drain;
			bias-disable;
		};
	};

	sdmmc1_b4_sleep_pins_a: sdmmc1-b4-sleep-0 {
		pins {
			pinmux = <STM32_PINMUX('C', 8, ANALOG)>, /* SDMMC1_D0 */
				 <STM32_PINMUX('C', 9, ANALOG)>, /* SDMMC1_D1 */
				 <STM32_PINMUX('C', 10, ANALOG)>, /* SDMMC1_D2 */
				 <STM32_PINMUX('C', 11, ANALOG)>, /* SDMMC1_D3 */
				 <STM32_PINMUX('C', 12, ANALOG)>, /* SDMMC1_CK */
				 <STM32_PINMUX('D', 2, ANALOG)>; /* SDMMC1_CMD */
		};
	};

	sdmmc1_clk_pins_a: sdmmc1-clk-0 {
		pins {
			pinmux = <STM32_PINMUX('C', 12, AF12)>; /* SDMMC1_CK */
			slew-rate = <1>;
			drive-push-pull;
			bias-disable;
		};
	};

	sdmmc2_b4_pins_a: sdmmc2-b4-0 {
		pins {
			pinmux = <STM32_PINMUX('B', 14, AF10)>, /* SDMMC2_D0 */
				 <STM32_PINMUX('B', 15, AF10)>, /* SDMMC2_D1 */
				 <STM32_PINMUX('B', 3, AF10)>, /* SDMMC2_D2 */
				 <STM32_PINMUX('B', 4, AF10)>, /* SDMMC2_D3 */
				 <STM32_PINMUX('G', 6, AF10)>; /* SDMMC2_CMD */
			slew-rate = <1>;
			drive-push-pull;
			bias-pull-up;
		};
	};

	sdmmc2_b4_b7_pins_a: sdmmc2-b4-b7-0 {
		pins {
			pinmux = <STM32_PINMUX('F', 0, AF10)>, /* SDMMC2_D4 */
				 <STM32_PINMUX('B', 9, AF10)>, /* SDMMC2_D5 */
				 <STM32_PINMUX('C', 6, AF10)>, /* SDMMC2_D6 */				 
				 <STM32_PINMUX('C', 7, AF10)>; /* SDMMC2_D7 */
			slew-rate = <1>;
			drive-push-pull;
			bias-pull-up;
		};
	};

	sdmmc2_b4_od_pins_a: sdmmc2-b4-od-0 {
		pins1 {
			pinmux = <STM32_PINMUX('B', 14, AF10)>, /* SDMMC2_D0 */
				 <STM32_PINMUX('B', 15, AF10)>, /* SDMMC2_D1 */
				 <STM32_PINMUX('B', 3, AF10)>, /* SDMMC2_D2 */
				 <STM32_PINMUX('B', 4, AF10)>; /* SDMMC2_D3 */
			slew-rate = <1>;
			drive-push-pull;
			bias-pull-up;
		};
		pins2 {
			pinmux = <STM32_PINMUX('G', 6, AF10)>; /* SDMMC2_CMD */
			slew-rate = <1>;
			drive-open-drain;
			bias-pull-up;
		};
	};

	sdmmc2_b4_b7_od_pins_a: sdmmc2-b4-b7-od-0 {
		pins {
			pinmux = <STM32_PINMUX('F', 0, AF10)>, /* SDMMC2_D4 */
				 <STM32_PINMUX('B', 9, AF10)>, /* SDMMC2_D5 */
				 <STM32_PINMUX('C', 6, AF10)>, /* SDMMC2_D6 */				 
				 <STM32_PINMUX('C', 7, AF10)>; /* SDMMC2_D7 */
			slew-rate = <1>;
			drive-push-pull;
			bias-pull-up;
		};
	};	

	sdmmc2_b4_sleep_pins_a: sdmmc2-b4-sleep-0 {
		pins {
			pinmux = <STM32_PINMUX('B', 14, ANALOG)>, /* SDMMC2_D0 */
				 <STM32_PINMUX('B', 15, ANALOG)>, /* SDMMC2_D1 */
				 <STM32_PINMUX('B', 3, ANALOG)>, /* SDMMC2_D2 */
				 <STM32_PINMUX('B', 4, ANALOG)>, /* SDMMC2_D3 */
				 <STM32_PINMUX('E', 3, ANALOG)>, /* SDMMC2_CK */
				 <STM32_PINMUX('G', 6, ANALOG)>; /* SDMMC2_CMD */
		};
	};

	sdmmc2_b4_b7_sleep_pins_a: sdmmc2-b4-b7-sleep-0 {
		pins {
			pinmux = <STM32_PINMUX('F', 0, ANALOG)>, /* SDMMC2_D4 */
				 <STM32_PINMUX('B', 9, ANALOG)>, /* SDMMC2_D5 */
				 <STM32_PINMUX('C', 6, ANALOG)>, /* SDMMC2_D6 */				 
				 <STM32_PINMUX('C', 7, ANALOG)>; /* SDMMC2_D7 */
		};
	};

	sdmmc2_clk_pins_a: sdmmc2-clk-0 {
		pins {
			pinmux = <STM32_PINMUX('E', 3, AF10)>; /* SDMMC2_CK */
			slew-rate = <1>;
			drive-push-pull;
			bias-pull-up;
		};
	};

	uart4_pins_a: uart4-0 {
		pins1 {
			pinmux = <STM32_PINMUX('D', 6, AF8)>; /* UART4_TX */
			bias-disable;
			drive-push-pull;
			slew-rate = <0>;
		};
		pins2 {
			pinmux = <STM32_PINMUX('D', 8, AF8)>; /* UART4_RX */
			bias-pull-up;
		};
	};

	uart4_idle_pins_a: uart4-idle-0 {
		pins1 {
			pinmux = <STM32_PINMUX('D', 6, ANALOG)>; /* UART4_TX */
		};
		pins2 {
			pinmux = <STM32_PINMUX('D', 8, AF8)>; /* UART4_RX */
			bias-pull-up;
		};
	};

	uart4_sleep_pins_a: uart4-sleep-0 {
		pins {
			pinmux = <STM32_PINMUX('D', 6, ANALOG)>, /* UART4_TX */
				 <STM32_PINMUX('D', 8, ANALOG)>; /* UART4_RX */
		};
	};

	usbotg_hs_pins_a: usbotg-hs-0 {
		pins {
			pinmux = <STM32_PINMUX('A', 10, ANALOG)>; /* OTG_ID */
		};
	};
};

3.11 其他

        在stm32mp135-atk-u-boot.dtsi里,关于adc那一行是检测usb电压的,把它注释掉,然后笔者把快速启动注释了,led灯也没有用到。

	config {
		// u-boot,boot-led = "led-blue";
		// u-boot,error-led = "led-red";
		u-boot,mmc-env-partition = "u-boot-env";
		// st,adc_usb_pd = <&adc1 6>, <&adc1 12>;
		// st,fastboot-gpios = <&gpioa 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
		st,stm32prog-gpios = <&gpioa 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
	};

3.12 网络补充

        这里一点至关重要!!!!

        正点原子修改了phy的驱动,所以我们要找到drivers\net\phy\phy.c这个文件,在genphy_config_aneg(struct phy_device *phydev)这个函数后面插入

/***************alientek add****************/
#define YT8531_REG_DEBUG_ADDR_OFFSET		0x1e
#define YT8531_REG_DEBUG_DATA				0x1f

static int yt8531_rd_ext(struct phy_device *phydev, u32 regnum)
{
	int val;

	phy_write(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_ADDR_OFFSET, regnum);
	val = phy_read(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_DATA);
	
	return val;
}

static int yt8531_wr_ext(struct phy_device *phydev, u32 regnum, u16 val)
{
	int ret;

	ret = phy_write(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_ADDR_OFFSET, regnum);
	ret = phy_write(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_DATA, val);
	
	return ret;
}

int yt8531_xtal_init(struct phy_device *phydev)
{
	int ret = 0;
	int val = 0;

	mdelay(50);

	do {
		ret = yt8531_wr_ext(phydev, 0xa012, 0x88);
		if (ret < 0)
			return ret;

		mdelay(100);

		val = yt8531_rd_ext(phydev, 0xa012);
		if (val < 0)
			return val;

		mdelay(20);
	} while (val != 0x88);

	ret = yt8531_wr_ext(phydev, 0xa012, 0xd0);
	if (ret < 0)
		return ret;

	return ret;
}

void yt8531_led_init(struct phy_device *phydev)
{
	yt8531_wr_ext(phydev, 0xa00d, 0x2600);	//yellow led blink
	yt8531_wr_ext(phydev, 0xa00c, 0x30);	//10_100M green led always light
	yt8531_wr_ext(phydev, 0xa00e, 0x40);	//1000M green led always light	
}

/*********************end add***************************/

然后修改 int genphy_update_link(struct phy_device *phydev)这个函数

/**
 * genphy_update_link - update link status in @phydev
 * @phydev: target phy_device struct
 *
 * Description: Update the value in phydev->link to reflect the
 *   current link value.  In order to do this, we need to read
 *   the status register twice, keeping the second value.
 */
int genphy_update_link(struct phy_device *phydev)
{
	unsigned int mii_reg;


	/************alientek add********/
	int ret = 0;
	unsigned int phyid1, phyid2;

	phyid1 = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
	phyid2 = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID2);
	if((phyid1 == 0x4f51) && (phyid2 == 0xe91b)) { //YT8531 ID
		ret = yt8531_xtal_init(phydev);
		if (ret < 0)
		{
			printf("yt8531_xtal_init failed.\r\n");
			return ret;
		}

		yt8531_led_init(phydev);
	}
	/*********************end add***************************/

	/*
	 * Wait if the link is up, and autonegotiation is in progress
	 * (ie - we're capable and it's not done)
	 */
	mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);

	/*
	 * If we already saw the link up, and it hasn't gone down, then
	 * we don't need to wait for autoneg again
	 */
	if (phydev->link && mii_reg & BMSR_LSTATUS)
		return 0;

	if ((phydev->autoneg == AUTONEG_ENABLE) &&
	    !(mii_reg & BMSR_ANEGCOMPLETE)) {
		int i = 0;

		printf("%s Waiting for PHY auto negotiation to complete",
		       phydev->dev->name);
		while (!(mii_reg & BMSR_ANEGCOMPLETE)) {
			/*
			 * Timeout reached ?
			 */
			if (i > (PHY_ANEG_TIMEOUT / 50)) {
				printf(" TIMEOUT !\n");
				phydev->link = 0;
				return -ETIMEDOUT;
			}

			if (ctrlc()) {
				puts("user interrupt!\n");
				phydev->link = 0;
				return -EINTR;
			}

			if ((i++ % 10) == 0)
				printf(".");

			mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
			mdelay(50);	/* 50 ms */
		}
		printf(" done\n");
		phydev->link = 1;
	} else {
		/* Read the link a second time to clear the latched state */
		mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);

		if (mii_reg & BMSR_LSTATUS)
			phydev->link = 1;
		else
			phydev->link = 0;
	}

	return 0;
}

四、编译

make -f ../Makefile.sdk all

        由于我们前面已经编译好了TF-A和optee,在这里编译uboot的时候,会自动用fiptool给我们打包好,然后生成我们需要的fip-stm32mp135-atk-optee.bin文件

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1060789.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

zookeeper选举机制

全新集群选举 zookeeper 全新集群选举机制网上资料很多说法很模糊&#xff0c;仔细思考了一下&#xff0c;应该是这样 得到票数最多的机器>机器总数半数 具体启动过程中的哪个节点成为 leader 与 zoo.cfg 中配置的节点数有关&#xff0c;下面以3个举例 选举过程如下 server…

【Vue组件化编程】

Vue组件化编程 1 对组件的理解2 非单文件组件2.1 基本使用2.2 几个注意点2.3 组件的嵌套2.4 VueComponent构造函数2.5 一个重要的内置关系 3 单文件组件 1 对组件的理解 组件&#xff1a;实现应用中局部功能代码和资源的集合。优点&#xff1a;文件好维护&#xff1b;依赖关系不…

力扣 -- 96. 不同的二叉搜索树

解题步骤&#xff1a; 参考代码&#xff1a; class Solution { public:int numTrees(int n) {vector<int> dp(n1);//初始化dp[0]1;//填表for(int i1;i<n;i){for(int j1;j<i;j){//状态转移方程dp[i](dp[j-1]*dp[i-j]);}}//返回值return dp[n];} }; 你学会了吗&…

SpringBoot美食网站系统

采用技术:springbootvue 项目亲测可以完美运行

typscript开发环境搭建

typescript是基于javascript的强类型标记性语言&#xff0c;使用typescript语言可开发出不同规模的、易于扩展的web页面应用&#xff0c;本文主要描述typescript的开发环境搭建。 npm install -g typescript 如上所示&#xff0c;在本地开发环境中&#xff0c;使用nodejs运行…

苹果ios应用ipa文件签名为什么需要签名才能上架?有没有别的方式替代苹果签名?

近年来&#xff0c;苹果设备的普及程度逐渐加深&#xff0c;随之而来的是越来越多的应用程序涌入了苹果的应用商店。为了保障用户设备和数据的安全&#xff0c;以及减少恶意程序和恶意软件的传播&#xff0c;苹果公司实行了一套严格的应用安全机制&#xff0c;其中就包括应用程…

【现代机器人学】学习笔记十四:中文版印刷/翻译勘误

首先声明&#xff0c;这个印刷/勘误并非经过官方的认可&#xff0c;只是我个人的粗浅的理解。如果内容有误&#xff0c;恳请大家谅解指正。 其实有的并不算错&#xff0c;只是我个人认为不太准确&#xff0c;在我学习过程中产生了一些小疑惑和误解。 都是一些小毛病&#xff…

2024级199管理类联考之数学基础(下篇)

平面几何(平均2题) 三角形(性质、特殊三角形、全等与相似) 性质 由不在同一直线的三条线段首尾依次连接所组成的图形三条边、三个内角、三个定点三角形内角和为180度,外角和为360度,多边形的外角和为360度,n多边形的内角和为(n-2)*180度一个外角等于不相邻的两个内角之和任意…

NXP公司K60N512+PWM控制BLDC电机

本篇文章介绍了使用NXP公司提供的塔式快速原型系统来驱动控制带霍尔传感器的无刷直流电机。文章涉及的塔式快速原型系统主要包括以下四个独立板卡&#xff1a;1.塔式系统支撑模块&#xff08;TWR-Elevator&#xff09;&#xff0c;用以连接微控制器以及周边模块&#xff1b;2.低…

雷达编程实战之提高探测速度

有效帧频率作为雷达一个非常核心的指标&#xff0c;它代表了雷达探测识别的速度&#xff0c;速度越快&#xff0c;后级各项智能驾驶功能就能得到更快、更有效的判断。本篇文章首先从硬件的角度&#xff0c;提供了一种合理利用片上资源提高探测识别速度的常用方法&#xff0c;然…

qt 5.15.2 安卓 macos

macos环境安卓配置 我的系统是monterey12.5.1 打开qt的配置界面 这里版本是java1.8&#xff0c;注意修改这个json文件&#xff0c;显示包内容 {"common": {"sdk_tools_url": {"linux": "https://dl.google.com/android/repository/comm…

Boost程序库完全开发指南:1-开发环境和构建工具

Boost官方于2019年12月发布的1.72版编写&#xff0c;共包含160余个库/组件&#xff0c;涵盖字符串与文本处理、容器、迭代器、算法、图像处理、模板元编程、并发编程等多个领域&#xff0c;使用Boost&#xff0c;将大大增强C的功能和表现力。环境&#xff1a;Windows 10&#x…

JAVA学习(4)-全网最详细~

&#x1f308;write in front&#x1f308; &#x1f9f8;大家好&#xff0c;我是Aileen&#x1f9f8;.希望你看完之后&#xff0c;能对你有所帮助&#xff0c;不足请指正&#xff01;共同学习交流. &#x1f194;本文由Aileen_0v0&#x1f9f8; 原创 CSDN首发&#x1f412; 如…

vertx的学习总结6

Beyond the event bus 一、章节覆盖&#xff1a; 如何在事件总线之上公开服务 verticles和事件总线服务的异步测试 动态代理&#xff1a; MyService 接口 package porxy.test;import io.vertx.codegen.annotations.ProxyGen;ProxyGen public interface MyService {void he…

Linux学习之悟空派上实现OLED的无线网IP及CPU温度显示【守护进程】

起因 最近各种网购平台似乎都在推送99元的悟空派全志H3的开发板&#xff0c;出于好奇就买了一块来试试水&#xff0c;由于这块板子基本上和orangepi-Zero的硬件结构一模一样&#xff0c;所以设备树、boot这些就用orangepi现成的部件了。 因为本人比较喜欢使用SSH操作&#xff…

全志ARM926 Melis2.0系统的开发指引①

全志ARM926 Melis2.0系统的开发指引① 1. 编写目的2. Melis2.0 系统概述3. Melis2.0 快速开发3.1. Melis2.0 SDK 目录结构3.2. Melis2.0 编译环境3.3. Melis2.0 固件打包3.4. Melis2.0 固件烧录3.5.串口打印信息3.6. Melis2.0 添加和调用一个模块3.6.1. 为什么划分模块&#xf…

Sentinel-微服务保护

一、初识Sentinel 1、雪崩问题及解决方案 雪崩问题 微服务调用链路中的某个服务故障&#xff0c;引起整个链路中的所有微服务都不可用&#xff0c;这就是雪崩。 解决雪崩问题的常见方式有四种&#xff1a; 1、超时处理&#xff1a;设定超时时间&#xff0c;请求超过一定时间…

【C语言】内存函数的详细教学和模拟实现

&#x1f680;write in front&#x1f680; &#x1f50e;大家好&#xff0c;我是gugugu。希望你看完之后&#xff0c;能对你有所帮助&#xff0c;不足请指正&#xff01;共同学习交流&#x1f50e; &#x1f194;本文由 gugugu 原创 CSDN首发&#x1f412; 如需转载还请通知⚠…

全志ARM926 Melis2.0系统的开发指引②

全志ARM926 Melis2.0系统的开发指引② 编写目的4. 编译工具链使用4.1.工具链通用配置4.2.模块的工具链配置4.3.简单的 makefile 5. 固件烧录工具的安装5.1.PhoenixSuit 的安装步骤5.2.检验 USB 驱动安装5.3.使用烧录软件 PhoenixSuit -全志相关工具和资源-.1 全志固件镜像修改工…