[U-Boot] [RFC] arm926ejs: fix jump to RAM nand_boot

Albert ARIBAUD
2010-11-01T17:03:32Z

Le 01/11/2010 10:15, Wolfgang Denk a ?crit :
> Dear Albert ARIBAUD,
>
> In message<4CCDF5FC.4060704@free.fr> you wrote:
>>
>> Wolfgang, could you:
>>
>> - make available to me the exact source tree you're compiling, including
>> my patches as you applied them plus your changes to them, either as a
>> clonable git repo or as a patch set to apply on the current u-boot
>> master branch;
>
> Please see git://git.denx.de/u-boot-testing.git , branch reloc-tests
>
>> - indicate exactly how you build your u-boot;
>
> Both with ELDK and CS tools:
>
> ../MAKELL tx25
>
>> - provide the u-boot binary that you last built (the one that has no
>> output).
>
> Will send two tarballs (built with ELDK and CS) in PM.
>
>> My goal here is to reproduce an u-boot identical to yours, in order to
>> make sur I can produce controlled u-boots for tx25, and then build some
>> specific tx25 u-boots for you to run.
>
> Thanks!

Thanks. With all this I am able to rebuild u-boot identically to yours;
our maps only differ by the absolute path of the source code.

Also, I understand why the second RFC change I did was harmful to tx25.
Contrary to u-boot itself, u-boot-spl is not compiled to be position
independent; it actually loads at a given address then copies itself,
without relocating, to its home location.

I also think I might have found out what hit tx25.

include/configs/tx25 defines the size of u-boot which SPL will use to
load from NAND into RAM. currently it is defined thus:

#define CONFIG_SYS_NAND_U_BOOT_SIZE 0x30000

However, looking at the output of 'readelf -a dump of u-boot'
(whitespace compressed to preserve formatting):

Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 81200000 008000 01b550 00 AX 0 0 32
[ 2] .rodata PROGBITS 8121b550 023550 006082 00 A 0 0 4
[ 3] .hash HASH 812215d4 0295d4 00003c 04 A 9 0 4
[ 4] .data PROGBITS 81221610 029610 001de4 00 WA 0 0 4
[ 5] .got.plt PROGBITS 812233f4 02b3f4 00000c 04 WA 0 0 4
[ 6] .u_boot_cmd PROGBITS 81223400 02b400 0003f0 00 WA 0 0 4
[ 7] .bss NOBITS 812237f0 02b7f0 009108 00 WA 0 0 8
[ 8] .rel.dyn REL 8122c8f8 02c8f8 003c60 08 A 9 0 4
[ 9] .dynsym DYNSYM 81230558 030558 0000a0 10 A 0 3 4

See how .rel.dyn crosses the limit of 0x812230000, and .dynsym is
completely beyond this limit? That means the SPL won't load the whole of
rel.dyn and won't load any of .dynsym, but u-boot does not know it, so:

- it will run the fixup loop beyond 0x81230000 nnd up to 0x81230558, at
best doing no harm if no 'relocation record' in that area is of type 2
or 23, at most corrupting memory randomly if any 'relocation record' in
that area happens to be type 2 or 23;

- it will not apply the fixup records generated by the linker and which
landed at 0x81230000 and beyond.

Wolfgang, please try the following:

- on u-boot-testing, branch reloc_tests, revert commit 7fab02d...
(that's "arm926ejs: fix jump to RAM nand_boot") as this 'fix' is a mistake.

- in include/configs/tx25.h, increasing CONFIG_SYS_NAND_U_BOOT_SIZE to
0x31000

Let me know if building tx25 after these two corrections makes things
better.

Amicalement,
--
Albert.