-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (41 loc) · 1 KB
/
Makefile
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
ifndef CROSS_COMPILE
$(error define CROSS_COMPILE env variable!)
endif
CC=$(CROSS_COMPILE)gcc
OBJCP=$(CROSS_COMPILE)objcopy
LD=$(CROSS_COMPILE)ld
OBJDMP=$(CROSS_COMPILE)objdump
CFLAGS=-g
FEL=./host/fel
ifeq ($(TARGET),qemu)
SCRIPT = image-ddr.lds
LDFLAGS=
IMAGE=uimage
else
SCRIPT=image-sram.lds
BASE=0x4000
LDFLAGS=-Ttext=$(BASE)
IMAGE=image.sunxi.bin
endif
all: $(IMAGE)
OBJS = main.o start.o
start.o: start.S
main.o: main.c
image.elf: $(OBJS) $(SCRIPT)
$(LD) -T $(SCRIPT) $(LDFLAGS) $(OBJS) -o $@ -Map=image.map
$(OBJDMP) -d $@ > $(@:.elf=.s)
image.bin: image.elf
$(OBJCP) -O binary $< $@
uimage-addr:
mkimage -A arm -O linux -T kernel -C none \
-a 0x${ADDR} -e 0x${ADDR} -n hello -d image.bin uimage
uimage: image.bin
$(MAKE) uimage-addr ADDR=`nm image.elf | awk '/_start/ {print $$1}'`
image.sunxi.bin: image.bin
./host/mksunxiboot $< $@
clean:
rm -f $(OBJS) image.elf image.s image*.bin uimage
fel: image.bin
$(FEL) write $(BASE) $<
$(FEL) exe $(BASE)
$(FEL) version #checks if alive