(六)正点原子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.mzph.cn/news/95989.shtml

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

相关文章

【Go语言实战】(25) 分布式算法 MapReduce

MapReduce 写在前面 身为大数据专业的学生&#xff0c;其实大学我也多多少少接触过mapreduce&#xff0c;但是当时觉得这玩意太老了&#xff0c;觉得这和php一样会被时代淘汰。只能说当时确实太年轻了&#xff0c;没有好好珍惜那时候的学习资源… 现在回过头来看mapreduce&a…

想做好接口测试,先把这些概念搞清楚了

接口一般来说有两种&#xff0c;一种是程序内部的接口&#xff0c;一种是系统对外的接口。 系统对外的接口 比如你要从别的网站或服务器上获取资源或信息&#xff0c;别人肯定不会把数据库共享给你&#xff0c;他只能给你提供一个他们写好的方法来获取数据&#xff0c;你引用…

【BBC新闻文章分类】使用 TF 2.0和 LSTM 的文本分类

一、说明 NLP上的许多创新是如何将上下文添加到词向量中。常见的方法之一是使用递归神经网络

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

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

如何选择合适的自动化测试工具?

自动化测试是高质量软件交付领域中最重要的实践之一。在今天的敏捷开发方法中&#xff0c;几乎任一软件开发过程都需要在开发阶段的某个时候进行自动化测试&#xff0c;以加速回归测试的工作。自动化测试工具可以帮助测试人员以及整个团队专注于自动化工具无法处理的各自任务&a…

【数据结构---排序】很详细的哦

本篇文章介绍数据结构中的几种排序哦~ 文章目录 前言一、排序是什么&#xff1f;二、排序的分类 1.直接插入排序2.希尔排序3.选择排序4.冒泡排序5.快速排序6.归并排序总结 前言 排序在我们的生活当中无处不在&#xff0c;当然&#xff0c;它在计算机程序当中也是一种很重要的操…

关掉在vscode使用copilot时的提示音

1. 按照图示的操作File --> Preferences --> Settings 2. 搜索框输入关键字Sound&#xff0c;因为是要关掉声音&#xff0c;所以找有关声音的设置 3. 找到如下图所示的选项 Audio Cues:Line Has Inline Suggetion,将其设置为Off 这样&#xff0c;就可以关掉suggest code时…

Elasticsearch:什么时候应该考虑在 Elasticsearch 中添加协调节点?

仅协调节点&#xff08;coordinating only nodes&#xff09;充当智能负载均衡器。 仅协调节点的这种特殊角色通过减轻数据和主节点的协调责任&#xff0c;为广泛的集群提供了优势。 加入集群后&#xff0c;这些节点与任何其他节点类似&#xff0c;都会获取完整的集群状态&…

毕业设计选题之Android基于移动端的线上订餐app外卖点餐安卓系统源码 调试 开题 lw

&#x1f495;&#x1f495;作者&#xff1a;计算机源码社 &#x1f495;&#x1f495;个人简介&#xff1a;本人七年开发经验&#xff0c;擅长Java、Python、PHP、.NET、微信小程序、爬虫、大数据等&#xff0c;大家有这一块的问题可以一起交流&#xff01; &#x1f495;&…

C# - Opencv应用(1) 之VS下环境配置详解

C# - Opencv应用&#xff08;1&#xff09; 之VS下环境配置详解 有时候&#xff0c;单纯c#做前端时会联合C实现的dll来落地某些功能由于有时候会用C - Opencv实现算法后封装成dll&#xff0c;但是有时候会感觉麻烦&#xff0c;不如直接通过C#直接调用Opencv在此慢慢总结下C# -…

SpringBoot vue云办公系统

SpringBoot vue云办公系统 系统功能 云办公系统 登录 员工资料管理: 搜索员工 添加编辑删除员工 导入导出excel 薪资管理: 工资账套管理 添加编辑删除工资账套 员工账套设置 系统管理: 基础信息设置 部门管理 职位管理 职称管理 权限组管理 操作员管理 开发环境和技术 开发语…

选择适合户外篷房企业的企业云盘解决方案

“户外篷房企业用什么企业云盘好&#xff1f;Zoho WorkDrive企业网盘可以帮助户外篷房企业实现文档统一管理、提高工作效率、加强团队协作&#xff0c;并且支持各种文件类型的预览和编辑。” S公司是一家注重管理规范的大型户外篷房企业&#xff0c;已经有10余年的经验。作为设…

string和const char*参数类型选择的合理性对比

在编程中&#xff0c;我们经常需要处理字符串类型的参数。在C中&#xff0c;有两种常见的表示字符串的参数类型&#xff0c;即string和const char*。本文将对比这两种参数类型的特点&#xff0c;分析其在不同情况下的合理性&#xff0c;以便程序员能够根据实际需求做出正确的选…

Docker安装ActiveMQ

ActiveMQ简介 官网地址&#xff1a;https://activemq.apache.org/ 简介&#xff1a; ActiveMQ 是Apache出品&#xff0c;最流行的&#xff0c;能力强劲的开源消息总线。ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现,尽管JMS规范出台已经是很久的事情了,…

次方计数的拆贡献法(考虑组合意义)+限定类问题善用值域与位置进行ds:1006T3

对于多次方的计数问题可以考虑拆贡献。 题目问 ∣ S ∣ 3 |S|^3 ∣S∣3&#xff0c; ∣ S ∣ |S| ∣S∣ 表示选的点数。相当于在 ∣ S ∣ |S| ∣S∣ 中选了3次&#xff0c;也就是选了3个可相同的点。 先考虑3个不相同点的贡献&#xff0c;对应任意3个点&#xff0c;必然会对…

【小工具-生成合并文件】使用python实现2个excel文件根据主键合并生成csv文件

1 小工具说明 1.1 功能说明 一般来说&#xff0c;我们会先有一个老的文件&#xff0c;这个文件内容是定制好相关列的表格&#xff0c;作为每天的报告。 当下一天来的时候&#xff0c;需要根据新的报表文件和昨天的报表文件做一个合并&#xff0c;合并的时候就会出现有些事新增…

【BI看板】Superset2.0+图表二次开发初探

Superset图表功能也很丰富了&#xff0c;但一些个性化的定制需求就需要二次开发了。网上二开的superset版本大多是0.xxx版本的或1.5xxx版本&#xff0c;本次用的是2.xxx。 源码相关说明 源码目录 superset-2.0\superset-frontend\plugins\plugin-chart-echarts 插件相关资料 官…

【重拾C语言】六、批量数据组织(二)线性表——分类与检索(主元排序、冒泡排序、插入排序、顺序检索、对半检索)

目录 前言 六、批量数据组织——数组 6.4 线性表——分类与检索 6.4.1 主元排序 6.4.2 冒泡排序 6.4.3 插入排序 6.4.4 顺序检索&#xff08;线性搜索&#xff09; 6.4.5 对半检索&#xff08;二分查找&#xff09; 算法比较 前言 线性表是一种常见的数据结构&#xf…

在linux下预览markdown的方法,转换成html和pdf

背景 markdown是一种便于编写和版本控制的格式&#xff0c;但却不便于预览——特别是包含表格等复杂内容时&#xff0c;单纯的语法高亮是远远不够的——这样就不能边预览边调整内容&#xff0c;需要找到一种预览方法。 思路 linux下有个工具&#xff0c;叫pandoc&#xff0c…

Go Gin Gorm Casbin权限管理实现 - 2. 使用Gorm存储Casbin权限配置以及`增删改查`

文章目录 0. 背景1. 准备工作2. 权限配置以及增删改查2.1 策略和组使用规范2.2 用户以及组关系的增删改查2.2.1 获取所有用户以及关联的角色2.2.2 角色组中添加用户2.2.3 角色组中删除用户 2.3 角色组权限的增删改查2.3.1 获取所有角色组权限2.3.2 创建角色组权限2.3.3 修改角色…