]> git.baikalelectronics.ru Git - uboot.git/commit
arm: mvebu: Espressobin: Fix default env variables
authorDerek LaHousse <derek@seaofdirac.org>
Mon, 12 Dec 2022 06:34:17 +0000 (07:34 +0100)
committerStefan Roese <sr@denx.de>
Mon, 12 Dec 2022 06:36:04 +0000 (07:36 +0100)
commit9aa0477a2a7612c3da57402b5f7d513a48f68930
tree2ec10c9631564890dc68444aefe513e94f88176b
parentf1521c2bb6700f73399699e25d2f6eab3505d55d
arm: mvebu: Espressobin: Fix default env variables

Default env variables on Espressobin boards are broken since commit 3a5e1ae19b8d
("arm: mvebu: Espressobin: Set default value for $fdtfile env variable") as well
as the 'env default -a' command.

The algorithm to find free space in the default_environment[] array returns
after the first env variable instead of the correct position of the last
variable, where there is allocated free space.

This causes that U-Boot board_late_init() function to overwrite a portion of the
default environment with $ethXaddr and $fdtfile variables immediately after the
first env variable and so it is overwriting other variables.

This patch also adds an additional null byte to terminate the environment array.

But U-Boot board_late_init() function do not fill this nul byte explicitly. And
because of that, U-Boot is later trying to interpret remaining buffer as a
continuation of variable list. Normally buffer should be empty but due to the
above issue, it contains garbage from remaining env variables.

For example 'env default -a' command results in damaging variable names. It was
observed that scritaddr variable name was changed to criptaddr (without leading
's').

This bug was reported and discussed on the Armbian forum:
https://forum.armbian.com/topic/19564-making-espressobin-v7-work-in-2022/?do=findComment&comment=138136

Fix these issues in two steps:

1) Change code which finds free space for dynamic env variables in
default_environment[] array by jumping to the end of the variable list instead
of jumping after the first defined variable. [By Derek]

2) Add code which appends terminating nul byte as indication of the end of the
env list, after the last nul term env string. [By Pali]

Fixes: 3a5e1ae19b8d ("arm: mvebu: Espressobin: Set default value for $fdtfile env variable")
Signed-off-by: Derek LaHousse <derek@seaofdirac.org>
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Stefan Roese <sr@denx.de>
board/Marvell/mvebu_armada-37xx/board.c