]> rtime.felk.cvut.cz Git - sysless.git/blob - arch/h8300/generic/bloader/Makefile.std
Included H8300 boot block and bootstrap loader code
[sysless.git] / arch / h8300 / generic / bloader / Makefile.std
1 # -*- makefile -*-
2 TOPDIR=..
3
4 TARGET_ARCH = -ms
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
10
11 TOHIT=../tohit/tohit -d /dev/ttyS0
12
13 BOARD_LAYOUT=id_cpu1
14 #BOARD_LAYOUT=edk2638
15
16 #CC = gcc
17 CC = h8300-coff-gcc
18
19 LINK = h8300-coff-ld
20
21 OBJCOPY = h8300-coff-objcopy
22
23 CFLAGS  += $(TARGET_ARCH)
24 CFLAGS  += -g 
25 CFLAGS  += -O2 -Wall
26
27 CFLAGS  += -I. -I../../_compiled/include
28
29
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
36 LDFLAGS += --relax
37 LDFLAGS += -L. -L../../_compiled/lib
38 LDFLAGS += -lboot_fn
39
40 CRT0_O = crt0.o
41
42 LCSCRIPTB = 
43
44 HIT_BAUD = 19200
45 #HIT_BAUD = 38400
46 #CFLAGS += -DHIT_LOAD_BAUD=$(HIT_BAUD)
47
48 #CFLAGS += -v
49 #LDFLAGS += -v
50
51 ######################################################################
52 # New rules
53
54 .S.o:
55         $(CC) -D__ASSEMBLY__ $(AFLAGS) $(TARGET_ARCH) -c $< -o $@
56
57 .c.s:
58         $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -S $< -o $@
59
60 ######################################################################
61
62 all   : bloader.bin
63
64 dep:
65         $(CC) $(CFLAGS) $(CPPFLAGS) -w -E -M *.c $(MORE_C_FILES) > depend
66
67 depend:
68         @touch depend
69
70 cleanapps : clean
71
72 clean   :
73         rm -f *.o
74         rm -f *.bin *.srec
75         rm -f bloader bloader-boot bloader-ram bloader-flash
76
77 boot_fn.o : ../../_build/arch/h8300/generic/libs/boot/boot_fn.o
78         ln -s $< $@ 
79
80 crt0.o : ../../_compiled/lib/crt0.o
81         ln -s $< $@ 
82
83 #LDFORBOOT += -Xlinker -Ttext -Xlinker 0xffc000 
84 #LDFORBOOT += -Xlinker -Tdata -Xlinker 0xffc000 
85 #LDFORBOOT += -Xlinker -Tbss  -Xlinker 0xffc000
86
87 bloader :bloader.o $(BOOT_FN_O)
88         $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-bload $(LDFORBOOT) $^ -o $@
89
90 bloader-flash :bloader.o $(BOOT_FN_O)
91         $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-flash $^ -o $@
92
93 bloader-ram :bloader.o $(BOOT_FN_O)
94         $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-ram $^ -o $@
95
96 bloader-boot :bloader.o $(BOOT_FN_O)
97         $(CC) $(LDFLAGS) -T $(BOARD_LAYOUT).ld-boot $^ -o $@
98
99 bloader.bin : bloader
100         $(OBJCOPY)  --output-target=binary -S bloader bloader.bin
101
102 # Load bloader to internal ram (in boot mode, all flash is erased)
103 load : bloader.bin
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
108
109 bloader1 :
110         ((cd ../boot ; rm *.o ; make ; ) ; rm *.o ; make bloader-ram; objdump --source bloader-ram ) 2>&1  | less
111
112
113 # Use previously loaded bloader to load bloader to external ram
114 load1 : bloader-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
120
121 # Use previously loaded bloader to store bloader in flash
122 load2 : bloader-boot
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
127
128 # Use previously loaded bloader to load bloader to internal ram as in boot-mode
129 load3 : bloader.bin
130         $(TOHIT) --baud $(HIT_BAUD) --start 0xffc000 --blockmode 32 --go 0xffc000 bloader.bin
131
132 read_bb : 
133         $(TOHIT) --baud $(HIT_BAUD) --upload --start 0xffc000 --length 0x400 bloader.rd
134
135 read_st : 
136         $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x280000 --length 0x1000 --blockmode 32 bloader.rd
137
138 read_flash : 
139         $(TOHIT) --baud $(HIT_BAUD) --upload --start 0x000000 --length 0x2000 bloader2.rd
140         cmp -l bloader2.bin bloader2.rd
141
142 flash_prg : 
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
147
148 flash_prg1 : 
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
153
154 ram_test : 
155         $(TOHIT) --baud $(HIT_BAUD) --wait-reply 1000 --blockmode 32 --start 0x200000 pat.bin
156 #       $(TOHIT) --baud $(HIT_BAUD) --break
157         sleep 1
158         $(TOHIT) --baud $(HIT_BAUD) --wait-reply 1000 --upload --start 0x200000 --length 0x0400 pat.rd
159         cmp -l pat.bin pat.rd
160
161 reset : 
162         $(TOHIT) --baud $(HIT_BAUD) --reset
163
164 break : 
165         $(TOHIT) --baud $(HIT_BAUD) --break
166
167 goto0 : 
168         $(TOHIT) --baud $(HIT_BAUD) --go 0xffc000
169
170 goto1 : 
171         $(TOHIT) --baud $(HIT_BAUD) --go 0x200000
172
173 goto2 : 
174         $(TOHIT) --baud $(HIT_BAUD) --go 0x000500
175
176
177 -include depend