新聞中心

EEPW首頁(yè) > 設(shè)計(jì)應(yīng)用 > 米爾STM32MP25x開(kāi)發(fā)板Bring Up培訓(xùn)課程(二)

米爾STM32MP25x開(kāi)發(fā)板Bring Up培訓(xùn)課程(二)

作者: 時(shí)間:2025-02-28 來(lái)源:EEPW 收藏

2.2.配置與編譯Optee-OS

本文引用地址:http://m.butianyuan.cn/article/202502/467457.htm

現(xiàn)在進(jìn)行OP-TEE的配置編譯,首先需要在設(shè)備樹(shù)中添加串口 UART 以及 PWR 相關(guān)的配置:

串口部分配置:

在之前 STM32CubeMX 配置串口的過(guò)程中,UART 的配置是沒(méi)辦法在 OP-TEE 中使能的,也就是說(shuō) OP-TEE 的設(shè)備樹(shù)中沒(méi)有任何關(guān)于串口的配置,包括 UART 節(jié)點(diǎn)以及引腳,這些都需 要我們手動(dòng)添加上去:

(BringupCA35DeviceTreeBringupoptee-osstm32mp257d-bringup-mx.dts)

/* USER CODE BEGIN includes */

#include "stm32mp25-pinctrl.dtsi"

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

#include <dt-bindings/regulator/st,stm32mp25-regulator.h>

#include <dt-bindings/reset/stm32mp25-resets.h>

#include <dt-bindings/soc/stm32mp-provisioning.h>

#include <dt-bindings/tamper/st,stm32mp25-tamp.h>

#include "stm32mp25xf.dtsi"

/* USER CODE END includes */

/* USER CODE BEGIN root */

aliases {

             serial0 = &usart2;

};

chosen {

             stdout-path = "serial0:115200n8";

 };

shadow-prov {

             compatible = "st,provisioning";

             hconf1_prov {

                    nvmem-cells = <&hconf1_otp>;

                    st,shadow-value = <0x00008DB6>;

            };

 };

/* USER CODE END root */

&rcc{

        status = "okay";

        /* USER CODE BEGIN rcc */

        st,c1msrd = <2>;

        st,clk_opp {

                st,ck_cpu1 {

                        cfg_1 {

                                hz = <1000000000>;

                                st,clksrc = <0>;

                                st,pll = <&pll1_cfg_1000Mhz>;

                        };

                        cfg_2 {

                                hz = <600000000>;

                                st,clksrc = <0>;

                                st,pll = <&pll2_cfg_600Mhz>;

                        };

                };

        };

        /* USER CODE END rcc */

};

添加pin腳定義

/* USER CODE BEGIN addons */

&usart2 {

        pinctrl-names = "default";

        pinctrl-0 = <&usart2_pins_a>;

        status = "okay";

};

/* USER CODE BEGIN addons */

使用是 PMIC,那么 VDD_CPU 的配置需要包含在 PMIC 中,所以同樣的建議 copy tf-a里的配置,增加到I2C7的設(shè)備樹(shù)里。

&i2c7{

             status = "okay";

             /* USER CODE BEGIN i2c7 */

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

        pinctrl-0 = <&i2c7_pins_a>;

        pinctrl-1 = <&i2c7_sleep_pins_a>;

        i2c-scl-rising-time-ns = <185>;

        i2c-scl-falling-time-ns = <20>;

        clock-frequency = <400000>;

        #address-cells = <1>;

        #size-cells = <0>;

             pmic2: stpmic2@33 {

                  compatible = "st,stpmic2";

                  reg = <0x33>;

                  st,wakeup-pin-number = <1>;

                  st,pmic-it-id = <IT_PKEY_FA IT_PKEY_RI>;

                  st,notif-it-id = <0 1>;

                  status = "okay";

                   regulators {

                     compatible = "st,stpmic2-regulators";

                     ldo1-supply = <&vddio_pmic>;

                     vddcpu: buck1 {

                            regulator-name = "vddcpu";

                            regulator-min-microvolt = <800000>;

                            regulator-max-microvolt = <910000>;

                            regulator-always-on;

                            st,pwrctrl-sel = <2>;

                            st,pwrctrl-enable;

                            default {

                                   regulator-off-in-suspend;

                            };

                            lplv {

                                   regulator-off-in-suspend;

                            };

                            standby {

                                   regulator-off-in-suspend;

                            };

                            off {

                                   regulator-off-in-suspend;

                            };

                     };

                     vddcore: buck2 {

                            regulator-name = "vddcore";

                            regulator-min-microvolt = <820000>;

                            regulator-max-microvolt = <820000>;

                            regulator-always-on;

                            st,pwrctrl-sel = <1>;

                            st,pwrctrl-enable;

 

                            default {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <820000>;

                            };

                            lplv {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <670000>;

                            };

                            standby {

                                   regulator-off-in-suspend;

                            };

                            off {

                                   regulator-off-in-suspend;

                            };

                     };

                     vddgpu_pmic: buck3 {

                            regulator-name = "vddgpu_pmic";

                            regulator-min-microvolt = <800000>;

                            regulator-max-microvolt = <900000>;

                            regulator-over-current-protection;

                     };

                     vddio_pmic: buck4 {

                            regulator-name = "vddio_pmic";

                            regulator-min-microvolt = <3300000>;

                            regulator-max-microvolt = <3300000>;

                            regulator-always-on;

                            st,mask-reset;

                            st,pwrctrl-sel = <1>;

                            st,pwrctrl-enable;

                            default {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <3300000>;

                            };

                            lplv {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <3300000>;

                            };

                            standby {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <3300000>;

                            };

                            off {

                                   /* ToDo: switch to LP */

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <3300000>;

                            };

                     };

                     v1v8: buck5 {

                            regulator-name = "v1v8";

                            regulator-min-microvolt = <1800000>;

                            regulator-max-microvolt = <1800000>;

                            regulator-always-on;

                            st,pwrctrl-sel = <1>;

                            st,pwrctrl-enable;

                            default {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1800000>;

                            };

                            lplv {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1800000>;

                            };

                            standby {

                                   regulator-off-in-suspend;

                            };

                            off {

                                   regulator-off-in-suspend;

                            };

                     };

                     vdd2_ddr: buck6 {

                            regulator-name = "vdd2_ddr";

                            regulator-min-microvolt = <1100000>;

                            regulator-max-microvolt = <1100000>;

                            regulator-always-on;

                            //regulator-pull-down;

                            st,pwrctrl-sel = <1>;

                            st,pwrctrl-enable;

                            default {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1100000>;

                            };

                            lplv {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1100000>;

                            };

                            standby {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1100000>;

                            };

                            off {

                                   regulator-off-in-suspend;

                            };

                     };

                     v3v3: buck7 {

                            regulator-name = "v3v3";

                            regulator-min-microvolt = <3300000>;

                            regulator-max-microvolt = <3300000>;

                            regulator-always-on;

                            regulator-over-current-protection;

                            st,pwrctrl-sel = <1>;

                            st,pwrctrl-enable;

                            default {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <3300000>;

                            };

                            lplv {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <3300000>;

                            };

                            standby {

                                   regulator-off-in-suspend;

                            };

                            off {

                                   regulator-off-in-suspend;

                            };

                     };

                     vdda1v8_aon: ldo1 {

                            regulator-name = "vdda1v8_aon";

                            regulator-min-microvolt = <1800000>;

                            regulator-max-microvolt = <1800000>;

                            regulator-always-on;

                            st,alternate-input-source;

                            st,mask-reset;

                     };

                     vdd_emmc: ldo2 {

                            regulator-name = "vdd_emmc";

                            regulator-min-microvolt = <3300000>;

                            regulator-max-microvolt = <3300000>;

                            regulator-over-current-protection;

                            st,pwrctrl-sel = <3>;

                            st,pwrctrl-reset;

                     };

                     vdd1_ddr: ldo3 {

                            regulator-name = "vdd1_ddr";

                            regulator-min-microvolt = <1800000>;

                            regulator-max-microvolt = <1800000>;

                            regulator-always-on;

                            st,pwrctrl-sel = <1>;

                            st,pwrctrl-enable;

                            default {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1800000>;

                            };

                            lplv {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1800000>;

                            };

                            standby {

                                   regulator-on-in-suspend;

                                   regulator-suspend-microvolt = <1800000>;

                            };

                            off {

                                   regulator-off-in-suspend;

                            };

                     };

                     vdd3v3_usb: ldo4 {

                            regulator-name = "vdd3v3_usb";

                            regulator-min-microvolt = <3300000>;

                            regulator-max-microvolt = <3300000>;

                            regulator-always-on;

                            regulator-over-current-protection;

                     };

                     v5v_hdmi: ldo5 {

                            regulator-name = "v5v_hdmi";

                            regulator-min-microvolt = <5000000>;

                            regulator-max-microvolt = <5000000>;

                            st,regulator-bypass-microvolt = <5000000>;

                            st,pwrctrl-sel = <0>;

                            st,pwrctrl-enable;

                     };

                     v5v_vconn: ldo6 {

                            regulator-name = "v5v_vconn";

                            regulator-min-microvolt = <5000000>;

                            regulator-max-microvolt = <5000000>;

                            regulator-always-on;

                            st,regulator-bypass-microvolt = <5000000>;

                            st,pwrctrl-sel = <0>;

                            st,pwrctrl-reset;

                     };

                     vdd_sdcard: ldo7 {

                            regulator-name = "vdd_sdcard";

                            regulator-min-microvolt = <3300000>;

                            regulator-max-microvolt = <3300000>;

                            regulator-over-current-protection;

                            st,regulator-bypass-microvolt = <3300000>;

                            st,pwrctrl-sel = <3>;

                            st,pwrctrl-reset;

                     };

                     vddio_sdcard: ldo8 {

                            regulator-name = "vddio_sdcard";

                            regulator-min-microvolt = <3300000>;

                            regulator-max-microvolt = <3300000>;

                            regulator-over-current-protection;

                            st,regulator-bypass-microvolt = <3300000>;

                            st,pwrctrl-sel = <3>;

                            st,pwrctrl-reset;

                     };

                     vref_ddr: refddr {

                            regulator-name = "vref_ddr";

                            regulator-always-on;

                            st,pwrctrl-sel = <1>;

                            st,pwrctrl-enable;

                            default {

                                   regulator-on-in-suspend;

                            };

                            lplv {

                                   regulator-on-in-suspend;

                            };

                            standby {

                                   regulator-on-in-suspend;

                            };

                            off {

                                   regulator-off-in-suspend;

                            };

                     };

              };

             };

};

             /* USER CODE END i2c7 */

};

增加CPU電源配置

/* USER CODE BEGIN addons */

&pwr {

             pinctrl-names = "default";

             pinctrl-0 = <&wakeup_pins>;

             status = "okay";

             vdd33ucpd: vdd33ucpd {

              status = "okay";

              regulator-min-microvolt = <3300000>;

              regulator-max-microvolt = <3300000>;

              vdd33ucpd-supply = <&vdd3v3_usb>;

              regulator-always-on;

             };

             vdda18adc: vdda18adc {

              status = "okay";

              regulator-min-microvolt = <1800000>;

              regulator-max-microvolt = <1800000>;

              vdda18adc-supply = <&v1v8>;

              regulator-always-on;

             };

             vddgpu: vddgpu {

              status = "okay";

              vddgpu-supply = <&vddgpu_pmic>;

             };

             vddio1: vddio1 {

              status = "okay";

              regulator-min-microvolt = <3300000>;

              regulator-max-microvolt = <3300000>;

              vddio1-supply = <&vddio_sdcard>;

             };

             vddio2: vddio2 {

              status = "okay";

              vddio2-supply = <&v1v8>;

              regulator-always-on;

             };

             vddio3: vddio3 {

              status = "okay";

              vddio3-supply = <&vddio_pmic>;

              regulator-always-on;

             };

             vddio4: vddio4 {

              status = "okay";

              vddio4-supply = <&vddio_pmic>;

              regulator-always-on;

             };

             vddio: vddio {

              status = "okay";

              vdd-supply = <&vddio_pmic>;

             };

};

&cpu0 {

        cpu-supply = <&vddcpu>;

};

&scmi_regu {

             scmi_vddcore: voltd-vddcore {

              reg = <VOLTD_SCMI_STPMIC2_BUCK2>;

              voltd-supply = <&vddcore>;

             };

             scmi_v1v8: voltd-v1v8 {

              reg = <VOLTD_SCMI_STPMIC2_BUCK5>;

              voltd-supply = <&v1v8>;

             };

             scmi_v3v3: voltd-v3v3 {

              reg = <VOLTD_SCMI_STPMIC2_BUCK7>;

              voltd-supply = <&v3v3>;

             };

             scmi_vdd_emmc: voltd-vdd-emmc {

              reg = <VOLTD_SCMI_STPMIC2_LDO2>;

              voltd-supply = <&vdd_emmc>;

             };

             scmi_vdd3v3_usb: voltd-vdd3v3-usb {

              reg = <VOLTD_SCMI_STPMIC2_LDO4>;

              voltd-supply = <&vdd3v3_usb>;

             };

             scmi_vdd_sdcard: voltd-vdd_sdcard {

              reg = <VOLTD_SCMI_STPMIC2_LDO7>;

              voltd-supply = <&vdd_sdcard>;

             };

};

/* USER CODE END addons */

/* USER CODE BEGIN addons */

&risaf2 {

             status = "disabled";

};

&risaf5 {

             status = "disabled";

};

&rtc {

             status = "okay";

};

&tamp {

        wakeup-source;

        wakeup-parent = <&exti2>;

        st,tamp-passive-precharge = <2>;

        st,tamp-passive-nb-sample = <4>;

        st,tamp-passive-sample-clk-div = <16384>;

        /* Tamper button */

        tamp_button: tamp-passive@1 {

                status = "disabled";

                reg = <EXT_TAMPER_1 0>;

                pinctrl-0 = <&tamp_in1_pin_a>;

                st,tamp-mode = <TAMPER_POTENTIAL_MODE>;

        };

};

/* USER CODE END addons */

在上一章節(jié)中提到stm32mp257d-bringup-mx-resmem.dtsi 和 stm32mp257d-bringup-mx-rif.dtsi 直接使用 SourceCode 壓縮包 Optee-os 目錄中的文件,如果還未拷貝,需要將其通過(guò)軟鏈接或者拷貝的方式放到stm32mp25x-BringUp-bsp/myir-st-optee/myir-st-optee/core/arch/arm/dts/目錄下。

編譯 Optee

myir@myir-vm: cd /home/myir/stm32mp25x-BringUp-bsp/myir-st-optee/myir-st-optee

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-optee/myir-st-optee$ source /opt/st/myd-ld25x/4.2.4-snapshot/environment-setup-cortexa35-ostl-linux

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-optee/myir-st-optee$ export FIP_DEPLOYDIR_ROOT=../../FIP_artifacts

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-optee/myir-st-optee$ export FWDDR_DIR=../../stm32mp-ddr-phy-A2022.11-r0/stm32mp-ddr-phy-A2022.11

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-optee/myir-st-optee$ make -f $PWD/../Makefile.sdk DEPLOYDIR=$FIP_DEPLOYDIR_ROOT/optee CFG_EMBED_DTB_SOURCE_FILE=stm32mp257d-bringup-mx optee

注:已將上述Optee單獨(dú)編譯的命令存放在/home/myir/stm32mp25x-BringUp-bsp/myir-st-optee/myir-st-optee/build.sh

可以看到已經(jīng)生成了bin文件

1740739457314012.png

1740739477250366.png

2.3.配置和編譯Uboot

已同樣的方式進(jìn)行手動(dòng)添加uboot的設(shè)備樹(shù)的一些配置,使用編輯工具打開(kāi)uboot下的(BringupCA35DeviceTreeBringupu-bootstm32mp257d-bringup-mx.dts)

/* USER CODE BEGIN root */

aliases {

             serial0 = &usart2;

};

chosen {

             stdout-path = "serial0:115200n8";

 };

/* USER CODE END root */

       需要增加eMMC的配置

&sdmmc2{

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

        pinctrl-0 = <&sdmmc2_pins_mx>;

        pinctrl-1 = <&sdmmc2_opendrain_pins_mx>;

        pinctrl-2 = <&sdmmc2_sleep_pins_mx>;

        status = "okay";

        /* USER CODE BEGIN sdmmc2 */

        non-removable;

        no-sd;

        no-sdio;

        st,neg-edge;

        bus-width = <8>;

        vmmc-supply = <&scmi_vdd_emmc>;

        vqmmc-supply = <&scmi_vddio2>;

        mmc-ddr-1_8v;

        mmc-hs200-1_8v;

        /* USER CODE END sdmmc2 */

};

       添加USB配置,后續(xù)用于刷機(jī)

/* USER CODE BEGIN addons */

&usb2_phy1{

        status = "okay";

        /* USER CODE BEGIN usb2_phy1 */

        vdd33-supply = <&scmi_vdd3v3_usb>;

        /* USER CODE END usb2_phy1 */

};

&usb2_phy2{

        status = "okay";

        /* USER CODE BEGIN usb2_phy2 */

        vdd33-supply = <&scmi_vdd3v3_usb>;

        /* USER CODE END usb2_phy2 */

};

&usb3dr{

        status = "okay";

        /* USER CODE BEGIN usb3dr */

        dwc3: usb@48300000 {

                maximum-speed = "high-speed";

                usb-role-switch;

                port {

                        dwc3_ep: endpoint {

                                remote-endpoint = <&typec_ep>;

                        };

                };

        };

        /* USER CODE END usb3dr */

};

&usbh{

        status = "okay";

        /* USER CODE BEGIN usbh */

        usbh_ehci: usb@482f0000 {

                #address-cells = <1>;

                #size-cells = <0>;

                /* onboard HUB */

                hub@1 {

                        compatible = "usb424,2514";

                        reg = <1>;

                        vdd-supply = <&scmi_v3v3>;

                };

        };

        usbh_ohci: usb@482e0000 {

                status = "disabled";

        };

        /* USER CODE END usbh */

};

&scmi_regu {

        scmi_vddio1: regulator@0 {

                regulator-min-microvolt = <1800000>;

                regulator-max-microvolt = <3300000>;

        };

        scmi_vddcore: regulator@11  {

                reg = <VOLTD_SCMI_STPMIC2_BUCK2>;

                regulator-name = "vddcore";

        };

        scmi_v1v8: regulator@14  {

                reg = <VOLTD_SCMI_STPMIC2_BUCK5>;

                regulator-name = "v1v8";

        };

        scmi_v3v3: regulator@16 {

                reg = <VOLTD_SCMI_STPMIC2_BUCK7>;

                regulator-name = "v3v3";

        };

        scmi_vdd_emmc: regulator@18 {

                reg = <VOLTD_SCMI_STPMIC2_LDO2>;

                regulator-name = "vdd_emmc";

        };

        scmi_vdd3v3_usb: regulator@20 {

                reg = <VOLTD_SCMI_STPMIC2_LDO4>;

                regulator-name = "vdd3v3_usb";

        };

        scmi_vdd_sdcard: regulator@23 {

                reg = <VOLTD_SCMI_STPMIC2_LDO7>;

                regulator-name = "vdd_sdcard";

        };

};

&mlahb {

        intc_rpmsg: interrupt-controller@1 {

                compatible = "rpmsg,intc";

                reg = <1 0>;

                #interrupt-cells = <1>;

                interrupt-controller;

        };

        i2c_rpmsg: i2c@2 {

                compatible = "rpmsg,i2c-controller";

                reg = <2 0>;

                rpmsg,dev-id = "rpmsg_i2c";

                #address-cells = <1>;

                #size-cells = <0>;

                status = "okay";

                typec@35 {

                        compatible = "st,stm32mp25-typec";

                        reg = <0x35>;

                        interrupts-extended = <&intc_rpmsg 0>;

                        status = "okay";

                        connector {

                                compatible = "usb-c-connector";

                                label = "USB-C";

                                port {

                                        typec_ep: endpoint {

                                                remote-endpoint = <&dwc3_ep>;

                                        };

                                };

                        };

                };

        };

};

/* USER CODE END addons */

使用編輯工具打開(kāi)uboot下的(BringupCA35DeviceTreeBringupu-bootstm32mp257d-bringup-mx-u-boot.dtsi)

/* USER CODE BEGIN addons */

&dwc3 {

        dr_mode = "peripheral";

        /delete-node/ port;

};

&i2c_rpmsg {

        /delete-node/ typec@35;

};

&usart2 {

             u-boot,dm-pre-reloc;

};

&usart2_pins_mx {

             u-boot,dm-pre-reloc;

             pins1 {

              u-boot,dm-pre-reloc;

             };

             pins2 {

              u-boot,dm-pre-reloc;

             };

};

/* USER CODE END addons */

PMIC配置與tf-a一樣,這里略寫。

修改完成后,編譯 U-Boot

myir@myir-vm:~$ cd stm32mp25x-BringUp-bsp/myir-st-uboot/u-boot-myir

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-uboot/u-boot-myir$ source /opt/st/myd-ld25x/4.2.4-snapshot/environment-setup-cortexa35-ostl-linux

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-uboot/u-boot-myir$ export FIP_DEPLOYDIR_ROOT=../../FIP_artifacts

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-uboot/u-boot-myir$ export FWDDR_DIR=../../stm32mp-ddr-phy-A2022.11-r0/stm32mp-ddr-phy-A2022.11

myir@myir-vm:~/stm32mp25x-BringUp-bsp/myir-st-uboot/u-boot-myir$ make -f $PWD/../Makefile.sdk DEPLOYDIR=../../FIP_artifacts/u-boot UBOOT_CONFIG=default UBOOT_DEFCONFIG=stm32mp25_defconfig UBOOT_BINARY=u-boot.dtb DEVICETREE=stm32mp257d-bringup-mx FIP_CONFIG="optee-emmc" all

注:已將上述uboot單獨(dú)編譯的命令存放在/home/myir/stm32mp25x-BringUp-bsp/myir-st-uboot/u-boot-myir/build.sh

編譯完成后生成fip文件在定義的FIP_artifacts文件夾下,如下圖所示:

1740739505527562.png

更多介紹請(qǐng)關(guān)注下一期介紹

或關(guān)注米爾電子公眾號(hào)


上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞:

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉