-
Notifications
You must be signed in to change notification settings - Fork 4
/
ecrobot.mak
392 lines (323 loc) · 11.4 KB
/
ecrobot.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# Common Makefile for C/C++(*.cc) with TOPPERS ATK(OSEK) and JSP(ƒÊITRON)
#
## ROOT path configurations
#
ifndef ROOT
ROOT := $(dir $(lastword $(MAKEFILE_LIST)))..
endif
ECROBOT_ROOT = $(ROOT)/ecrobot
CXX_ROOT=$(ROOT)/c++
LEJOSNXJSRC_ROOT = $(ROOT)/lejos_nxj/src/
ifeq ($(TOPPERS_KERNEL), NXT_JSP)
TOPPERS_ROOT = $(ROOT)/toppers_jsp
else
TOPPERS_ROOT = $(ROOT)/toppers_osek
endif
# 03/11/2009 added by takashic
ECROBOT_C_ROOT = $(ECROBOT_ROOT)/c
vpath %.c $(LEJOSNXJSRC_ROOT) $(TOPPERS_ROOT) $(ECROBOT_ROOT) $(ECROBOT_C_ROOT)
vpath %.S $(LEJOSNXJSRC_ROOT) $(TOPPERS_ROOT)
vpath %.s $(LEJOSNXJSRC_ROOT) $(TOPPERS_ROOT) $(ECROBOT_ROOT) $(ECROBOT_C_ROOT)
################################################################################
# TOPPERS ATK/JSP specific settings. By default, TOPPERS ATK is configured as
# RTOS for the NXT, however, JSP also can be used by defining TOPPERS_KERNEL = NXT_JSP
# macro in user Makefile
ifeq ($(TOPPERS_KERNEL), NXT_JSP)
TOPPERS_INC_PATH = \
$(TOPPERS_ROOT)/kernel \
$(TOPPERS_ROOT)/include \
$(TOPPERS_ROOT)/config/armv4 \
$(TOPPERS_ROOT)/config/armv4/at91sam7s
TOPPERS_KERNEL_SOURCES = $(addprefix kernel/, \
banner.c \
cyclic.c \
dataqueue.c \
eventflag.c \
exception.c \
interrupt.c \
mailbox.c \
mempfix.c \
semaphore.c \
startup.c \
sys_manage.c \
syslog.c \
task.c \
task_except.c \
task_manage.c \
task_sync.c \
time_event.c \
time_manage.c \
wait.c )
TOPPERS_CONFIG_SOURCES = $(addprefix config/armv4/, \
cpu_config.c )
TOPPERS_CONFIG_SYS_SOURCES = $(addprefix config/armv4/at91sam7s/, \
sys_config.c )
TOPPERS_SYSLIB_SOURCES = $(addprefix library/, \
log_output.c \
strerror.c \
t_perror.c \
vasyslog.c )
TOPPERS_SRAM_SOURCES = \
config/armv4/cpu_support.s \
config/armv4/at91sam7s/irq.s
else
# if you need to modify the Makefiles to set absolute path,
# TOPPERS_OSEK_ROOT_SG should be defined like...
# TOPPERS_OSEK_ROOT_SG = C:/cygwin/nxtOSEK/toppers_osek
ifndef TOPPERS_OSEK_ROOT_SG
TOPPERS_OSEK_ROOT_SG = $(TOPPERS_ROOT)
endif
TOPPERS_INC_PATH = \
$(TOPPERS_ROOT)/kernel \
$(TOPPERS_ROOT)/com \
$(TOPPERS_ROOT)/include \
$(TOPPERS_ROOT)/config/at91sam7s-gnu \
$(TOPPERS_ROOT)/config/at91sam7s-gnu/lego_nxt \
$(TOPPERS_ROOT)/sg \
$(TOPPERS_ROOT)/syslib/at91sam7s-gnu/lego_nxt
TOPPERS_KERNEL_SOURCES = $(addprefix kernel/, \
alarm.c \
event.c \
interrupt.c \
osctl.c \
resource.c \
task.c \
task_manage.c )
TOPPERS_CONFIG_SOURCES = $(addprefix config/at91sam7s-gnu/, \
cpu_config.c )
TOPPERS_CONFIG_SYS_SOURCES = $(addprefix config/at91sam7s-gnu/lego_nxt/, \
sys_config.c )
TOPPERS_SYSLIB_SOURCES = $(addprefix syslib/at91sam7s-gnu/lego_nxt/, \
hw_sys_timer.c )
TOPPERS_S_SOURCES = \
config/at91sam7s-gnu/debug.s \
config/at91sam7s-gnu/lego_nxt/sys_support.s
TOPPERS_SRAM_SOURCES = \
config/at91sam7s-gnu/cpu_support.s \
config/at91sam7s-gnu/irq.s
ifeq ($(TOPPERS_KERNEL), OSEK_COM)
OSEK_COM_SOURCES = $(addprefix com/, \
com.c \
)
COM_CFG_SOURCE = ./com_cfg.c
COM_CFG_HEADER = ./com_cfg.h
endif
endif
TOPPERS_CFG_SOURCE = ./kernel_cfg.c
TOPPERS_CFG_HEADER = ./kernel_id.h
################################################################################
# Embedded Coder Robot(ECRobot) NXT specific settings
#
ifndef ECROBOT_SOURCES
ECROBOT_SOURCES = \
syscalls.c \
ecrobot_bluetooth.c \
ecrobot_base.c \
ecrobot.c
endif
################################################################################
# leJOS NXJ specific settings
#
LEJOS_PLATFORM_SOURCES_PATH = nxtvm/platform/nxt
LEJOS_VM_SOURCES_PATH = nxtvm/javavm
################################################################################
# Common settings
#
C_SOURCES = \
$(TOPPERS_KERNEL_SOURCES) \
$(COM_CFG_SOURCE) \
$(OSEK_COM_SOURCES) \
$(TOPPERS_CONFIG_SOURCES) \
$(TOPPERS_CONFIG_SYS_SOURCES) \
$(TOPPERS_CFG_SOURCE) \
$(ECROBOT_SOURCES) \
$(TARGET_SOURCES)
C_RAMSOURCES = \
$(TOPPERS_SYSLIB_SOURCES)
S_SOURCES = \
$(LEJOS_PLATFORM_SOURCES_PATH)/vectors.s \
$(TOPPERS_S_SOURCES) \
nxt_binary_header.s \
nxt_entry_point.s \
ecrobot_init.s
S_RAMSOURCES = \
$(TOPPERS_SRAM_SOURCES)
CC_SOURCES = \
$(TARGET_CC_SOURCES)
# using the new linker script
LDSCRIPT_SOURCE = $(ECROBOT_C_ROOT)/sam7_ecrobot.lds
LIBECROBOT = -lecrobot
LIBLEJOSOSEK = -llejososek
include $(ECROBOT_ROOT)/tool_gcc.mak
INC_PATH = \
$(LEJOSNXJSRC_ROOT)/$(LEJOS_PLATFORM_SOURCES_PATH) \
$(LEJOSNXJSRC_ROOT)/$(LEJOS_VM_SOURCES_PATH) \
$(ECROBOT_ROOT)/bios \
$(ECROBOT_ROOT) \
$(ECROBOT_C_ROOT) \
$(CXX_ROOT) \
$(USER_INC_PATH)
PHONY: EnvironmentMessage
EnvironmentMessage:
@echo " CC $(CC)"
@echo " CPP $(CPP)"
@echo " AS $(AS)"
@echo " AR $(AR)"
@echo " LD $(LD)"
@echo " OBJCOPY $(OBJCOPY)"
ROM_TARGET = $(TARGET)_rom.elf
RAM_TARGET = $(TARGET)_ram.elf
RXE_TARGET = $(TARGET)_rxe.elf
ROMBIN_TARGET = $(TARGET)_rom.bin
RAMBIN_TARGET = $(TARGET)_ram.bin
RXEBIN_TARGET = $(TARGET).rxe
ROM_LDSCRIPT = $(O_PATH)/$(TARGET)_rom.ld
RAM_LDSCRIPT = $(O_PATH)/$(TARGET)_ram.ld
RXE_LDSCRIPT = $(O_PATH)/$(TARGET)_rxe.ld
S_OBJECTS = $(addprefix $(O_PATH)/,$(S_SOURCES:.s=.o) $(S_RAMSOURCES:.s=.oram))
C_OBJECTS = $(addprefix $(O_PATH)/,$(C_SOURCES:.c=.o) $(C_RAMSOURCES:.c=.oram))
CC_OBJECTS = $(addprefix $(O_PATH)/,$(CC_SOURCES:.cc=.o) $(CC_RAMSOURCES:.cc=.oram))
WAV_OBJECTS = $(addprefix $(O_PATH)/,$(WAV_SOURCES:.wav=.owav))
BMP_OBJECTS = $(addprefix $(O_PATH)/,$(BMP_SOURCES:.bmp=.obmp))
SPR_OBJECTS = $(addprefix $(O_PATH)/,$(SPR_SOURCES:.spr=.ospr))
dependencies = $(subst .o,.d,$(C_OBJECTS) $(CC_OBJECTS) $(S_OBJECTS))
dependencies += $(subst .owav,.d,$(WAV_OBJECTS))
dependencies += $(subst .obmp,.d,$(BMP_OBJECTS))
dependencies += $(subst .ospr,.d,$(SPR_OBJECTS))
def_target: all
ifndef BUILD_MODE
ALL_TARGETS = $(ROM_TARGET) $(ROMBIN_TARGET) $(RAM_TARGET) $(RAMBIN_TARGET) $(RXE_TARGET) $(RXEBIN_TARGET) biosflash appflash ramboot rxeflash
else
ifeq ($(BUILD_MODE), ROM_ONLY)
ALL_TARGETS = $(ROM_TARGET) $(ROMBIN_TARGET) biosflash appflash
else
ifeq ($(BUILD_MODE), RAM_ONLY)
ALL_TARGETS = $(RAM_TARGET) $(RAMBIN_TARGET) ramboot
else
ifeq ($(BUILD_MODE), RXE_ONLY)
ALL_TARGETS = $(RXE_TARGET) $(RXEBIN_TARGET) rxeflash
else
$(error BUILD_MODE is not set correctly. Change "Flash_only" to "ROM_ONLY" or "SRAM_only" to "RAM_ONLY" in the Makefile.)
endif
endif
endif
endif
.PHONY: all
all: toppers_cfg $(ALL_TARGETS)
PHONY: TargetMessage
TargetMessage:
@echo ""
@echo "Building: $(ALL_TARGETS)"
@echo ""
@echo "C sources: $(C_SOURCES) to $(C_OBJECTS)"
@echo ""
@echo "C++ sources: $(CC_SOURCES) to $(CC_OBJECTS)"
@echo ""
@echo "Assembler sources: $(S_SOURCES) to $(S_OBJECTS)"
@echo ""
@echo "LD source: $(LDSCRIPT_SOURCE)"
@echo ""
.PHONY: BuildMessage
BuildMessage: TargetMessage EnvironmentMessage
$(RXE_LDSCRIPT): $(LDSCRIPT_SOURCE)
sed -e 's/^RXE_ONLY//' -e '/^RAM_ONLY/d' -e '/^ROM_ONLY/d' $< >$@
$(RAM_LDSCRIPT): $(LDSCRIPT_SOURCE)
sed -e 's/^RAM_ONLY//' -e '/^ROM_ONLY/d' -e '/^RXE_ONLY/d' $< >$@
$(ROM_LDSCRIPT): $(LDSCRIPT_SOURCE)
sed -e 's/^ROM_ONLY//' -e '/^RAM_ONLY/d' -e '/^RXE_ONLY/d' $< >$@
$(RXE_TARGET): $(C_OBJECTS) $(CC_OBJECTS) $(S_OBJECTS) $(WAV_OBJECTS) $(BMP_OBJECTS) $(SPR_OBJECTS) $(RXE_LDSCRIPT)
$(LD) -o $@ $(C_OBJECTS) $(CC_OBJECTS) $(S_OBJECTS) $(WAV_OBJECTS) $(BMP_OBJECTS) $(SPR_OBJECTS) -T $(RXE_LDSCRIPT) $(LDFLAGS) $(EXTRALIBS)
$(RAM_TARGET): $(C_OBJECTS) $(CC_OBJECTS) $(S_OBJECTS) $(WAV_OBJECTS) $(BMP_OBJECTS) $(SPR_OBJECTS) $(RAM_LDSCRIPT)
$(LD) -o $@ $(C_OBJECTS) $(CC_OBJECTS) $(S_OBJECTS) $(WAV_OBJECTS) $(BMP_OBJECTS) $(SPR_OBJECTS) -T $(RAM_LDSCRIPT) $(LDFLAGS) $(EXTRALIBS)
$(ROM_TARGET): $(C_OBJECTS) $(CC_OBJECTS) $(S_OBJECTS) $(WAV_OBJECTS) $(BMP_OBJECTS) $(SPR_OBJECTS) $(ROM_LDSCRIPT)
$(LD) -o $@ $(C_OBJECTS) $(CC_OBJECTS) $(S_OBJECTS) $(WAV_OBJECTS) $(BMP_OBJECTS) $(SPR_OBJECTS) -T $(ROM_LDSCRIPT) $(LDFLAGS) $(EXTRALIBS)
$(ROMBIN_TARGET): $(ROM_TARGET)
@echo "Generating binary image file: $@"
$(OBJCOPY) -O binary $< $@
$(RAMBIN_TARGET): $(RAM_TARGET)
@echo "Generating binary image file: $@"
$(OBJCOPY) -O binary $< $@
$(RXEBIN_TARGET): $(RXE_TARGET)
@echo "Generating binary image file: $@"
$(OBJCOPY) -O binary $< $@
# on Linux, use wine to run the windows application
ifneq "$(OS)" "Windows_NT"
WINECONSOLE := wine
endif
# Detect OS name
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
# Mac OS X detected.
# Use WineBottler's startwine script to launch wineconsole
# in order to proper set up environment variables and avoid warnings.
WINECONSOLE := /Applications/Wine.app/Contents/MacOS/startwine wineconsole
# Native tools for Mac OS X doesn't need any launcher
LAUNCHER :=
else
# for other OS (e.g. Linux) launch *.exe via pre-defined $(WINECONSOLE)
LAUNCHER := $(WINECONSOLE)
endif
.PHONY: toppers_cfg
toppers_cfg:
ifeq ($(TOPPERS_KERNEL), NXT_JSP)
$(TOPPERS_CFG_SOURCE) $(TOPPERS_CFG_HEADER) : $(TOPPERS_JSP_CFG_SOURCE)
@echo "Generating JSP kernel config files from $(TOPPERS_JSP_CFG_SOURCE)"
$(CC) -E -x c-header $(TOPPERS_JSP_CFG_SOURCE) $(addprefix -I ,$(CXX_ROOT)) $(addprefix -iquote ,$(INC_PATH)) -I. $(addprefix -I,$(TOPPERS_INC_PATH)) > tmpfile1
$(TOPPERS_ROOT)/cfg/cfg -s tmpfile1 -c -obj
else ifeq ($(TOPPERS_KERNEL), OSEK_COM)
$(TOPPERS_CFG_SOURCE) $(TOPPERS_CFG_HEADER) $(COM_CFG_SOURCE) $(COM_CFG_HEADER) implementation.oil : $(TOPPERS_OSEK_OIL_SOURCE)
@echo "Generating OSEK kernel config files from $(TOPPERS_OSEK_OIL_SOURCE)"
$(WINECONSOLE) $(TOPPERS_OSEK_ROOT_SG)/sg/sg $(TOPPERS_OSEK_OIL_SOURCE) \
-os=ECC2 -com=CCCA -I$(TOPPERS_OSEK_ROOT_SG)/sg/impl_oil -template=$(TOPPERS_OSEK_ROOT_SG)/sg/lego_nxt.sgt
else
$(TOPPERS_CFG_SOURCE) $(TOPPERS_CFG_HEADER) implementation.oil : $(TOPPERS_OSEK_OIL_SOURCE)
@echo "Generating OSEK kernel config files from $(TOPPERS_OSEK_OIL_SOURCE)"
$(WINECONSOLE) $(TOPPERS_OSEK_ROOT_SG)/sg/sg $(TOPPERS_OSEK_OIL_SOURCE) \
-os=ECC2 -I$(TOPPERS_OSEK_ROOT_SG)/sg/impl_oil -template=$(TOPPERS_OSEK_ROOT_SG)/sg/lego_nxt.sgt
endif
.PHONY: biosflash
biosflash:
@echo "echo Executing NeXTTool to upload $(ROOT)/ecrobot/bios/nxt_bios_rom.rfw..." >./biosflash.sh
@echo "$(LAUNCHER) $(NEXTTOOL_ROOT)/$(NEXTTOOL) /COM=usb -firmware=$(ROOT)/ecrobot/bios/nxt_bios_rom.rfw" >>./biosflash.sh
chmod 700 ./biosflash.sh
.PHONY: appflash
appflash:
@echo "echo Executing appflash to upload $(ROMBIN_TARGET)..." >./appflash.sh
@echo "$(LAUNCHER) $(ROOT)/bin/$(APPFLASH) ./$(ROMBIN_TARGET)" >>./appflash.sh
chmod 700 ./appflash.sh
.PHONY: ramboot
ramboot:
@echo "echo Executing ramboot to upload $(RAMBIN_TARGET)..." >./ramboot.sh
@echo "$(LAUNCHER) $(ROOT)/bin/$(RAMBOOT) ./$(RAMBIN_TARGET)" >>./ramboot.sh
chmod 700 ./ramboot.sh
.PHONY: rxeflash
rxeflash:
@echo "echo Executing NeXTTool to upload $(RXEBIN_TARGET)..." >./rxeflash.sh
@echo "$(LAUNCHER) $(NEXTTOOL_ROOT)/$(NEXTTOOL) /COM=usb -download=$(RXEBIN_TARGET)" >>./rxeflash.sh
@echo "$(LAUNCHER) $(NEXTTOOL_ROOT)/$(NEXTTOOL) /COM=usb -listfiles=$(RXEBIN_TARGET)" >>./rxeflash.sh
@echo "echo NeXTTool is terminated." >>./rxeflash.sh
chmod 700 ./rxeflash.sh
.PHONY: clean
clean:
@echo "Removing kernel config files"
@rm -f $(TOPPERS_CFG_SOURCE)
@rm -f $(TOPPERS_CFG_HEADER)
@rm -f $(COM_CFG_SOURCE)
@rm -f $(COM_CFG_HEADER)
@rm -f implementation.oil
@rm -f *.dat
@rm -f tmpfile1
ifeq ($(TOPPERS_KERNEL), NXT_JSP)
@rm -f kernel_chk.c
endif
@echo "Removing objects"
@rm -rf $(O_PATH)
@echo "Removing targets"
@rm -f $(ALL_TARGETS)
@echo "Removing map files"
@rm -f *.map
@echo "Removing upload scripts"
@rm -f *.sh
ifneq "$(MAKECMDGOALS)" "clean"
-include $(dependencies)
endif