1 # Copyright 2019 - Robin Krens
3 # TODO: Somehow integrate this assembly start.asm (start.o)
6 # Cross compilers links
10 MKIMG=arm-none-eabi-objcopy
13 # TODO:Cortex-m3 or Cortex-m0?
14 LDFLAGS+= -mthumb -mcpu=cortex-m3
15 ASFLAGS+= -mcpu=cortex-m3 -mthumb -g
16 CFLAGS+= -mcpu=cortex-m3 -mthumb -g -ffreestanding
21 _OBJ = ivt.o uart.o systick.o sysinfo.o lib.o regf.o pool.o term.o main.o
22 OBJ = $(patsubst %, $(ODIR)/%,$(_OBJ))
26 $(CC) -c $< $(CFLAGS) -I./include -o $@
28 # Start up machine assembly
30 $(AS) $(ASFLAGS) -o start.o start.asm
32 # Compile and link all
34 $(AS) $(ASFLAGS) -o start.o start.asm
35 $(LD) -nostartfiles -Map $@.MAP -T link.ld -o $(BIN)/$@.ELF start.o $^ --print-memory-usage
36 @echo "Creating binary..."
38 $(MKIMG) -Obinary -R .data $(BIN)/$@.ELF $(BIN)/$@.bin
40 # Run in Qemu; note this is a patched version for stm32-f103c8
42 /usr/local/bin/qemu-system-arm -serial stdio -M stm32-f103c8 -kernel $(BIN)/kernel.bin
44 # Examine all sections
46 arm-none-eabi-objdump -D $(BIN)/kernel.ELF | less
48 # Examine just headers
50 arm-none-eabi-objdump -x $(BIN)/kernel.ELF | less
52 # Flash kernel to board
54 stm32flash -w $(BIN)/kernel.bin -v /dev/ttyUSB0
59 rm -rf $(ODIR)/*.o start.o $(BIN)/kernel.*
61 # Altijd handig deze template
63 # $(CC) -c $(CFLAGS) $< -o $@
64 # $(CC) -MM $(CFLAGS) $< > $*.d
67 # $(CC) -c $(CFLAGS) $< -o $@