Skip to contentSkip to conversation

stm32mp1: add support of M4 coprocessor firmware

PATCH New Patrick Delaunay 2 participants 7 messages Aug 2, 2019 – Aug 13, 2019

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

cover stm32mp1: add support of M4 coprocessor firmware

Activate remoteproc and add the M4 coprocessor support of firmware in stm32mp157 U-Boot.

The M4 firmware can be loaded manually (with remoteproc command) or automatically (with config selected in FIT including the M4 firmware with extlinux for example).

Patrick Delaunay (5):
stm32mp1: Add remoteproc support for m4 coprocessor
image: add new "copro" image type
stm32mp1: Add copro image support for M4 firmware
stm32mp1: add example files for FIT generation
stm32mp1: update README for remoteproc support

 arch/arm/dts/stm32mp157a-dk1.dts           |   6 ++
 arch/arm/dts/stm32mp157c-ed1.dts           |   6 ++
 arch/arm/dts/stm32mp157c.dtsi              |  20 ++++++
 board/st/stm32mp1/README                   |  36 +++++++++-
 board/st/stm32mp1/extlinux.conf            |  20 ++++++
 board/st/stm32mp1/fit_copro_kernel_dtb.its | 103 +++++++++++++++++++++++++++++
 board/st/stm32mp1/fit_kernel_dtb.its       |  82 +++++++++++++++++++++++
 board/st/stm32mp1/stm32mp1.c               |  24 +++++++
 common/image.c                             |   1 +
 configs/stm32mp15_basic_defconfig          |   1 +
 configs/stm32mp15_optee_defconfig          |   1 +
 configs/stm32mp15_trusted_defconfig        |   1 +
 drivers/remoteproc/stm32_copro.c           |   2 +-
 include/image.h                            |   1 +
 14 files changed, 301 insertions(+), 3 deletions(-)
 create mode 100644 board/st/stm32mp1/extlinux.conf
 create mode 100644 board/st/stm32mp1/fit_copro_kernel_dtb.its
 create mode 100644 board/st/stm32mp1/fit_kernel_dtb.its
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 stm32mp1: Add remoteproc support for m4 coprocessor

Alignment with kernel patch proposal for binding:

[PATCH v4 0/8] stm32 m4 remoteproc on STM32MP157c
https://lkml.org/lkml/2019/5/14/159

---

 arch/arm/dts/stm32mp157a-dk1.dts    |  6 ++++++
 arch/arm/dts/stm32mp157c-ed1.dts    |  6 ++++++
 arch/arm/dts/stm32mp157c.dtsi       | 20 ++++++++++++++++++++
 configs/stm32mp15_basic_defconfig   |  1 +
 configs/stm32mp15_optee_defconfig   |  1 +
 configs/stm32mp15_trusted_defconfig |  1 +
 drivers/remoteproc/stm32_copro.c    |  2 +-
 7 files changed, 36 insertions(+), 1 deletion(-)
arch/arm/dts/stm32mp157a-dk1.dts +6 -0
index adb2464..330b8d0 100644
@@ -241,6 +241,12 @@
 	status = "okay";
 };
 
+&m4_rproc {
+	mboxes = <&ipcc 0>, <&ipcc 1>, <&ipcc 2>;
+	mbox-names = "vq0", "vq1", "shutdown";
+	status = "okay";
+};
+
 &pwr {
 	pwr-supply = <&vdd>;
 };
arch/arm/dts/stm32mp157c-ed1.dts +6 -0
index 11981d6..31f448b 100644
@@ -201,6 +201,12 @@
 	status = "okay";
 };
 
+&m4_rproc {
+	mboxes = <&ipcc 0>, <&ipcc 1>, <&ipcc 2>;
+	mbox-names = "vq0", "vq1", "shutdown";
+	status = "okay";
+};
+
 &pwr {
 	pwr-supply = <&vdd>;
 };
arch/arm/dts/stm32mp157c.dtsi +20 -0
index d15fba0..d851929 100644
@@ -1363,4 +1363,24 @@
 			status = "disabled";
 		};
 	};
+
+	mlahb {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		dma-ranges = <0x00000000 0x38000000 0x10000>,
+			     <0x10000000 0x10000000 0x60000>,
+			     <0x30000000 0x30000000 0x60000>;
+
+		m4_rproc: m4 at 10000000 {
+			compatible = "st,stm32mp1-m4";
+			reg = <0x10000000 0x40000>,
+			      <0x30000000 0x40000>,
+			      <0x38000000 0x10000>;
+			resets = <&rcc MCU_R>;
+			st,syscfg-holdboot = <&rcc 0x10C 0x1>;
+			st,syscfg-tz = <&rcc 0x000 0x1>;
+			status = "disabled";
+		};
+	};
 };
configs/stm32mp15_basic_defconfig +1 -0
index 27b8525..4ef9c0b 100644
@@ -32,6 +32,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
configs/stm32mp15_optee_defconfig +1 -0
index 0565e5e..d3e990e 100644
@@ -23,6 +23,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
configs/stm32mp15_trusted_defconfig +1 -0
index 844cbcd..c4d2516 100644
@@ -22,6 +22,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
drivers/remoteproc/stm32_copro.c +1 -1
index de3b972..ad941f6 100644
@@ -243,7 +243,7 @@ static const struct dm_rproc_ops stm32_copro_ops = {
 };
 
 static const struct udevice_id stm32_copro_ids[] = {
-	{.compatible = "st,stm32mp1-rproc"},
+	{.compatible = "st,stm32mp1-m4"},
 	{}
 };
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/5 image: add new "copro" image type

In reply to Patrick Delaunay

Define new image type for coprocessor images. It is used in FIT to identify the files loaded with remoteproc command (elf or bin).

---

 common/image.c  | 1 +
 include/image.h | 1 +
 2 files changed, 2 insertions(+)
common/image.c +1 -0
index 4958831..f65c3e9 100644
@@ -174,6 +174,7 @@ static const table_entry_t uimage_type[] = {
 	{       IH_TYPE_PMMC,        "pmmc",        "TI Power Management Micro-Controller Firmware",},
 	{	IH_TYPE_STM32IMAGE, "stm32image", "STMicroelectronics STM32 Image" },
 	{	IH_TYPE_MTKIMAGE,   "mtk_image",   "MediaTek BootROM loadable Image" },
+	{	IH_TYPE_COPRO, "copro", "Coprocessor Image"},
 	{	-1,		    "",		  "",			},
 };
 
include/image.h +1 -0
index 27d7cb9..64a694f 100644
@@ -283,6 +283,7 @@ enum {
 	IH_TYPE_MTKIMAGE,		/* MediaTek BootROM loadable Image */
 	IH_TYPE_IMX8MIMAGE,		/* Freescale IMX8MBoot Image	*/
 	IH_TYPE_IMX8IMAGE,		/* Freescale IMX8Boot Image	*/
+	IH_TYPE_COPRO,			/* Coprocessor Image for remoteproc*/
 
 	IH_TYPE_COUNT,			/* Number of image types */
 };
Signature · 1 line
2.7.4
#4 lore raw

PATCH 3/5 stm32mp1: Add copro image support for M4 firmware

In reply to Patrick Delaunay

Implements copro image loading with FIT. Once image is loaded with remoteproc,
the M4 coprocessor is automatically started.

---

 board/st/stm32mp1/stm32mp1.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
board/st/stm32mp1/stm32mp1.c +24 -0
index b99c6c0..629fb63 100644
@@ -17,6 +17,7 @@
 #include <mtd.h>
 #include <mtd_node.h>
 #include <phy.h>
+#include <remoteproc.h>
 #include <reset.h>
 #include <syscon.h>
 #include <usb.h>
@@ -770,3 +771,26 @@ int ft_board_setup(void *blob, bd_t *bd)
 	return 0;
 }
 #endif
+
+static void board_copro_image_process(ulong fw_image, size_t fw_size)
+{
+	int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
+
+	if (!rproc_is_initialized())
+		if (rproc_init()) {
+			printf("Remote Processor %d initialization failed\n",
+			       id);
+			return;
+		}
+
+	ret = rproc_load(id, fw_image, fw_size);
+	printf("Load Remote Processor %d with data at addr=0x%08lx %u bytes:%s\n",
+	       id, fw_image, fw_size, ret ? " Failed!" : " Success!");
+
+	if (!ret) {
+		rproc_start(id);
+		env_set("copro_state", "booted");
+	}
+}
+
+U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);
Signature · 1 line
2.7.4
#5 lore raw

PATCH 4/5 stm32mp1: add example files for FIT generation

In reply to Patrick Delaunay

Add example of its files to generate FIT to start kernel on ev1 or dk2 board with
- only kernel and dtb = fit_copro_kernel_dtb.its
- kernel, M4 copro firmware and dtb = it_copro_kernel_dtb.its

Add extlinux example to manage config in generated FIT.

---

 board/st/stm32mp1/extlinux.conf            |  20 ++++++
 board/st/stm32mp1/fit_copro_kernel_dtb.its | 103 +++++++++++++++++++++++++++++
 board/st/stm32mp1/fit_kernel_dtb.its       |  82 +++++++++++++++++++++++
 3 files changed, 205 insertions(+)
 create mode 100644 board/st/stm32mp1/extlinux.conf
 create mode 100644 board/st/stm32mp1/fit_copro_kernel_dtb.its
 create mode 100644 board/st/stm32mp1/fit_kernel_dtb.its
board/st/stm32mp1/extlinux.conf new file +20 -0
new file mode 100644
index 0000000..2b46328
@@ -0,0 +1,20 @@
+# Generic Distro Configuration for STM32MP157
+menu title Select the boot mode
+TIMEOUT 20
+DEFAULT stm32mp157c-ev1
+
+LABEL stm32mp157c-ev1
+	KERNEL /fit_kernel_dtb.itb#ev1
+	APPEND root=/dev/mmcblk0p6 rootwait rw earlyprintk console=ttyS3,115200
+
+LABEL stm32mp157c-ev1-m4
+	KERNEL /fit_copro_kernel_dtb.itb#ev1-m4
+	APPEND root=/dev/mmcblk0p6 rootwait rw earlyprintk console=ttyS3,115200
+
+LABEL stm32mp157c-dk2
+	KERNEL /fit_kernel_dtb.itb#dk2
+	APPEND root=/dev/mmcblk0p6 rootwait rw earlyprintk console=ttyS3,115200
+
+LABEL stm32mp157c-dk2-m4
+	KERNEL /fit_copro_kernel_dtb.itb#dk2-m4
+	APPEND root=/dev/mmcblk0p6 rootwait rw earlyprintk console=ttyS3,115200
board/st/stm32mp1/fit_copro_kernel_dtb.its new file +103 -0

103 lines not on this page · raw message

board/st/stm32mp1/fit_kernel_dtb.its new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
2.7.4
#6 lore raw

PATCH 5/5 stm32mp1: update README for remoteproc support

In reply to Patrick Delaunay

Add information for remoteproc usage to load firmware in M4 coprocessor on stm32mp157.

---

 board/st/stm32mp1/README | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
board/st/stm32mp1/README +34 -2
index 428357c..c807e08 100644
@@ -139,7 +139,6 @@ the supported device trees for stm32mp157 are:
 
 	# make DEVICE_TREE=<name> all
 
-
   example:
   a) trusted boot on ev1
 	# export KBUILD_OUTPUT=stm32mp15_trusted
@@ -190,7 +189,7 @@ the supported device trees for stm32mp157 are:
 6. Switch Setting for Boot Mode
 ===============================
 
-You can select the boot mode, on the board ed1 with the switch SW1
+You can select the boot mode, on the board with one switch :
 
 - on the daugther board ed1 with the switch SW1 : BOOT0, BOOT1, BOOT2
 
@@ -358,3 +357,36 @@ on bank 0 to access to internal OTP:
     4 check env update
        STM32MP> print ethaddr
        ethaddr=12:34:56:78:9a:bc
+
+10. Coprocessor firmware
+========================
+
+U-Boot can boot the coprocessor before the kernel (coprocessor early boot).
+
+A/ Manuallly by using rproc commands (update the bootcmd)
+     Configurations
+	# env set name_copro "rproc-m4-fw.elf"
+	# env set dev_copro 0
+	# env set loadaddr_copro 0xC1000000
+
+     Load binary from bootfs partition (number 4) on SDCard (mmc 0)
+	# ext4load mmc 0:4 ${loadaddr_copro} ${name_copro}
+	=> ${filesize} updated with the size of the loaded file
+
+     Start M4 firmware with remote proc command
+	# rproc init
+	# rproc load ${dev_copro} ${loadaddr_copro} ${filesize}
+	# rproc start ${dev_copro}
+
+B/ Automatically by using FIT feature and generic DISTRO bootcmd
+
+   see examples in this directory :
+
+   Generate FIT including kernel + device tree + M4 firmware
+   with cfg with M4 boot
+        $> mkimage -f fit_copro_kernel_dtb.its fit_copro_kernel_dtb.itb
+
+    Then using DISTRO configuration file: see extlinux.conf to select
+    the correct configuration
+	=> stm32mp157c-ev1-m4
+	=> stm32mp157c-dk2-m4
Signature · 1 line
2.7.4