* [U-Boot] [U-BOOT PATCH] set serial environment variable
@ 2019-08-12 6:41 Sagar Shrikant Kadam
2019-08-12 6:41 ` [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp Sagar Shrikant Kadam
0 siblings, 1 reply; 6+ messages in thread
From: Sagar Shrikant Kadam @ 2019-08-12 6:41 UTC (permalink / raw)
To: u-boot
This patch sets serial environment variable by reading the OTP memory
region of FU540-C000 SoC which is mounted on HiFive Unleashed A00 board.
The patch is based on master branch of[1]
[1] https://gitlab.denx.de/u-boot/custodians/u-boot-riscv
Following is the result:
U-Boot 2019.10-rc1-03748-gab38b00-dirty (Aug 11 2019 - 23:14:27 -0700)
CPU: rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM: 8 GiB
MMC: spi at 10050000:mmc at 0: 0
In: serial at 10010000
Out: serial at 10010000
Err: serial at 10010000
Net: eth0: ethernet at 10090000
Hit any key to stop autoboot: 0
=> env print serial#
serial#=000000d0
Sagar Shrikant Kadam (1):
riscv: sifive: fu540: set serial environment variable from otp
board/sifive/fu540/fu540.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp
2019-08-12 6:41 [U-Boot] [U-BOOT PATCH] set serial environment variable Sagar Shrikant Kadam
@ 2019-08-12 6:41 ` Sagar Shrikant Kadam
2019-08-12 7:30 ` Anup Patel
2019-08-12 9:03 ` Bin Meng
0 siblings, 2 replies; 6+ messages in thread
From: Sagar Shrikant Kadam @ 2019-08-12 6:41 UTC (permalink / raw)
To: u-boot
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@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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp
2019-08-12 6:41 ` [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp Sagar Shrikant Kadam
@ 2019-08-12 7:30 ` Anup Patel
2019-08-12 14:22 ` Sagar Kadam
2019-08-12 9:03 ` Bin Meng
1 sibling, 1 reply; 6+ messages in thread
From: Anup Patel @ 2019-08-12 7:30 UTC (permalink / raw)
To: u-boot
On Mon, Aug 12, 2019 at 12:12 PM Sagar Shrikant Kadam
<sagar.kadam@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@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@brainfault.org>
Regards,
Anup
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp
2019-08-12 6:41 ` [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp Sagar Shrikant Kadam
2019-08-12 7:30 ` Anup Patel
@ 2019-08-12 9:03 ` Bin Meng
2019-08-12 14:54 ` Sagar Kadam
1 sibling, 1 reply; 6+ messages in thread
From: Bin Meng @ 2019-08-12 9:03 UTC (permalink / raw)
To: u-boot
On Mon, Aug 12, 2019 at 2:42 PM Sagar Shrikant Kadam
<sagar.kadam@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@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};
buf[9] should be enough.
> +
> + /* 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 !!");
nits: please use true instead of 1, and adding a '\n' at the end.
> + return 0;
> + }
> + snprintf(buf, sizeof(buf), "%08x", serial_num);
> + env_set("serial#", buf);
> + fu540_setup_macaddr(serial_num);
> + }
> return 0;
> }
Regards,
Bin
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp
2019-08-12 7:30 ` Anup Patel
@ 2019-08-12 14:22 ` Sagar Kadam
0 siblings, 0 replies; 6+ messages in thread
From: Sagar Kadam @ 2019-08-12 14:22 UTC (permalink / raw)
To: u-boot
Hi Anup,
On Mon, Aug 12, 2019 at 1:00 PM Anup Patel <anup@brainfault.org> wrote:
>
> On Mon, Aug 12, 2019 at 12:12 PM Sagar Shrikant Kadam
> <sagar.kadam@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@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@brainfault.org>
>
Thanks for the review.
BR,
Sagar
> Regards,
> Anup
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp
2019-08-12 9:03 ` Bin Meng
@ 2019-08-12 14:54 ` Sagar Kadam
0 siblings, 0 replies; 6+ messages in thread
From: Sagar Kadam @ 2019-08-12 14:54 UTC (permalink / raw)
To: u-boot
Hi Bin,
On Mon, Aug 12, 2019 at 2:34 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Mon, Aug 12, 2019 at 2:42 PM Sagar Shrikant Kadam
> <sagar.kadam@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@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};
>
> buf[9] should be enough.
>
> > +
> > + /* 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 !!");
>
> nits: please use true instead of 1, and adding a '\n' at the end.
>
Thanks for your suggestions, I will incorporate these in the next
version of this patch.
BR,
Sagar Kadam
> > + return 0;
> > + }
> > + snprintf(buf, sizeof(buf), "%08x", serial_num);
> > + env_set("serial#", buf);
> > + fu540_setup_macaddr(serial_num);
> > + }
> > return 0;
> > }
>
> Regards,
> Bin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-12 14:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 6:41 [U-Boot] [U-BOOT PATCH] set serial environment variable Sagar Shrikant Kadam
2019-08-12 6:41 ` [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp Sagar Shrikant Kadam
2019-08-12 7:30 ` Anup Patel
2019-08-12 14:22 ` Sagar Kadam
2019-08-12 9:03 ` Bin Meng
2019-08-12 14:54 ` Sagar Kadam
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.