The 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? Signed-off-by: Trent Piepho <[EMAIL PROTECTED]> --- 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(-) diff --git a/board/freescale/mpc8536ds/u-boot.lds b/board/freescale/mpc8536ds/u-boot.lds index 901f633..05c8d4d 100644 --- a/board/freescale/mpc8536ds/u-boot.lds +++ b/board/freescale/mpc8536ds/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8540ads/u-boot.lds b/board/freescale/mpc8540ads/u-boot.lds index 515d320..2148e12 100644 --- a/board/freescale/mpc8540ads/u-boot.lds +++ b/board/freescale/mpc8540ads/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8541cds/u-boot.lds b/board/freescale/mpc8541cds/u-boot.lds index d728d8b..13ec8bf 100644 --- a/board/freescale/mpc8541cds/u-boot.lds +++ b/board/freescale/mpc8541cds/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8544ds/u-boot.lds b/board/freescale/mpc8544ds/u-boot.lds index a05ece5..10a333b 100644 --- a/board/freescale/mpc8544ds/u-boot.lds +++ b/board/freescale/mpc8544ds/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8548cds/u-boot.lds b/board/freescale/mpc8548cds/u-boot.lds index d4a2f72..2dca78a 100644 --- a/board/freescale/mpc8548cds/u-boot.lds +++ b/board/freescale/mpc8548cds/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8555cds/u-boot.lds b/board/freescale/mpc8555cds/u-boot.lds index 11885e8..644db2c 100644 --- a/board/freescale/mpc8555cds/u-boot.lds +++ b/board/freescale/mpc8555cds/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8560ads/u-boot.lds b/board/freescale/mpc8560ads/u-boot.lds index 515d320..2148e12 100644 --- a/board/freescale/mpc8560ads/u-boot.lds +++ b/board/freescale/mpc8560ads/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8568mds/u-boot.lds b/board/freescale/mpc8568mds/u-boot.lds index ad96410..0c59e8c 100644 --- a/board/freescale/mpc8568mds/u-boot.lds +++ b/board/freescale/mpc8568mds/u-boot.lds @@ -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) diff --git a/board/freescale/mpc8572ds/u-boot.lds b/board/freescale/mpc8572ds/u-boot.lds index a05ece5..7ee7d61 100644 --- a/board/freescale/mpc8572ds/u-boot.lds +++ b/board/freescale/mpc8572ds/u-boot.lds @@ -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) -- 1.5.4.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot