[PATCH 0/2] ARM: i.MX: riotboard: Add OP-TEE integration

STALE162d SUPERSEDED

Revision v1 of 2 in this series.

5 messages, 2 authors, 2026-05-08 · open the first message on its own page

[PATCH 0/2] ARM: i.MX: riotboard: Add OP-TEE integration

From: Fabian Pflug <hidden>
Date: 2026-05-08 14:44:52

Configure the riotboard to use the default OP-TEE implementation
provided by the generic i.MX6 OP-TEE firmware target.

Signed-off-by: Fabian Pflug <redacted>
---
Fabian Pflug (2):
      ARM: i.MX: riotboard: add tzasc.h to flashheader
      ARM: i.MX: riotboard: rewrite lowlevel.c

 .../flash-header-embest-riotboard.imxcfg           |  1 +
 arch/arm/boards/embest-riotboard/lowlevel.c        | 37 ++++++++++++++--------
 2 files changed, 24 insertions(+), 14 deletions(-)
---
base-commit: 1d386a53086d28a0c4eda138ae9408a418b97b7e
change-id: 20251216-v2025-11-0-topic-riotboard-e4d47d428af5

Best regards,
-- 
Fabian Pflug [off-list ref]


[PATCH 1/2] ARM: i.MX: riotboard: add tzasc.h to flashheader

From: Fabian Pflug <hidden>
Date: 2026-05-08 14:44:46

Even though the riotboard is a i.MX6S, the flashheader is the same for
QDLS variants. It allows to integrate OP-TEE and does not hinder in
normal operation.

Signed-off-by: Fabian Pflug <redacted>
---
 arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg b/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg
index 1f27163417..335f5033ce 100644
--- a/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg
+++ b/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg
@@ -67,4 +67,5 @@ wm 32 MX6_MMDC_P0_MDPDC 0x00025565
 wm 32 MX6_MMDC_P0_MAPSR 0x00011006
 wm 32 MX6_MMDC_P0_MDSCR 0x00000000
 
+#include <mach/imx/imx6q-tzasc.h>
 #include <mach/imx/habv4-imx6-gencsf.h>
-- 
2.47.3


[PATCH 2/2] ARM: i.MX: riotboard: rewrite lowlevel.c

From: Fabian Pflug <hidden>
Date: 2026-05-08 14:44:47

Make use of the imx6q_barebox_entry instead of calling
barebox_arm_entry directly, which allows us to profit from optional
OP-TEE loading in this function.
Always setup UART, in case OP-TEE gets integrated, which will crash if
the UART is not configured correctly and debug is enabled.
Since now a bit more functions are called, we use
relocate_to_current_adr instead of get_runtime_offset.

This should not change behaviour of current implementations, but makes
way for OP-TEE implementations.

Signed-off-by: Fabian Pflug <redacted>
---
 arch/arm/boards/embest-riotboard/lowlevel.c | 37 ++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/arch/arm/boards/embest-riotboard/lowlevel.c b/arch/arm/boards/embest-riotboard/lowlevel.c
index f1b37c2aa0..e44fb3582e 100644
--- a/arch/arm/boards/embest-riotboard/lowlevel.c
+++ b/arch/arm/boards/embest-riotboard/lowlevel.c
@@ -11,26 +11,35 @@
 #include <asm/cache.h>
 #include <asm/mmu.h>
 #include <mach/imx/imx6.h>
+#include <mach/imx/iomux-mx6.h>
+#include <mach/imx/esdctl.h>
 
 extern char __dtb_imx6s_riotboard_start[];
 
-ENTRY_FUNCTION(start_imx6s_riotboard, r0, r1, r2)
+static noinline void setup_riotboard_uart(void)
 {
-	void *fdt;
+	void __iomem *iomuxbase = IOMEM(MX6_IOMUXC_BASE_ADDR);
 
-	imx6_cpu_lowlevel_init();
+	writel(0x4, iomuxbase + 0x016c);
+
+	imx6_ungate_all_peripherals();
+	// if uart ist not set-up, then OP-TEE will fail if debugging is enabled.
+	imx6_uart_setup(IOMEM(MX6_UART2_BASE_ADDR));
 
 	if (IS_ENABLED(CONFIG_DEBUG_LL)) {
-		/*
-		 * CONFIG_DEBUG_IMX6Q_UART=y
-		 * CONFIG_DEBUG_IMX_UART_PORT=2
-		 */
-		writel(0x4, 0x020e016c);
-		imx6_ungate_all_peripherals();
-		imx6_uart_setup_ll();
-		putc_ll('a');
+		pbl_set_putc(imx_uart_putc, IOMEM(MX6_UART2_BASE_ADDR));
+		putc_ll('>');
 	}
-
-	fdt = __dtb_imx6s_riotboard_start + get_runtime_offset();
-	barebox_arm_entry(0x10000000, SZ_1G, fdt);
+}
+
+ENTRY_FUNCTION(start_imx6s_riotboard, r0, r1, r2)
+{
+	imx6_cpu_lowlevel_init();
+
+	relocate_to_current_adr();
+	setup_c();
+
+	setup_riotboard_uart();
+
+	imx6q_barebox_entry(__dtb_imx6s_riotboard_start);
 }
-- 
2.47.3


Re: [PATCH 2/2] ARM: i.MX: riotboard: rewrite lowlevel.c

From: Ahmad Fatoum <a.fatoum@pengutronix.de>
Date: 2026-05-08 15:04:24

Hi,

On 5/8/26 4:43 PM, Fabian Pflug wrote:
Make use of the imx6q_barebox_entry instead of calling
barebox_arm_entry directly, which allows us to profit from optional
OP-TEE loading in this function.
maybe change commit message title to

ARM: i.MX: riotboard: switch to imx6q_barebox_entry

?
quoted hunk
Always setup UART, in case OP-TEE gets integrated, which will crash if
the UART is not configured correctly and debug is enabled.
Since now a bit more functions are called, we use
relocate_to_current_adr instead of get_runtime_offset.

This should not change behaviour of current implementations, but makes
way for OP-TEE implementations.

Signed-off-by: Fabian Pflug <redacted>
---
 arch/arm/boards/embest-riotboard/lowlevel.c | 37 ++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/arch/arm/boards/embest-riotboard/lowlevel.c b/arch/arm/boards/embest-riotboard/lowlevel.c
index f1b37c2aa0..e44fb3582e 100644
--- a/arch/arm/boards/embest-riotboard/lowlevel.c
+++ b/arch/arm/boards/embest-riotboard/lowlevel.c
@@ -11,26 +11,35 @@
 #include <asm/cache.h>
 #include <asm/mmu.h>
 #include <mach/imx/imx6.h>
+#include <mach/imx/iomux-mx6.h>
+#include <mach/imx/esdctl.h>
 
 extern char __dtb_imx6s_riotboard_start[];
 
-ENTRY_FUNCTION(start_imx6s_riotboard, r0, r1, r2)
+static noinline void setup_riotboard_uart(void)
 {
-	void *fdt;
+	void __iomem *iomuxbase = IOMEM(MX6_IOMUXC_BASE_ADDR);
 
-	imx6_cpu_lowlevel_init();
+	writel(0x4, iomuxbase + 0x016c);
+
+	imx6_ungate_all_peripherals();
+	// if uart ist not set-up, then OP-TEE will fail if debugging is enabled.
+	imx6_uart_setup(IOMEM(MX6_UART2_BASE_ADDR));
 
 	if (IS_ENABLED(CONFIG_DEBUG_LL)) {
-		/*
-		 * CONFIG_DEBUG_IMX6Q_UART=y
-		 * CONFIG_DEBUG_IMX_UART_PORT=2
-		 */
-		writel(0x4, 0x020e016c);
-		imx6_ungate_all_peripherals();
-		imx6_uart_setup_ll();
-		putc_ll('a');
+		pbl_set_putc(imx_uart_putc, IOMEM(MX6_UART2_BASE_ADDR));
+		putc_ll('>');
 	}
-
-	fdt = __dtb_imx6s_riotboard_start + get_runtime_offset();
-	barebox_arm_entry(0x10000000, SZ_1G, fdt);
Move

  imx6q_barebox_entry(__dtb_imx6s_riotboard_start);

here.
quoted hunk
+}
+
+ENTRY_FUNCTION(start_imx6s_riotboard, r0, r1, r2)
+{
+	imx6_cpu_lowlevel_init();
+
+	relocate_to_current_adr();
+	setup_c();
+
+	setup_riotboard_uart();
Rename to continue_imx6s_riotboard() or similar.
+
+	imx6q_barebox_entry(__dtb_imx6s_riotboard_start);
Illegal reference to global variable in function that does relocation,
move it into the noinline function above.

Cheers,
Ahmad
 }
-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |


Re: [PATCH 1/2] ARM: i.MX: riotboard: add tzasc.h to flashheader

From: Ahmad Fatoum <a.fatoum@pengutronix.de>
Date: 2026-05-08 15:34:04

On 5/8/26 4:43 PM, Fabian Pflug wrote:
Even though the riotboard is a i.MX6S, the flashheader is the same for
QDLS variants. It allows to integrate OP-TEE and does not hinder in
normal operation.

Signed-off-by: Fabian Pflug <redacted>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
quoted hunk
---
 arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg b/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg
index 1f27163417..335f5033ce 100644
--- a/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg
+++ b/arch/arm/boards/embest-riotboard/flash-header-embest-riotboard.imxcfg
@@ -67,4 +67,5 @@ wm 32 MX6_MMDC_P0_MDPDC 0x00025565
 wm 32 MX6_MMDC_P0_MAPSR 0x00011006
 wm 32 MX6_MMDC_P0_MDSCR 0x00000000
 
+#include <mach/imx/imx6q-tzasc.h>
 #include <mach/imx/habv4-imx6-gencsf.h>
-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help