Optionally: Set the serial# environment variable on the i.MX7.
Subsystems (3)
PATCH 1/1 Optionally: Set the serial# environment variable on the i.MX7.
Enabling this new option allows the kernel to obtain the unique ID of the CPU when not using ATAGS.
---
arch/arm/include/asm/bootm.h +1 -1
@@ -39,7 +39,7 @@ extern void udc_disconnect(void);#endif struct tag_serialnr ; -#ifdef CONFIG_SERIAL_TAG +#if defined(CONFIG_SERIAL_TAG ) || defined(CONFIG_SET_SERIAL_ENV )#define BOOTM_ENABLE_SERIAL_TAG 1void get_board_serial (struct tag_serialnr *serialnr);#else
arch/arm/mach-imx/mx7/Kconfig +7 -0
@@ -71,6 +71,13 @@ config TARGET_COLIBRI_IMX7 endchoice +config SET_SERIAL_ENV + bool "Set serial number variable from the OCOTP" + help + Selecting this option will populate the serial# environment + variable with a unique identifier from the i.MX7 CPU. The + Linux kernel will use this as the serial number of the machine. + config SYS_SOC default "mx7"
arch/arm/mach-imx/mx7/soc.c +14 -1
@@ -344,11 +344,24 @@ int arch_misc_init(void)sec_init ();#endif +#ifdef CONFIG_SET_SERIAL_ENV + { +struct tag_serialnr serialnr; +char serialbuf[sizeof (serialnr) *2 +8 ]; + +get_board_serial (&serialnr); +snprintf (serialbuf,sizeof (serialbuf), +"%08lx%08lx" , + (ulong )serialnr.high, (ulong )serialnr.low); +env_set ("serial#" , serialbuf); + } +#endif + return 0; }#endif -#ifdef CONFIG_SERIAL_TAG +#if defined(CONFIG_SERIAL_TAG ) || defined(CONFIG_SET_SERIAL_ENV )/* * OCOTP_TESTER * i.MX 7Solo Applications Processor Reference Manual, Rev. 0.1, 08/2016
Signature · 1 line
2.17.1
PATCH 1/1 Optionally: Set the serial# environment variable on the i.MX7.
Hi Mark,
patch was hidden in the flood of other patches and I am unsure if this belongs to i.MX:
Quoted 26 lines · Mark G
Enabling this new option allows the kernel to obtain the unique ID of the CPU when not using ATAGS.
Signed-off-by Mark G <[email protected]>---
arch/arm/include/asm/bootm.h +0
-0@@ -39,7 +39,7 @@ extern void udc_disconnect(void);?#endif
?struct
tag_serialnr;arch/arm/include/asm/bootm.h +1
-1-#ifdef CONFIG_SERIAL_TAG +#if defined(CONFIG_SERIAL_TAG ) || defined(CONFIG_SET_SERIAL_ENV )? #define
BOOTM_ENABLE_SERIAL_TAG??? 1
?voidget_board_serial(struct tag_serialnr *serialnr); ?#elsearch/arm/mach-imx/mx7/Kconfig +0
-0@@ -71,6 +71,13 @@ config TARGET_COLIBRI_IMX7?endchoice
arch/arm/mach-imx/mx7/Kconfig
Quoted 7 lines
arch/arm/mach-imx/mx7/Kconfig +7
-0+config SET_SERIAL_ENV +??? bool "Set serial number variable from the OCOTP" +??? help +????? Selecting this option will populate the serial# environment +????? variable with a unique identifier from the i.MX7 CPU. The +????? Linux kernel will use this as the serial number of the machine. +
I do not see the need of *another* CONFIG_ option. To make this available, CONFIG_SERIAL_TAG should also be on, else you cannot call get_board_serial() to get the serial from OCOTP. It think SET_SERIAL_ENV is quite superflous.
Quoted 12 lines
?config
SYS_SOC
???? default "mx7"arch/arm/mach-imx/mx7/soc.c +0
-0@@ -344,11 +344,24 @@ int arch_misc_init(void) ???? sec_init();?#endif
arch/arm/mach-imx/mx7/soc.c +1
-0+#ifdef CONFIG_SET_SERIAL_ENV
arch/arm/mach-imx/mx7/soc.c
Quoted 10 lines
arch/arm/mach-imx/mx7/soc.c +10
-0+??? { +??????? struct tag_serialnr serialnr; +??????? char serialbuf[sizeof(serialnr) * 2 + 8]; + +??????? get_board_serial(&serialnr); +??????? snprintf(serialbuf, sizeof(serialbuf), +???????????? "%08lx%08lx", +???????????? (ulong)serialnr.high, (ulong)serialnr.low); +??????? env_set("serial#", serialbuf); +??? }
If this should be done global, local solution should be moved too. I mean the warp board doing exactly this in board code.
So which is the idea of this ? To move warp code and making global, or what ?
Regards,
Stefano Babic
Quoted 11 lines
arch/arm/mach-imx/mx7/soc.c +2
-0+#endif +???? return 0;
?}
?#endifarch/arm/mach-imx/mx7/soc.c +1
-1-#ifdef CONFIG_SERIAL_TAG +#if defined(CONFIG_SERIAL_TAG ) || defined(CONFIG_SET_SERIAL_ENV )?/*
? *OCOTP_TESTER
? * i.MX 7Solo Applications Processor Reference Manual, Rev. 0.1, 08/2016
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH 1/1 Optionally: Set the serial# environment variable on the i.MX7.
Quoted 2 lines · Stefano Babic
patch was hidden in the flood of other patches and I am unsure if this belongs to i.MX:
No worries. To clarify the patch applies to all i.MX7 boards.
Quoted 8 lines · Mark G
Quoted 2 lines
+????? Linux kernel will use this as the serial number of the machine. +
I do not see the need of *another*
CONFIG_option. To make this available,CONFIG_SERIAL_TAGshould also be on, else you cannot callget_board_serial()to get the serial from OCOTP. It thinkSET_SERIAL_ENVis quite superflous.
The intent here is to pass in the serial number via the environemnt (i.e. when not using ATAGS). My patch changes the preprocessor machinery so that get_board_serial() is callable if this option is set.
This then lets fdt_root() put it in the FDT passed to the kernel. It also means that it's easily changed for testing by being in the environment. The origins of this patch were for a customer switching to the Meerkat96 board that utilized the CPU serial number in Linux for provisioning and testing.
Quoted 2 lines
If this should be done global, local solution should be moved too. I mean the warp board doing exactly this in board code.
Ah. To be fair I never looked at the port for the Warp7 board as I do not have one. This really should be done globally; there isn't anything board specific for this behavior. It should apply to all i.MX7 boards, at a minimum.
Well - to clarify in theory there is nothing board specific. Could there be a board out there with an EEPROM that contains a different serial number that a customer would want to pass to the kernel? Possibly but unlikely.
Quoted 2 lines
So which is the idea of this ? To move warp code and making global, or what ?
I would say this behavior should be global but the Warp7 port seems to add a board specific prefix to the CPU serial number. So I am hesitant to remove it. If you like I can #ifdef around it.
Additionally the Warp7 code isn't quite the same as it relies on ATAGS being enabled where as my patch does not.
Sincerely,
Mark G.