5 #TARGET_ARCH = -bh8300-coff -ms
6 #TARGET_ARCH = -bh8300-coff -ms -mrelax
7 #TARGET_ARCH = -bm68k-coff -m68332
8 #TARGET_ARCH = -bm68k-elf -m68332
9 #TARGET_ARCH = -bi586-mingw32
11 TOHIT=../tohit/tohit -d /dev/ttyS0
21 OBJCOPY = h8300-coff-objcopy
23 CFLAGS += $(TARGET_ARCH)
27 CFLAGS += -I. -I../../_compiled/include
30 LDFLAGS += $(TARGET_ARCH)
31 #LDFLAGS += -Xlinker -Ttext -Xlinker 0x0FFE400
32 LDFLAGS += -nostartfiles
33 #LDFLAGS += -nodefaultlibs
34 #LDFLAGS += -Xlinker -T -Xlinker h8300s.x
35 LDFLAGS += -Xlinker -Map -Xlinker bloader.map
37 LDFLAGS += -L. -L../../_compiled/lib
46 #CFLAGS += -DHIT_LOAD_BAUD=$(HIT_BAUD)
51 ######################################################################
55 $(CC) -D__ASSEMBLY__ $(AFLAGS) $(TARGET_ARCH) -c $< -o $@
58 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -S $< -o $@
60 ######################################################################
65 $(CC) $(CFLAGS) $(CPPFLAGS) -w -E -M *.c $(MORE_C_FILES) > depend
75 rm -f bloader bloader-boot bloader-ram bloader-flash
77 boot_fn.o : ../../_build/arch/h8300/generic/libs/boot/boot_fn.o
80 crt0.o : ../../_compiled/lib/crt0.o
83 #LDFORBOOT += -Xlinker -Ttext -Xlinker 0xffc000
84 #LDFORBOOT += -Xlinker -Tdata -Xlinker 0xffc000
85 #LDFORBOOT += -Xlinker -Tbss -Xlinker 0xffc000
87 bloader :bloader.o $(BOOT_FN_O)
88 $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-bload $(LDFORBOOT) $^ -o $@
90 bloader-flash :bloader.o $(BOOT_FN_O)
91 $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-flash $^ -o $@
93 bloader-ram :bloader.o $(BOOT_FN_O)
94 $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-ram $^ -o $@
96 bloader-boot :bloader.o $(BOOT_FN_O)
97 $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-boot $^ -o $@
100 $(OBJCOPY) --output-target=binary -S bloader bloader.bin
102 # Load bloader to internal ram (in boot mode, all flash is erased)
104 $(TOHIT) --baud 4800 --command B --blockmode 128 bloader.bin /* boot program mode */
105 # $(TOHIT) --command B bloader.bin
106 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0 --length 0x400 bloader.rd
107 # $(TOHIT) B 0 bloader.bin
110 ((cd ../boot ; rm *.o ; make ; ) ; rm *.o ; make bloader-ram; objdump --source bloader-ram ) 2>&1 | less
113 # Use previously loaded bloader to load bloader to external ram
115 $(OBJCOPY) --output-target=binary -S bloader-ram bloader1.bin
116 $(OBJCOPY) --output-target=srec -S bloader-ram bloader1.srec
117 $(TOHIT) --baud $(HIT_BAUD) --blockmode 32 --start 0x200000 bloader1.bin
118 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x200000 --length 0x1A00 bloader1.rd
119 $(TOHIT) --baud $(HIT_BAUD) --go 0x200000
121 # Use previously loaded bloader to store bloader in flash
123 $(OBJCOPY) --output-target=binary -S bloader-boot bloader2.bin
124 $(TOHIT) --baud $(HIT_BAUD) --erase --start 0x000000 --length 0x1600
125 $(TOHIT) --baud $(HIT_BAUD) --command 1 --blockmode 32 --start 0x000000 bloader2.bin
126 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x000000 --length 0x1600 --blockmode 32 bloader2.rd
128 # Use previously loaded bloader to load bloader to internal ram as in boot-mode
130 $(TOHIT) --baud $(HIT_BAUD) --start 0xffc000 --blockmode 32 --go 0xffc000 bloader.bin
133 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0xffc000 --length 0x400 bloader.rd
136 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x280000 --length 0x1000 --blockmode 32 bloader.rd
139 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x000000 --length 0x2000 bloader2.rd
140 cmp -l bloader2.bin bloader2.rd
143 $(TOHIT) --baud $(HIT_BAUD) --erase --start 0x010000 --length 0x80
144 $(TOHIT) --baud $(HIT_BAUD) --command 1 --blockmode 32 --start 0x010000 pat.bin
145 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x010000 --length 0x80 pat.rd
146 cmp -l pat.bin pat.rd
149 $(TOHIT) --baud $(HIT_BAUD) --erase --start 0x007000 --length 0x200
150 $(TOHIT) --baud $(HIT_BAUD) --command 1 --blockmode 32 --start 0x007000 pat1.bin
151 $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x007000 --length 0x200 pat1.rd
152 cmp -l pat1.bin pat1.rd
155 $(TOHIT) --baud $(HIT_BAUD) --wait-reply 1000 --blockmode 32 --start 0x200000 pat.bin
156 # $(TOHIT) --baud $(HIT_BAUD) --break
158 $(TOHIT) --baud $(HIT_BAUD) --wait-reply 1000 --upload --start 0x200000 --length 0x0400 pat.rd
159 cmp -l pat.bin pat.rd
162 $(TOHIT) --baud $(HIT_BAUD) --reset
165 $(TOHIT) --baud $(HIT_BAUD) --break
168 $(TOHIT) --baud $(HIT_BAUD) --go 0xffc000
171 $(TOHIT) --baud $(HIT_BAUD) --go 0x200000
174 $(TOHIT) --baud $(HIT_BAUD) --go 0x000500