From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 3/3] arm: mvebu: Espressobin: Set default value for $ethNaddr env variable
Date: Wed, 23 Dec 2020 12:21:30 +0100 [thread overview]
Message-ID: <20201223112130.31389-4-pali@kernel.org> (raw)
In-Reply-To: <20201223112130.31389-1-pali@kernel.org>
On Espressobin board are MAC addresses stored in U-Boot env area. Therefore
they are not present in default_environment[] array constructed at compile
time.
This change puts permanent MAC addresses into default_environment[] array
at board runtime. Espressobin board has enabled DEFAULT_ENV_IS_RW option
and therefore can modify this array.
This change ensure that 'env default -a' does not delete permanent MAC
addresses from Espressobin env storage area.
Signed-off-by: Pali Roh?r <pali@kernel.org>
---
board/Marvell/mvebu_armada-37xx/board.c | 19 +++++++++++++++++++
include/configs/mvebu_armada-37xx.h | 4 ++++
2 files changed, 23 insertions(+)
diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
index 9297ea0f90..dabd4eefd6 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -88,6 +88,9 @@ int board_late_init(void)
char *ptr = (char *)&default_environment[0];
struct mmc *mmc_dev;
bool ddr4, emmc;
+ const char *mac;
+ char eth[10];
+ int i;
if (!of_machine_is_compatible("globalscale,espressobin"))
return 0;
@@ -96,6 +99,22 @@ int board_late_init(void)
while (*ptr != '\0' && *(ptr+1) != '\0') ptr++;
ptr += 2;
+ /*
+ * Ensure that 'env default -a' does not erase permanent MAC addresses
+ * stored in env variables: $ethaddr, $eth1addr, $eth2addr and $eth3addr
+ */
+
+ mac = env_get("ethaddr");
+ if (mac && strlen(mac) <= 17)
+ ptr += sprintf(ptr, "ethaddr=%s", mac) + 1;
+
+ for (i = 1; i <= 3; i++) {
+ sprintf(eth, "eth%daddr", i);
+ mac = env_get(eth);
+ if (mac && strlen(mac) <= 17)
+ ptr += sprintf(ptr, "%s=%s", eth, mac) + 1;
+ }
+
/* If the memory controller has been configured for DDR4, we're running on v7 */
ddr4 = ((readl(A3700_CH0_MC_CTRL2_REG) >> A3700_MC_CTRL2_SDRAM_TYPE_OFFS)
& A3700_MC_CTRL2_SDRAM_TYPE_MASK) == A3700_MC_CTRL2_SDRAM_TYPE_DDR4;
diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h
index 6df702367c..2ad4325eaf 100644
--- a/include/configs/mvebu_armada-37xx.h
+++ b/include/configs/mvebu_armada-37xx.h
@@ -94,6 +94,10 @@
/* filler for default values filled by board_early_init_f() */
#define ENV_RW_FILLER \
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" /* for ethaddr= */ \
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" /* for eth1addr= */ \
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" /* for eth2addr= */ \
+ "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" /* for eth3addr= */ \
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" /* for fdtfile= */ \
""
--
2.20.1
next prev parent reply other threads:[~2020-12-23 11:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 11:21 [PATCH 0/3] arm: mvebu: Espressobin: Set default env values at runtime Pali Rohár
2020-12-23 11:21 ` [PATCH 1/3] env: Allow to set default_environment[] from board code via compile option DEFAULT_ENV_IS_RW Pali Rohár
2020-12-23 11:21 ` [PATCH 2/3] arm: mvebu: Espressobin: Set default value for $fdtfile env variable Pali Rohár
2020-12-23 11:21 ` Pali Rohár [this message]
2021-01-11 10:51 ` [PATCH 0/3] arm: mvebu: Espressobin: Set default env values at runtime Pali Rohár
2021-01-12 8:18 ` Andre Heider
2021-01-12 8:42 ` Andre Heider
2021-01-12 9:24 ` Pali Rohár
2021-02-02 15:09 ` Stefan Roese
2021-02-02 15:19 ` Pali Rohár
2021-02-02 16:13 ` Andre Heider
2021-02-02 16:32 ` Stefan Roese
2021-02-02 17:24 ` Andre Heider
2021-02-01 15:24 ` Pali Rohár
2021-02-08 11:33 ` Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201223112130.31389-4-pali@kernel.org \
--to=pali@kernel.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox