diff mbox series

[10/16] board: stm32mp1: set environment variable fdtfile

Message ID 20200331180330.10.If6131518ee15d3299da69d674674ec03978eb58b@changeid
State Superseded
Delegated to: Patrick Delaunay
Headers show
Series [01/16] arm: stm32mp: update dependency for STM32_ETZPC | expand

Commit Message

Patrick DELAUNAY March 31, 2020, 4:04 p.m. UTC
For booting Linux in the generic distro mechanism and support of
FDTDIR in extlinux.conf , cmd/pxe.c retrieves the FDT file name
from "fdtfile" environment variable.

Dynamically build this variable with compatible of STMicroelectronics
boards.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 board/st/stm32mp1/stm32mp1.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Patrice CHOTARD April 1, 2020, 8:06 a.m. UTC | #1
Hi PAtrick

On 3/31/20 6:04 PM, Patrick Delaunay wrote:
> For booting Linux in the generic distro mechanism and support of
> FDTDIR in extlinux.conf , cmd/pxe.c retrieves the FDT file name
> from "fdtfile" environment variable.
>
> Dynamically build this variable with compatible of STMicroelectronics
> boards.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  board/st/stm32mp1/stm32mp1.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 52881adef7..89a088cd28 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -715,10 +715,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),

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks
diff mbox series

Patch

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 52881adef7..89a088cd28 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -715,10 +715,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),