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

2023-10-06 18:56

本文主要是介绍(四)正点原子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文件

这篇关于(四)正点原子STM32MP135移植——u-boot移植的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/153763

相关文章

FreeRTOS-基本介绍和移植STM32

FreeRTOS-基本介绍和STM32移植 一、裸机开发和操作系统开发介绍二、任务调度和任务状态介绍2.1 任务调度2.1.1 抢占式调度2.1.2 时间片调度 2.2 任务状态 三、FreeRTOS源码和移植STM323.1 FreeRTOS源码3.2 FreeRTOS移植STM323.2.1 代码移植3.2.2 时钟中断配置 一、裸机开发和操作系统开发介绍 裸机:前后台系

RabbitMQ使用及与spring boot整合

1.MQ   消息队列(Message Queue,简称MQ)——应用程序和应用程序之间的通信方法   应用:不同进程Process/线程Thread之间通信   比较流行的中间件:     ActiveMQ     RabbitMQ(非常重量级,更适合于企业级的开发)     Kafka(高吞吐量的分布式发布订阅消息系统)     RocketMQ   在高并发、可靠性、成熟度等

Spring Boot 入门篇

一、简介 Spring Boot是一款开源的Java Web应用框架,旨在简化Spring应用的初始搭建以及开发过程。它整合了Spring技术栈中的诸多关键组件,为开发者提供了一种快速、简便的Spring应用开发方式。Spring Boot遵循“约定优于配置”的原则,通过自动配置、起步依赖和内置的Servlet容器,极大地简化了传统Spring应用的配置和部署过程。 二、Spring Boot

Spring Boot集成Tess4J实现OCR

1.什么是Tess4j? Tesseract是一个开源的光学字符识别(OCR)引擎,它可以将图像中的文字转换为计算机可读的文本。支持多种语言和书面语言,并且可以在命令行中执行。它是一个流行的开源OCR工具,可以在许多不同的操作系统上运行。Tess4J是一个基于Tesseract OCR引擎的Java接口,可以用来识别图像中的文本,说白了,就是封装了它的API,让Java可以直接调用。 Tess

Lua 脚本在 Redis 中执行时的原子性以及与redis的事务的区别

在 Redis 中,Lua 脚本具有原子性是因为 Redis 保证在执行脚本时,脚本中的所有操作都会被当作一个不可分割的整体。具体来说,Redis 使用单线程的执行模型来处理命令,因此当 Lua 脚本在 Redis 中执行时,不会有其他命令打断脚本的执行过程。脚本中的所有操作都将连续执行,直到脚本执行完成后,Redis 才会继续处理其他客户端的请求。 Lua 脚本在 Redis 中原子性的原因

部署若依Spring boot项目

nohup和& nohup命令解释 nohup命令:nohup 是 no hang up 的缩写,就是不挂断的意思,但没有后台运行,终端不能标准输入。nohup :不挂断的运行,注意并没有后台运行的功能,就是指,用nohup运行命令可以使命令永久的执行下去,和用户终端没有关系,注意了nohup没有后台运行的意思;&才是后台运行在缺省情况下该作业的所有输出都被重定向到一个名为nohup.o

使用Spring Boot集成Spring Data JPA和单例模式构建库存管理系统

引言 在企业级应用开发中,数据库操作是非常重要的一环。Spring Data JPA提供了一种简化的方式来进行数据库交互,它使得开发者无需编写复杂的JPA代码就可以完成常见的CRUD操作。此外,设计模式如单例模式可以帮助我们更好地管理和控制对象的创建过程,从而提高系统的性能和可维护性。本文将展示如何结合Spring Boot、Spring Data JPA以及单例模式来构建一个基本的库存管理系统

Spring Boot集成PDFBox实现电子签章

概述 随着无纸化办公的普及,电子文档的使用越来越广泛。电子签章作为一种有效的身份验证方式,在很多场景下替代了传统的纸质文件签名。Apache PDFBox 是一个开源的Java库,可以用来渲染、生成、填写PDF文档等操作。本文将介绍如何使用Spring Boot框架结合PDFBox来实现电子签章功能。 准备工作 环境搭建:确保你的开发环境中安装了JDK 8或更高版本,并且配置好了Maven或

spring boot 创建no-web应用

1. 问题 不是所有的Spring应用都必须是web应用(或web服务)。如果你想在main方法中执行一些代码,但需要启动一个Spring应用去设置需要的底层设施,那使用Spring Boot的SpringApplication特性可以很容易实现。 spring boot绝大多数用于web应用,但是有时我们只想用spring boot启动容器、使用它的一些特性,单并不想启动一个web服务,如何

android打包解包boot.img,system.img

原帖地址:http://www.52pojie.cn/thread-488025-1-1.html 转载Mark一下,日后研究 最近工作需要对boot.img,system.img进行破解。顺便将心得分享一下。 我的工作环境是在linux下的。所以工具都是针对linux的。 boot.img破解相关工具: 1、split_boot    perl脚本 2、boot_i