board: stm32mp1: set environment variable fdtfile
[oweals/u-boot.git] / board / st / stm32mp1 / stm32mp1.c
index 62b648f6e47eb03e3b3e1848911f12798a8b39ce..c64f20ab08670fbb09503ff9bb9050b67575cc89 100644 (file)
@@ -699,10 +699,19 @@ int board_late_init(void)
        fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
                                 &fdt_compat_len);
        if (fdt_compat && fdt_compat_len) {
-               if (strncmp(fdt_compat, "st,", 3) != 0)
+               if (strncmp(fdt_compat, "st,", 3) != 0) {
                        env_set("board_name", fdt_compat);
-               else
+               } else {
+                       char dtb_name[256];
+                       int buf_len = sizeof(dtb_name);
+
                        env_set("board_name", fdt_compat + 3);
+
+                       strncpy(dtb_name, fdt_compat + 3, buf_len);
+                       buf_len -= strlen(fdt_compat + 3);
+                       strncat(dtb_name, ".dtb", buf_len);
+                       env_set("fdtfile", dtb_name);
+               }
        }
        ret = uclass_get_device_by_driver(UCLASS_MISC,
                                          DM_GET_DRIVER(stm32mp_bsec),