armv7_helloworld

Simple bare metal ARMv7 example
git clone https://0xdd.org/code/armv7_helloworld.git
Log | Files | Refs | README | LICENSE

Makefile (1461B)


      1 #2018 David DiPaola
      2 #licensed under CC0 (public domain, see https://creativecommons.org/publicdomain/zero/1.0/)
      3 
      4 SRC = main.c
      5 BIN_ELF = boot.elf
      6 BIN_BIN = $(BIN_ELF:.elf=.bin)
      7 
      8 OBJ = $(SRC:.c=.o)
      9 
     10 PREFIX ?= arm-none-eabi-
     11 GCC ?= $(PREFIX)gcc
     12 GCC_FLAGS = \
     13 	-std=c99 \
     14 	-mcpu=cortex-a7 \
     15 	-ffreestanding -nostdinc \
     16 	-ffunction-sections -fdata-sections \
     17 	-O2 \
     18 	-g \
     19 	$(CPP_FLAGS_DEBUG)
     20 GLD ?= $(PREFIX)ld
     21 GLD_FLAGS = \
     22 	-static -nostdlib \
     23 	-O1 --gc-sections --print-gc-sections
     24 QEMU ?= qemu-system-arm
     25 QEMU_FLAGS = \
     26 	-gdb tcp::1234 \
     27 	-nographic \
     28 	-machine vexpress-a15 -cpu cortex-a7 \
     29 	-m 32M
     30 GDB ?= gdb-multiarch
     31 GDB_FLAGS = \
     32 	--command=gdbinit
     33 OBJDUMP ?= $(PREFIX)objdump
     34 
     35 .PHONY: all
     36 all: $(BIN_ELF)
     37 
     38 .PHONY: run
     39 run: $(BIN_ELF)
     40 	@echo [QEMU] $<
     41 	@$(QEMU) $(QEMU_FLAGS) -kernel $<
     42 
     43 .PHONY: run-paused
     44 run-paused: $(BIN_ELF)
     45 	@echo [QEMU] $<
     46 	@$(QEMU) $(QEMU_FLAGS) -S -kernel $<
     47 
     48 .PHONY: run-debugger
     49 run-debugger: $(BIN_ELF)
     50 	@echo [GDB] $<
     51 	@$(GDB) $(GDB_FLAGS) $<
     52 
     53 .PHONY: dump-elf
     54 dump-elf: $(BIN_ELF)
     55 	@echo [OBJDUMP] $<
     56 	@$(OBJDUMP) --disassemble --source --line-numbers $<
     57 
     58 .PHONY: dump-elf-syms
     59 dump-elf-syms: $(BIN_ELF)
     60 	@echo [OBJDUMP] $<
     61 	@$(OBJDUMP) --syms $<
     62 
     63 .PHONY: clean
     64 clean:
     65 	@echo [RM] $(OBJ) $(BIN_ELF) $(BIN_BIN)
     66 	@rm -rf $(OBJ) $(BIN_ELF) $(BIN_BIN)
     67 
     68 .c.o:
     69 	@echo [GCC] $<
     70 	@$(GCC) $(GCC_FLAGS) -o $@ -c $<
     71 
     72 $(BIN_ELF): layout.lds $(OBJ)
     73 	@echo [GLD] -T layout.lds -o $@ $(OBJ)
     74 	@$(GLD) $(GLD_FLAGS) -T layout.lds -o $@ $(OBJ)
     75