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

一、概述

        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				0x1fstatic 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 blinkyt8531_wr_ext(phydev, 0xa00c, 0x30);	//10_100M green led always lightyt8531_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 IDret = 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;elsephydev->link = 0;}return 0;
}

四、编译

make -f ../Makefile.sdk all

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

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

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

手动实现BERT

本文重点介绍了如何从零训练一个BERT模型的过程&#xff0c;包括整体上BERT模型架构、数据集如何做预处理、MASK替换策略、训练模型和保存、加载模型和测试等。 一.BERT架构   BERT设计初衷是作为一个通用的backbone&#xff0c;然后在下游接入各种任务&#xff0c;包括翻译…

反素数

198. 反素数 - AcWing题库 最大的反素数也就是约数个数最多的数中最小的那个数&#xff0c;可以考虑分解质因子形式 2、3、5、7、11、13、17、19、23、29这些&#xff0c;还有每个质因子的指数一定大于等于下一个质因子的指数&#xff0c;这样可以保证约数最多的时候数字尽可能…

力扣 -- 873. 最长的斐波那契子序列的长度

解题步骤&#xff1a; 参考代码&#xff1a; class Solution { public:int lenLongestFibSubseq(vector<int>& nums) {int nnums.size();unordered_map<int,int> hash;for(int i0;i<n;i){hash[nums[i]]i;}int ret2;vector<vector<int>> dp(n,v…

Java编程技巧:swagger2、knif4j集成SpringBoot或者SpringCloud项目

目录 1、springbootswagger2knif4j2、springbootswagger3knif4j3、springcloudswagger2knif4j 1、springbootswagger2knif4j 2、springbootswagger3knif4j 3、springcloudswagger2knif4j 注意点&#xff1a; Api注解&#xff1a;Controller类上的Api注解需要添加tags属性&a…

sheng的学习笔记-【中文】【吴恩达课后测验】Course 2 - 改善深层神经网络 - 第二周测验

课程2_第2周_测验题 目录&#xff1a;目录 第一题 1.当输入从第8个mini-batch的第7个的例子的时候&#xff0c;你会用哪种符号表示第3层的激活&#xff1f; A. 【  】 a [ 3 ] { 8 } ( 7 ) a^{[3]\{8\}(7)} a[3]{8}(7) B. 【  】 a [ 8 ] { 7 } ( 3 ) a^{[8]\{7\}(3)} a…

2023/10/4 QT实现TCP服务器客户端搭建

服务器端&#xff1a; 头文件 #ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include <QTcpServer> #include <QTcpSocket> #include <QList> #include <QMessageBox> #include <QDebug>QT_BEGIN_NAMESPACE namespace Ui { cla…

Flutter AI五子棋

前言 在上一篇文章中&#xff0c;讲解了如何实现双人在本地对战的五子棋&#xff0c;但是只有一个人的时候就不太好玩&#xff0c;同时博主也没有把五子棋相关的文章写过瘾。那么这篇文章&#xff0c;我们来实现一个功能更加丰富的五子棋吧&#xff01;在设计五子棋的算法方面&…

竞赛 机器视觉人体跌倒检测系统 - opencv python

0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; 机器视觉人体跌倒检测系统 该项目较为新颖&#xff0c;适合作为竞赛课题方向&#xff0c;学长非常推荐&#xff01; &#x1f947;学长这里给一个题目综合评分(每项满分5分) 难度系数&…

JVM篇---第三篇

系列文章目录 文章目录 系列文章目录一、什么是Java虚拟机?为什么Java被称作是“平台无关的编程语言”?二、Java内存结构三、说说对象分配规则一、什么是Java虚拟机?为什么Java被称作是“平台无关的编程语言”? Java虚拟机是一个可以执行Java字节码的虚拟机进程。Java源文…

C#捕捉全局异常

1.运行图片 2.源码 using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms;namespace 捕捉全局异常 {internal static class Program{/// <summary>/// 应用程序的主入口点。/// </summary…

【算法|动态规划No.9】leetcodeLCR 091. 粉刷房子

个人主页&#xff1a;兜里有颗棉花糖 欢迎 点赞&#x1f44d; 收藏✨ 留言✉ 加关注&#x1f493;本文由 兜里有颗棉花糖 原创 收录于专栏【手撕算法系列专栏】【LeetCode】 &#x1f354;本专栏旨在提高自己算法能力的同时&#xff0c;记录一下自己的学习过程&#xff0c;希望…

MongoDB数据库网站网页实例-编程语言Python+Django

程序示例精选 PythonDjangoMongoDB数据库网站网页实例 如需安装运行环境或远程调试&#xff0c;见文章底部个人QQ名片&#xff0c;由专业技术人员远程协助&#xff01; 前言 这篇博客针对《PythonDjangoMongoDB数据库网站网页实例》编写代码&#xff0c;代码整洁&#xff0c;…