[U-Boot] [PATCH 0/4] Convert MPC85xx platforms to a single linker script
Trent Piepho
tpiepho at freescale.com
Tue Oct 14 22:18:15 CEST 2008
On Tue, 14 Oct 2008, Wolfgang Denk wrote:
> In message <Pine.LNX.4.64.0810131647450.3399 at t2.domain.actdsltmp> you wrote:
>>> U-Boot should *never* assume static flash bank sizes. The whole
>>> design is based on the idea to automatically determine the actual
>>> size of flash and RAM that is fit on a specific board, and to
>>> auto-adjust for this.
>>
>> The bank size here is only used for linking u-boot. The actual u-boot code is
>> no different that it is now.
>
> How is this expected to work if the flash bank size used to link the
> u-boot image is different from the real flash bank size present on the
> board?
This really has absolutely nothing to do with my patches!
All the mpc85xx platforms hard code the size of the flash via the local bus
controller settings. For example, if you look in include/configs/MPC8572DS.h
you will find these lines:
#define CFG_BR0_PRELIM 0xe8001001
#define CFG_OR0_PRELIM 0xf8000ff7
Those two lines encode the location of the flash bank at 0xe800_0000 and the
size of the bank at 128MB. Also the port width and the timing parameters.
Determining the value of these registers at run time would be somewhat of a
challenge. You can't query the size of the flash chip with CFI until the chip
is mapped. And you can't map the chip until you know its size, which creates
a certain chicken and egg problem.
I think what you would have to do is create a huge initial mapping, big enough
to cover the chip with the most address lines. I suppose you could map 4 GB
to the flash and be assured of getting all 32 address lines on the eLBC. But
you'd be running from the flash you just re-mapped, that makes things a little
more interesting. Then you could do a CFI query to the base of that mapping
to get the bank size, then resize the mapping to the correct value. I'm not
sure how to figure out the port size. Maybe one could try 8, 16 and 32 bit
ports and see which one worked, but that sounds a little iffy. Actually, I
think this must be in the cpu reset strapping somewhere, otherwise how would
it boot?
But again, this has nothing to do with my patch. I'm just improving the way
the linker script works. If you want to talk about how the local bus
controller is programmed, can we have another thread please? Something like
"TODO: dynamically determine Freescale eLBC parameters at run time".
>> In order to boot on mpc85xx, the u-boot image must be linked to locate the
>> boot page as the last page in the flash bank. There is no way to do this at
>> run time, it's the boot page. All existing 85xx platforms hard code the
>> location of the boot page in the u-boot image one way or another. I'm just
>> changing the linker script to do it in a way where the same script will work
>> on all 85xx boards.
>
> But in the patch you submit you hard-wire certain flash bank sizes
> into the linker scriopts, don't you?
Not really. I'm calculating the boot page location in a better way.
Let's look at what's there now.
freescale/mpc8572ds/u-boot.lds: ADDR(.text) + 0x7f000
tqc/tqm85xx/u-boot.lds: 0xFFFFF000
mpc8540eval/u-boot.lds: (. & 0xFFF80000) + 0x0007F000
I do this:
PROVIDE(__flash_mask = 4M - 1);
(ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask)
Suppose you want to change the size of the u-boot image from 512k to 256k? If
you use the expression from mpc8572ds, it won't work. You must edit the
linker script to change 0x7f000 to 0x3f000. With my method, the linker script
doesn't need to be edited.
The expression from tqm85xx will let you change the image size without being
edited. Why not use that one then? Suppose you decide to change the location
of the flash bank? Then it won't work, unless you edit the linker script.
That's why the tqm85xx expresion won't work for mpc8572ds, it would make a
256MB u-boot image because flash is mapped differently on that board. My
expression works fine for both tqm85xx _and_ mpc8572ds and let's you change the
location of the flash bank without editing the linker script.
The expression from mpc8540eval is *very* similar to what I've done. Mine has
a couple advantages though. If you try to make a u-boot that is too small,
mine will properly fail at link time when it tries to place the too large for
the image u-boot code on top of the boot page. The mpc8540eval will happily
create a broken image (that is 8MB+ in size). If you want to support a board
with a 2 MB flash bank with the mpc8540eval style script, you need to copy the
entire linker script and edit it. With my method method, you can create a two
line script:
__flash_mask = 2M - 1;
INCLUDE cpu/mpc85xx/u-boot.lds
Which doesn't require creating a duplicate copy of the linker script.
This is what my patch is for. Letting all existing 85xx boards use one
script. And if a board is created that can't use the script alone, it can be
handled easily, re-using the common script without duplicating any code.
Clearly this is an improvement over how things work now, is it not?
More information about the U-Boot
mailing list