[U-Boot] [PATCH v2 0/3] Add set_env_soc_name() for STM32 SoCs

From: Patrice Chotard patrice.chotard@st.com
This series allows to create and set the environment variable "soc_name" corresponding to the current STM32 SoCs name.
We will add STM32 SoCs support in buildroot environment Our objective is to propose a flexible solution to boot linux kernel from sdcard.
As for STM32F4, STM32F7 and STM32H7 linux defconfig is slightly different (specific CONFIG_DRAM_BASE and CONFIG_DRAM_SIZE) we can't use the same zImage for all these SoCs.
To simplify, we will embed all dtb/zImage in the sdcard and using the soc_name environment variable to select the correct zImage.
v2: _ Remove get_cpu_id() function and use directly CONFIG_STM32xx flag to identify the STM32 SoC family.
Patrice Chotard (8): mach-stm32: Add get_cpu_id support mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig board: stm32: Add set_env_soc_name() in board_late_init()
arch/arm/include/asm/arch-stm32f4/stm32.h | 1 + arch/arm/include/asm/arch-stm32f7/stm32.h | 1 + arch/arm/include/asm/arch-stm32h7/stm32.h | 3 +++ arch/arm/mach-stm32/Kconfig | 3 +++ arch/arm/mach-stm32/soc.c | 15 +++++++++++++++ board/st/stm32f429-discovery/stm32f429-discovery.c | 7 +++++++ board/st/stm32f429-evaluation/stm32f429-evaluation.c | 7 +++++++ board/st/stm32f469-discovery/stm32f469-discovery.c | 7 +++++++ board/st/stm32f746-disco/stm32f746-disco.c | 2 ++ board/st/stm32h743-disco/stm32h743-disco.c | 4 ++++ board/st/stm32h743-eval/stm32h743-eval.c | 4 ++++ include/configs/stm32f746-disco.h | 1 - include/configs/stm32h743-disco.h | 1 - include/configs/stm32h743-eval.h | 1 - 14 files changed, 54 insertions(+), 3 deletions(-)

From: Patrice Chotard patrice.chotard@st.com
This allows to create and set the environment variable "soc_name" which contains the current STM32 SoC's name.
Signed-off-by: Christophe Priouzeau christophe.priouzeau@st.com Signed-off-by: Patrice Chotard patrice.chotard@st.com ---
v2: _ Remove get_cpu_id() function and use directly CONFIG_STM32xx flag to identify the STM32 SoC family.
arch/arm/include/asm/arch-stm32f4/stm32.h | 1 + arch/arm/include/asm/arch-stm32f7/stm32.h | 1 + arch/arm/include/asm/arch-stm32h7/stm32.h | 3 +++ arch/arm/mach-stm32/soc.c | 15 +++++++++++++++ 4 files changed, 20 insertions(+)
diff --git a/arch/arm/include/asm/arch-stm32f4/stm32.h b/arch/arm/include/asm/arch-stm32f4/stm32.h index 0449fcecede0..d4b0c40804c0 100644 --- a/arch/arm/include/asm/arch-stm32f4/stm32.h +++ b/arch/arm/include/asm/arch-stm32f4/stm32.h @@ -50,5 +50,6 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = { };
void stm32_flash_latency_cfg(int latency); +void set_env_soc_name(void);
#endif /* _MACH_STM32_H_ */ diff --git a/arch/arm/include/asm/arch-stm32f7/stm32.h b/arch/arm/include/asm/arch-stm32f7/stm32.h index f54e6f195575..315d2a14790c 100644 --- a/arch/arm/include/asm/arch-stm32f7/stm32.h +++ b/arch/arm/include/asm/arch-stm32f7/stm32.h @@ -63,5 +63,6 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
void stm32_flash_latency_cfg(int latency); +void set_env_soc_name(void);
#endif /* _ASM_ARCH_HARDWARE_H */ diff --git a/arch/arm/include/asm/arch-stm32h7/stm32.h b/arch/arm/include/asm/arch-stm32h7/stm32.h index f2922aa3237e..9377c5d65bfb 100644 --- a/arch/arm/include/asm/arch-stm32h7/stm32.h +++ b/arch/arm/include/asm/arch-stm32h7/stm32.h @@ -18,4 +18,7 @@ * arch/arm/include/asm/arch-stm32f4/stm32.h * arch/arm/include/asm/arch-stm32f7/stm32.h */ + +void set_env_soc_name(void); + #endif /* _ASM_ARCH_HARDWARE_H */ diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c index df20d547c500..06ca61b270cf 100644 --- a/arch/arm/mach-stm32/soc.c +++ b/arch/arm/mach-stm32/soc.c @@ -8,6 +8,7 @@ #include <common.h> #include <asm/io.h> #include <asm/armv7m_mpu.h> +#include <asm/arch/stm32.h>
int arch_cpu_init(void) { @@ -54,3 +55,17 @@ int arch_cpu_init(void)
return 0; } + +void set_env_soc_name(void) +{ + char soc[16]; + +#ifdef CONFIG_STM32F4 + snprintf(soc, sizeof(soc), "stm32f4"); +#elif CONFIG_STM32F7 + snprintf(soc, sizeof(soc), "stm32f7"); +#elif CONFIG_STM32H7 + snprintf(soc, sizeof(soc), "stm32h7"); +#endif + env_set("soc_name", soc); +}

Hi,
On 02/05/2018 02:33 AM, patrice.chotard@st.com wrote:
From: Patrice Chotard patrice.chotard@st.com
This allows to create and set the environment variable "soc_name" which contains the current STM32 SoC's name.
Signed-off-by: Christophe Priouzeau christophe.priouzeau@st.com Signed-off-by: Patrice Chotard patrice.chotard@st.com
For the series, Reviewed-by: Vikas Manocha vikas.manocha@st.com
One point below, [...]
#endif /* _ASM_ARCH_HARDWARE_H */ diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c index df20d547c500..06ca61b270cf 100644 --- a/arch/arm/mach-stm32/soc.c +++ b/arch/arm/mach-stm32/soc.c @@ -8,6 +8,7 @@ #include <common.h> #include <asm/io.h> #include <asm/armv7m_mpu.h> +#include <asm/arch/stm32.h>
int arch_cpu_init(void) { @@ -54,3 +55,17 @@ int arch_cpu_init(void)
return 0; }
+void set_env_soc_name(void) +{
- char soc[16];
+#ifdef CONFIG_STM32F4
- snprintf(soc, sizeof(soc), "stm32f4");
+#elif CONFIG_STM32F7
- snprintf(soc, sizeof(soc), "stm32f7");
+#elif CONFIG_STM32H7
- snprintf(soc, sizeof(soc), "stm32h7");
+#endif
Can we move these conditional checks in the background like in some header file inline function & use it like get_soc_name();
Cheers, Vikas
- env_set("soc_name", soc);
+}

Hi Vikas
On 02/05/2018 05:24 PM, Vikas Manocha wrote:
Hi,
On 02/05/2018 02:33 AM, patrice.chotard@st.com wrote:
From: Patrice Chotard patrice.chotard@st.com
This allows to create and set the environment variable "soc_name" which contains the current STM32 SoC's name.
Signed-off-by: Christophe Priouzeau christophe.priouzeau@st.com Signed-off-by: Patrice Chotard patrice.chotard@st.com
For the series, Reviewed-by: Vikas Manocha vikas.manocha@st.com
One point below, [...]
- #endif /* _ASM_ARCH_HARDWARE_H */
diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c index df20d547c500..06ca61b270cf 100644 --- a/arch/arm/mach-stm32/soc.c +++ b/arch/arm/mach-stm32/soc.c @@ -8,6 +8,7 @@ #include <common.h> #include <asm/io.h> #include <asm/armv7m_mpu.h> +#include <asm/arch/stm32.h>
int arch_cpu_init(void) { @@ -54,3 +55,17 @@ int arch_cpu_init(void)
return 0; }
+void set_env_soc_name(void) +{
- char soc[16];
+#ifdef CONFIG_STM32F4
- snprintf(soc, sizeof(soc), "stm32f4");
+#elif CONFIG_STM32F7
- snprintf(soc, sizeof(soc), "stm32f7");
+#elif CONFIG_STM32H7
- snprintf(soc, sizeof(soc), "stm32h7");
+#endif
Can we move these conditional checks in the background like in some header file inline function & use it like get_soc_name();
Sure, i will send a v3
Thanks
Patrice
Cheers, Vikas
- env_set("soc_name", soc);
+}

Hi Patrice,
From: Patrice CHOTARD
Sure, i will send a v3
Thanks
Patrice
You can also activate CONFIG_ENV_VARS_UBOOT_CONFIG
Then the variables are defined in ./include/env_default.h :
arch=CONFIG_SYS_ARCH cpu=CONFIG_SYS_CPU board=CONFIG_SYS_BOARD board_name=CONFIG_SYS_BOARD vendor=CONFIG_SYS_VENDOR soc=CONFIG_SYS_SOC
It is perhaps more simple.
Regards

Hi Patrick
On 02/06/2018 09:52 AM, Patrick DELAUNAY wrote:
Hi Patrice,
From: Patrice CHOTARD
Sure, i will send a v3
Thanks
Patrice
You can also activate CONFIG_ENV_VARS_UBOOT_CONFIG
Then the variables are defined in ./include/env_default.h :
arch=CONFIG_SYS_ARCH cpu=CONFIG_SYS_CPU board=CONFIG_SYS_BOARD board_name=CONFIG_SYS_BOARD vendor=CONFIG_SYS_VENDOR soc=CONFIG_SYS_SOC
It is perhaps more simple.
1000 % more simple !!
Thanks for the tips
Regards

On 02/06/2018 12:52 AM, Patrick DELAUNAY wrote:
Hi Patrice,
From: Patrice CHOTARD
Sure, i will send a v3
Thanks
Patrice
You can also activate CONFIG_ENV_VARS_UBOOT_CONFIG
Great ! Thanks Patrick.
Cheers, Vikas
Then the variables are defined in ./include/env_default.h :
arch=CONFIG_SYS_ARCH cpu=CONFIG_SYS_CPU board=CONFIG_SYS_BOARD board_name=CONFIG_SYS_BOARD vendor=CONFIG_SYS_VENDOR soc=CONFIG_SYS_SOC
It is perhaps more simple.
Regards

From: Patrice Chotard patrice.chotard@st.com
Move BOARD_LATE_INIT flag from include/configs/stm32*.h to mach-stm32/Kconfig. Enable this flag also for STM32F4 SoCs family.
Signed-off-by: Patrice Chotard patrice.chotard@st.com ---
v2: _ None
arch/arm/mach-stm32/Kconfig | 3 +++ include/configs/stm32f746-disco.h | 1 - include/configs/stm32h743-disco.h | 1 - include/configs/stm32h743-eval.h | 1 - 4 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-stm32/Kconfig b/arch/arm/mach-stm32/Kconfig index f79b1a2c700e..c734a0ab8768 100644 --- a/arch/arm/mach-stm32/Kconfig +++ b/arch/arm/mach-stm32/Kconfig @@ -13,6 +13,7 @@ config STM32F4 select STM32_RCC select STM32_RESET select STM32_SERIAL + select BOARD_LATE_INIT
config STM32F7 bool "stm32f7 family" @@ -27,6 +28,7 @@ config STM32F7 select STM32_RCC select STM32_RESET select STM32_SERIAL + select BOARD_LATE_INIT select SUPPORT_SPL select SPL select SPL_BOARD_INIT @@ -63,6 +65,7 @@ config STM32H7 select STM32_RESET select STM32_SERIAL select SYSCON + select BOARD_LATE_INIT
source "arch/arm/mach-stm32/stm32f4/Kconfig" source "arch/arm/mach-stm32/stm32f7/Kconfig" diff --git a/include/configs/stm32f746-disco.h b/include/configs/stm32f746-disco.h index 3e952c2acd82..ae6889584a03 100644 --- a/include/configs/stm32f746-disco.h +++ b/include/configs/stm32f746-disco.h @@ -65,7 +65,6 @@ #define CONFIG_AUTO_COMPLETE #define CONFIG_CMDLINE_EDITING #define CONFIG_CMD_CACHE -#define CONFIG_BOARD_LATE_INIT #define CONFIG_DISPLAY_BOARDINFO
/* For SPL */ diff --git a/include/configs/stm32h743-disco.h b/include/configs/stm32h743-disco.h index 531de701492a..44b2813d3eeb 100644 --- a/include/configs/stm32h743-disco.h +++ b/include/configs/stm32h743-disco.h @@ -46,6 +46,5 @@ #define CONFIG_AUTO_COMPLETE #define CONFIG_CMDLINE_EDITING #define CONFIG_CMD_CACHE -#define CONFIG_BOARD_LATE_INIT
#endif /* __CONFIG_H */ diff --git a/include/configs/stm32h743-eval.h b/include/configs/stm32h743-eval.h index 531de701492a..44b2813d3eeb 100644 --- a/include/configs/stm32h743-eval.h +++ b/include/configs/stm32h743-eval.h @@ -46,6 +46,5 @@ #define CONFIG_AUTO_COMPLETE #define CONFIG_CMDLINE_EDITING #define CONFIG_CMD_CACHE -#define CONFIG_BOARD_LATE_INIT
#endif /* __CONFIG_H */

From: Patrice Chotard patrice.chotard@st.com
Add set_env_soc_name() call in board_late_init() to set environment variable "soc_name" with the name of current STM32 SoC.
Signed-off-by: Christophe Priouzeau christophe.priouzeau@st.com Signed-off-by: Patrice Chotard patrice.chotard@st.com --- v2: _ None
board/st/stm32f429-discovery/stm32f429-discovery.c | 7 +++++++ board/st/stm32f429-evaluation/stm32f429-evaluation.c | 7 +++++++ board/st/stm32f469-discovery/stm32f469-discovery.c | 7 +++++++ board/st/stm32f746-disco/stm32f746-disco.c | 2 ++ board/st/stm32h743-disco/stm32h743-disco.c | 4 ++++ board/st/stm32h743-eval/stm32h743-eval.c | 4 ++++ 6 files changed, 31 insertions(+)
diff --git a/board/st/stm32f429-discovery/stm32f429-discovery.c b/board/st/stm32f429-discovery/stm32f429-discovery.c index 3d90218faa61..44dcca5be508 100644 --- a/board/st/stm32f429-discovery/stm32f429-discovery.c +++ b/board/st/stm32f429-discovery/stm32f429-discovery.c @@ -60,6 +60,13 @@ int board_init(void) return 0; }
+int board_late_init(void) +{ + set_env_soc_name(); + + return 0; +} + #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { diff --git a/board/st/stm32f429-evaluation/stm32f429-evaluation.c b/board/st/stm32f429-evaluation/stm32f429-evaluation.c index 25e020784d62..9041dca5937b 100644 --- a/board/st/stm32f429-evaluation/stm32f429-evaluation.c +++ b/board/st/stm32f429-evaluation/stm32f429-evaluation.c @@ -54,6 +54,13 @@ int board_init(void) return 0; }
+int board_late_init(void) +{ + set_env_soc_name(); + + return 0; +} + #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { diff --git a/board/st/stm32f469-discovery/stm32f469-discovery.c b/board/st/stm32f469-discovery/stm32f469-discovery.c index 36f7b2e8e176..263d995c1534 100644 --- a/board/st/stm32f469-discovery/stm32f469-discovery.c +++ b/board/st/stm32f469-discovery/stm32f469-discovery.c @@ -54,6 +54,13 @@ int board_init(void) return 0; }
+int board_late_init(void) +{ + set_env_soc_name(); + + return 0; +} + #ifdef CONFIG_MISC_INIT_R int misc_init_r(void) { diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c index 8da70281f976..d259bb14fee3 100644 --- a/board/st/stm32f746-disco/stm32f746-disco.c +++ b/board/st/stm32f746-disco/stm32f746-disco.c @@ -115,6 +115,8 @@ int board_late_init(void) struct gpio_desc gpio = {}; int node;
+ set_env_soc_name(); + node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1"); if (node < 0) return -1; diff --git a/board/st/stm32h743-disco/stm32h743-disco.c b/board/st/stm32h743-disco/stm32h743-disco.c index 226b7045d278..d4ad9230c06e 100644 --- a/board/st/stm32h743-disco/stm32h743-disco.c +++ b/board/st/stm32h743-disco/stm32h743-disco.c @@ -8,6 +8,8 @@ #include <common.h> #include <dm.h>
+#include <asm/arch/stm32.h> + DECLARE_GLOBAL_DATA_PTR;
int dram_init(void) @@ -46,6 +48,8 @@ u32 get_board_rev(void)
int board_late_init(void) { + set_env_soc_name(); + return 0; }
diff --git a/board/st/stm32h743-eval/stm32h743-eval.c b/board/st/stm32h743-eval/stm32h743-eval.c index 226b7045d278..d4ad9230c06e 100644 --- a/board/st/stm32h743-eval/stm32h743-eval.c +++ b/board/st/stm32h743-eval/stm32h743-eval.c @@ -8,6 +8,8 @@ #include <common.h> #include <dm.h>
+#include <asm/arch/stm32.h> + DECLARE_GLOBAL_DATA_PTR;
int dram_init(void) @@ -46,6 +48,8 @@ u32 get_board_rev(void)
int board_late_init(void) { + set_env_soc_name(); + return 0; }

Hi
This series will be abandoned and replaced by a new patch using CONFIG_ENV_VARS_UBOOT_CONFIG flag.
Patrice
On 02/05/2018 11:33 AM, patrice.chotard@st.com wrote:
From: Patrice Chotard patrice.chotard@st.com
This series allows to create and set the environment variable "soc_name" corresponding to the current STM32 SoCs name.
We will add STM32 SoCs support in buildroot environment Our objective is to propose a flexible solution to boot linux kernel from sdcard.
As for STM32F4, STM32F7 and STM32H7 linux defconfig is slightly different (specific CONFIG_DRAM_BASE and CONFIG_DRAM_SIZE) we can't use the same zImage for all these SoCs.
To simplify, we will embed all dtb/zImage in the sdcard and using the soc_name environment variable to select the correct zImage.
v2: _ Remove get_cpu_id() function and use directly CONFIG_STM32xx flag to identify the STM32 SoC family.
Patrice Chotard (8): mach-stm32: Add get_cpu_id support mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig board: stm32: Add set_env_soc_name() in board_late_init()
arch/arm/include/asm/arch-stm32f4/stm32.h | 1 + arch/arm/include/asm/arch-stm32f7/stm32.h | 1 + arch/arm/include/asm/arch-stm32h7/stm32.h | 3 +++ arch/arm/mach-stm32/Kconfig | 3 +++ arch/arm/mach-stm32/soc.c | 15 +++++++++++++++ board/st/stm32f429-discovery/stm32f429-discovery.c | 7 +++++++ board/st/stm32f429-evaluation/stm32f429-evaluation.c | 7 +++++++ board/st/stm32f469-discovery/stm32f469-discovery.c | 7 +++++++ board/st/stm32f746-disco/stm32f746-disco.c | 2 ++ board/st/stm32h743-disco/stm32h743-disco.c | 4 ++++ board/st/stm32h743-eval/stm32h743-eval.c | 4 ++++ include/configs/stm32f746-disco.h | 1 - include/configs/stm32h743-disco.h | 1 - include/configs/stm32h743-eval.h | 1 - 14 files changed, 54 insertions(+), 3 deletions(-)
participants (4)
-
Patrice CHOTARD
-
patrice.chotard@st.com
-
Patrick DELAUNAY
-
Vikas Manocha