Flash probing can cause the Boot Flash to lock up - Entire contents of
Flash (minus the low level asm init which is not needed post-bootstrap)
is copied to RAM

This is not an ideal relocation mechanism. This change sets TEXT_BASE
to an area just below the guaranteed 64MB RAM which exists on all eNET
boards. At some stage in the future, I hope to implement a proper
relocation mechanism

Signed-off-by: Graeme Russ <graeme.r...@gmail.com>
---
 board/eNET/config.mk   |    2 +-
 board/eNET/u-boot.lds  |   65 ++++++++++++++++++++++++++++-------------------
 cpu/i386/start.S       |    8 ++++++
 include/configs/eNET.h |    6 ++--
 4 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/board/eNET/config.mk b/board/eNET/config.mk
index a763841..833c66e 100644
--- a/board/eNET/config.mk
+++ b/board/eNET/config.mk
@@ -21,4 +21,4 @@
 # MA 02111-1307 USA
 #
 
-TEXT_BASE = 0x38040000
+TEXT_BASE = 0x03FC0000
diff --git a/board/eNET/u-boot.lds b/board/eNET/u-boot.lds
index 284d2bd..7311e8b 100644
--- a/board/eNET/u-boot.lds
+++ b/board/eNET/u-boot.lds
@@ -27,47 +27,42 @@ ENTRY(_start)
 
 SECTIONS
 {
-       . = 0x38040000;         /* Location of bootcode in flash */
+       /*
+        * All eNET boards have at least 64MB memory on board. The Boot Flash
+        * is 512kB, but only 256kB of this is used for U-Boot. start.S will
+        * copy the 256kB U-Boot executable from Flash into RAM starting at
+        * the address 256kB below 64MB (i.e. 0x03FC0000)
+        */
+       . = 0x03FC0000;
+ 
+       _i386boot_rom_copy_start = .;
+       /* ---  Begin data copied from Flash --- */
        .text  : { *(.text); }
-
        . = ALIGN(4);
-       .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
-       _i386boot_text_size = SIZEOF(.text) + SIZEOF(.rodata);
+       .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+       . = ALIGN(4);
 
-       . = 0x03FF0000;         /* Ram data segment to use */
-       _i386boot_romdata_dest = ABSOLUTE(.);
-       .data : AT ( LOADADDR(.rodata) + SIZEOF(.rodata) ) { *(.data) }
-       _i386boot_romdata_start = LOADADDR(.data);
+       .u_boot_cmd : { *(.u_boot_cmd) }
+       . = ALIGN(4);
 
+       .data : { *(.data) }
        . = ALIGN(4);
-       .got : AT ( LOADADDR(.data) + SIZEOF(.data) ) { *(.got) }
 
+       .got : { *(.got) }
        . = ALIGN(4);
-       __u_boot_cmd_start = .;
-       .u_boot_cmd : { *(.u_boot_cmd) }
-       __u_boot_cmd_end = .;
-       _i386boot_cmd_start = LOADADDR(.u_boot_cmd);
 
-       _i386boot_romdata_size = SIZEOF(.data) + SIZEOF(.got) + 
SIZEOF(.u_boot_cmd);
+       /* ---  End data copied from Flash --- */
+       _i386boot_rom_copy_end = .;
 
-       . = ALIGN(4);
-       _i386boot_bss_start = ABSOLUTE(.);
        .bss (NOLOAD) : { *(.bss) }
-       _i386boot_bss_size = SIZEOF(.bss);
 
        /* 16bit realmode trampoline code */
        .realmode 0x7c0 : AT ( LOADADDR(.got) + SIZEOF(.got) + 
SIZEOF(.u_boot_cmd)) { *(.realmode) }
 
-       _i386boot_realmode = LOADADDR(.realmode);
-       _i386boot_realmode_size = SIZEOF(.realmode);
-
        /* 16bit BIOS emulation code (just enough to boot Linux) */
        .bios 0 : AT ( LOADADDR(.realmode) + SIZEOF(.realmode) ) { *(.bios) }
 
-       _i386boot_bios = LOADADDR(.bios);
-       _i386boot_bios_size = SIZEOF(.bios);
-
        /* The load addresses below assumes that the flash
         * will be mapped so that 0x387f0000 == 0xffff0000
         * at reset time
@@ -79,12 +74,30 @@ SECTIONS
         */
 
        . = 0xffffee00;
-       .start32 : AT (0x3807ee00) { *(.start32); }
+       .start32 : AT (0x03ffee00) { *(.start32); }
 
        . = 0xf800;
-       .start16 : AT (0x3807f800) { *(.start16); }
+       .start16 : AT (0x03fff800) { *(.start16); }
 
        . = 0xfff0;
-       .resetvec : AT (0x3807fff0) { *(.resetvec); }
+       .resetvec : AT (0x03fffff0) { *(.resetvec); }
        _i386boot_end = (LOADADDR(.resetvec) + SIZEOF(.resetvec) );
+
+       /* Export section information */
+       _i386boot_bss_start = ADDR(.bss);
+       _i386boot_bss_size  = SIZEOF(.bss);
+       _i386boot_realmode = LOADADDR(.realmode);
+       _i386boot_realmode_size = SIZEOF(.realmode);
+       _i386boot_bios = LOADADDR(.bios);
+       _i386boot_bios_size = SIZEOF(.bios);
+
+       _i386boot_romdata_start = LOADADDR(.rodata);
+
+       _i386boot_romdata_dest = LOADADDR(.data);
+       _i386boot_cmd_start = LOADADDR(.u_boot_cmd);
+       _i386boot_romdata_size = SIZEOF(.data) + SIZEOF(.got) + 
SIZEOF(.u_boot_cmd);
+
+       __u_boot_cmd_start = ADDR(.u_boot_cmd);
+       __u_boot_cmd_end = ADDR(.u_boot_cmd) + SIZEOF(.u_boot_cmd);
+
 }
diff --git a/cpu/i386/start.S b/cpu/i386/start.S
index bb4a5cf..cb2633f 100644
--- a/cpu/i386/start.S
+++ b/cpu/i386/start.S
@@ -116,10 +116,18 @@ stack_ok:
        jmp     show_boot_progress_asm
 .progress2:
 
+#ifdef CONFIG_SYS_FULL_CODE_COPY
+       /* copy text, rodata, u_boot_cmd, data, and got sections from Flash */
+       movl    $TEXT_BASE, %edi                /* destination address */
+       movl    $CONFIG_SYS_MONITOR_BASE, %esi  /* source address */
+       movl    $_i386boot_rom_copy_end, %ecx
+       subl    $_i386boot_rom_copy_start, %ecx
+#else
        /* copy data section to ram, size must be 4-byte aligned */
        movl    $_i386boot_romdata_dest, %edi     /* destination address */
        movl    $_i386boot_romdata_start, %esi    /* source address */
        movl    $_i386boot_romdata_size, %ecx     /* number of bytes to copy */
+#endif
        movl    %ecx, %eax
        andl    $3, %eax
        jnz     data_fail
diff --git a/include/configs/eNET.h b/include/configs/eNET.h
index 243a554..cfcd909 100644
--- a/include/configs/eNET.h
+++ b/include/configs/eNET.h
@@ -28,6 +28,8 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+#define CONFIG_SKIP_RELOCATE_UBOOT
+#define CONFIG_SYS_FULL_CODE_COPY
 /*
  * Stuff still to be dealt with -
  */
@@ -154,9 +156,7 @@
  * Memory organization
  */
 #define CONFIG_SYS_STACK_SIZE          0x8000          /* Size of bootloader 
stack */
-#define CONFIG_SYS_BL_START_FLASH      0x38040000      /* Address of relocated 
code */
-#define CONFIG_SYS_BL_START_RAM                0x03fd0000      /* Address of 
relocated code */
-#define CONFIG_SYS_MONITOR_BASE                TEXT_BASE
+#define CONFIG_SYS_MONITOR_BASE         0x38040000     /* Address of code in 
Boot Flash */
 #define CONFIG_SYS_MONITOR_LEN         (256 * 1024)    /* Reserve 256 kB for 
Mon       */
 #define CONFIG_SYS_FLASH_BASE          0x38000000      /* Boot Flash */
 #define CONFIG_SYS_FLASH_BASE_1                0x10000000      /* StrataFlash 
1 */
-- 
1.6.0.2.GIT

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to