Skip to contentSkip to conversation

Add get_cpu_id for STM32 SoCs

PATCH New patrice.chotard at st.com 2 participants 17 messages Jan 31, 2018 – Feb 5, 2018

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

cover Add get_cpu_id for STM32 SoCs

From: Patrice Chotard <[email protected]>

This series allows to get the cpu id of STM32 SoCs and to set the environment variable "soc_name" with the corresponding SoC name.

This will be useful in some development environment to retrieve files correspondig to SoC family.

Patrice Chotard (8):
mach-stm32: Add get_cpu_id support
mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig
board: stm32f429-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32h743-evaluation: Add set_env_soc_name() in
board_late_init()
board: stm32f743-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f429-evaluation: Add set_env_soc_name() in
board_late_init()

 arch/arm/include/asm/arch-stm32f4/stm32.h          |  2 +
 arch/arm/include/asm/arch-stm32f7/stm32.h          |  2 +
 arch/arm/include/asm/arch-stm32h7/stm32.h          |  4 ++
 arch/arm/mach-stm32/Kconfig                        |  3 ++
 arch/arm/mach-stm32/soc.c                          | 46 ++++++++++++++++++++++
 board/st/stm32f429-discovery/stm32f429-discovery.c |  7 ++++
 .../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, 88 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/8 mach-stm32: Add get_cpu_id support

From: Patrice Chotard <[email protected]>

This allows to read the CPU ID into STM32 DBGMCU_IDCODE register and create an environment variable which contains the soc name.

---
 arch/arm/include/asm/arch-stm32f4/stm32.h |  2 ++
 arch/arm/include/asm/arch-stm32f7/stm32.h |  2 ++
 arch/arm/include/asm/arch-stm32h7/stm32.h |  4 +++
 arch/arm/mach-stm32/soc.c                 | 46 +++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+)
arch/arm/include/asm/arch-stm32f4/stm32.h +2 -0
index 0449fcecede0..87fd0fa893e5 100644
@@ -50,5 +50,7 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 };
 
 void stm32_flash_latency_cfg(int latency);
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
 
 #endif /* _MACH_STM32_H_ */
arch/arm/include/asm/arch-stm32f7/stm32.h +2 -0
index f54e6f195575..dade6e9661ac 100644
@@ -63,5 +63,7 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 
 
 void stm32_flash_latency_cfg(int latency);
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
 
 #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/include/asm/arch-stm32h7/stm32.h +4 -0
index f2922aa3237e..e520c7ea0dbd 100644
@@ -18,4 +18,8 @@
  * arch/arm/include/asm/arch-stm32f4/stm32.h
  * arch/arm/include/asm/arch-stm32f7/stm32.h
  */
+
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
+
 #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/mach-stm32/soc.c +46 -0

55 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/8 mach-stm32: Add get_cpu_id support

Hi Patrice,

arch/arm/include/asm/arch-stm32h7/stm32.h

Quoted 42 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

This allows to read the CPU ID into STM32 DBGMCU_IDCODE register and create an environment variable which contains the soc name.

---
 arch/arm/include/asm/arch-stm32f4/stm32.h |  2 ++
 arch/arm/include/asm/arch-stm32f7/stm32.h |  2 ++
 arch/arm/include/asm/arch-stm32h7/stm32.h |  4 +++
 arch/arm/mach-stm32/soc.c                 | 46 +++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+)
arch/arm/include/asm/arch-stm32f4/stm32.h +2 -0
index 0449fcecede0..87fd0fa893e5 100644
@@ -50,5 +50,7 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 };
 
 void stm32_flash_latency_cfg(int latency);
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
 
 #endif /* _MACH_STM32_H_ */
arch/arm/include/asm/arch-stm32f7/stm32.h +2 -0
index f54e6f195575..dade6e9661ac 100644
@@ -63,5 +63,7 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 
 
 void stm32_flash_latency_cfg(int latency);
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
 
 #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/include/asm/arch-stm32h7/stm32.h +0 -0
index f2922aa3237e..e520c7ea0dbd 100644

how about creating one common header file for stm32.

Quoted 14 lines
arch/arm/include/asm/arch-stm32h7/stm32.h +4 -0
@@ -18,4 +18,8 @@
  * arch/arm/include/asm/arch-stm32f4/stm32.h
  * arch/arm/include/asm/arch-stm32f7/stm32.h
  */
+
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
+
 #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/mach-stm32/soc.c +0 -0
index df20d547c500..0933dfce656d 100644

arch/arm/mach-stm32/soc.c line 12

Quoted 4 lines
arch/arm/mach-stm32/soc.c +1 -0
@@ -9,6 +9,30 @@
 #include <asm/io.h>
 #include <asm/armv7m_mpu.h>
 
+#define STM32_DBGMCU_IDCODE_DEV_ID	GENMASK(11, 0)

to make it clear it is MASK macro, pls replace xx_DEV_D with xx_MASK.

arch/arm/mach-stm32/soc.c line 18

Quoted 6 lines
arch/arm/mach-stm32/soc.c +6 -0
+
+#if !defined(CONFIG_STM32H7)
+#define STM32_DBGMCU_IDCODE		0xE0042000
+#else
+#define STM32_DBGMCU_IDCODE		0x5C001000
+#endif

move it to arch/soc register definitions like to arch/arm/include/asm/arch-stm32f7/stm32.h

Quoted 26 lines
arch/arm/mach-stm32/soc.c +19 -0
+
+struct cpu_id_table {
+	unsigned int	id;
+	const char	*name;
+	};
+
+const struct cpu_id_table stm32_cpu_id_table[] = {
+	{ 0x413, "stm32f4" },
+	{ 0x419, "stm32f4" },
+	{ 0x434, "stm32f4" },
+	{ 0x449, "stm32f7" },
+	{ 0x451, "stm32f7" },
+	{ 0x450, "stm32h7" },
+	{ 0x452, "stm32f7" },
+	{ 0 },
+};
+
 int arch_cpu_init(void)
 {
 	int i;
@@ -54,3 +78,25 @@ int arch_cpu_init(void)
 
 	return 0;
 }
+
+int get_cpu_id(void)

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

Quoted 10 lines
arch/arm/mach-stm32/soc.c +10 -0
+{
+	return readl(STM32_DBGMCU_IDCODE) & STM32_DBGMCU_IDCODE_DEV_ID;
+}
+
+void set_env_soc_name(int cpu_id)
+{
+	char soc[16];
+	int i;
+
+	memset(soc, '\0', sizeof(soc));

do we need it ?

Cheers,
Vikas

Quoted 11 lines
arch/arm/mach-stm32/soc.c +10 -0
+
+	for (i = 0; i < sizeof(stm32_cpu_id_table); i++) {
+		if (stm32_cpu_id_table[i].id == cpu_id) {
+			snprintf(soc, sizeof(soc), stm32_cpu_id_table[i].name);
+			break;
+		}
+	}
+
+	env_set("soc_name", soc);
+}
#3 lore raw

PATCH 1/8 mach-stm32: Add get_cpu_id support

Hi Vikas

Quoted 40 lines · Vikas Manocha

Hi Patrice,

Quoted 37 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

This allows to read the CPU ID into STM32 DBGMCU_IDCODE register and create an environment variable which contains the soc name.

---
  arch/arm/include/asm/arch-stm32f4/stm32.h |  2 ++
  arch/arm/include/asm/arch-stm32f7/stm32.h |  2 ++
  arch/arm/include/asm/arch-stm32h7/stm32.h |  4 +++
  arch/arm/mach-stm32/soc.c                 | 46 +++++++++++++++++++++++++++++++
  4 files changed, 54 insertions(+)
arch/arm/include/asm/arch-stm32f4/stm32.h +2 -0
index 0449fcecede0..87fd0fa893e5 100644
@@ -50,5 +50,7 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
  };
 
  void stm32_flash_latency_cfg(int latency);
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
 
  #endif /* _MACH_STM32_H_ */
arch/arm/include/asm/arch-stm32f7/stm32.h +2 -0
index f54e6f195575..dade6e9661ac 100644
@@ -63,5 +63,7 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 
 
  void stm32_flash_latency_cfg(int latency);
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
 
Quoted 7 lines

arch/arm/include/asm/arch-stm32h7/stm32.h

Quoted 5 lines
arch/arm/include/asm/arch-stm32f7/stm32.h +0 -0
  #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/include/asm/arch-stm32h7/stm32.h +0 -0
index f2922aa3237e..e520c7ea0dbd 100644

how about creating one common header file for stm32.

It will be done in another series which is in preparation :
_ factorize arch/arm/include/asm/arch-stm32xx/stm32.h and all others
acrh files (gpio.h, stm32_defs.h, stm32_periph.h ....)
_ add a common stm32_timer driver and remove arch/arm/mach-
stm32/stm32f4/timer.c and arch/arm/mach-stm32/stm32f7/timer.c

Quoted 18 lines
Quoted 18 lines
arch/arm/include/asm/arch-stm32h7/stm32.h +4 -0
@@ -18,4 +18,8 @@
   * arch/arm/include/asm/arch-stm32f4/stm32.h
   * arch/arm/include/asm/arch-stm32f7/stm32.h
   */
+
+int get_cpu_id(void);
+void set_env_soc_name(int cpu_id);
+
  #endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/mach-stm32/soc.c +0 -0
index df20d547c500..0933dfce656d 100644
@@ -9,6 +9,30 @@
  #include <asm/io.h>
  #include <asm/armv7m_mpu.h>
 
Quoted 3 lines

arch/arm/mach-stm32/soc.c line 12

Quoted 1 line
arch/arm/mach-stm32/soc.c +1 -0
+#define STM32_DBGMCU_IDCODE_DEV_ID	GENMASK(11, 0)

to make it clear it is MASK macro, pls replace xx_DEV_D with xx_MASK.

ok

Quoted 9 lines

arch/arm/mach-stm32/soc.c line 18

Quoted 7 lines
arch/arm/mach-stm32/soc.c +6 -0
+
+#if !defined(CONFIG_STM32H7)
+#define STM32_DBGMCU_IDCODE		0xE0042000
+#else
+#define STM32_DBGMCU_IDCODE		0x5C001000
+#endif

move it to arch/soc register definitions like to arch/arm/include/asm/arch-stm32f7/stm32.h

ok

Quoted 23 lines
Quoted 23 lines
arch/arm/mach-stm32/soc.c +17 -0
+
+struct cpu_id_table {
+	unsigned int	id;
+	const char	*name;
+	};
+
+const struct cpu_id_table stm32_cpu_id_table[] = {
+	{ 0x413, "stm32f4" },
+	{ 0x419, "stm32f4" },
+	{ 0x434, "stm32f4" },
+	{ 0x449, "stm32f7" },
+	{ 0x451, "stm32f7" },
+	{ 0x450, "stm32h7" },
+	{ 0x452, "stm32f7" },
+	{ 0 },
+};
+
  int arch_cpu_init(void)
  {
  	int i;
@@ -54,3 +78,25 @@ int arch_cpu_init(void)
 
Quoted 16 lines
Quoted 4 lines
arch/arm/mach-stm32/soc.c +2 -0
  	return 0;
  }
+
+int get_cpu_id(void)

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

Quoted 10 lines
arch/arm/mach-stm32/soc.c +10 -0
+{
+	return readl(STM32_DBGMCU_IDCODE) & STM32_DBGMCU_IDCODE_DEV_ID;
+}
+
+void set_env_soc_name(int cpu_id)
+{
+	char soc[16];
+	int i;
+
+	memset(soc, '\0', sizeof(soc));

do we need it ?

No, i will remove it

Thanks

Patrice

Quoted 15 lines

Cheers,
Vikas

Quoted 11 lines
arch/arm/mach-stm32/soc.c +10 -0
+
+	for (i = 0; i < sizeof(stm32_cpu_id_table); i++) {
+		if (stm32_cpu_id_table[i].id == cpu_id) {
+			snprintf(soc, sizeof(soc), stm32_cpu_id_table[i].name);
+			break;
+		}
+	}
+
+	env_set("soc_name", soc);
+}
#4 lore raw

PATCH 2/8 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.

---
 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
#5 lore raw

PATCH 3/8 board: stm32f429-discovery: 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.

---
 board/st/stm32f429-discovery/stm32f429-discovery.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/st/stm32f429-discovery/stm32f429-discovery.c +7 -0
index 3d90218faa61..b0d884cb95fa 100644
@@ -60,6 +60,13 @@ int board_init(void)
 	return 0;
 }
 
+int board_late_init(void)
+{
+	set_env_soc_name(get_cpu_id());
+
+	return 0;
+}
+
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
Signature · 1 line
1.9.1
#6 lore raw

PATCH 4/8 board: stm32h743-evaluation: 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.

---
 board/st/stm32h743-eval/stm32h743-eval.c | 4 ++++
 1 file changed, 4 insertions(+)
board/st/stm32h743-eval/stm32h743-eval.c +4 -0
index 226b7045d278..501cecf5387a 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(get_cpu_id());
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#7 lore raw

PATCH 5/8 board: stm32f743-discovery: 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.

---
 board/st/stm32h743-disco/stm32h743-disco.c | 4 ++++
 1 file changed, 4 insertions(+)
board/st/stm32h743-disco/stm32h743-disco.c +4 -0
index 226b7045d278..501cecf5387a 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(get_cpu_id());
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#8 lore raw

PATCH 6/8 board: stm32f469-discovery: 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.

---
 board/st/stm32f746-disco/stm32f746-disco.c | 2 ++
 1 file changed, 2 insertions(+)
board/st/stm32f746-disco/stm32f746-disco.c +2 -0
index 8da70281f976..0ad03ce96d33 100644
@@ -115,6 +115,8 @@ int board_late_init(void)
 	struct gpio_desc gpio = {};
 	int node;
 
+	set_env_soc_name(get_cpu_id());
+
 	node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1");
 	if (node < 0)
 		return -1;
Signature · 1 line
1.9.1
#9 lore raw

PATCH 6/8 board: stm32f469-discovery: Add set_env_soc_name() in board_late_init()

Hi,

board/st/stm32f746-disco/stm32f746-disco.c

Quoted 12 lines · 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.

---
 board/st/stm32f746-disco/stm32f746-disco.c | 2 ++
 1 file changed, 2 insertions(+)
board/st/stm32f746-disco/stm32f746-disco.c +0 -0

does not match with the Subject, same mis-match in one more patch. Can we club these board patches in one.

Cheers,
Vikas

Quoted 13 lines

index 8da70281f976..0ad03ce96d33 100644

board/st/stm32f746-disco/stm32f746-disco.c +2 -0
@@ -115,6 +115,8 @@ int board_late_init(void)
 	struct gpio_desc gpio = {};
 	int node;
 
+	set_env_soc_name(get_cpu_id());
+
 	node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1");
 	if (node < 0)
 		return -1;
#10 lore raw

PATCH 6/8 board: stm32f469-discovery: Add set_env_soc_name() in board_late_init()

Hi Vikas

Quoted 14 lines · Vikas Manocha

Hi,

Quoted 11 lines · 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.

---
  board/st/stm32f746-disco/stm32f746-disco.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 4 lines

board/st/stm32f746-disco/stm32f746-disco.c

Quoted 1 line
board/st/stm32f746-disco/stm32f746-disco.c +0 -0

does not match with the Subject, same mis-match in one more patch. Can we club these board patches in one.

Ok

Thanks

Patrice

Quoted 17 lines

Cheers,
Vikas

Quoted 13 lines

index 8da70281f976..0ad03ce96d33 100644

board/st/stm32f746-disco/stm32f746-disco.c +2 -0
@@ -115,6 +115,8 @@ int board_late_init(void)
  	struct gpio_desc gpio = {};
  	int node;
 
+	set_env_soc_name(get_cpu_id());
+
  	node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1");
  	if (node < 0)
  		return -1;
#11 lore raw

PATCH 7/8 board: stm32f469-discovery: 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.

---
 board/st/stm32f469-discovery/stm32f469-discovery.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/st/stm32f469-discovery/stm32f469-discovery.c +7 -0
index 36f7b2e8e176..c2ef76ba9ac3 100644
@@ -54,6 +54,13 @@ int board_init(void)
 	return 0;
 }
 
+int board_late_init(void)
+{
+	set_env_soc_name(get_cpu_id());
+
+	return 0;
+}
+
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
Signature · 1 line
1.9.1
#12 lore raw

PATCH 8/8 board: stm32f429-evaluation: 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.

---
 board/st/stm32f429-evaluation/stm32f429-evaluation.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/st/stm32f429-evaluation/stm32f429-evaluation.c +7 -0
index 25e020784d62..108b22a8dcba 100644
@@ -54,6 +54,13 @@ int board_init(void)
 	return 0;
 }
 
+int board_late_init(void)
+{
+	set_env_soc_name(get_cpu_id());
+
+	return 0;
+}
+
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
Signature · 1 line
1.9.1
#13 lore raw

cover Add get_cpu_id for STM32 SoCs

In reply to patrice.chotard at st.com

Hi Patrice,

Quoted 7 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

This series allows to get the cpu id of STM32 SoCs and to set the environment variable "soc_name" with the corresponding SoC name.

This will be useful in some development environment to retrieve files correspondig to SoC family.

can you provide some example ? We have the device tree compatible string to distinguish board & soc.

Cheers,
Vikas

Quoted 33 lines

Patrice Chotard (8):
mach-stm32: Add get_cpu_id support
mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig
board: stm32f429-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32h743-evaluation: Add set_env_soc_name() in
board_late_init()
board: stm32f743-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f429-evaluation: Add set_env_soc_name() in
board_late_init()

 arch/arm/include/asm/arch-stm32f4/stm32.h          |  2 +
 arch/arm/include/asm/arch-stm32f7/stm32.h          |  2 +
 arch/arm/include/asm/arch-stm32h7/stm32.h          |  4 ++
 arch/arm/mach-stm32/Kconfig                        |  3 ++
 arch/arm/mach-stm32/soc.c                          | 46 ++++++++++++++++++++++
 board/st/stm32f429-discovery/stm32f429-discovery.c |  7 ++++
 .../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, 88 insertions(+), 3 deletions(-)
#14 lore raw

cover Add get_cpu_id for STM32 SoCs

+Christophe Priouzeau who is the requester/developper of this feature

Quoted 5 lines · Vikas Manocha

Hi Patrice,

Quoted 2 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Quoted 7 lines
Quoted 5 lines

This series allows to get the cpu id of STM32 SoCs and to set the environment variable "soc_name" with the corresponding SoC name.

This will be useful in some development environment to retrieve files correspondig to SoC family.

can you provide some example ? We have the device tree compatible string to distinguish board & soc.

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.

Patrice

Quoted 37 lines

Cheers,
Vikas

Quoted 33 lines

Patrice Chotard (8):
mach-stm32: Add get_cpu_id support
mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig
board: stm32f429-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32h743-evaluation: Add set_env_soc_name() in
board_late_init()
board: stm32f743-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f429-evaluation: Add set_env_soc_name() in
board_late_init()

  arch/arm/include/asm/arch-stm32f4/stm32.h          |  2 +
  arch/arm/include/asm/arch-stm32f7/stm32.h          |  2 +
  arch/arm/include/asm/arch-stm32h7/stm32.h          |  4 ++
  arch/arm/mach-stm32/Kconfig                        |  3 ++
  arch/arm/mach-stm32/soc.c                          | 46 ++++++++++++++++++++++
  board/st/stm32f429-discovery/stm32f429-discovery.c |  7 ++++
  .../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, 88 insertions(+), 3 deletions(-)
#15 lore raw

cover Add get_cpu_id for STM32 SoCs

Hi Patrice,

Quoted 21 lines · Patrice CHOTARD

+Christophe Priouzeau who is the requester/developper of this feature

Quoted 5 lines · Vikas Manocha

Hi Patrice,

Quoted 2 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Quoted 7 lines
Quoted 5 lines

This series allows to get the cpu id of STM32 SoCs and to set the environment variable "soc_name" with the corresponding SoC name.

This will be useful in some development environment to retrieve files correspondig to SoC family.

can you provide some example ? We have the device tree compatible string to distinguish board & soc.

We will add STM32 SoCs support in buildroot environment Our objective is to propose a flexible solution to boot linux kernel from sdcard.

Quoted 6 lines

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.

soc name is already part of configuration (SYS_SOC). It would be simpler and less expensive (for both cpu & memory) to use it.
In this patchset, 56 Bytes(currently, which will increase with more SOCs support) of lookup table are becoming part of text apart from the additional code.

Cheers,
Vikas

Quoted 41 lines

Patrice

Quoted 37 lines

Cheers,
Vikas

Quoted 33 lines

Patrice Chotard (8):
mach-stm32: Add get_cpu_id support
mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig
board: stm32f429-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32h743-evaluation: Add set_env_soc_name() in
board_late_init()
board: stm32f743-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f429-evaluation: Add set_env_soc_name() in
board_late_init()

  arch/arm/include/asm/arch-stm32f4/stm32.h          |  2 +
  arch/arm/include/asm/arch-stm32f7/stm32.h          |  2 +
  arch/arm/include/asm/arch-stm32h7/stm32.h          |  4 ++
  arch/arm/mach-stm32/Kconfig                        |  3 ++
  arch/arm/mach-stm32/soc.c                          | 46 ++++++++++++++++++++++
  board/st/stm32f429-discovery/stm32f429-discovery.c |  7 ++++
  .../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, 88 insertions(+), 3 deletions(-)
#16 lore raw

cover Add get_cpu_id for STM32 SoCs

Hi Vikas

Quoted 28 lines · Vikas Manocha

Hi Patrice,

Quoted 25 lines · Patrice CHOTARD

+Christophe Priouzeau who is the requester/developper of this feature

Quoted 5 lines · Vikas Manocha

Hi Patrice,

Quoted 2 lines · patrice.chotard at st.com

From: Patrice Chotard <[email protected]>

Quoted 7 lines
Quoted 5 lines

This series allows to get the cpu id of STM32 SoCs and to set the environment variable "soc_name" with the corresponding SoC name.

This will be useful in some development environment to retrieve files correspondig to SoC family.

can you provide some example ? We have the device tree compatible string to distinguish board & soc.

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.

Quoted 5 lines
Quoted 2 lines

To simplify, we will embed all dtb/zImage in the sdcard and using the soc_name environment variable to select the correct zImage.

soc name is already part of configuration (SYS_SOC). It would be simpler and less expensive (for both cpu & memory) to use it.
In this patchset, 56 Bytes(currently, which will increase with more SOCs support) of lookup table are becoming part of text apart from the additional code.

Ok i got your point, i will rework this series

Thanks

Patrice

Quoted 45 lines

Cheers,
Vikas

Quoted 41 lines

Patrice

Quoted 37 lines

Cheers,
Vikas

Quoted 33 lines

Patrice Chotard (8):
mach-stm32: Add get_cpu_id support
mach-stm32: Move BOARD_LATE_INIT flag to mach-stm32 Kconfig
board: stm32f429-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32h743-evaluation: Add set_env_soc_name() in
board_late_init()
board: stm32f743-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f469-discovery: Add set_env_soc_name() in
board_late_init()
board: stm32f429-evaluation: Add set_env_soc_name() in
board_late_init()

   arch/arm/include/asm/arch-stm32f4/stm32.h          |  2 +
   arch/arm/include/asm/arch-stm32f7/stm32.h          |  2 +
   arch/arm/include/asm/arch-stm32h7/stm32.h          |  4 ++
   arch/arm/mach-stm32/Kconfig                        |  3 ++
   arch/arm/mach-stm32/soc.c                          | 46 ++++++++++++++++++++++
   board/st/stm32f429-discovery/stm32f429-discovery.c |  7 ++++
   .../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, 88 insertions(+), 3 deletions(-)