On i.MX8M SoCs, the /firmware/optee Devicetree node is created just before booting the OS when OP-TEE is found running. If the node already exists, this results in an error, which prevents the OS to boot:
Could not create optee node. ERROR: system-specific fdt fixup failed: FDT_ERR_EXISTS - must RESET the board to recover. failed to process device tree On the i.MX8M systems where CONFIG_OF_SYSTEM_SETUP is defined, the ft_add_optee_node() function is called before booting the OS. It will create the OP-TEE Devicetree node and populate it with reserved memory informations gathered at runtime. On on most i.MX8M systems the Devicetree is built with an optee node if CONFIG_OPTEE is defined. This node is indeed necessary for commands and drivers communicating with OP-TEE, even before attempting OS boot. The aforementioned issue can happen on the Compulab IOT-GATE-iMX8, which is the only in-tree i.MX8M system where both CONFIG_OPTEE and CONFIG_OF_SYSTEM_SETUP are defined (see the imx8mm-cl-iot-gate* defconfigs). Deal with an existing optee node gracefully at runtime to fix this issue. Signed-off-by: Vincent Stehlé <vincent.ste...@arm.com> Cc: Stefano Babic <sba...@denx.de> Cc: Fabio Estevam <feste...@gmail.com> Cc: Tom Rini <tr...@konsulko.com> Cc: Tim Harvey <thar...@gateworks.com> --- arch/arm/mach-imx/imx8m/soc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 85dc8b51a14..567e8e9e81a 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -1270,8 +1270,9 @@ static int ft_add_optee_node(void *fdt, struct bd_info *bd) } } + /* Locate the optee node if it exists or create it. */ subpath = "optee"; - offs = fdt_add_subnode(fdt, offs, subpath); + offs = fdt_find_or_add_subnode(fdt, offs, subpath); if (offs < 0) { printf("Could not create %s node.\n", subpath); return offs; -- 2.47.2