collab/mm20
git clone https://git.julia.blue/collab/mm20
708f735
pcb
1SRCS = $( wildcard src/*.c) $( wildcard lib/*.c) 2OBJS = $( addprefix obj/,$( notdir $( SRCS:.c=.o))) 3 4OS = $( shell lsb_release -si ) 5 6ifeq ($( OS ) , Arch) 7LIB_PREFIX = /usr 8LIB_SUFFIX = v7e-m+fp/hard 9else 10LIB_PREFIX = /usr/lib 11LIB_SUFFIX = v7e-m/fpv4-sp 12endif 13 14CC = clang --target=thumbv7em-unknown-none-eabi -Wno-keyword-macro -fshort-enums 15HEADERS = -I$( LIB_PREFIX ) /arm-none-eabi/include 16LIBS = -L$( LIB_PREFIX ) /arm-none-eabi/lib/thumb/$( LIB_SUFFIX ) 17LIBS += -L/usr/lib/gcc/arm-none-eabi/9.2.0 18 19CFLAGS = -ggdb -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -Wall -pedantic 20CFLAGS += -fdata-sections -ffunction-sections -MD -std=c99 21CFLAGS += $( HEADERS ) -mfloat-abi=hard -O0 22 23OPENOCD = openocd -c 'source [find board/ek-tm4c123gxl.cfg]' 24 25all : out/out.elf 26 27obj/%.o : src/%.c 28$( CC ) -o $ @ $ ^ -Iinc$( CFLAGS ) -c 29 30obj/%.o : lib/%.c 31$( CC ) -o $ @ $ ^ -Iinc$( CFLAGS ) -c 32 33out/out.elf : $( OBJS ) 34ld.lld -o $ @ $ ^ $( LIBS ) -lgcc -lc_nano -lnosys -lm \ 35-T misc/tm4c.ld-u _printf_float-u _scanf_float 36 37flash : out/out.elf 38$( OPENOCD ) -c "program out/out.elf verify exit" 39 40run : out/out.elf 41$( OPENOCD ) -c "program out/out.elf verify reset exit" 42 43uart : run 44screen -L /dev/ttyACM0 115200 45 46debug : flash 47gdb-multiarch out/out.elf-x misc/debug.gdb 48 49debug_gui : flash 50gdbgui -g arm-none-eabi-gdb--gdb-args= "-command=misc/debug_gui.gdb" \ 51 out/out.elf 52 53size : out/out.elf 54llvm-nm --demangle --print-size --size-sort --no-weak --radix=d \ 55 out/out.elf| cut -f 2,4-d ' ' | numfmt --field 1--to=iec \ 56--padding -6 | sed '/^0/d' 57 58disassemble : out/out.elf 59llvm-objdump out/out.elf-d -S -C --arch-name=thumb --no-show-raw-insn \ 60--no-leading-addr > out/disassembly.asm 61 62clean : 63 -rm -rf obj 64 -rm -rf out 65 66$( shell mkdir -p out) 67$( shell mkdir -p obj) 68 69.PHONY : all clean debug debug_gui flash run size