[U-Boot] is there any issue with creating and using more than one hashtable?

Robert P. J. Day rpjday at crashcourse.ca
Fri Sep 30 17:12:59 CEST 2016


  short version: migrating target board from legacy OS to linux and,
in a fixed address in flash, there is a legacy "bootline" of the form

var=value var=value ... etc etc ...

that i want to convert to u-boot compatible values such as ipaddr,
gatewayip, serverip and so on.

  in misc_init_r(), i create a new hashtable to just grab the contents
of that bootline as is. i then create a *second* hashtable and
selectively move over just those keys i want from the first hashtable,
possibly renaming them in the process.

  in the end, i end up with a small hashtable of u-boot compatible
values, which i dump by walking through that second hashtable:

  Walking populated bootline_htab_2...
  k: [gatewayip], d: [192.168.1.1]
  k: [netmask], d: [255.255.255.0]
  k: [ipaddr], d: [192.168.1.2]

now here's the thing ... after all that, i manually check whether the
CRC for the env table in persistent storage is valid and, if it is, i
do *nothing* with all that hashtable content -- that was all wasted
cycles, but it should not do any harm.

  but it does, because this is what happens:

  TFTP from server 10.35.5.37; our IP address is 192.168.1.2; sending
  through gateway 192.168.1.1

the server address is correct, but the IP address and gateway are
totally wrong -- they should have been untouched and been completely
different values; instead, they now equal the values in that second
hashtable, which i chose to do nothing with.

  is there some weird issue with re-entrancy here? if i print "ipaddr"
and "gatewayip", they seem correct. if i "md" the environment in
persistent storage, again, they seem correct. and yet, when TFTP kicks
in, it seems to pick up the values from that hashtable.

  thoughts? is there some weird way that values from one hashtable can
"bleed" into another one? i'm baffled.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



More information about the U-Boot mailing list