Linux第51步_移植ST公司的linux内核第3步_添加修改设备树

1、设备树文件的路径

1)、创建linux中的设备树头文件

在"my_linux/linux-5.4.31/arch/arm/boot/dts/"目录中,以"stm32mp15xx-edx.dtsi"为蓝本,复制一份,并命名为 "stm32mp157d-atk.dtsi",这就是我们开发板的设备树头文件。

2)、创建linux中的设备树文件

在"my_linux/linux-5.4.31/arch/arm/boot/dts/"目录中,以"stm32mp157d-ed1.dts"为蓝本,复制一份,并命名为 "stm32mp157d-atk.dts",这就是我们开发板的设备树文件。

2、添加设备树

1)、打开终端

输入"ls回车"

输入"cd linux/回车",切换到"linux"目录

输入"ls回车",列出"linux"目录下的文件和文件夹

输入"cd atk-mp1/回车",切换到"atk-mp1"目录

输入"ls回车",列出"atk-mp1"目录下的文件和文件夹

输入"cd linux/回车",切换到"linux"目录

输入"ls回车",列出"linux"目录下的文件和文件夹

输入"cd my_linux/回车",切换到"my_linux"目录

输入"ls回车",列出"my_linux"目录下的文件和文件夹

输入"cd linux-5.4.31/回车",切换到"linux-5.4.31"目录

输入"ls回车",列出"linux-5.4.31"目录下的文件和文件夹

2)、输入"cd arch/回车",切换到"arch"目录

输入"ls回车",列出"arch"目录下的文件和文件夹

输入"cd arm/回车",切换到"arm"目录

输入"ls回车",列出"arm"目录下的文件和文件夹

输入"cd boot/回车",切换到"boot"目录

输入"ls回车",列出"boot"目录下的文件和文件夹

输入"cd dts/回车",切换到"dts"目录

输入"ls回车",列出"dts"目录下的文件和文件夹

发现ST公司开发板的设备树头文件"stm32mp15xx-edx.dtsi"

3)、输入"cp stm32mp15xx-edx.dtsi stm32mp157d-atk.dtsi回车",以"stm32mp15xx-edx.dtsi"为蓝本,复制一份,并命名为 "stm32mp157d-atk.dtsi"

输入"ls stm32mp157d-at*回车"

输入"cp stm32mp157d-ed1.dts stm32mp157d-atk.dts回车",以"stm32mp157c-ed1.dts"为蓝本,复制一份,并命名为 "stm32mp157d-atk.dts"

输入"ls stm32mp157d-at*回车"

至此,设备树文件和头文件添加成功。

5、修改设备树文件"stm32mp157d-atk.dts"

1)、使用VSCode打开"linux-5.4.31.code-workspace",然后点击"arch",点击"arm",点击"boot",点击"dts",找到"stm32mp157d-atk.dts",见下图:

2)、将"stm32mp15xx-edx.dtsi"修改为"stm32mp157d-atk.dtsi",

见下图:

6、修改设备树头文件"stm32mp157d-atk.dtsi"

1)、使用VSCode打开"linux-5.4.31.code-workspace"

点击"转到",点击"转到文件",在搜索框中,输入"stm32mp157d-atk.dtsi"就可打开搜索到的文件;

见下图:

文件打开如下:

2)、添加头文件,内容如下:

#include "stm32mp157-m4-srm.dtsi"

#include "stm32mp157-m4-srm-pinctrl.dtsi"

见下图

3)、删除下面的"led"节点和"sd_switch"节点,见下图:

删除后,文件如下:

4)、删除下面的"vin"节点,见下图:

删除后,文件如下:

5)、在59行开始处,添加"vddcore"和"v3v3"

vddcore: buck1 {

compatible = "regulator-fixed";

regulator-name = "vddcore";

regulator-min-microvolt = <1200000>;

regulator-max-microvolt = <1350000>;

regulator-always-on;

regulator-boot-on;

};

v3v3: regulator-3p3v {

compatible = "regulator-fixed";

regulator-name = "v3v3";

regulator-min-microvolt = <3300000>;

regulator-max-microvolt = <3300000>;

regulator-always-on;

regulator-boot-on;

};

见下图:

6)、删除adc节点,见下图:

删除后,文件如下:

7)、删除dac节点

删除后文件如下:

8)、添加"ethernet0"节点

ðernet0 {

status = "okay";

pinctrl-0 = <ðernet0_rgmii_pins_a>;

pinctrl-1 = <ðernet0_rgmii_pins_sleep_a>;

pinctrl-names = "default", "sleep";

phy-mode = "rgmii-id";

max-speed = <1000>;

phy-handle = <&phy0>;

mdio0 {

#address-cells = <1>;

#size-cells = <0>;

compatible = "snps,dwmac-mdio";

phy0: ethernet-phy@0 {

reg = <0>;

};

};

};

添加"ethernet0"节点后,见下图:

9)、删除"i2c4"节点,删除后见下图:

10)、删除"m4_rproc"和"pwr_regulators",见下图:

删除后,见下图:

11)、使用下面的内容替换sdmmc1节点

&sdmmc1 {

pinctrl-names = "default", "opendrain", "sleep";

pinctrl-0 = <&sdmmc1_b4_pins_a>;

pinctrl-1 = <&sdmmc1_b4_od_pins_a>;

pinctrl-2 = <&sdmmc1_b4_sleep_pins_a>;

broken-cd;

st,neg-edge;

bus-width = <4>;

vmmc-supply = <&v3v3>;

status = "okay";

};

替换sdmmc1节点后,见下图:

12)、使用下面的内容替换"sdmmc2"

&sdmmc2 {

pinctrl-names = "default", "opendrain", "sleep";

pinctrl-0 = <&sdmmc2_b4_pins_a>;

pinctrl-1 = <&sdmmc2_b4_od_pins_a>;

pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;

non-removable;

st,neg-edge;

bus-width = <8>;

vmmc-supply = <&v3v3>;

keep-power-in-suspend;

status = "okay";

};

替换后,见下图:

13)、删除"timers6"节点

删除"timers6"节点后,见下图:

14)、删除"usbotg_hs","usbphyc_port0"和"usbphyc_port1"

/* Copyright (C) STMicroelectronics 2017 - All Rights Reserved

* Author: Ludovic Barre <ludovic.barre@st.com> for STMicroelectronics.

*/

#include "stm32mp157-m4-srm.dtsi"

#include "stm32mp157-m4-srm-pinctrl.dtsi"

#include <dt-bindings/gpio/gpio.h>

#include <dt-bindings/mfd/st,stpmic1.h>

/ {

memory@c0000000 {

device_type = "memory";

reg = <0xC0000000 0x40000000>;

};

reserved-memory {

#address-cells = <1>;

#size-cells = <1>;

ranges;

mcuram2: mcuram2@10000000 {

compatible = "shared-dma-pool";

reg = <0x10000000 0x40000>;

no-map;

};

vdev0vring0: vdev0vring0@10040000 {

compatible = "shared-dma-pool";

reg = <0x10040000 0x1000>;

no-map;

};

vdev0vring1: vdev0vring1@10041000 {

compatible = "shared-dma-pool";

reg = <0x10041000 0x1000>;

no-map;

};

vdev0buffer: vdev0buffer@10042000 {

compatible = "shared-dma-pool";

reg = <0x10042000 0x4000>;

no-map;

};

mcuram: mcuram@30000000 {

compatible = "shared-dma-pool";

reg = <0x30000000 0x40000>;

no-map;

};

retram: retram@38000000 {

compatible = "shared-dma-pool";

reg = <0x38000000 0x10000>;

no-map;

};

};

vddcore: buck1 {

compatible = "regulator-fixed";

regulator-name = "vddcore";

regulator-min-microvolt = <1200000>;

regulator-max-microvolt = <1350000>;

regulator-always-on;

regulator-boot-on;

};

v3v3: regulator-3p3v {

compatible = "regulator-fixed";

regulator-name = "v3v3";

regulator-min-microvolt = <3300000>;

regulator-max-microvolt = <3300000>;

regulator-always-on;

regulator-boot-on;

};

};

&cpu0{

cpu-supply = <&vddcore>;

};

&crc1 {

status = "okay";

};

&dma1 {

sram = <&dma_pool>;

};

&dma2 {

sram = <&dma_pool>;

};

&dts {

status = "okay";

};

ðernet0 {

status = "okay";

pinctrl-0 = <ðernet0_rgmii_pins_a>;

pinctrl-1 = <ðernet0_rgmii_pins_sleep_a>;

pinctrl-names = "default", "sleep";

phy-mode = "rgmii-id";

max-speed = <1000>;

phy-handle = <&phy0>;

mdio0 {

#address-cells = <1>;

#size-cells = <0>;

compatible = "snps,dwmac-mdio";

phy0: ethernet-phy@0 {

reg = <0>;

};

};

};

&hash1 {

status = "okay";

};

&ipcc {

status = "okay";

};

&iwdg2 {

timeout-sec = <32>;

status = "okay";

};

&rng1 {

status = "okay";

};

&rtc {

status = "okay";

};

&sdmmc1 {

pinctrl-names = "default", "opendrain", "sleep";

pinctrl-0 = <&sdmmc1_b4_pins_a>;

pinctrl-1 = <&sdmmc1_b4_od_pins_a>;

pinctrl-2 = <&sdmmc1_b4_sleep_pins_a>;

broken-cd;

st,neg-edge;

bus-width = <4>;

vmmc-supply = <&v3v3>;

status = "okay";

};

&sdmmc2 {

pinctrl-names = "default", "opendrain", "sleep";

pinctrl-0 = <&sdmmc2_b4_pins_a>;

pinctrl-1 = <&sdmmc2_b4_od_pins_a>;

pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;

non-removable;

st,neg-edge;

bus-width = <8>;

vmmc-supply = <&v3v3>;

keep-power-in-suspend;

status = "okay";

};

&sram {

dma_pool: dma_pool@0 {

reg = <0x50000 0x10000>;

pool;

};

};

&uart4 {

pinctrl-names = "default", "sleep", "idle";

pinctrl-0 = <&uart4_pins_a>;

pinctrl-1 = <&uart4_sleep_pins_a>;

pinctrl-2 = <&uart4_idle_pins_a>;

pinctrl-3 = <&uart4_pins_a>;

/delete-property/dmas;

/delete-property/dma-names;

status = "okay";

};

7、修改"arch/arm/boot/dts/"目录中的"Makefile"

1)、打开"arch/arm/boot/dts/Makefile",找到"dtb-$(CONFIG_ARCH_STM32)"配置项。

2)、添加配置项"stmm32mp157d-atk.dtb",修改后,见下图:

3)、保存"arch/arm/boot/dts/"目录中的"Makefile"。

相关推荐
zy张起灵28 分钟前
48v72v-100v转12v 10A大功率转换电源方案CSM3100SK
经验分享·嵌入式硬件·硬件工程
sinat_384241093 小时前
使用 npm 安装 Electron 作为开发依赖
服务器
朝九晚五ฺ3 小时前
【Linux探索学习】第十四弹——进程优先级:深入理解操作系统中的进程优先级
linux·运维·学习
自由的dream3 小时前
Linux的桌面
linux
xiaozhiwise4 小时前
Makefile 之 自动化变量
linux
Kkooe4 小时前
GitLab|数据迁移
运维·服务器·git
猫爪笔记5 小时前
前端:HTML (学习笔记)【1】
前端·笔记·学习·html
pq113_65 小时前
ftdi_sio应用学习笔记 3 - GPIO
笔记·学习·ftdi_sio
澄澈i6 小时前
设计模式学习[8]---原型模式
学习·设计模式·原型模式