MP157-2-TF-A移植:

MP157-2-TF-A移植:

  • 1. TF-A移植:
    • 1.1 新建开发板的设备树
    • 1.2 修改设备树电源管理
    • 1.3修改TF卡和EMMC设备树
    • 1.4 修改USBOTG设备树
  • 2 编译测试
    • 2.1 Makefile.sdk 修改内容:
    • 2.2 编译命令:

正点原子第九章内容:
自己记的笔记,详细内容请参考正点原子教程STM32MP1 嵌入式 Linux 驱动开发指南2.0。

1. TF-A移植:

1.1 新建开发板的设备树

VSCODE 打开 tf-a-stm32mp-2.2.r1\fdts 目录并且打开终端MP157-2-TF-A移植:_第1张图片
复制这两个文件stm32mp157d-ed1.dts,stm32mp15xx-edx.dtsi 为atk,我测试了qcy不能用。。。

cp stm32mp157d-ed1.dts stm32mp157d-atk.dts
cp stm32mp15xx-edx.dtsi stm32mp157d-atk.dtsi

在这里插入图片描述
头文件名称也要修改
MP157-2-TF-A移植:_第2张图片

1.2 修改设备树电源管理

打开 stm32mp157d-atk.dtsi 文件,第 54~281 行的内容全部删除掉,pmic节点信息内容全部删除。
MP157-2-TF-A移植:_第3张图片
MP157-2-TF-A移植:_第4张图片
将上面vin 节点内容全部删除掉,也就是将 17~23 行代码删除掉,替换为下面的
代码:

MP157-2-TF-A移植:_第5张图片

vddcore: regulator-vddcore {
        compatible = "regulator-fixed";
        regulator-name = "vddcore";
        regulator-min-microvolt = <1200000>;
        regulator-max-microvolt = <1350000>;
        regulator-off-in-suspend;
        regulator-always-on;
    };

    v3v3: regulator-3p3v {
        compatible = "regulator-fixed";
        regulator-name = "v3v3";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-off-in-suspend;
        regulator-always-on;
    };	

    vdd: regulator-vdd {
        compatible = "regulator-fixed";
        regulator-name = "vdd";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-off-in-suspend;
        regulator-always-on;
    };

    vdd_usb: regulator-vdd-usb {
        compatible = "regulator-fixed";
        regulator-name = "vdd_usb";
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
        regulator-off-in-suspend;
        regulator-always-on;
    };

1.3修改TF卡和EMMC设备树

继续操作 stm32mp157d-atk.dtsi 这个文件,找到“sdmmc1”和“sdmmc2”这 2 个节点。

MP157-2-TF-A移植:_第6张图片
将 sdmmc1 和 sdmmc2 节点改为如下所示内容:
MP157-2-TF-A移植:_第7张图片

&sdmmc1 {
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc1_b4_pins_a &sdmmc1_dir_pins_a>;
	st,neg-edge;
    broken-cd;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	status = "okay";
};

&sdmmc2 {
	pinctrl-names = "default";
	pinctrl-0 = <&sdmmc2_b4_pins_a &sdmmc2_d47_pins_a>;
	non-removable;
	st,neg-edge;
	bus-width = <8>;
	vmmc-supply = <&v3v3>;
    vqmmc-supply = <&v3v3>;
	status = "okay";
};

1.4 修改USBOTG设备树

继续操作 stm32mp157d-atk.dtsi,找到
“usbotg_hs”这个节点。
MP157-2-TF-A移植:_第8张图片
将 usbotg_hs 节点改为如下所示内容:
并文件里面添加了一个名为“usbphyc”的节点。
MP157-2-TF-A移植:_第9张图片

&usbotg_hs {
	phys = <&usbphyc_port1 0>;
	phy-names = "usb2-phy";
	usb-role-switch;
	status = "okay";
};

&usbphyc {
	status = "okay";
};

2 编译测试

2.1 Makefile.sdk 修改内容:

#remove default variable
LDFLAGS=
CFLAGS=
CPPFLAGS=
CC=
CPP=
AS=
AR=
LD=
NM=

LOCAL_PATH=$(PWD)

EXTRA_OEMAKE=CROSS_COMPILE=arm-none-linux-gnueabihf- DEBUG=1 LOG_LEVEL=40 PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 STM32MP_SDMMC=1 STM32MP_EMMC=1 STM32MP_SPI_NOR=1 STM32MP_RAW_NAND=1 STM32MP_SPI_NAND=1
#EXTRA_OEMAKE_SERIAL= STM32MP_UART_PROGRAMMER=1 STM32MP_USB_PROGRAMMER=1
EXTRA_OEMAKE_SERIAL=$(filter-out STM32MP_SDMMC=1 STM32MP_EMMC=1 STM32MP_SPI_NOR=1 STM32MP_RAW_NAND=1 STM32MP_SPI_NAND=1,$(EXTRA_OEMAKE)) STM32MP_UART_PROGRAMMER=1 STM32MP_USB_PROGRAMMER=1

# Set default config
ELF_DEBUG_ENABLE ?= 1
TF_A_CONFIG ?=  trusted  optee  serialboot

# Set specific OEMAKE config
TF_A_CONFIG_OEMAKE =  trusted,"AARCH32_SP=sp_min" optee,"AARCH32_SP=optee" serialboot,"AARCH32_SP=sp_min"
# Set default TFA_DEVICETREE
#TFA_DEVICETREE ?=   stm32mp157d-atk stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2   stm32mp157c-ed1 stm32mp157f-ed1   stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 
TFA_DEVICETREE ?= stm32mp157d-atk

#Set default TF_A_ENABLE_DEBUG_WRAPPER
TF_A_ENABLE_DEBUG_WRAPPER ?= 1

help:
	@echo
	@echo "Available targets:"
	@echo "  all   : build TF-A binaries for defined config(s)"
	@echo "  clean : clean build directories from generated files"
	@echo
	@echo "TF-A configuration:"
	@echo "  TF_A_CONFIG = $(TF_A_CONFIG)"
	@echo "  TFA_DEVICETREE = $(TFA_DEVICETREE)"
	@echo "  ELF_DEBUG_ENABLE = '$(ELF_DEBUG_ENABLE)' ('1' to export elf files)"
	@echo "  TF_A_ENABLE_DEBUG_WRAPPER = '$(TF_A_ENABLE_DEBUG_WRAPPER)' ('1' to generate tf-a for debugging)"
	@echo

all: tf

host_tools:
	@$(MAKE) --no-print-directory -C $(LOCAL_PATH)/tools/stm32image

tf: host_tools
	for config in $(TF_A_CONFIG) ; do \
		# Init any extraoemake \
		add_extraoemake= ; \
		for fullconfig in $(TF_A_CONFIG_OEMAKE) ; do \
			extraconfig=$$(echo $$fullconfig | cut -d',' -f1) ; \
			if [ "$$extraconfig" = "$$config" ]; then \
				add_extraoemake=$$(echo $$fullconfig | cut -d',' -f2) ; \
			fi ; \
		done ; \
		mkdir -p $(LOCAL_PATH)/../build/$$config ; \
		if test -n "$(TFA_DEVICETREE)" ; then \
			for dt in $(TFA_DEVICETREE) ; do \
				if [ "$(TF_A_CONFIG)" != "serialboot" ]; then \
					$(MAKE) $(EXTRA_OEMAKE) -C $(LOCAL_PATH) DTB_FILE_NAME=$$dt.dtb BUILD_PLAT=$(LOCAL_PATH)/../build/$$config $$add_extraoemake ; \
				else \
					$(MAKE) $(EXTRA_OEMAKE_SERIAL) -C $(LOCAL_PATH) DTB_FILE_NAME=$$dt.dtb BUILD_PLAT=$(LOCAL_PATH)/../build/$$config $$add_extraoemake ; \
				fi \
				# Copy binary file with explicit name \
				cp -f $(LOCAL_PATH)/../build/$$config/tf-a-$$dt.stm32 $(LOCAL_PATH)/../build/$$config/tf-a-$$dt-$$config.stm32 ; \
				if [ "$(TF_A_ENABLE_DEBUG_WRAPPER)" = "1" ]; then \
					# Generate wrapper for debugging \
					stm32wrapper4dbg -s $(LOCAL_PATH)/../build/$$config/tf-a-$$dt.stm32 -d $(LOCAL_PATH)/../build/$$config/debug-tf-a-$$dt-$$config.stm32 ; \
				fi \
			done ; \
		else \
			$(MAKE) $(EXTRA_OEMAKE) -C $(LOCAL_PATH) BUILD_PLAT=$(LOCAL_PATH)/../build/$$config $$add_extraoemake; \
			tf_version=$$(find $(LOCAL_PATH)/../build/$$config -name tf-a*.stm32 -exec basename {} \; | sed "s/\.stm32//") ; \
			# Copy binary file with explicit name \
			cp -f $(LOCAL_PATH)/../build/$$config/$$tf_version.stm32 $(LOCAL_PATH)/../build/$$config/$$tf_version-$$config.stm32 ; \
			if [ "$(TF_A_ENABLE_DEBUG_WRAPPER)" = "1" ]; then \
				# Generate wrapper for debugging \
				stm32wrapper4dbg -s $(LOCAL_PATH)/../build/$$config/$$tf_version.stm32 $(LOCAL_PATH)/../build/$$config/debug-$$tf_version-$$config.stm32 ; \
			fi \
		fi ; \
		# Copy elf files with explicit name \
		if [ "$(ELF_DEBUG_ENABLE)" = "1" ] ; then \
			if [ -f $(LOCAL_PATH)/../build/$$config/bl2/bl2.elf ] ; then \
				cp -f $(LOCAL_PATH)/../build/$$config/bl2/bl2.elf $(LOCAL_PATH)/../build/$$config/tf-a-bl2-$$config.elf ; \
			fi ; \
			if [ -f $(LOCAL_PATH)/../build/$$config/bl32/bl32.elf ] ; then \
				cp -f $(LOCAL_PATH)/../build/$$config/bl32/bl32.elf $(LOCAL_PATH)/../build/$$config/tf-a-bl32-$$config.elf ; \
			fi ; \
		fi ; \
	done

clean:
	@for config in $(TF_A_CONFIG) ; do \
		rm -rf $(LOCAL_PATH)/../build/$$config ; \
	done

2.2 编译命令:

make -f ../Makefile.sdk TFA_DEVICETREE=stm32mp157d-atk TF_A_CONFIG=serialboot ELF_DEBUG_ENABLE=`1` all

注意 ELF_DEBUG_ENABLE=,1 不是单引号,是tab键上面的一个键。
MP157-2-TF-A移植:_第10张图片

你可能感兴趣的:(STM32MP157,单片机,stm32,嵌入式硬件)