[U-Boot] Setting ipaddr via setenv() - H_INTERACTIVE vs H_PROGRAMMATIC
Joe Hershberger
joe.hershberger at gmail.com
Tue Mar 1 20:40:05 CET 2016
Hi Stefan,
On Tue, Mar 1, 2016 at 4:35 AM, Stefan Roese <sr at denx.de> wrote:
> Hi Joe,
>
> I'm currently stumbling over a problem in some board specific code
> (not in mainline yet), that sets the "ipaddr" env variable via
> setenv(). But as I now noticed, the callback on_ipaddr() doesn't
> set net_ip to this new value. As flags has H_PROGRAMMATIC set and
> op_ipaddr() skips setting this value in this case.
>
> I fail to see why we need this check in on_ipaddr(). Could you
> please explain why this is needed? Why would someone use setenv()
> for the "ipaddr" and not want to also update the net_ip value.
> This results in the "ipaddr" value being updated but net_ip
> still being configured to the old value.
The purpose is that programmatic accesses may write directly to the
net_ip variable, but the user on the console cannot. This is because
the "programmatic" accesses to these variables is expected to be
things like the dhcp command and the linklocal command after
successful netloop. You can see this call in the netboot_update_env()
function in cmd/net.c.
> Or if this is really needed, what is the correct way to update
> the ipaddr (env variable and net_ip value) from the U-Boot code?
You can work around it in a similar way to what I did in the initial
change (94b467b14ed908c89a0780256e89b375aa3cf3ef - env: Distinguish
finer between source of env change). The do_env_edit function used to
call setenv, but I changed it to call as though it was interactive.
You could do the same thing in your board driver.
Cheers,
-Joe
More information about the U-Boot
mailing list