]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
h8300: Yet another update of bloader
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 16 Mar 2011 15:34:54 +0000 (16:34 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 16 Mar 2011 15:34:54 +0000 (16:34 +0100)
Now it should be bullet-proof and is tested with h8canusb.

arch/h8300/generic/bloader/Makefile.omk
arch/h8300/generic/bloader/bloader.c
board/h8300/h8canusb/libs/bspbase/bsp0hwinit.c
board/h8300/h8canusb/libs/h8canusb.ld-bload
board/h8300/h8canusb/libs/h8canusb.ld-boot
board/h8300/h8canusb/libs/h8canusb.ld-flash
board/h8300/h8eurobot/libs/h8canusb.ld-boot

index be8fba6ceaa416ae27b5fe5235bde74e4945a43c..06abb3c92d620dfc1935b9f9d9d17f20923cdf69 100644 (file)
@@ -10,18 +10,22 @@ link_VARIANTS = boot bload
 
 VERBOSE=-vv
 
-bootstrap: TOHIT=$(USER_COMPILED_DIR_NAME)/bin-utils/tohit -d $(HIT_DEV)
-bootstrap: HIT_BAUD=19200
-.PHONY: bootstrap
+TOHIT=$(USER_COMPILED_DIR_NAME)/bin-utils/tohit -d $(HIT_DEV)
+HIT_BAUD=19200
 
-bootstrap:
+.PHONY: bootstrap bootstrap_ram bootstrap_erase bootstrap_flash
+bootstrap: bootstrap_ram bootstrap_erase bootstrap_flash
+
+bootstrap_ram:
        @$(QUIET_CMD_ECHO) "Bootstrap to internal ram"
        $(Q)$(TOHIT) $(VERBOSE) --baud 4800 --command B --blockmode 128 $(USER_COMPILED_DIR_NAME)/bin/bloader-bload.bin || exit 1
        @$(QUIET_CMD_ECHO) "Done"
-       $(Q)sleep 3
+
+bootstrap_erase:
        @$(QUIET_CMD_ECHO) "Erasing flash"
        $(Q)$(TOHIT) $(VERBOSE) --baud $(HIT_BAUD) --erase --start 0x000000 --length 0x1600 || exit 1
        @$(QUIET_CMD_ECHO) "Done"
-       $(Q)sleep 1
+
+bootstrap_flash:
        @$(QUIET_CMD_ECHO) "Programming flash"
        $(Q)$(TOHIT) $(VERBOSE) --baud $(HIT_BAUD) --command 1 --blockmode 32 --start 0x000000 $(USER_COMPILED_DIR_NAME)/bin/bloader-boot.bin || exit
index f0144adec77a6b841f4ef8a3f906ee94baa6ff1f..ec637c0a863b89da7ef7c7fb1715b46017e8ba5d 100644 (file)
@@ -79,20 +79,6 @@ static void deb_led_out(char val)
 
 #include <boot_fn.h>
 
-/* Provided by linker script */
-extern char __boot_fn_start;
-extern char __boot_fn_end;
-extern char etext;
-
-void RelocatedProgMode(unsigned baud)
-{ 
-  size_t reloc_size=&__boot_fn_end-&__boot_fn_start;
-  memcpy(&__boot_fn_start,&etext,reloc_size);
-  /*deb_wr_hex((long)ProgMode_ptr,8);*/
-  ProgMode(baud);
-}
-
-
 void boot_test()
 {
   /*set power on for SCI0 and SCI1 module*/
@@ -121,13 +107,7 @@ void boot_test()
   }
 
  
-  if((__u8*)&etext<(__u8*)0xffb000) {
-         /* If we are not in the internal RAM, copy and run us from
-          * there */
-         RelocatedProgMode(HIT_LOAD_BAUD);
-  }
-   else
-    ProgMode(HIT_LOAD_BAUD);
+  ProgMode(HIT_LOAD_BAUD);
 }
 
 #endif /* BOOT_TEST */
index 8163124fecc0b1c304817e1906b6e36f20d9412c..1cb8668ca5ec777ab78edfbc8ec3490c20f10fb5 100644 (file)
@@ -31,6 +31,20 @@ static void deb_led_out(char val)
     DEB_LED_OFF(3);
 }
 
+/* Provided by linker script */
+extern char __boot_fn_load;
+extern char __boot_fn_start;
+extern char __boot_fn_end;
+
+static void relocate_boot_fn()
+{
+  size_t reloc_size=&__boot_fn_end-&__boot_fn_start;
+
+  if(&__boot_fn_load != &__boot_fn_start) {
+    memcpy(&__boot_fn_start,&__boot_fn_load,reloc_size);
+  }
+}
+
 void _setup_board()
 {
   //int i, j;// POE-100
@@ -54,6 +68,8 @@ void _setup_board()
 
   DEB_LED_INIT();
 
+  relocate_boot_fn();
+
   /* show something on debug leds */
   deb_led_out(0);
   FlWait(1*100000);
index 95a6a50e222a0e64b72931a92f94c06609e97530..07a495f5f510b0371fd7777582ab1feba2c7fcec 100644 (file)
@@ -17,6 +17,7 @@ SECTIONS
          *(.strings)
          . = ALIGN( 4 ) ;
          ___boot_fn_start = ALIGN( 0x4 ) ;
+         ___boot_fn_load = ALIGN( 0x4 ) ;
           KEEP (*boot_fn.o(.text))
          KEEP (*boot_fn.o(.rodata))
          . = ALIGN( 4 ) ;
index ba4080645bae5f40864ab1d4886395a4c62f4eb6..b50ec7da2b0d422a5a2db7b2cbbf785ca7508201 100644 (file)
@@ -24,29 +24,30 @@ SECTIONS
          . = ALIGN( 0x4 ) ;
        } > iram0
 
-        .text :
+       .text.boot_fn ALIGN(4) :
        {
-         text_start = . ;
-         KEEP (crt0.o(.text))
-          *(EXCLUDE_FILE(*boot_fn.o) .text)
-         *(EXCLUDE_FILE(*boot_fn.o) .rodata)                           
-         *(EXCLUDE_FILE(*boot_fn.o) .text .stub .text.* .gnu.linkonce.t.*)
-         *(EXCLUDE_FILE(*boot_fn.o) .rodata .rodata.* .gnu.linkonce.r.*)
-         *(EXCLUDE_FILE(*boot_fn.o) .strings)
          . = ALIGN( 0x4 ) ;
-         _etext = ALIGN( 0x4 ) ;
-        } > flashbb
-       .text.boot_fn :
-       {
-         . = ALIGN( 4 ) ;
-         ___boot_fn_start = ALIGN( 0x4 ) ;
           KEEP (boot_fn.o(.text))
          KEEP (boot_fn.o(.rodata))
          KEEP (boot_fn.o(.strings))
          . = ALIGN( 4 ) ;
-         ___boot_fn_end = ALIGN( 0x4 ) ;
-       } > bloader AT>flashbb
+       } > iram0 AT>flashbb
+       ___boot_fn_start = ADDR(.text.boot_fn);
+       ___boot_fn_end   = ADDR(.text.boot_fn) + SIZEOF(.text.boot_fn);
+       ___boot_fn_load  = LOADADDR(.text.boot_fn);
 
+        .text :
+       {
+         text_start = . ;
+         KEEP (crt0.o(.text))
+          *(.text)
+         *(.rodata)                            
+         *(.text .stub .text.* .gnu.linkonce.t.*)
+         *(.rodata .rodata.* .gnu.linkonce.r.*)
+         *(.strings)
+         . = ALIGN( 0x4 ) ;
+         _etext = ALIGN( 0x4 ) ;
+        } > flashbb
        .tors : 
        {
          ___ctors = . ;
index ac4d03212b27896a9905fdc3604e5fc1a3251d62..e4a6c98cfb415ca292a670b5d3f80ce9215643df 100644 (file)
@@ -19,6 +19,7 @@ SECTIONS
          LONG( ABSOLUTE( _start ) + 0x5a000000 ) /* JMP _start */
 /*       KEEP (crt0.o(.text)) */
          . = ALIGN( 4 ) ;
+         ___boot_fn_load = ALIGN( 0x4 ) ;
          ___boot_fn_start = ALIGN( 0x4 ) ;
           KEEP (*boot_fn.o(.text))
          KEEP (*boot_fn.o(.rodata))
index ba4080645bae5f40864ab1d4886395a4c62f4eb6..d3d2bfa739a50f938b236142f223ef29653e38ca 100644 (file)
@@ -45,7 +45,7 @@ SECTIONS
          KEEP (boot_fn.o(.strings))
          . = ALIGN( 4 ) ;
          ___boot_fn_end = ALIGN( 0x4 ) ;
-       } > bloader AT>flashbb
+       } > iram0 AT>flashbb
 
        .tors : 
        {