Re: [PATCH v2] powerpc: mpc: Put U-Boot version string at correct place by linker script

Wolfgang Denk
2021-08-24T09:47:01Z

Dear Christophe,

In message <75ae39aa-3762-6b90-c39a-7595fc417870@csgroup.eu> you wrote:
>
> > Also, could you look at this, why version string is at specific location
> > of u-boot.bin header?
>
> I have no idea. AFAIKS it's been like that since the first version
> in git in 2002. Maybe Wolfgang has the answer ?

The Power Architecture was the very first where PPCBoot / U-Boot were
running, more than 20 years ago. At that time, resources were tight.
Systems would typically boot from a small NOR flash. Typical
configurations came with 4 MB NOR / 16 MB RAM or such.

One problem was that you needed always at least one (or better two,
with redundancy) full sectors of the flash for the environment, even
though this was typically only a few hundred bytes long. Many NOR
flash chips of that time did not have uniform sector sizes; instead,
they would come with mixed sector sizes.

For example, there were NOR flash chips which came with sector sizes
of 8, 4, 4, 16, 32, 32, 32, 32, ... kB.

Here you would naturally want to use the two small 4 kB sectors for
the environment, but this results in the need to have the
environment storage "embedded" within the U-Boot image. This
resulted in the need to come up with special linker scripts. And of
course you would try to use the first 8 kB sector as good as
possible, which was achieved by used manually optimized linker
scripts, collecting functions or other objects such that the wasted
gap at the end of the first sector was minimal - usually less than
100 bytes were wasted.

As part of such optimizations, it might have made sense to put the
version string there, too - it has a fixed size of a few ten bytes,
so it is a good candidate to fill the gap.

Today, such boot sector NOR flashes are no longer found in new
designs, nor does anybody care to keep U-Boot small and tidy.
As a result, knowledge about such optimizations is disappearing.

Hope this helps.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
"If you want to eat hippopotamus, you've got to pay the freight." -
attributed to an IBM guy, about why IBM software uses so much memory