Skip to contentSkip to conversation

Add set_env_soc_name() for STM32 SoCs

PATCH Superseded patrice.chotard at st.com 3 participants 10 messages Feb 5, 2018 – Feb 6, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Add set_env_soc_name() for STM32 SoCs

From: Patrice Chotard <[email protected]>

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(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/3 mach-stm32: Add set_env_soc_name support

From: Patrice Chotard <[email protected]>

This allows to create and set the environment variable "soc_name" which contains the current STM32 SoC's name.

---

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(+)
arch/arm/include/asm/arch-stm32f4/stm32.h +1 -0
index 0449fcecede0..d4b0c40804c0 100644
@@ -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_ */
arch/arm/include/asm/arch-stm32f7/stm32.h +1 -0
index f54e6f195575..315d2a14790c 100644
@@ -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 */
arch/arm/include/asm/arch-stm32h7/stm32.h +3 -0
index f2922aa3237e..9377c5d65bfb 100644
@@ -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 */
arch/arm/mach-stm32/soc.c +15 -0
index df20d547c500..06ca61b270cf 100644
@@ -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);
+}
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/3 mach-stm32: Add set_env_soc_name support

Hi,

Quoted 7 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

This allows to create and set the environment variable "soc_name" which contains the current STM32 SoC's name.

For the series,

One point below,
[...]

Quoted 20 lines
(quoted diff) +1 -0
+
 #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/mach-stm32/soc.c +3 -0
index df20d547c500..06ca61b270cf 100644
@@ -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)

arch/arm/mach-stm32/soc.c int arch_cpu_init(void) · line 69

Quoted 10 lines
arch/arm/mach-stm32/soc.c +10 -0
+{
+	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

Quoted 3 lines
arch/arm/mach-stm32/soc.c +2 -0
+	env_set("soc_name", soc);
+}
#3 lore raw

PATCH v2 1/3 mach-stm32: Add set_env_soc_name support

Hi Vikas

Quoted 33 lines · Vikas Manocha

Hi,

Quoted 7 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

This allows to create and set the environment variable "soc_name" which contains the current STM32 SoC's name.

For the series,

One point below,
[...]

Quoted 16 lines
(quoted diff) +1 -0
+
  #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/mach-stm32/soc.c +1 -0
index df20d547c500..06ca61b270cf 100644
@@ -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)
 
Quoted 16 lines
Quoted 4 lines
arch/arm/mach-stm32/soc.c +2 -0
  	return 0;
  }
+
+void set_env_soc_name(void)

arch/arm/mach-stm32/soc.c int arch_cpu_init(void) · line 69

Quoted 10 lines
arch/arm/mach-stm32/soc.c +10 -0
+{
+	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

Quoted 7 lines

Cheers,
Vikas

Quoted 3 lines
arch/arm/mach-stm32/soc.c +2 -0
+	env_set("soc_name", soc);
+}
#4 lore raw

PATCH v2 1/3 mach-stm32: Add set_env_soc_name support

Hi Patrice,

Quoted 8 lines

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

#5 lore raw

PATCH v2 1/3 mach-stm32: Add set_env_soc_name support

Hi Patrick

Quoted 15 lines · Patrick DELAUNAY

Hi Patrice,

Quoted 8 lines

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 :

Quoted 8 lines

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

Quoted 3 lines

Regards

#6 lore raw

PATCH v2 1/3 mach-stm32: Add set_env_soc_name support

In reply to Patrick DELAUNAY
Quoted 4 lines · Patrick DELAUNAY

Hi Patrice,

Quoted 2 lines

From: Patrice CHOTARD

Quoted 8 lines
Quoted 6 lines

Sure, i will send a v3

Thanks

Patrice

You can also activate CONFIG_ENV_VARS_UBOOT_CONFIG

Great ! Thanks Patrick.

Cheers,
Vikas

Quoted 14 lines

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

#7 lore raw

PATCH v2 2/3 mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Move BOARD_LATE_INIT flag from include/configs/stm32*.h to mach-stm32/Kconfig.
Enable this flag also for STM32F4 SoCs family.

---

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(-)
arch/arm/mach-stm32/Kconfig +3 -0
index f79b1a2c700e..c734a0ab8768 100644
@@ -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"
include/configs/stm32f746-disco.h +0 -1
index 3e952c2acd82..ae6889584a03 100644
@@ -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 */
include/configs/stm32h743-disco.h +0 -1
index 531de701492a..44b2813d3eeb 100644
@@ -46,6 +46,5 @@
 #define CONFIG_AUTO_COMPLETE
 #define CONFIG_CMDLINE_EDITING
 #define CONFIG_CMD_CACHE
-#define CONFIG_BOARD_LATE_INIT
 
 #endif /* __CONFIG_H */
include/configs/stm32h743-eval.h +0 -1
index 531de701492a..44b2813d3eeb 100644
@@ -46,6 +46,5 @@
 #define CONFIG_AUTO_COMPLETE
 #define CONFIG_CMDLINE_EDITING
 #define CONFIG_CMD_CACHE
-#define CONFIG_BOARD_LATE_INIT
 
 #endif /* __CONFIG_H */
Signature · 1 line
1.9.1
#8 lore raw

PATCH v2 3/3 board: stm32: Add set_env_soc_name() in board_late_init()

In reply to patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Add set_env_soc_name() call in board_late_init() to set environment variable "soc_name" with the name of current STM32 SoC.

---
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(+)
board/st/stm32f429-discovery/stm32f429-discovery.c +7 -0
index 3d90218faa61..44dcca5be508 100644
@@ -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)
 {
board/st/stm32f429-evaluation/stm32f429-evaluation.c +7 -0
index 25e020784d62..9041dca5937b 100644
@@ -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)
 {
board/st/stm32f469-discovery/stm32f469-discovery.c +7 -0
index 36f7b2e8e176..263d995c1534 100644
@@ -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)
 {
board/st/stm32f746-disco/stm32f746-disco.c +2 -0
index 8da70281f976..d259bb14fee3 100644
@@ -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;
board/st/stm32h743-disco/stm32h743-disco.c +4 -0
index 226b7045d278..d4ad9230c06e 100644
@@ -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;
 }
 
board/st/stm32h743-eval/stm32h743-eval.c +4 -0
index 226b7045d278..d4ad9230c06e 100644
@@ -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;
 }
 
Signature · 1 line
1.9.1
#9 lore raw

v2 cover Add set_env_soc_name() for STM32 SoCs

In reply to patrice.chotard at st.com

Hi

This series will be abandoned and replaced by a new patch using CONFIG_ENV_VARS_UBOOT_CONFIG flag.

Patrice

Quoted 41 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

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(-)