Skip to contentSkip to conversation

Enable DMA on STM32 MCU based on cortex-M7

PATCH Superseded Alexandre Torgue 2 participants 7 messages Feb 28, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Enable DMA on STM32 MCU based on cortex-M7

This series enable DMA on several STM32 MCU based on cortex-M7. To make it possible, a dedicated dma pool memory area has to be created. This patchset activate also ARM_MPU flag which will configure MPU (Memory Protection Unit) according to devicetree information (mem and dma-pool). Note that on cortex-M7 DMA has to use a NO cache-able memory region.

v2:
-select ARM_MPU in mach-stm32 Kconfig instead of add it in stm32 defconfig -Remove XIP configuration from stm32_defconfig: ARM_MPU flag imposes XIP image to be aligned on 1MB. It is currently not the case. I had choice to either modify current XIP start address to be aligned on 1MB or to remove global configuration. I make choice to remove XIP configuration. Indeed, SD card support has been recently added for most of STM32 MCU boards (except for stm32f429-disco). As kernel is growing up for stm32 it will be more and more difficult to flash it in embeded flash (max size: 2MB).
-fix typo in commit message

Regards
Alex

Alexandre Torgue (4):
ARM: dts: stm32: add DMA memory pool on MCU which embed a cortex-M7
ARM: configs: stm32: remove XIP configuration
ARM: stm32: Select ARM_MPU for cortex-M7 machines
ARM: dts: stm32: enable dma on MCU which embed a cortex-M7

 arch/arm/boot/dts/stm32746g-eval.dts   | 21 +++++++++++++++++++++
 arch/arm/boot/dts/stm32f769-disco.dts  | 21 +++++++++++++++++++++
 arch/arm/boot/dts/stm32h743i-disco.dts | 21 +++++++++++++++++++++
 arch/arm/boot/dts/stm32h743i-eval.dts  | 21 +++++++++++++++++++++
 arch/arm/configs/stm32_defconfig       |  2 --
 arch/arm/mach-stm32/Kconfig            |  3 +++
 6 files changed, 87 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/4 ARM: dts: stm32: add DMA memory pool on MCU which embed a cortex-M7

On cortex-M7 MCU, DMA have to use a non cache-able memory area. For this reason a dedicated memory pool is created for DMA.
This patch creates a DMA memory pool of 1MB of each STM32 MCU which embeds a cortex-M7 except stm32f746-disco. Indeed, as stm32f746-disco has only a 8MB SDRAM and it's tricky to reduce memory used by Kernel.

arch/arm/boot/dts/stm32746g-eval.dts +13 -0
index e3f5a83..92651c3 100644
@@ -58,6 +58,19 @@
 		reg = <0xc0000000 0x2000000>;
 	};
 
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		linux,dma {
+			compatible = "shared-dma-pool";
+			linux,dma-default;
+			no-map;
+			reg = <0xc1f00000 0x100000>;
+		};
+	};
+
 	aliases {
 		serial0 = &usart1;
 	};
arch/arm/boot/dts/stm32f769-disco.dts +13 -0
index d712260..c526853 100644
@@ -59,6 +59,19 @@
 		reg = <0xC0000000 0x1000000>;
 	};
 
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		linux,dma {
+			compatible = "shared-dma-pool";
+			linux,dma-default;
+			no-map;
+			reg = <0xc0f00000 0x100000>;
+		};
+	};
+
 	aliases {
 		serial0 = &usart1;
 	};
arch/arm/boot/dts/stm32h743i-disco.dts +13 -0
index 45e088c..3689e70 100644
@@ -57,6 +57,19 @@
 		reg = <0xd0000000 0x2000000>;
 	};
 
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		linux,dma {
+			compatible = "shared-dma-pool";
+			linux,dma-default;
+			no-map;
+			reg = <0xc1f00000 0x100000>;
+		};
+	};
+
 	aliases {
 		serial0 = &usart2;
 	};
arch/arm/boot/dts/stm32h743i-eval.dts +13 -0
index c7187e1..b9af696 100644
@@ -57,6 +57,19 @@
 		reg = <0xd0000000 0x2000000>;
 	};
 
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		linux,dma {
+			compatible = "shared-dma-pool";
+			linux,dma-default;
+			no-map;
+			reg = <0xc1f00000 0x100000>;
+		};
+	};
+
 	aliases {
 		serial0 = &usart1;
 	};
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/4 ARM: configs: stm32: remove XIP configuration

In reply to Alexandre Torgue

Embedded flash becomes too small to be used as XIP support. SD card is now available on most of stm32 boards and could be used as boot support. Furthermore, ARM_MPU flags will be used by default and it imposes that XIP image to be aligned on 1MB (which is not the case). For all those reasons I prefer to remove XIP configuration from default stm32 config and let user configure it if needed.

arch/arm/configs/stm32_defconfig +0 -2
index ba805b7..b162b8d 100644
@@ -28,8 +28,6 @@ CONFIG_PREEMPT=y
 # CONFIG_ATAGS is not set
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_XIP_KERNEL=y
-CONFIG_XIP_PHYS_ADDR=0x08008000
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_SHARED_FLAT=y
 # CONFIG_COREDUMP is not set
Signature · 1 line
2.7.4
#3 lore raw

PATCH v2 3/4 ARM: stm32: Select ARM_MPU for cortex-M7 machines

In reply to Alexandre Torgue

STM32 MCUs embed a Memory Protection Unit. Enabling ARM_MPU flag will allow the Kernel to configure the MPU according to the devicetree.

arch/arm/mach-stm32/Kconfig +3 -0
index 713c068..c2ad8e9 100644
@@ -29,15 +29,18 @@ config MACH_STM32F469
 config MACH_STM32F746
 	bool "STMicroelectronics STM32F746"
 	select ARM_AMBA
+	select ARM_MPU
 	default y
 
 config MACH_STM32F769
 	bool "STMicroelectronics STM32F769"
 	select ARM_AMBA
+	select ARM_MPU
 	default y
 
 config MACH_STM32H743
 	bool "STMicroelectronics STM32H743"
+	select ARM_MPU
 	default y
 
 endif # ARMv7-M
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 4/4 ARM: dts: stm32: enable dma on MCU which embed a cortex-M7

In reply to Alexandre Torgue

Enable dma1 and dma2 on:
-stm32746g-eval board
-stm32f769-disco board
-stm32h743i-disco board
-stm32h743i-eval board

arch/arm/boot/dts/stm32746g-eval.dts +8 -0
index 92651c3..c87e289 100644
@@ -114,6 +114,14 @@
 	status = "okay";
 };
 
+&dma1 {
+	status = "okay";
+};
+
+&dma2 {
+	status = "okay";
+};
+
 &i2c1 {
 	pinctrl-0 = <&i2c1_pins_b>;
 	pinctrl-names = "default";
arch/arm/boot/dts/stm32f769-disco.dts +8 -0
index c526853..3985c6d 100644
@@ -117,6 +117,14 @@
 	clock-frequency = <25000000>;
 };
 
+&dma1 {
+	status = "okay";
+};
+
+&dma2 {
+	status = "okay";
+};
+
 &rtc {
 	status = "okay";
 };
arch/arm/boot/dts/stm32h743i-disco.dts +8 -0
index 3689e70..e1623e3 100644
@@ -79,6 +79,14 @@
 	clock-frequency = <25000000>;
 };
 
+&dma1 {
+	status = "okay";
+};
+
+&dma2 {
+	status = "okay";
+};
+
 &usart2 {
 	pinctrl-0 = <&usart2_pins>;
 	pinctrl-names = "default";
arch/arm/boot/dts/stm32h743i-eval.dts +8 -0
index b9af696..3a1f471 100644
@@ -105,6 +105,14 @@
 	clock-frequency = <25000000>;
 };
 
+&dma1 {
+	status = "okay";
+};
+
+&dma2 {
+	status = "okay";
+};
+
 &rtc {
 	status = "okay";
 };
Signature · 1 line
2.7.4
#5 lore raw

v2 cover Enable DMA on STM32 MCU based on cortex-M7

In reply to Alexandre Torgue
Quoted 11 lines · Alexandre Torgue

This series enable DMA on several STM32 MCU based on cortex-M7. To make it possible, a dedicated dma pool memory area has to be created. This patchset activate also ARM_MPU flag which will configure MPU (Memory Protection Unit) according to devicetree information (mem and dma-pool). Note that on cortex-M7 DMA has to use a NO cache-able memory region.

v2:

(quoted diff) +0 -2
-select ARM_MPU in mach-stm32 Kconfig instead of add it in stm32 defconfig
-Remove XIP configuration from stm32_defconfig: ARM_MPU flag imposes XIP image
Quoted 6 lines

to be aligned on 1MB. It is currently not the case. I had choice to either modify current XIP start address to be aligned on 1MB or to remove global configuration. I make choice to remove XIP configuration. Indeed, SD card support has been recently added for most of STM32 MCU boards (except for stm32f429-disco). As kernel is growing up for stm32 it will be more and more difficult to flash it in embeded flash (max size: 2MB).

It is sad we are loosing XIP configuration - it used to uncover some bugs in a past. Probably, you might consider to have stm32 tiny (+xip) defconfig for those who do not want/need all-in-one kernel.

Cheers
Vladimir

Quoted 19 lines

-fix typo in commit message

Regards
Alex

Alexandre Torgue (4):
ARM: dts: stm32: add DMA memory pool on MCU which embed a cortex-M7
ARM: configs: stm32: remove XIP configuration
ARM: stm32: Select ARM_MPU for cortex-M7 machines
ARM: dts: stm32: enable dma on MCU which embed a cortex-M7

 arch/arm/boot/dts/stm32746g-eval.dts   | 21 +++++++++++++++++++++
 arch/arm/boot/dts/stm32f769-disco.dts  | 21 +++++++++++++++++++++
 arch/arm/boot/dts/stm32h743i-disco.dts | 21 +++++++++++++++++++++
 arch/arm/boot/dts/stm32h743i-eval.dts  | 21 +++++++++++++++++++++
 arch/arm/configs/stm32_defconfig       |  2 --
 arch/arm/mach-stm32/Kconfig            |  3 +++
 6 files changed, 87 insertions(+), 2 deletions(-)
#6 lore raw

v2 cover Enable DMA on STM32 MCU based on cortex-M7

Hi Vlad

Quoted 9 lines · Vladimir Murzin
Quoted 8 lines · Alexandre Torgue

This series enable DMA on several STM32 MCU based on cortex-M7. To make it possible, a dedicated dma pool memory area has to be created. This patchset activate also ARM_MPU flag which will configure MPU (Memory Protection Unit) according to devicetree information (mem and dma-pool). Note that on cortex-M7 DMA has to use a NO cache-able memory region.

Quoted 13 lines
Quoted 9 lines

v2:

(quoted diff) +0 -2
-select ARM_MPU in mach-stm32 Kconfig instead of add it in stm32 defconfig
-Remove XIP configuration from stm32_defconfig: ARM_MPU flag imposes XIP image

to be aligned on 1MB. It is currently not the case. I had choice to either modify current XIP start address to be aligned on 1MB or to remove global configuration. I make choice to remove XIP configuration. Indeed, SD card support has been recently added for most of STM32 MCU boards (except for stm32f429-disco). As kernel is growing up for stm32 it will be more and more difficult to flash it in embeded flash (max size: 2MB).

It is sad we are loosing XIP configuration - it used to uncover some bugs in a past. Probably, you might consider to have stm32 tiny (+xip) defconfig for those who do not want/need all-in-one kernel.

I agree and I don't want to loose XIP configuration. I just want that default stm32_defconfig covers the main MCU boards and the maximum IPs/driver for those boards. SD cards will be the boot support that will be supported in buildroot (except for stm32f429-disco).

But I agree, I could maybe use a frag to have a tiny configuration for stm32 to be able to flash xip in embeded flash and provide a "basic" support (kernel boot + console).

Regards
Alex

Quoted 24 lines

Cheers
Vladimir

Quoted 19 lines

-fix typo in commit message

Regards
Alex

Alexandre Torgue (4):
ARM: dts: stm32: add DMA memory pool on MCU which embed a cortex-M7
ARM: configs: stm32: remove XIP configuration
ARM: stm32: Select ARM_MPU for cortex-M7 machines
ARM: dts: stm32: enable dma on MCU which embed a cortex-M7

  arch/arm/boot/dts/stm32746g-eval.dts   | 21 +++++++++++++++++++++
  arch/arm/boot/dts/stm32f769-disco.dts  | 21 +++++++++++++++++++++
  arch/arm/boot/dts/stm32h743i-disco.dts | 21 +++++++++++++++++++++
  arch/arm/boot/dts/stm32h743i-eval.dts  | 21 +++++++++++++++++++++
  arch/arm/configs/stm32_defconfig       |  2 --
  arch/arm/mach-stm32/Kconfig            |  3 +++
  6 files changed, 87 insertions(+), 2 deletions(-)