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

目录

一、概述

二、编译官方代码

三、移植

四、编译


一、概述

        前面已经移植好了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.rhkb.cn/news/152111.html

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

相关文章

【网络安全 ---- 靶场搭建】凡诺企业网站管理系统靶场详细搭建过程(asp网站,练习sql注入)

一&#xff0c;资源下载 百度网盘资源下载链接&#xff1a;百度网盘 请输入提取码百度网盘为您提供文件的网络备份、同步和分享服务。空间大、速度快、安全稳固&#xff0c;支持教育网加速&#xff0c;支持手机端。注册使用百度网盘即可享受免费存储空间https://pan.baidu.com…

jira+confluence安装

准备如下所有包&#xff1a; atlassian-agent.jar jdk-8u241-linux-x64.tar.gz atlassian-confluence-8.0.0-x64.bin atlassian-jira-software-9.4.0-x64.bin mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar mysql-connector-java-8.0.28.jar confluence-8.2.1破解 1.安装j…

wpf webBrowser控件 常用的函数和内存泄漏问题

介绍 WebBrowsers可以让我们在窗体中进行导航网页。 WebBrowser控件内部使用ie的引擎&#xff0c;因此使用WebBrowser我们必须安装ie浏览器&#xff08;windows默认安装的&#xff09;。 使用 直接在xmal中使用webBrowser控件 <WebBrowser x:Name"WebBrowser1"…

【用unity实现100个游戏之14】Unity2d做一个建造与防御类rts游戏

文章目录 前言素材新建项目放置物品放置不同物品类型资源管理管理和配置生成资源的信息绘制资源UI同步资源生成绘制地图&#xff0c;优化场景控制虚拟相机添加建筑物按钮UIUI上放置建筑问题修复添加点击事件选中效果箭头空物体效果建造跟随鼠标显示添加资源物体实现树叶的随风摇…

MySQL:主从复制-基础复制(6)

环境 主服务器 192.168.254.1 从服务器&#xff08;1&#xff09;192.168.254.2 从服务器&#xff08;2&#xff09;192.168.253.3 我在主服务器上执行的操作会同步至从服务器 主服务器 yum -y install ntp 我们去配置ntp是需要让从服务器和我们主服务器时间同步 sed -i /…

FFmpeg 命令:从入门到精通 | FFmpeg 解码流程

FFmpeg 命令&#xff1a;从入门到精通 | FFmpeg 解码流程 FFmpeg 命令&#xff1a;从入门到精通 | FFmpeg 解码流程流程图FFmpeg 解码的函数FFmpeg 解码的数据结构补充小知识 FFmpeg 命令&#xff1a;从入门到精通 | FFmpeg 解码流程 本内容参考雷霄骅博士的 FFmpeg 教程。 流…

用min-max容斥实现lcm与gcd互换

lcm本质是每个质因子质数取max&#xff0c;gcd是每个质因子质数取min 然后我们就可以直接套min-max容斥&#xff1a;

unity中绑定动画的行为系统

主要代码逻辑是创建一个action队列,当动画播放结束时就移除队头,执行后面的事件 public class Enemy : MonoBehaviour {public event Action E_AnimatorFin;//当动画播放完毕时public Action DefaultAction;//默认事件public Dictionary<Action, string> EventAnimator n…

Java版工程行业管理系统源码-专业的工程管理软件-提供一站式服务

项目背景 一、随着公司的快速发展&#xff0c;企业人员和经营规模不断壮大。为了提高工程管理效率、减轻劳动强度、提高信息处理速度和准确性&#xff0c;公司对内部工程管理的提升提出了更高的要求。 二、企业通过数字化转型&#xff0c;不仅有利于优化业务流程、提升经营管理…

2019年[海淀区赛 第2题] 阶乘

题目描述 n的阶乘定义为n!n*(n -1)* (n - 2)* ...* 1。n的双阶乘定义为n!!n*(n -2)* (n -4)* ...* 2或n!!n(n - 2)*(n - 4)* ...* 1取决于n的奇偶性&#xff0c;但是阶乘的增长速度太快了&#xff0c;所以我们现在只想知道n!和n!!末尾的的个数 输入格式 一个正整数n &#xff…

AI驱动的3D模型无缝纹理生成

创建无缝纹理一直是一个需要艺术技巧的劳动密集型过程。 然而&#xff0c;随着稳定扩散模型&#xff08;Stable Diffusion&#xff09;的出现&#xff0c;情况发生了变化。 通过将文本转换为逼真、无边界的图像&#xff0c;稳定扩散彻底改变了纹理创建&#xff0c;使其变得易于…

Axios、SASS学习笔记

目录 前言 一、Axios基础认识 1、简介 2、相关文档 3、基本配置 4、基础快捷使用 二、Axios封装 1、公共配置文件 2、细化每个接口的配置 3、使用并发送请求 三、SASS 1、简介 2、相关文档 3、使用前奏 4、使用变量 5、嵌套规则 6、父级选择器标识 & 前言…

Leetcode hot 100之二叉树

目录 (反)序列化二叉树&#xff08;str<->tree&#xff09;&#xff1a;前序 前序遍历&#xff08;迭代&#xff09;/路径 stack.length 入栈&#xff1a;中右左 出栈&#xff1a;中左右 中序遍历&#xff08;迭代&#xff09; cur||stack.length 后序遍历&#x…

计算机视觉处理的开源框架

计算机视觉是一门涉及图像和视频分析的领域&#xff0c;有许多开源的框架和库可用于构建计算机视觉应用程序。以下是一些常见的计算机视觉开源框架及其特点&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合…

一盏茶的功夫帮你彻底搞懂JavaScript异步编程从回调地狱到async/await

&#x1f3ac; 江城开朗的豌豆&#xff1a;个人主页 &#x1f525; 个人专栏 :《 VUE 》 《 javaScript 》 ⛺️ 生活的理想&#xff0c;就是为了理想的生活 ! 目录 &#x1f4d8; 1. 引言 &#x1f4d8; 2. 使用方法 &#x1f4d8; 3. 实现原理 &#x1f4d8; 4. 写到最后…

Android 自定义PopupWindow,实现下拉框

1、效果图 2、前言 1、页面由 MagicIndicator ViewPager2 Fragment 实现&#xff1b; 2、下拉框是基于WindowManager实现&#xff1b; 3、我使用PopupWindow实现下拉框时&#xff0c;发现一个问题&#xff0c;PopupWindow 在窗口显示的情况下&#xff0c;无法直接从外部修…

(c语言进阶)指针的进阶

一.字符指针 1.一般应用 &#xff08;1&#xff09;%c的应用 &#xff08;2&#xff09;%s的应用 字符指针没有权限通过解引用去改变指针指向的值 2.笔试题 题目&#xff1a;判断输出结果 int main() { const char* p1 "abcdef"; const char* p2 "…

无法向会话状态服务器发出会话状态请求。请确保 ASP.NET State Service (ASP.NET 状态服务)已启动,并且客户端端口与服务器端口相同

“/”应用程序中的服务器错误。 无法向会话状态服务器发出会话状态请求。请确保 ASP.NET State Service (ASP.NET 状态服务)已启动&#xff0c;并且客户端端口与服务器端口相同。如果服务器位于远程计算机上&#xff0c;请检查 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Se…

【云备份】

文章目录 [toc] 1 :peach:云备份的认识:peach:1.1 :apple:功能了解:apple:1.2 :apple:实现目标:apple:1.3 :apple:服务端程序负责功能:apple:1.4 :apple:服务端功能模块划分:apple:1.5 :apple:客户端程序负责功能:apple:1.6 :apple:客户端功能模块划分:apple: 2 :peach:环境搭建…

[VC++]圆形进度条

[VC]圆形进度条 源码开发环境&#xff1a;VC6.0 WIN10 64位下编译通过利用绘制饼图的原理&#xff0c;来制作的圆形进度条&#xff0c;可以显示百分比。软件运行截图如下&#xff1a; 附件源码下载(点击下载&#xff09;