link_VARIANTS = boot bload
+VERBOSE=-vv
+
bootstrap: TOHIT=$(USER_COMPILED_DIR_NAME)/bin-utils/tohit -d $(HIT_DEV)
bootstrap: HIT_BAUD=19200
.PHONY: bootstrap
/* Provided by linker script */
extern char __boot_fn_start;
extern char __boot_fn_end;
+extern char etext;
-void RelocatedProgMode(unsigned long where, unsigned baud)
+void RelocatedProgMode(unsigned baud)
{
- void (*ProgMode_ptr)(unsigned baud);
- unsigned long reloc_offs=where-(unsigned long)&__boot_fn_start;
size_t reloc_size=&__boot_fn_end-&__boot_fn_start;
- ProgMode_ptr=&ProgMode;
- ProgMode_ptr=(__u8*)ProgMode_ptr+reloc_offs;
- memcpy((char*)where,&__boot_fn_start,reloc_size);
+ memcpy(&__boot_fn_start,&etext,reloc_size);
/*deb_wr_hex((long)ProgMode_ptr,8);*/
- (*ProgMode_ptr)(baud);
+ ProgMode(baud);
}
if((__u8*)&__boot_fn_start<(__u8*)0xffb000) {
/* If we are not in the internal RAM, copy and run us from
* there */
- RelocatedProgMode(0xffb000,HIT_LOAD_BAUD);
+ RelocatedProgMode(HIT_LOAD_BAUD);
}
else
ProgMode(HIT_LOAD_BAUD);
# -*- makefile -*-
lib_LIBRARIES=boot_fn
-boot_fn_SOURCES = boot_fn.o
+boot_fn_SOURCES = boot_fn.c
#bin_PROGRAMS = boot
-boot_SOURCES = boot.c boot_fn.o
+boot_SOURCES = boot.c boot_fn.c
#link_VARIANTS = ram flash
lib_obj_SOURCES = crt0.S boot_fn.o
include_HEADERS = boot_fn.h
-
-default_CONFIG = CONFIG_PIC_BOOT_FN=y
-
-ifeq ($(CONFIG_PIC_BOOT_FN),y)
-# The following is for non-standard compilation of boot_fn
-define local_EVALUATE
-$(call COMPILE_c_o_template,$(SOURCES_DIR)/boot_fn.c,boot_fn.s1,-fpic -S)
-$(call COMPILE_S_o_template,boot_fn.s,boot_fn.o,-fpic -c)
-endef
-
-# This rule replaces jsr instructions by bsr ones which are relative
-# calls.
-boot_fn.s : boot_fn.s1
- @$(QUIET_CMD_ECHO) " SED $@"
- $(Q) sed 's/jsr[^0-9_A-Za-z]*@_\([0-9_A-Za-z]*\)\([^0-9_A-Za-z]*\)/bsr _\1:16\2/g' <$< >$@
-
-clean-custom:
- @rm boot_fn.s1 boot_fn.s
-else
-USER_SOURCES += boot_fn.c
-endif # CONFIG_PIC_BOOT_FN
#define TO_TEXT __attribute__ ((section (".text")))
-#define PIC_ADR(_ptr,_var) \
- { \
- __asm__ ( \
- "bsr 1f\n" \
- "1:\tmov.l @sp+,%0\n" \
- "\tadd.l %1-1b,%0\n" \
- : "=r" (_ptr) : "i" (&(_var)) : "cc" \
- ); \
- }
-
static const unsigned long
flash_blocks[] TO_TEXT =
{0x00000,0x01000,0x02000,0x03000,0x04000,0x05000,0x06000,0x07000,
{
int bl=0;
unsigned long *blocks;
- PIC_ADR(blocks,flash_blocks[0]);
+ blocks = &flash_blocks[0];
if(adr<blocks[0]) return -1;
while(blocks[bl+1]){
{
__u16 *p, *pe;
unsigned long *blocks;
- PIC_ADR(blocks,flash_blocks[0]);
+ blocks = &flash_blocks[0];
if(bl>=flash_block_count) return -2;
if(bl<0) return -2;
{
int res;
verbose(2, "Waiting for end reply\n");
- rs232_test(fd,2000000);
+ rs232_test(fd,3000000);
res=rs232_recch(fd);
if(res<0){
printf("Error no end reply\n");
{
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(.text))
+ KEEP (boot_fn.o(.rodata))
+ KEEP (boot_fn.o(.strings))
. = ALIGN( 4 ) ;
___boot_fn_end = ALIGN( 0x4 ) ;
- *(.text .stub .text.* .gnu.linkonce.t.*)
- *(.rodata .rodata.* .gnu.linkonce.r.*)
- *(.strings)
- . = ALIGN( 0x4 ) ;
- _etext = ALIGN( 0x4 ) ;
- } > flashbb
+ } > bloader AT>flashbb
.tors :
{