
Wolfgang Denk wrote:
I'm not exactly sure what you mean by the "global vars" in the Subject line. The declaration you show here says "static". This may or may not be what you mean.
To me, a variable defined outside of a function is a global variable, regardless as to whether it's "static" or not. Technically, these variables are static globals, but I don't think removing the "static" would change what I'm seeing. Would it?
As you can see, I defined two static volatile global vars: i2c_bus_num and i2c_dev.
Yes, and one of these is initialized with non-zero values (so it will go to the data segment), while the other is not (so it will go to bss).
I realized that about two minutes after I posted my email, which is why I posted a follow-up.
THis is perfectly OK. Just check the variables after U-Boot has been relocated to RAM and BSS has been initialized.
I can't. This code is used to initialize the I2C bus, which is used to initialize SPD on DDR, which is obviously done before U-Boot is relocated.
These variables contain the I2C bus number. On some boards, SPD is on bus 0, on some they're on bus 1. So the compile-time initializer needs to be the right bus.
(An alternative would be to change i2c_read() and i2c_write() to take a bus number as a parameter, but that would change hundreds of files).