Convert MPC85xx platforms to a single linker script
cover Convert MPC85xx platforms to a single linker script
This patch series does $SUBJ.
The first patch changes the way the existing linker scripts locate the boot page, reset vector, and bss section. This method works for any size of u-boot image (the previous one didn't work images that weren't 512K) and any location flash is mapped to.
At this point all the mpc85xx linker scripts are exactly the same, except for one line that defines the flash bank size, so they are combined into one script in cpu/mpc85xx/u-boot.lds. A common flash bank size that will work for all boards is used. If a board in the future needs something different (either very small flash or a very large u-boot), then it can easily be overridden by using a two line board/*/config.mk file that defines the flash bank size and then includes cpu/mpc85xx/u-boot.lds.
The next two patches clean up the common boot script some more.
I imagine there is more cruft in the script still, like the .data.init and .text.init sections that are 256 byte aligned but have nothing in them.
cover Convert MPC85xx platforms to a single linker script
Dear Trent,
Quoted 5 lines · In message <[email protected]> you wrote:
At this point all the mpc85xx linker scripts are exactly the same, except for one line that defines the flash bank size, so they are combined into one script in
cpu/mpc85xx/u-boot.lds. A common flash bank size that will work for all boards is used. If a board in the future needs something different
Umm... This is not how it should be done.
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.
There are many vendors out there who manufacture boards in different memory configurations. For these it is essential that they can use only one U-Boot image on all boards, no matter what the exact memory configuration of this board is.
I am aware that there are ports out there which violate this design principle, but if we touch this area, thenplease only to make more boards conformant, not to make things worse.
Thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Voodoo Programming: Things programmers do that they know shouldn't work but they try anyway, and which sometimes actually work, such as recompiling everything. - Karl Lehenbauer
cover Convert MPC85xx platforms to a single linker script
Quoted 9 lines · Wolfgang Denk
Dear Trent,
Quoted 5 lines · In message <[email protected]> you wrote:
At this point all the mpc85xx linker scripts are exactly the same, except for one line that defines the flash bank size, so they are combined into one script in
cpu/mpc85xx/u-boot.lds. A common flash bank size that will work for all boards is used. If a board in the future needs something different
Quoted 6 lines
Umm... This is not how it should be done.
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.
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.
Right now changing the u-boot image size and/or the boot flash bank mapping requires changes to the linker script. Since not all boards have the same image size and/or flash bank mapping, they can't use the same script.
cover Convert MPC85xx platforms to a single linker script
Dear Trent Piepho,
Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 5 lines
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?
Quoted 6 lines
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?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I wish I had a bronze torc for every user who didn't read the manual.
- Terry Pratchett, _The Light Fantastic_cover Convert MPC85xx platforms to a single linker script
Quoted 6 lines · Wolfgang Denk
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 4 lines
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.
Quoted 6 lines
Quoted 2 lines
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".
Quoted 9 lines
Quoted 6 lines
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) + 0x7f000tqc/tqm85xx/u-boot.lds: 0xFFFFF000mpc8540eval/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?
cover Convert MPC85xx platforms to a single linker script
Dear Trent,
Quoted 2 lines · In message <[email protected]> you wrote:
All the mpc85xx platforms hard code the size of the flash via the local bus
No, they don't.
Quoted 5 lines
controller settings. For example, if you look in
include/configs/MPC8572DS.hyou will find these lines:#define
CFG_BR0_PRELIM0xe8001001
#defineCFG_OR0_PRELIM0xf8000ff7
Mind the "PRELIM" part in that names. PRELIM as in PRELIMINARY.
Quoted 6 lines
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.
You think you have to tell me that? Umm...
Quoted 3 lines
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
Not really. You just have to map a small part, just big enough to be able to read the CFI information.
Quoted 5 lines
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
You might want to have a look at the CFI driver, then.
Quoted 7 lines
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".
We are talking about your patches here, which claim to cover "all MPC85xx" boards.
Quoted 4 lines
Quoted 2 lines
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.
Now what. First you say you do, then you say you don't?
Quoted 2 lines
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
He. Funny that you come up with that example.
Quoted 1 line
of the flash bank? Then it won't work, unless you edit the linker script.
"Change the location of the flash bank" - what exactly do you mean by that?
Quoted 6 lines
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;
INCLUDEcpu/mpc85xx/u-boot.lds
And what do I do with a board that can have 2, 4, 8, 16, 32 or 64 MB of flash?
Quoted 4 lines
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?
I'd be happy if that works, but somehow you don't add the missing pieces of explanation I'm looking for.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Fascinating, a totally parochial attitude. -- Spock, "Metamorphosis", stardate 3219.8
cover Convert MPC85xx platforms to a single linker script
Quoted 5 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:
All the mpc85xx platforms hard code the size of the flash via the local bus
No, they don't.
Name one that doesn't.
Quoted 7 lines
Quoted 5 lines
controller settings. For example, if you look in
include/configs/MPC8572DS.hyou will find these lines:#define
CFG_BR0_PRELIM0xe8001001
#defineCFG_OR0_PRELIM0xf8000ff7Mind the "PRELIM" part in that names. PRELIM as in PRELIMINARY.
For all the Freescale mpc85xx platforms, PRELIM also means final. But even for something like tqm85xx, this preliminary mapping is compiled in, is it not? This compiled in mapping is the one that must be taken into account when linking the u-boot image. Trying changing the BR0 value for tqm85xx and not editing the boot script and see what happens. Doesn't work. Then try using my boot script and see what happens. Does work.
Quoted 7 lines
Quoted 5 lines
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
You might want to have a look at the CFI driver, then.
I'm not seeing where it programs the local bus controller while u-boot is running from flash.
Quoted 10 lines
Quoted 7 lines
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".
We are talking about your patches here, which claim to cover "all MPC85xx" boards.
You're talking about dynamically programming the local bus controller. My patches have nothing to do with that.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
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.
Now what. First you say you do, then you say you don't?
First of all, the boot scripts already have the boot flash bank location and size hardwired in. Secondly, it doesn't really matter. It only makes a difference in certain extreme situations of a very small flash bank mapped in an unusual manner or a very very large u-boot image.
Quoted 9 lines
Quoted 2 lines
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
He. Funny that you come up with that example.
Quoted 1 line
of the flash bank? Then it won't work, unless you edit the linker script.
"Change the location of the flash bank" - what exactly do you mean by that?
Change CFG_BR0_PRELIM (and probably also TEXT_BASE and CFG_FLASH_BASE too).
Quoted 9 lines
Quoted 6 lines
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;
INCLUDEcpu/mpc85xx/u-boot.ldsAnd what do I do with a board that can have 2, 4, 8, 16, 32 or 64 MB of flash?
Same thing as now. You have to pick values for CFG_B/OR0_PRELIM, FLASH_BASE and TEXT_BASE. You can almost certainly just use cpu/mpc85xx/u-boot.lds, unless you've chosen very odd values for BR0/OR0/TEXT_BASE. In that case can you make the two line custom script from above, and set __flash_mask based on what you chose for B/OR0.
Quoted 7 lines
Quoted 4 lines
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?
I'd be happy if that works, but somehow you don't add the missing pieces of explanation I'm looking for.
How does it not work? Programming the local bus controller has nothing to do with my patch in any way.
Did you actually look at the patch? You're going on about how the local bus controller is programmed, doing CFI querying while u-boot is still running out of the boot flash bank, the image can't be linked with bss at 0 and all these things that have nothing what so ever to do with my patch.
PATCH 1/4 Use absolute addressing for mpc85xx boot page
In reply to Trent PiephoThe boot page and reset vector need to be at the absolute address 0xfffff000 and 0xfffffffc, respectively, when the CPU boots.
However, their location in the U-Boot image is relative to the address that flash is mapped at. For instance, mpc8572ds maps the 128MB flash boot bank to 0xe8000000, which means the boot page is at 0xeffff000 in the U-Boot image.
Currently the linker scripts use ADDR(.text) + 0x7f000 to location the boot page, but this only works if .text starts 512kB from the end of the flash window, e.g. TEXT_BASE is 0xeff80000 for mpc8572ds. If TEXT_BASE is somewhere else, such as when creating a 256kB image, the boot page will be at the wrong location.
To handle to both different U-Boot image sizes and flash locations, what we do is take the upper bits of the boot page from the location of .text and the lower bits are taken from the absolute address 0xfffff000. How many bits to take depends on the size of the flash bank. In effect the upper bits come from the location of the flash bank in the CPU address space and the lower bits come from the fixed location of the boot page within the flash bank.
The bss segment should go after the end of the u-boot image. Which is only at the fixed address 0 for platforms that don't remap flash. For those that do it's somewhere else, e.g. on mpc8572ds it's at 0xf0000000. The easiest way to locate bss is to say it starts 4k after the boot page, since we already put that in the final 4k of the image.
Since this part of the linker script is the same for all mpc85xx targets, maybe it should be placed into an include file instead of duplicated?
--- board/freescale/mpc8536ds/u-boot.lds | 11 +++++------ board/freescale/mpc8540ads/u-boot.lds | 11 +++++------ board/freescale/mpc8541cds/u-boot.lds | 11 +++++------ board/freescale/mpc8544ds/u-boot.lds | 12 ++++++------ board/freescale/mpc8548cds/u-boot.lds | 11 +++++------ board/freescale/mpc8555cds/u-boot.lds | 11 +++++------ board/freescale/mpc8560ads/u-boot.lds | 11 +++++------ board/freescale/mpc8568mds/u-boot.lds | 11 +++++------ board/freescale/mpc8572ds/u-boot.lds | 11 +++++------ 9 files changed, 46 insertions(+), 54 deletions(-)
board/freescale/mpc8536ds/u-boot.lds +5 -6
@@ -118,21 +118,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 128M - 1; + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8540ads/u-boot.lds +5 -6
@@ -121,21 +121,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 16M - 1; + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8541cds/u-boot.lds +5 -6
@@ -118,21 +118,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 8M - 1; /* Flash bank is 8 MB */ + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8544ds/u-boot.lds +6 -6
@@ -118,21 +118,21 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + /* Flash blank size is 8M */ + __flash_mask = 8M - 1; + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8548cds/u-boot.lds +5 -6
@@ -118,21 +118,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 8M - 1; /* Flash bank is 8 MB */ + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8555cds/u-boot.lds +5 -6
@@ -118,21 +118,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 8M - 1; /* Flash bank is 8 MB */ + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8560ads/u-boot.lds +5 -6
@@ -121,21 +121,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 16M - 1; + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8568mds/u-boot.lds +5 -6
@@ -118,21 +118,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 8M - 1; /* Flash bank is 8 MB */ + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
board/freescale/mpc8572ds/u-boot.lds +5 -6
@@ -118,21 +118,20 @@ SECTIONS . = ALIGN(256); __init_end = .; - .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 128M - 1; + .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : { cpu/mpc85xx/start.o (.bootpg) } :text = 0xffff - .resetvec ADDR(.text) + 0x7fffc : + .resetvec ADDR(.bootpg) + 0xffc : { *(.resetvec) } :text = 0xffff - . = ADDR(.text) + 0x80000; - - __bss_start = .; - .bss (NOLOAD) : + .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : { + __bss_start = ABSOLUTE(.); *(.sbss) *(.scommon) *(.dynbss) *(.bss)
Signature · 1 line
1.5.4.1
PATCH 1/4 Use absolute addressing for mpc85xx boot page
Dear Trent Piepho,
Quoted 2 lines · In message <[email protected]> you wrote:
The boot page and reset vector need to be at the absolute address
0xfffff000and0xfffffffc, respectively, when the CPU boots.
...
Quoted 4 lines
To handle to both different U-Boot image sizes and flash locations, what we do is take the upper bits of the boot page from the location of .text and the lower bits are taken from the absolute address
0xfffff000. How many bits to take depends on the size of the flash bank. In effect the upper
I would like to point out that it is essential that the code must be able to handle the situation where the flash bank size is unknown at compile time, and becomes known anly at runtime when the flash driver probes the actual flash size on the board.
This may be not strictly needed for the Freescale evaluation boards, but it is definitely needed for other boards, and we must be able to handle this.
Quoted 2 lines
The bss segment should go after the end of the u-boot image. Which is only at the fixed address 0 for platforms that don't remap flash. For those
I'm not sure what you mean here. Bss becomes significant only after relocation to RAM. By then, it must be located in a valid RAM area. "fixed address 0" is no such valid address.
Quoted 2 lines
Since this part of the linker script is the same for all mpc85xx targets, maybe it should be placed into an include file instead of duplicated?
That would make sense, indeed.
Review
Quoted 2 lines
(quoted diff) +1
-1- .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 128M - 1;
Does the linker actually understand the "128M" notation? Interesting - I didn't know that.
But - where is the number coming from? I guess that's a hard-wired flash size for this specific board?
This is bad, for two reasons: it means we have to maintain the same data in several places (in the linker script plus in the board config file), and second, we cannot handle boards where several size options exist.
Flash bank sizes must not be hard wired.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de As in certain cults it is possible to kill a process if you know its true name. -- Ken Thompson and Dennis M. Ritchie
PATCH 1/4 Use absolute addressing for mpc85xx boot page
Quoted 9 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:
The boot page and reset vector need to be at the absolute address
0xfffff000and0xfffffffc, respectively, when the CPU boots....
Quoted 4 lines
To handle to both different U-Boot image sizes and flash locations, what we do is take the upper bits of the boot page from the location of .text and the lower bits are taken from the absolute address
0xfffff000. How many bits to take depends on the size of the flash bank. In effect the upper
Quoted 4 lines
I would like to point out that it is essential that the code must be able to handle the situation where the flash bank size is unknown at compile time, and becomes known anly at runtime when the flash driver probes the actual flash size on the board.
This is an issue for how the local bus controller is programmed and has nothing to do with my patch.
Quoted 6 lines
Quoted 2 lines
The bss segment should go after the end of the u-boot image. Which is only at the fixed address 0 for platforms that don't remap flash. For those
I'm not sure what you mean here. Bss becomes significant only after relocation to RAM. By then, it must be located in a valid RAM area. "fixed address 0" is no such valid address.
One way to avoid editing the linker script when changing the image size is to *link* u-boot with bss at 0. But that only works for boards that have have *linked* the boot page at 0xffff_f000, it doesn't work for boards, like mpc8572ds, that link the boot page at 0xefff_f000. The way I find address to link bss at works for all boards.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- .bootpg ADDR(.text) + 0x7f000 : + __flash_mask = 128M - 1;Does the linker actually understand the "128M" notation? Interesting - I didn't know that.
If it didn't understand the notation, I sure wouldn't have tested my patches very well! I'm using this on mpc8572ds hardware now. I tested the other platforms and verified that the u-boot image remains unchanged, as it should.
Quoted 7 lines
But - where is the number coming from? I guess that's a hard-wired flash size for this specific board?
This is bad, for two reasons: it means we have to maintain the same data in several places (in the linker script plus in the board config file), and second, we cannot handle boards where several size options exist.
This data doesn't exist in the board config file. The linker scripts already in effect contain this data. I have a calculation that uses the flash bank size. What's there now is the result of a calculation that uses the flash bank size. Change the flash mapping and the result changes. The existing scripts depend on the flash mapping just as much as mine does, if not more.
Which is not that much of a dependency really. If you look at the comments to the patch, it's only an issue in certain extreme cases that current don't exist.
PATCH 1/4 Use absolute addressing for mpc85xx boot page
Dear Trent,
Quoted 6 lines · in message <[email protected]> you wrote:
This data doesn't exist in the board config file. The linker scripts already in effect contain this data. I have a calculation that uses the flash bank size. What's there now is the result of a calculation that uses the flash bank size. Change the flash mapping and the result changes. The existing scripts depend on the flash mapping just as much as mine does, if not more.
So how do you handle boards where the flash size is unknown at compile-time?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Four thousand throats may be cut in one night by a running man. -- Klingon Soldier, "Day of the Dove", stardate unknown
PATCH 1/4 Use absolute addressing for mpc85xx boot page
Quoted 4 lines · Wolfgang Denk
Dear Trent,
Quoted 1 line · in message <[email protected]> you wrote:
Quoted 8 lines
Quoted 5 lines
This data doesn't exist in the board config file. The linker scripts already in effect contain this data. I have a calculation that uses the flash bank size. What's there now is the result of a calculation that uses the flash bank size. Change the flash mapping and the result changes. The existing scripts depend on the flash mapping just as much as mine does, if not more.
So how do you handle boards where the flash size is unknown at compile-time?
You're talking about how the eLBC is programmed. That has nothing to do with my patches!
When someone adds code to dynamically program the local bus controller they'll have to figure out what to do.
Probably the same way the CPU boots, by defaulting to an 8MB flash bank and then re-programming it later. Obviously the CPU can't find the size of the flash bank before it boots! Using the wrong bank size doesn't actually make much difference.
PATCH 2/4 Merge all mpc85xx platforms to use a single ld script
In reply to Trent PiephoThey are all the same except for the flash size and some copyright comments.
The combined script assumes a flash bank size of 4 MB, which work for all current platforms. This assumtion is only a problem if:
A) The flash bank is less than 4 MB and it is mapped to a location that not aligned to the top of a 4 MB boundary. E.g., a 1 MB bank mapped to 0xefff0000 is ok, but if it were mapped at 0xeffd0000 then it would be a problem.
B) The U-Boot image is over 4MB in size. The image size for this is from TEXT_BASE to the end of the reset vector. It's not the size of the U-Boot code as there could be a huge gap between the end of the code and the reset vector. The BSS section does not count for this size, as it goes after the reset vector (and it not actually present in the image). This should be the same as the size of the u-boot.bin file.
If someone ever has one of these problems, they can create a custom ld script that overrides the flash bank size and then just include the common mpc85xx script. It would look something like this:
__flash_mask = 2M - 1; /* For a 2MB flash bank */
INCLUDE cpu/mpc85xx/u-boot.lds
--- board/freescale/mpc8536ds/u-boot.lds | 144 ----------------------------- board/freescale/mpc8540ads/u-boot.lds | 147 ----------------------------- board/freescale/mpc8541cds/u-boot.lds | 144 ----------------------------- board/freescale/mpc8544ds/u-boot.lds | 145 ----------------------------- board/freescale/mpc8548cds/u-boot.lds | 144 ----------------------------- board/freescale/mpc8555cds/u-boot.lds | 144 ----------------------------- board/freescale/mpc8560ads/u-boot.lds | 147 ----------------------------- board/freescale/mpc8568mds/u-boot.lds | 144 ----------------------------- board/freescale/mpc8572ds/u-boot.lds | 144 ----------------------------- cpu/mpc85xx/config.mk | 3 + cpu/mpc85xx/u-boot.lds | 163 +++++++++++++++++++++++++++++++++ 11 files changed, 166 insertions(+), 1303 deletions(-) delete mode 100644 board/freescale/mpc8536ds/u-boot.lds delete mode 100644 board/freescale/mpc8540ads/u-boot.lds delete mode 100644 board/freescale/mpc8541cds/u-boot.lds delete mode 100644 board/freescale/mpc8544ds/u-boot.lds delete mode 100644 board/freescale/mpc8548cds/u-boot.lds delete mode 100644 board/freescale/mpc8555cds/u-boot.lds delete mode 100644 board/freescale/mpc8560ads/u-boot.lds delete mode 100644 board/freescale/mpc8568mds/u-boot.lds delete mode 100644 board/freescale/mpc8572ds/u-boot.lds create mode 100644 cpu/mpc85xx/u-boot.lds
board/freescale/mpc8536ds/u-boot.lds deleted +0 -144
@@ -1,144 +0,0 @@ -/* - * Copyright 2008 Freescale Semiconductor, Inc. - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -OUTPUT_ARCH(powerpc) -/* Do we need any of these for elf? - __DYNAMIC = 0; */ -PHDRS -{ - text PT_LOAD; - bss PT_LOAD; -} - -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = + SIZEOF_HEADERS; - .interp : { *(.interp) } - .hash : { *(.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .rel.text : { *(.rel.text) } - .rela.text : { *(.rela.text) } - .rel.data : { *(.rel.data) } - .rela.data : { *(.rela.data) } - .rel.rodata : { *(.rel.rodata) } - .rela.rodata : { *(.rela.rodata) } - .rel.got : { *(.rel.got) } - .rela.got : { *(.rela.got) } - .rel.ctors : { *(.rel.ctors) } - .rela.ctors : { *(.rela.ctors) } - .rel.dtors : { *(.rel.dtors) } - .rela.dtors : { *(.rela.dtors) } - .rel.bss : { *(.rel.bss) } - .rela.bss : { *(.rela.bss) } - .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } - .init : { *(.init) } - .plt : { *(.plt) } - .text : - { - *(.text) - *(.fixup) - *(.got1) - } :text - _etext = .; - PROVIDE (etext = .); - .rodata : - { - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) - *(.eh_frame) - } :text - .fini : { *(.fini) } =0 - .ctors : { *(.ctors) } - .dtors : { *(.dtors) } - - /* Read-write section, merged into data segment: */ - . = (. + 0x00FF) & 0xFFFFFF00; - _erotext = .; - PROVIDE (erotext = .); - .reloc : - { - *(.got) - _GOT2_TABLE_ = .; - *(.got2) - _FIXUP_TABLE_ = .; - *(.fixup) - } - __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2; - __fixup_entries = (. - _FIXUP_TABLE_) >> 2; - - .data : - { - *(.data) - *(.data1) - *(.sdata) - *(.sdata2) - *(.dynamic) - CONSTRUCTORS - } - _edata = .; - PROVIDE (edata = .); - - . = .; - __u_boot_cmd_start = .; - .u_boot_cmd : { *(.u_boot_cmd) } - __u_boot_cmd_end = .; - - . = .; - __start___ex_table = .; - __ex_table : { *(__ex_table) } - __stop___ex_table = .; - - . = ALIGN(256); - __init_begin = .; - .text.init : { *(.text.init) } - .data.init : { *(.data.init) } - . = ALIGN(256); - __init_end = .; - - __flash_mask = 128M - 1; - .bootpg (ADDR(.text) & ~(__flash_mask)) | (0xfffff000 & __flash_mask) : - { - cpu/mpc85xx/start.o (.bootpg) - } :text = 0xffff - - .resetvec ADDR(.bootpg) + 0xffc : - { - *(.resetvec) - } :text = 0xffff - - .bss ADDR(.bootpg) + 0x1000 (NOLOAD) : - { - __bss_start = ABSOLUTE(.); - *(.sbss) *(.scommon) - *(.dynbss) - *(.bss) - *(COMMON) - } :bss - - . = ALIGN(4); - _end = . ; - PROVIDE (end = .); -}
board/freescale/mpc8540ads/u-boot.lds deleted +0 -147
147 lines not on this page · raw message
board/freescale/mpc8541cds/u-boot.lds deleted +0 -144
144 lines not on this page · raw message
board/freescale/mpc8544ds/u-boot.lds deleted +0 -145
145 lines not on this page · raw message
board/freescale/mpc8548cds/u-boot.lds deleted +0 -144
144 lines not on this page · raw message
board/freescale/mpc8555cds/u-boot.lds deleted +0 -144
144 lines not on this page · raw message
board/freescale/mpc8560ads/u-boot.lds deleted +0 -147
147 lines not on this page · raw message
board/freescale/mpc8568mds/u-boot.lds deleted +0 -144
144 lines not on this page · raw message
board/freescale/mpc8572ds/u-boot.lds deleted +0 -144
144 lines not on this page · raw message
cpu/mpc85xx/config.mk +3 -0
@@ -26,3 +26,6 @@ PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi PLATFORM_CPPFLAGS += -DCONFIG_MPC85xx -DCONFIG_E500 -ffixed-r2 \ -Wa,-me500 -msoft-float -mno-string PLATFORM_CPPFLAGS +=$(call cc-option,-mno-spe) + +# Use default linker script. Board port can override in board/*/config.mk +LDSCRIPT := $(SRCTREE)/cpu/mpc85xx/u-boot.lds
cpu/mpc85xx/u-boot.lds new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 2/4 Merge all mpc85xx platforms to use a single ld script
Dear Trent Piepho,
Quoted 7 lines · In message <[email protected]> you wrote:
B) The U-Boot image is over 4MB in size. The image size for this is from
TEXT_BASEto the end of the reset vector. It's not the size of the U-Boot code as there could be a huge gap between the end of the code and the reset vector. The BSS section does not count for this size, as it goes after the reset vector (and it not actually present in the image). This should be the same as the size of the u-boot.bin file.
Where is bss then, if you try to locate it beyond the end of physical memory? To the best of my understanding there are two possibilities:
tool chains running on a 32 bit host will simply wrapr addresses around, i. e. start placing bss at physical address 0, which is not wrong. I don't remember eacty what you get on 64 bit hosts, but the result is not correct either.
Have you actually tested this code? Didn't you run into such problems?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de EMACS belongs in <sys/errno.h>: Editor too big!
PATCH 2/4 Merge all mpc85xx platforms to use a single ld script
Quoted 11 lines · Wolfgang Denk
Dear Trent Piepho,
Quoted 7 lines · In message <[email protected]> you wrote:
B) The U-Boot image is over 4MB in size. The image size for this is from
TEXT_BASEto the end of the reset vector. It's not the size of the U-Boot code as there could be a huge gap between the end of the code and the reset vector. The BSS section does not count for this size, as it goes after the reset vector (and it not actually present in the image). This should be the same as the size of the u-boot.bin file.
Quoted 6 lines
Where is bss then, if you try to locate it beyond the end of physical memory? To the best of my understanding there are two possibilities:
tool chains running on a 32 bit host will simply wrapr addresses around, i. e. start placing bss at physical address 0, which is not wrong. I don't remember eacty what you get on 64 bit hosts, but the result is not correct either.
This is where bss goes when u-boot is linked. It gets relocated to a different address in ram.
What the linker scripts *were* doing is putting bss at ADDR(.text) + 0x80000, which ends up being 0 for most boards and 0xf0000000 for some others.
Unless you try to make a non 512K image. Then bss might end up at 0x40000 when it should still be at 0. You could hard code the address 0, there are linker scripts that have done that. But that doesn't work on mpc8572ds for example, which should be 0xf0000000.
The way I'm finding the location to link bss works for all mpc85xx system and for all images sizes. This lets them share the same linker script.
Quoted 1 line
Have you actually tested this code? Didn't you run into such problems?
The resulting u-boot binary is exactly the same. This produces the same binaries as before using one linker script for all 85xx instead of a different one for each board.
PATCH 2/4 Merge all mpc85xx platforms to use a single ld script
Dear Trent,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 7 lines
Where is bss then, if you try to locate it beyond the end of physical memory? To the best of my understanding there are two possibilities:
tool chains running on a 32 bit host will simply wrapr addresses around, i. e. start placing bss at physical address 0, which is not wrong. I don't remember eacty what you get on 64 bit hosts, but the result is not correct either.This is where bss goes when u-boot is linked. It gets relocated to a different address in ram.
Where is defined which address it is, then?
Note that this added complexity of image layout is not shared by other architectures.
Quoted 2 lines
What the linker scripts *were* doing is putting bss at ADDR(.text) +
0x80000, which ends up being 0 for most boards and0xf0000000for some others.
Let's be careful here in our terminology. Your "most boards" is most probably not my "most boards". From the global point of view, "most boards" have a very simple layout like this:
...
. = ALIGN(256);
__init_begin = .;
.text.init : { *(.text.init) }
.data.init : { *(.data.init) }
. = ALIGN(256);
__init_end = .;
__bss_start = .;
.bss (NOLOAD) :
{
*(.sbss) *(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
...
BTW - this example is from a MPC85xx system...
Quoted 2 lines
Unless you try to make a non 512K image. Then bss might end up at
0x40000when it should still be at 0. You could hard code the address 0, there are
The bss must NEVER, never ever be loated at 0.
Quoted 2 lines
The way I'm finding the location to link bss works for all mpc85xx system and for all images sizes. This lets them share the same linker script.
Are you really talking about *all* MPC85xx systems, oronlyu about the FSL boards?
And where is bss in your design at run-time, after relocation?
Quoted 5 lines
Quoted 1 line
Have you actually tested this code? Didn't you run into such problems?
The resulting u-boot binary is exactly the same. This produces the same binaries as before using one linker script for all 85xx instead of a different one for each board.
Please define "all 85xx". I tend to doubt that.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de In the pitiful, multipage, connection-boxed form to which the flow- chart has today been elaborated, it has proved to be useless as a design tool -- programmers draw flowcharts after, not before, writing the programs they describe. - Fred Brooks, Jr.
PATCH 2/4 Merge all mpc85xx platforms to use a single ld script
Quoted 6 lines · Wolfgang Denk
Quoted 3 lines · In message <[email protected]> you wrote:
This is where bss goes when u-boot is linked. It gets relocated to a different address in ram.
Where is defined which address it is, then?
It is determined at run time. Look in cpu/mpc85xx/start.S at relocate_code.
But this has nothing to do with my patch. I'm not touching those files or changing how they work.
Quoted 2 lines
Note that this added complexity of image layout is not shared by other architectures.
I suppose locating the reset vector at the bottom instead of the top makes that easier.
Quoted 6 lines
Quoted 2 lines
What the linker scripts *were* doing is putting bss at ADDR(.text) +
0x80000, which ends up being 0 for most boards and0xf0000000for some others.Let's be careful here in our terminology. Your "most boards" is most probably not my "most boards". From the global point of view, "most boards" have a very simple layout like this:
My most boards is most 85xx boards.
Quoted 6 lines
__init_end= .;
__bss_start= .;
.bss (NOLOAD) :BTW - this example is from a MPC85xx system...
This wastes space in the u-boot image. bss is consuming address space between the end of the data section and the boot page that it doesn't need to.
All the Freescale mpc85xx boards have been changed to no longer do this, since this patch:
commit f0ff885ca64655bee6540eb8a25eed90b1152686
Author: Kumar Gala <[email protected]> Date: Wed Jul 30 14:13:30 2008 -0500
mpc85xx: Update linker scripts for Freescale boards
* Move to using absolute addressing always. Makes the scripts a bit more portable and common
* Moved .bss after the end of the image. These allows us to have more room in the resulting binary image for code and data.
....
It looks like you're looking at something like mpc8540eval, which could probably benefit from this change as well if the maintainer of that board feels like doing it.
BTW, if you continue to look at the mpc8540eval script, just past were you cut it off, you'll see:
. = (. & 0xFFF80000) + 0x0007F000;
.bootpg :
That 0xFFF80000 comes a flask bank size of 8MB! If __flash_mask = 8M - 1, then ~(__flash_mask) == 0xFFF80000. So don't say I'm *adding* the flash bank size to the linker script. It's already there! I'm just doing it in a better way.
Quoted 4 lines
Quoted 2 lines
Unless you try to make a non 512K image. Then bss might end up at
0x40000when it should still be at 0. You could hard code the address 0, there areThe bss must NEVER, never ever be loated at 0.
Seems to be working fine since Jul 30th. This is without my patchs applied, though they don't make any difference.
$ make MPC8548CDS_config && make $ grep ^.bss u-boot.map .bss 0x00000000 0x69b8
OMFG, bss is at zero! Fasten your seatbelts, 'cause we're all gonna crash!
Quoted 5 lines
Quoted 2 lines
The way I'm finding the location to link bss works for all mpc85xx system and for all images sizes. This lets them share the same linker script.
Are you really talking about *all* MPC85xx systems, oronlyu about the FSL boards?
All the FSL boards, but all the other mpc85xx system could probably do it the same way and use the same linker script that I've made the FSL boards use.
Quoted 1 line
And where is bss in your design at run-time, after relocation?
It's not "my" design. The code's been there since before *I* ever looked at it. And I'm not changing this design either.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Have you actually tested this code? Didn't you run into such problems?
The resulting u-boot binary is exactly the same. This produces the same binaries as before using one linker script for all 85xx instead of a different one for each board.
Please define "all 85xx". I tend to doubt that.
How about this, ALL boards. Every single last one of them. Either my patches don't touch them or they use the new common linker script and get linked in the same way they were before. Go ahead and try applying my first two patches and do a before and after comparison on the u-boot.map file. It's nothing but cosmetic changes, all the code is at the same place.
$ make MPC8548CDS_config && make
$ cp u-boot.map u-boot.map.old
$ stg push abs-boot && stg push mpc85xx-single-ld-script
$ make clean && make
$ diff -u u-boot.map.old u-boot.map
--- u-boot.map.old 2008-10-14 16:13:59.000000000 -0700
+++ u-boot.map 2008-10-14 16:15:38.000000000 -0700
@@ -1735,19 +1735,19 @@
*(.data.init)
0xfffb3c00 . = ALIGN (0x100)
0xfffb3c00 __init_end = .
+ 0x003fffff PROVIDE (__flash_mask, 0x3fffff) .bootpg 0xfffff000 0x1cc
- cpu/mpc85xx/start.o(.bootpg)
+ *(.bootpg)
.bootpg 0xfffff000 0x1cc cpu/mpc85xx/start.o
0xfffff000 _start_e500
.resetvec 0xfffffffc 0x4
*(.resetvec)
.resetvec 0xfffffffc 0x4 cpu/mpc85xx/resetvec.o
- 0x00000000 . = (ADDR (.text) + 0x80000) - 0x00000000 __bss_start = .
.bss 0x00000000 0x69b8
+ 0x00000000 __bss_start = <code 345> (.)
*(.sbss)
.sbss 0x00000000 0x0 cpu/mpc85xx/start.o .sbss 0x00000000 0x8 cpu/mpc85xx/libmpc85xx.a(traps.o)
It's nothing but cosmetic differences. All the objects have the same size and same location as they did pre-patch.
PATCH 2/4 Merge all mpc85xx platforms to use a single ld script
In reply to Wolfgang DenkQuoted 17 lines · Wolfgang Denk
Quoted 7 lines · In message <[email protected]> you wrote:
B) The U-Boot image is over 4MB in size. The image size for this is from
TEXT_BASEto the end of the reset vector. It's not the size of the U-Boot code as there could be a huge gap between the end of the code and the reset vector. The BSS section does not count for this size, as it goes after the reset vector (and it not actually present in the image). This should be the same as the size of the u-boot.bin file.Where is bss then, if you try to locate it beyond the end of physical memory? To the best of my understanding there are two possibilities:
tool chains running on a 32 bit host will simply wrapr addresses around, i. e. start placing bss at physical address 0, which is not wrong. I don't remember eacty what you get on 64 bit hosts, but the result is not correct either.
Quoted 1 line
Have you actually tested this code? Didn't you run into such problems?
It's locate the same place it is now! I'm telling you, these patches don't change the resulting u-boot binaries. How could the same binary stop working because a better build process was used to make it?
And yes I tested the code.
The u-boot image doesn't contain bss. The code is linked to expect bss at a certain location, relative to the rest of the code (because it's compiled PIC). But in the image, and when u-boot is executing from flash, bss doesn't exist. There was a bug in Timur's speed setting patch to the FSL I2C code because of that: it tried to write to bss while running out of flash. When u-boot gets moved from flash to ram, the bss section is created at the new location.
For instance, suppose u-boot is linked at 0xfff8_0000 and bss placed at 0x0000_0000. That how most 85xx platforms work now. After ram is enabled, u-boot is moved to ram at say 0x0010_0000. The bss segment will be created (space in ram set aside and zeroed) at 0x0018_0000. All the PIC code in u-boot that uses variables in bss will use this region starting at 0x0018_0000, because the relative position of 0x0018_0000 vs 0x0010_0000 is the same as 0xfff8_0000 vs 0x0000_0000. Yes, the calculations in the relocation code handle the wrap around correctly. If they didn't nothing would work now.
PATCH 3/4 Improve mpc85xx link script rodata section
In reply to Trent PiephoA recent gcc added a new unaligned rodata section called '.rodata.str1.1' and that needs to be added the the linker script.
Rather than just add that one section, instead use '*(.rodata*)' to catch that section and any future rodata sections.
'*(.rodata*)' by itself will result in sub-optimal section ordering. The section will be sorted by object file, which causes extra padding between the unaligned rodata.str.1.1 of one object file and the aligned rotdata of the next object file. This is easy to fix by using the SORT_BY_ALIGNMENT command.
--- cpu/mpc85xx/u-boot.lds | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
cpu/mpc85xx/u-boot.lds +1 -3
@@ -84,10 +84,8 @@ SECTIONS PROVIDE (etext = .); .rodata : { - *(.rodata) - *(.rodata1) - *(.rodata.str1.4) *(.eh_frame) + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } :text .fini : { *(.fini) } =0 .ctors : { *(.ctors) }
Signature · 1 line
1.5.4.1
PATCH 3/4 Improve mpc85xx link script rodata section
Dear Trent Piepho,
Quoted 5 lines · In message <[email protected]> you wrote:
A recent gcc added a new unaligned rodata section called '.rodata.str1.1' and that needs to be added the the linker script.
Rather than just add that one section, instead use '*(.rodata*)' to catch that section and any future rodata sections.
This affects *all* boards and should therefore be implemented for *all* boards, not only for 85xx.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A wise person makes his own decisions, a weak one obeys public opinion. -- Chinese proverb
PATCH 3/4 Improve mpc85xx link script rodata section
Quoted 11 lines · Wolfgang Denk
Dear Trent Piepho,
Quoted 5 lines · In message <[email protected]> you wrote:
A recent gcc added a new unaligned rodata section called '.rodata.str1.1' and that needs to be added the the linker script.
Rather than just add that one section, instead use '*(.rodata*)' to catch that section and any future rodata sections.
This affects *all* boards and should therefore be implemented for *all* boards, not only for 85xx.
The other board's linker scripts are somewhat different. Maybe someone who maintains them and knows them better should do it to make sure it's correct.
In fact, there's already patches that do this for other boards out there.
PATCH 3/4 Improve mpc85xx link script rodata section
Dear Trent,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines
This affects *all* boards and should therefore be implemented for *all* boards, not only for 85xx.
The other board's linker scripts are somewhat different. Maybe someone who maintains them and knows them better should do it to make sure it's correct.
I would like to see this in one commit, though, or a small series of connectred commits.
Quoted 1 line
In fact, there's already patches that do this for other boards out there.
Are there? I'm not aware of this. Do you have a link for me?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Things that try to look like things often do look more like things than things. Well-known fact. - Terry Pratchett, _Wyrd Sisters_
PATCH 3/4 Improve mpc85xx link script rodata section
Quoted 8 lines · Wolfgang Denk
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines
This affects *all* boards and should therefore be implemented for *all* boards, not only for 85xx.
The other board's linker scripts are somewhat different. Maybe someone who maintains them and knows them better should do it to make sure it's correct.
Quoted 6 lines
I would like to see this in one commit, though, or a small series of connectred commits.
Quoted 1 line
In fact, there's already patches that do this for other boards out there.
Are there? I'm not aware of this. Do you have a link for me?
I've seen them posted internally at Freescale for a couple months now. Some BSPs are using them. I don't think anyone, besides me, has tried to get any rodata fixes committed upstream. Maybe the thought of fixing 500 other boards they know nothing about is scaring them away? Some links:
http://www.bitshrine.org/gpp/u-boot-1.1.3-mpc832x-rodata-str-1.patch
http://www.bitshrine.org/gpp/u-boot-1.1.3-mpc8349itx-rodata-str-1.patch
http://www.bitshrine.org/gpp/u-boot-1.3.2-mpc8272ads-rodata-str-1.patch
IMHO, the way I've done it is better.
PATCH 4/4 Use ALIGN() in mpc85xx linker script
In reply to Trent PiephoIt wasn't used in one instance where the end of the rotext section is aligned to 256 bytes.
Maybe this alignment isn't necessary? I have to wonder about the alignment of the .data.init and .text.init sections too, since they don't appear to even exist.
--- cpu/mpc85xx/u-boot.lds | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cpu/mpc85xx/u-boot.lds +1 -1
@@ -92,7 +92,7 @@ SECTIONS .dtors : { *(.dtors) } /* Read-write section, merged into data segment: */ - . = (. + 0x00FF) & 0xFFFFFF00; + . = ALIGN(0x100); _erotext = .; PROVIDE (erotext = .); .reloc :
Signature · 1 line
1.5.4.1