[U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp
Sagar Kadam
sagar.kadam at sifive.com
Mon Aug 12 14:22:38 UTC 2019
Hi Anup,
On Mon, Aug 12, 2019 at 1:00 PM Anup Patel <anup at brainfault.org> wrote:
>
> On Mon, Aug 12, 2019 at 12:12 PM Sagar Shrikant Kadam
> <sagar.kadam at sifive.com> wrote:
> >
> > This patch sets the serial# environment variable by reading the
> > board serial number from the OTP memory region.
> >
> > Signed-off-by: Sagar Shrikant Kadam <sagar.kadam at sifive.com>
> > ---
> > board/sifive/fu540/fu540.c | 18 ++++++++++++++----
> > 1 file changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
> > index 11daf1a..06bf442 100644
> > --- a/board/sifive/fu540/fu540.c
> > +++ b/board/sifive/fu540/fu540.c
> > @@ -122,10 +122,20 @@ static void fu540_setup_macaddr(u32 serialnum)
> >
> > int misc_init_r(void)
> > {
> > - /* Set ethaddr environment variable if not set */
> > - if (!env_get("ethaddr"))
> > - fu540_setup_macaddr(fu540_read_serialnum());
> > -
> > + u32 serial_num;
> > + char buf[11] = {0};
> > +
> > + /* Set ethaddr environment variable from board serial number */
> > + if (!env_get("serial#")) {
> > + serial_num = fu540_read_serialnum();
> > + if (!serial_num) {
> > + WARN(1, "Board serial number should not be 0 !!");
> > + return 0;
> > + }
> > + snprintf(buf, sizeof(buf), "%08x", serial_num);
> > + env_set("serial#", buf);
> > + fu540_setup_macaddr(serial_num);
> > + }
> > return 0;
> > }
> >
> > --
> > 2.7.4
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
>
> Looks good to me.
>
> Reviewed-by: Anup Patel <anup at brainfault.org>
>
Thanks for the review.
BR,
Sagar
> Regards,
> Anup
More information about the U-Boot
mailing list