diff options
author | Tom Rini <trini@konsulko.com> | 2022-12-12 09:00:58 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-12-12 09:00:58 -0500 |
commit | c917865c7fd14420d25388bb3c8c24cb03911caf (patch) | |
tree | eb3479387b13309745db36a5e7661affa0fc148e | |
parent | b560f2c61f2d7eefd40a8650799a23ab77e88c81 (diff) | |
parent | 3a68fda33fe5b53be7e15099de856acb1f41097e (diff) |
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell
- mvebu: Espressobin: Fix default env variables (Derek)
-rw-r--r-- | board/Marvell/mvebu_armada-37xx/board.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c index c6ecc323bb9..44c72344e8b 100644 --- a/board/Marvell/mvebu_armada-37xx/board.c +++ b/board/Marvell/mvebu_armada-37xx/board.c @@ -99,9 +99,16 @@ int board_late_init(void) if (!of_machine_is_compatible("globalscale,espressobin")) return 0; - /* Find free buffer in default_environment[] for new variables */ - while (*ptr != '\0' && *(ptr+1) != '\0') ptr++; - ptr += 2; + /* + * Find free space for new variables in default_environment[] array. + * Free space is after the last variable, each variable is termined + * by nul byte and after the last variable is additional nul byte. + * Move ptr to the position where new variable can be filled. + */ + while (*ptr != '\0') { + do { ptr++; } while (*ptr != '\0'); + ptr++; + } /* * Ensure that 'env default -a' does not erase permanent MAC addresses @@ -145,6 +152,13 @@ int board_late_init(void) strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-emmc.dtb"); else strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin.dtb"); + ptr += strlen(ptr) + 1; + + /* + * After the last variable (which is nul term string) append another nul + * byte which terminates the list. So everything after ptr is ignored. + */ + *ptr = '\0'; return 0; } |