-
Notifications
You must be signed in to change notification settings - Fork 27
/
common.mk
52 lines (47 loc) · 1.41 KB
/
common.mk
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
BOOT = out/boot
SRCS = $(foreach dir,$(DIRS) $(DIRD),$(wildcard $(dir)/*.c))
SRCH = $(foreach dir,$(DIRS) $(DIRD),$(wildcard $(dir)/*.h))
OBJS = $(patsubst %.c,out/%.o,$(notdir $(SRCS) $(CSRCS)))
vpath %.c $(dir $(SRCS))
RAMSIZE = 32M
#RAMSIZE = 64M
BRD = DBC_BOARD
#BRD = MANGO_BOARD
CC = arm-none-eabi-
CFLAGS += $(addprefix -I,$(DIRS)) -c -O3 -mcpu=arm926ej-s \
-ffunction-sections -fdata-sections -fno-builtin-function \
-MMD -MT$@ -Wall -Wformat=0 -DARM -DRAMSIZE$(RAMSIZE) -D$(BRD)
LFLAGS += -lm -Xlinker --gc-sections -Wl,-Map,$(NAME).map \
-Wl,--defsym=RAMSIZE=$(RAMSIZE) -T$(BASE)drv/
FEL = "$(BASE)tools\sunxi\sunxi-fel"
MKSUNXI = "$(BASE)tools\sunxi\mksunxi"
.PHONY: all clean run flash
all: out $(BOOT).bin $(NAME).bin
$(CC)size -G out/*.elf
run: #all
$(FEL) -p spl $(BOOT).bin
$(FEL) -p write 0x80000000 $(NAME).bin
$(FEL) exec 0x80000000
flash: all
$(FEL) -p spiflash-write 0 $(BOOT).bin
$(FEL) -p spiflash-write 8192 $(NAME).bin
build: clean all
rm -fr out/*.d* out/*.e* out/*.m* out/*.o*
$(NAME).bin: $(NAME).elf
$(CC)objcopy -O binary $^ $@
$(NAME).elf: $(OBJS)
$(CC)gcc $^ -o$@ --specs=rdimon.specs $(LFLAGS)link.ld
$(BOOT).bin: $(BOOT).elf
$(CC)objcopy -O binary $^ $@
$(MKSUNXI) $@ 1>&0
$(BOOT).elf: $(OBJS)
$(CC)gcc $^ -o$@ -nostartfiles $(LFLAGS)boot.ld
out/%.o: %.c
@echo . $(notdir $<)
$(CC)gcc $(CFLAGS) -o$@ $<
out:
mkdir $@
clean:
echo Clean
rm -fr out
-include $(patsubst %.o,%.d,$(OBJS))