(六)正点原子STM32MP135移植——内核移植

news2024/11/19 23:23:10

目录

一、概述

二、编译官方代码

三、移植

四、编译


一、概述

        前面已经移植好了TF-A、optee、u-boot,在u-boot能正常跑起来的情况下,现在来移植内核。

二、编译官方代码

        进入kernel目录

2.1 解压源码、打补丁

/* 解压源码 */
tar xf linux-6.1.28.tar.xz

/* 进入源码目录 */
cd linux-6.1.28/

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

2.2 配置Kernel

        根据官方手册进行配置即可

/* 配置交叉编译器 */
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 OUTPUT_BUILD_DIR=$PWD/../build
mkdir -p ${OUTPUT_BUILD_DIR}

/* 默认配置文件 */
make ARCH=arm O="${OUTPUT_BUILD_DIR}" multi_v7_defconfig fragment*.config

2.3 编译内核

        编译模块好像要好久,可以不要编译

/* 编译uImage 设备树 */
make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040 O="${OUTPUT_BUILD_DIR}"

/* 编译模块 */
make ARCH=arm modules O="${OUTPUT_BUILD_DIR}"

/* 配置输出文件路径 */
make ARCH=arm INSTALL_MOD_PATH="${OUTPUT_BUILD_DIR}/install_artifact" modules_install O="${OUTPUT_BUILD_DIR}"
mkdir -p ${OUTPUT_BUILD_DIR}/install_artifact/boot/

/* 拷贝输出文件 */
cp ${OUTPUT_BUILD_DIR}/arch/arm/boot/uImage ${OUTPUT_BUILD_DIR}/install_artifact/boot/
cp ${OUTPUT_BUILD_DIR}/arch/arm/boot/dts/st*.dtb ${OUTPUT_BUILD_DIR}/install_artifact/boot/

        这时候去查看build/install_artifact目录下,有boot和lib两个文件夹,boot里有uImage和设备树,lib里是内核模块

三、移植

3.1 复制文件

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

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

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

3.2 修改头文件

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

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

3.3 修改电源

        首先找到&scmi_regu节点,全都干掉

// &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";
// 	};
// };

        去根节点下添加我们对电源的描述,找到v3v3_ao这个节点,把它删了,替换成我们的

	// v3v3_ao: v3v3-ao {
	// 	compatible = "regulator-fixed";
	// 	regulator-name = "v3v3_ao";
	// 	regulator-min-microvolt = <3300000>;
	// 	regulator-max-microvolt = <3300000>;
	// 	regulator-always-on;
	// };
vddcore: vddcore {
        compatible = "regulator-fixed";
        regulator-name = "vddcore";
        regulator-min-microvolt = <1250000>;
        regulator-max-microvolt = <1250000>;
        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;
    };

	v1v8_audio: regulator-v1v8_audio {
 		compatible = "regulator-fixed";
 		regulator-name = "v1v8_audio";
 		regulator-min-microvolt = <1800000>;
 		regulator-max-microvolt = <1800000>;
 		regulator-always-on;
 		regulator-boot-on;
	};

    v3v3_hdmi: regulator-v3v3-hdmi {
        compatible = "regulator-fixed";
        regulator-name = "v3v3_hdmi";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-always-on;
        regulator-boot-on;
    };

    v1v2_hdmi: regulator-v1v2-hdmi {
        compatible = "regulator-fixed";
        regulator-name = "v1v2_hdmi";
        regulator-min-microvolt = <1200000>;
        regulator-max-microvolt = <1200000>;
        regulator-always-on;
        regulator-boot-on;
    };

3.4 添加看门狗

        由于笔者前面移植u-boot、optee、TF-A哪里遗忘了一个iwdg2,正点原子使用的是iwdg2,而ST官方使用的是arm_wdt,如果前面用到了iwdg2,那就在这里添加上,如果没有则pass这一部分

&iwdg2 {
	timeout-sec = <32>;
	status = "okay";
};

3.5 修改网络

        找到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 {
	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.6 修改sdmmc

        找到sdmmc1和sdmmc2,修改成我们的

&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)>;
	st,neg-edge;
 	no-1-8-v;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	#address-cells = <1>;
	#size-cells = <0>;
	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>;
	keep-power-in-suspend;
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";
};

3.7 删掉其它

        如果根文件系统是在emmc里,只需要修改一个sdmmc2能用就行;如果根文件系统需要通过nfs挂载,那就需要修改eth1和eth2节点。而对于其他部分,USB、OTG、LCD等外设,都是可以删除的,这些都是正点原子会讲会移植的东西,所以笔者在这里把不需要的外设全部移除

1.        usbh_ehci、usbotg_hs、usbphyc、usbphyc_port0、usbphyc_port1

2.        usart1、 usart2、uart8

3.        timers3、timers4、timers8、timers14

4.        spi5

5.        rtc

6.        ltdc

7.        i2c1、i2c5

8.        dcmipp

9.        adc1

10.      根节点下:gpio-keys、leds、panel_backlight、panel_rgb、wake_up、wifi_pwrseq

        删除之后可以得到一个相对精简的设备树:

// 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> for STMicroelectronics.
 */

/dts-v1/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/regulator/st,stm32mp13-regulator.h>
#include <dt-bindings/rtc/rtc-stm32.h>
#include "stm32mp135.dtsi"
#include "stm32mp13xf.dtsi"
#include "stm32mp13-pinctrl-atk.dtsi"

/ {
	model = "ATK STM32MP135-ATK Discovery Board";
	compatible = "st,stm32mp135-ATK", "st,stm32mp135";

	aliases {
		ethernet0 = &eth1;
		ethernet1 = &eth2;
		serial0 = &uart4;
	};

	chosen {
		stdout-path = "serial0:115200n8";
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		framebuffer {
			compatible = "simple-framebuffer";
			clocks = <&rcc LTDC_PX>;
			status = "disabled";
		};
	};

	clocks {
		clk_ext_camera: clk-ext-camera {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <24000000>;
		};

		clk_mco1: clk-mco1 {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <24000000>;
		};
	};

	memory@c0000000 {
		device_type = "memory";
		reg = <0xc0000000 0x20000000>;
	};

	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		optee@dd000000 {
			reg = <0xdd000000 0x3000000>;
			no-map;
		};
	};

	vddcore: vddcore {
        compatible = "regulator-fixed";
        regulator-name = "vddcore";
        regulator-min-microvolt = <1250000>;
        regulator-max-microvolt = <1250000>;
        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;
    };

	v1v8_audio: regulator-v1v8_audio {
 		compatible = "regulator-fixed";
 		regulator-name = "v1v8_audio";
 		regulator-min-microvolt = <1800000>;
 		regulator-max-microvolt = <1800000>;
 		regulator-always-on;
 		regulator-boot-on;
	};

    v3v3_hdmi: regulator-v3v3-hdmi {
        compatible = "regulator-fixed";
        regulator-name = "v3v3_hdmi";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-always-on;
        regulator-boot-on;
    };

    v1v2_hdmi: regulator-v1v2-hdmi {
        compatible = "regulator-fixed";
        regulator-name = "v1v2_hdmi";
        regulator-min-microvolt = <1200000>;
        regulator-max-microvolt = <1200000>;
        regulator-always-on;
        regulator-boot-on;
    };
};

&iwdg2 {
	timeout-sec = <32>;
	status = "okay";
};

&arm_wdt {
	timeout-sec = <32>;
	status = "okay";
};

&crc1 {
	status = "okay";
};

&cryp {
	status = "okay";
};

&dts {
	status = "okay";
};

&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 {
	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>;
		};
	};
};



&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)>;
	st,neg-edge;
 	no-1-8-v;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	#address-cells = <1>;
	#size-cells = <0>;
	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>;
	keep-power-in-suspend;
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";
};

&uart4 {
	pinctrl-names = "default", "sleep", "idle";
	pinctrl-0 = <&uart4_pins_a>;
	pinctrl-1 = <&uart4_sleep_pins_a>;
	pinctrl-2 = <&uart4_idle_pins_a>;
	/delete-property/dmas;
	/delete-property/dma-names;
	status = "okay";
};



3.8 修改引脚

        由于前面删了很多无关外设,引脚我们只需要复制原子的部分即可:eth1、eth2、emmc1、emmc2

// 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 */
		};
	};

	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 */
		};
	};
};

3.9 修改Makefile

        在源码目录下arch/arm/boot/dts/这个目录里有一个Makefile,找到里面的stm32

dtb-$(CONFIG_ARCH_STM32) += \
	stm32f429-disco.dtb \
	stm32f469-disco.dtb \
	stm32f746-disco.dtb \
	stm32f769-disco.dtb \
	stm32429i-eval.dtb \
	stm32746g-eval.dtb \
	stm32h743i-eval.dtb \
	stm32h743i-disco.dtb \
	stm32h750i-art-pi.dtb \
	stm32mp135f-dk.dtb \
	stm32mp135f-dk-a7-examples.dtb \
	stm32mp151a-prtt1a.dtb \
	stm32mp151a-prtt1c.dtb \
	stm32mp151a-prtt1s.dtb \
	stm32mp153c-dhcom-drc02.dtb \
	stm32mp153c-dhcor-drc-compact.dtb \
	stm32mp157a-avenger96.dtb \
	stm32mp157a-dhcor-avenger96.dtb \
	stm32mp157a-dk1.dtb \
	stm32mp157a-dk1-a7-examples.dtb \
	stm32mp157a-dk1-m4-examples.dtb \
	stm32mp157a-ed1.dtb \
	stm32mp157a-ev1.dtb \
	stm32mp157a-ev1-a7-examples.dtb \
	stm32mp157a-ev1-m4-examples.dtb \
	stm32mp157a-iot-box.dtb \
	stm32mp157a-microgea-stm32mp1-microdev2.0.dtb \
	stm32mp157a-microgea-stm32mp1-microdev2.0-of7.dtb \
	stm32mp157a-icore-stm32mp1-ctouch2.dtb \
	stm32mp157a-icore-stm32mp1-ctouch2-of10.dtb \
	stm32mp157a-icore-stm32mp1-edimm2.2.dtb \
	stm32mp157a-stinger96.dtb \
	stm32mp157c-dhcom-pdk2.dtb \
	stm32mp157c-dhcom-picoitx.dtb \
	stm32mp157c-dk2.dtb \
	stm32mp157c-dk2-a7-examples.dtb \
	stm32mp157c-dk2-m4-examples.dtb \
	stm32mp157c-ed1.dtb \
	stm32mp157c-emsbc-argon.dtb \
	stm32mp157c-ev1.dtb \
	stm32mp157c-ev1-a7-examples.dtb \
	stm32mp157c-ev1-m4-examples.dtb \
	stm32mp157c-lxa-mc1.dtb \
	stm32mp157c-odyssey.dtb \
	stm32mp157d-dk1.dtb \
	stm32mp157d-dk1-a7-examples.dtb \
	stm32mp157d-dk1-m4-examples.dtb \
	stm32mp157d-ed1.dtb \
	stm32mp157d-ev1.dtb \
	stm32mp157d-ev1-a7-examples.dtb \
	stm32mp157d-ev1-m4-examples.dtb \
	stm32mp157f-dk2.dtb \
	stm32mp157f-dk2-a7-examples.dtb \
	stm32mp157f-dk2-m4-examples.dtb \
	stm32mp157f-ed1.dtb \
	stm32mp157f-ev1.dtb \
	stm32mp157f-ev1-a7-examples.dtb \
	stm32mp157f-ev1-m4-examples.dtb \

        添加上我们的设备树,或者全删了只留我们自己的设备树

dtb-$(CONFIG_ARCH_STM32) += \
	stm32mp135-atk.dtb

至此,内核所需要修改的文件已全部完成。

四、编译

4.1 配置内核

        在这里笔者遇到一个问题,内核编译后直接跑,会提示无法修改CPU主频,然后上网找到了需要配置内核:

/* 打开Linux图形化配置界面 */
make ARCH=arm O="${OUTPUT_BUILD_DIR}" menuconfig

->CPU Power Management

        ->CPU Frequency scaling

                ->[*]        CPU frequency transition statistics

                        ->        Default CPUFreq governor(userspace)

         把CPUFreq改为userspace这个选项

cp ../build/.config arch/arm/configs/stm32mp135_atk_defconfig

        把配置文件保存为我们的默认配置文件,以便下次使用

4.2 编译

/* 编译内核、设备树 */
make ARCH=arm uImage vmlinux dtbs LOADADDR=0xC2000040 O="${OUTPUT_BUILD_DIR}"

/* 复制文件到输出文件夹 */
cp ${OUTPUT_BUILD_DIR}/arch/arm/boot/uImage ${OUTPUT_BUILD_DIR}/install_artifact/boot/
cp ${OUTPUT_BUILD_DIR}/arch/arm/boot/dts/st*.dtb ${OUTPUT_BUILD_DIR}/install_artifact/boot/

        这时候查看build/install_artifact/boot文件夹,会发现有刚刚编译好的uImage和stm32mp135-atk.dtb,剩下的烧写就就可以根据原子的详细教程就行了

4.3 nfs挂载根文件系统

        这里可能有个小小的坑,在设备树中,ethernet0是eth1,ethernet1是eth2,所以用nfs挂根文件系统的时候,应该选eth0或eth1。反正大家可以多尝试几个。

        笔者用tftp和nfs启动内核:

setenv bootcmd 'tftp c2000000 uImage;tftp c4000000 stm32mp135-atk.dtb;bootm c2000000 - c4000000'
setenv bootargs 'console=ttySTM0,115200 root=/dev/nfs nfsroot=192.168.1.2:/home/zhangrl/Linux/nfs/rootfs,proto=tcp rw ip=192.168.1.3:192.168.1.2:192.168.1.1:255.255.255.0::eth1:off'

4.4 emmc挂根文件系统

        烧写到emmc中的时候,先去uboot里查看自己的内核在emmc的哪一个分区,rootfs在哪一个分区:

        使用ext4ls命令,对一个一个分区进行扫描,直到看到自己的分区(笔者只会这个笨方法)

        ext4ls:

        第一个参数mmc,设备,选择mmc设备

        第二个参数1,选择mmc1,就是我们的emmc

        第三个参数,选择分区,一个一个试

        知道自己的分区之后,就可以该bootcmd和bootargs:

setenv bootcmd  'ext4load mmc 1:6 c2000000 uImage;ext4load mmc 1:6 c4000000 stm32mp135-atk.dtb;bootm c2000000 - c4000000'
setenv bootargs 'console=ttySTM0,115200 root=/dev/mmcblk1p7 rootwait rw'

        至此,STM32MP135的全套移植教程完成,补上了正点原子的空白,剩下的根文件系统直接跟正点原子的教程即可,使用buildroot和busybox都可以。笔者今年刚学Linux,从i.mx6ull学完过来,对Linux的理解可能并不到位

        如果文章有错误,希望大家指正

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

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

相关文章

【算法|动态规划No.13】leetcode LCR 166. 珠宝的最高价值

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

HVDC-MMC互连(1000MW,±320KV)使用聚合MMC模型进行优化的SPS模拟

微❤关注“电气仔推送”获得资料&#xff08;专享优惠&#xff09; 模型概述&#xff1a; 本示例展示了一个SimPowerSystems&#xff08;SPS&#xff09;模型&#xff0c;使用基于模块化多电平变换器&#xff08;MMC&#xff09;技术的电压源换流器&#xff08;VSC&#xff09…

C++基础知识(四) -- 内联函数

概念 宏 提到内联函数就不得不提一下c语言里面的宏了&#xff0c;也可以说c的内联函数是从c语言里面的宏进化过来了的。 宏属于是暴力替换&#xff0c;过于生硬了&#xff0c;宏的缺点有如下 宏缺点&#xff1a; 1、不能调试 2、没有类型安全的检查 3、有些场景下非常复杂,容易…

数据结构之带头双向循环链表

目录 链表的分类 带头双向循环链表的实现 带头双向循环链表的结构 带头双向循环链表的结构示意图 空链表结构示意图 单结点链表结构示意图 多结点链表结构示意图 链表创建结点 双向链表初始化 销毁双向链表 打印双向链表 双向链表尾插 尾插函数测试 双向链表头插 …

《Spring Boot前世今生》

&#x1f337;&#x1f341; 博主猫头虎&#xff08;&#x1f405;&#x1f43e;&#xff09;带您 Go to New World✨&#x1f341; &#x1f984; 博客首页——&#x1f405;&#x1f43e;猫头虎的博客&#x1f390; &#x1f433; 《面试题大全专栏》 &#x1f995; 文章图文…

VMware Workstation Pro详解

零、文章目录 VMware Workstation Pro详解 1、虚拟机介绍 &#xff08;1&#xff09;介绍 VMware Workstation Pro 是行业标准桌面 Hypervisor&#xff0c;使用它可在 Windows 或 Linux 桌面上运行 Windows、Linux 和 BSD 虚拟机。VMware官网地址&#xff1a;https://www.v…

【Python】如何使用PyInstaller打包自己写好的代码

使用PyInstaller打包自己写好的代码 零、需求 最近接到一个小单&#xff0c;需要批量修改文档内容&#xff0c;用Python做好后要打包成exe程序给客户的Win7电脑使用&#xff0c;此时需要用到PyInstaller打包自己的代码&#xff0c;想到还要有给用户试用的需求&#xff0c;所以…

第六章 数字化工作方法与应用

第一节 题目 A C 第二节 题目 A C B D A 右侧原因型&#xff0c;在左侧是对策型。主要记得右侧是原因行就可以了。 C B D 字面意思。 ABCD CD

笔训【day3】

目录 选择题 1、二维数组初始化 2、[]优先级高于* ​编辑 3、for初始化只执行一次​编辑 4、大小端 编程题 1、字符串中找出最长连续数字串 2、数组中出现次数超过一半的数 选择题 1、二维数组初始化 C&#xff1a;多初始化了一行 D&#xff1a;不能中间用两个逗号跳过。…

外包做了3个月,技术退步明显。。。。。

先说一下自己的情况&#xff0c;大专生&#xff0c;17年通过校招进入广州某软件公司&#xff0c;干了接近4年的功能测试&#xff0c;今年年初&#xff0c;感觉自己不能够在这样下去了&#xff0c;长时间呆在一个舒适的环境会让一个人堕落!而我已经在一个企业干了四年的功能测试…

【群智能算法】光学显微镜算法 OMA算法【Matlab代码#59】

文章目录 【获取资源请见文章第4节&#xff1a;资源获取】1. 光学显微镜算法&#xff08;OMA&#xff09;1.1 物镜放大倍数1.2 目镜放大倍数 2. 部分代码展示3. 仿真结果展示4. 资源获取说明 【获取资源请见文章第4节&#xff1a;资源获取】 1. 光学显微镜算法&#xff08;OMA&…

win10睡眠快捷方式

新建快捷方式 如下图 内容如下 rundll32.exe powrprof.dll,SetSuspendState 0,1,0 下一步 点击完成即可。 特此记录 anlog 2023年10月6日

ssm+vue的培训机构运营管理系统(有报告)。Javaee项目,ssm vue前后端分离项目。

演示视频&#xff1a; ssmvue的培训机构运营管理系统&#xff08;有报告&#xff09;。Javaee项目&#xff0c;ssm vue前后端分离项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;三层体系结…

Linux工具(三)

继Linux工具&#xff08;一&#xff09;和Linux工具&#xff08;二&#xff09;&#xff0c;下面我们就来讲解Linux最后的两个工具&#xff0c;分别是代码托管的版本控制器git和代码调试器gdb。 目录 1.git-版本控制器 从0到1的实现git代码托管 检测并安装git 新建git仓库…

rk3588 香橙派 vncserver连接 图形界面远程登陆

直接使用windows远程连接失败 然后看有用vncserver 进行连接的方案 需要再rk3588板端执行&#xff1a; sudo apt-get install xfce4 sudo apt0get update vncserver vncpasswd配置vnc 密码。不配置只看密码 下载vncserver 后不会自动启动&#xff0c;不会启动 需要执行 vncse…

Spring基础以及核心概念(IoC和DI)

1.Spring是什么 Spring是包含了众多工具方法的IoC容器 2.loC&#xff08;Inversion of Control &#xff09;是什么 IoC:控制反转,Spring是一个控制反转容器(控制反转对象的生命周期) Spring是一个loC容器&#xff0c;我们之前学过的List/Map就是数据存储的容器&#xff0c;to…

【1.1】神经网络:关于神经网络的介绍

✅作者简介&#xff1a;大家好&#xff0c;我是 Meteors., 向往着更加简洁高效的代码写法与编程方式&#xff0c;持续分享Java技术内容。 &#x1f34e;个人主页&#xff1a;Meteors.的博客 &#x1f49e;当前专栏&#xff1a; 神经网络&#xff08;随缘更新&#xff09; ✨特色…

黑马点评-02使用Redis代替session,Redis + token机制实现

Redis代替session session共享问题 每个Tomcat中都有一份属于自己的session,所以多台Tomcat并不共享session存储空间,当请求切换到不同tomcat服务时可能会导致数据丢失 用户第一次访问1号tomcat并把自己的信息存放session域中, 如果第二次访问到了2号tomcat就无法获取到在1号…

7 航空公司客户价值分析

第7章 航空公司客户价值分析 7.1 了解航空公司现状与客户价值分析7.1.1 了解航空公司现状7.1.2 认识客户价值分析7.1.3 熟悉航空客户价值分析的步骤与流程 7.2 预处理航空客户数据7.2.1 处理数据缺失值与异常值7.2.2 构建航空客户价值分析的关键特征1. RFM模型介绍2. RFM模型结…

Golang--channel+waitGroup控制并发量

文章目录 channelwaitGroup控制并发量前言示例 channelwaitGroup控制并发量 前言 golang的goroutine非常轻量级&#xff0c;同时启动数万协程都没问题。如果不对并发量进行控制&#xff0c;比如同时产生数百万的协程&#xff0c;会压垮服务器通过控制channel缓冲区的大小&…