[PING][PATCH] Optionally: Set the serial# environment variable on the i.MX7.

Stefano Babic sbabic at denx.de
Mon May 11 15:43:50 CEST 2020


Hi Mark,

patch was hidden in the flood of other patches and I am unsure if this
belongs to i.MX:

On 19.02.20 22:01, Mark G wrote:
> Enabling this new option allows the kernel to obtain the unique ID of
> the CPU when not using ATAGS.
> 
> Signed-off-by: Mark G <mark at novtech.com>
> ---
> diff --git a/arch/arm/include/asm/bootm.h b/arch/arm/include/asm/bootm.h
> index a2131ca07c..64ceb36ed8 100644
> --- a/arch/arm/include/asm/bootm.h
> +++ b/arch/arm/include/asm/bootm.h
> @@ -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    1
>  void get_board_serial(struct tag_serialnr *serialnr);
>  #else
> diff --git a/arch/arm/mach-imx/mx7/Kconfig b/arch/arm/mach-imx/mx7/Kconfig
> index 286d36589d..4cf14d43c0 100644
> --- a/arch/arm/mach-imx/mx7/Kconfig
> +++ b/arch/arm/mach-imx/mx7/Kconfig
> @@ -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.
> +

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.

>  config SYS_SOC
>      default "mx7"
> 
> diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
> index 4aafeed188..208400a4a7 100644
> --- a/arch/arm/mach-imx/mx7/soc.c
> +++ b/arch/arm/mach-imx/mx7/soc.c
> @@ -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);
> +    }

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

> +#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


-- 
=====================================================================
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
=====================================================================


More information about the U-Boot mailing list