add tercel speed-up but missing id for arty a7 at the moment
[ls2.git] / coldboot / Makefile
1 ARCH = $(shell uname -m)
2 ifneq ("$(ARCH)", "ppc64")
3 ifneq ("$(ARCH)", "ppc64le")
4 CROSS_COMPILE ?= powerpc64le-linux-gnu-
5 endif
6 endif
7
8 # a multiplier factor on sleep loops. this allows simulations to run
9 # at much shorter intervals
10 LONG_TIMER_MULT = 100000
11 SHORT_TIMER_MULT = 1000
12 #LONG_TIMER_MULT = 1
13 #SHORT_TIMER_MULT = 1
14
15 # SPI boot address 0xf000_0000, main SRAM boot would be 0x0000_0000
16 # but remember to recompile external_core_top.v with a matching
17 # --pc_reset=0xNNNNNNNN
18 # BOOT_INIT_BASE ?= 0xf0000000 # at QSPI address
19 BOOT_INIT_BASE ?= 0xff000000 # at ROM hi address (with coldboot firmware)
20 # BOOT_INIT_BASE ?= 0x0 # start at zero (usual)
21
22 LIBGRAMDIR = ../libgram
23 LIBGRAMINC = ../libgram/include
24
25 GRAMOBJS := $(LIBGRAMDIR)/src/init.o \
26 $(LIBGRAMDIR)/src/dfii.o \
27 $(LIBGRAMDIR)/src/calibration.o
28
29 CC = $(CROSS_COMPILE)gcc
30 LD = $(CROSS_COMPILE)ld
31 OBJCOPY = $(CROSS_COMPILE)objcopy
32
33 CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string \
34 -mno-multiple -mno-vsx -mno-altivec -mlittle-endian \
35 -fno-stack-protector -mstrict-align -ffreestanding \
36 -fno-delete-null-pointer-checks \
37 -fdata-sections -ffunction-sections -I../include \
38 -I $(LIBGRAMINC) \
39 -DLONG_TIMER_MULT=$(LONG_TIMER_MULT) \
40 -DBOOT_INIT_BASE=$(BOOT_INIT_BASE) \
41 -DSHORT_TIMER_MULT=$(SHORT_TIMER_MULT)
42 ASFLAGS = $(CFLAGS)
43 LDFLAGS = -static -nostdlib -T powerpc.lds
44
45 all: coldboot.hex coldboot.S
46
47 console.o: ../lib/console.c
48 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
49
50 init.o: ../libgram/src/init.c
51 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
52
53 dfii.o: ../libgram/src/dfii.c
54 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
55
56 calibration.o: ../libgram/src/calibration.c
57 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
58
59 powerpc.lds: powerpc.lds.S
60 $(CC) $(CFLAGS) -P -E powerpc.lds.S -o powerpc.lds
61
62 OBJS := coldboot.o tercel.o head.o ../lib/console.o $(GRAMOBJS)
63
64 coldboot.elf: $(OBJS) powerpc.lds
65 $(LD) $(LDFLAGS) -o $@ $(OBJS)
66
67 coldboot.bin: coldboot.elf
68 $(OBJCOPY) -O binary $^ $@
69
70 coldboot.hex: coldboot.bin
71 ../scripts/bin2hex.py $^ > $@
72 powerpc64le-linux-gnu-objdump -D coldboot.elf > coldboot.as
73
74 coldboot.S: coldboot.elf
75 objdump -S coldboot.elf > coldboot.S
76
77
78 clean:
79 @rm -f ../lib/*.o ../libgram/src/*.o *.o coldboot.elf coldboot.bin \
80 coldboot.hex coldboot.as coldboot.S powerpc.lds
81 distclean: clean
82 rm -f *~
83