From 9ff9f51c07f7226d6467bc9db608cc53c82365bd Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Tue, 6 Aug 2019 08:53:42 -0400 Subject: Initial commit. --- Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a78d29f --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +# How to compile the examples. +APP = bleusb +RELEASE = debug +TARGET = thumbv6m-none-eabi + +# VID and PID of device to flash firmware to. +USBVID = 239a +USBPID = '001e|801e' + +BOSSAC = bossac +SERIAL = $(shell ./find-serial-port $(USBVID) $(USBPID) || echo 'cant-find-serial-port') +OFFSET = 0x2000 + +OBJCOPY = arm-none-eabi-objcopy + +TARGETDIR = target/$(TARGET) +OUTDIR = $(TARGETDIR)/$(RELEASE) + +CARGOFLAGS = --target thumbv6m-none-eabi + +.PHONY: all clean cargo-build $(OUTDIR)/$(APP) + +all: $(OUTDIR)/$(APP) + +clean: + rm -f $(APP).uf2 + rm -f $(APP).bin + cargo clean + +test: + cargo test + +cargo-build: + cargo rustc $(CARGOFLAGS) -- -C link-arg=-Tlink.x + +$(OUTDIR)/$(APP): cargo-build + +flash: $(APP).bin $(SERIAL) + $(BOSSAC) -R -e -w -v -o$(OFFSET) -p$(SERIAL) $< + +qemu: $(OUTDIR)/$(APP) + qemu-system-arm -d in_asm,int,exec,cpu,guest_errors,unimp -pidfile qemu.pid -cpu cortex-m0 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -s -S -kernel $< + +gdb: $(OUTDIR)/$(APP) + gdb-multiarch -ex "target remote localhost:1234" -ex "break main" -ex "continue" $< + +%.bin: $(OUTDIR)/% + $(OBJCOPY) -O binary $< $@ + +# Requires https://github.com/sajattack/uf2conv-rs.git +%.uf2: %.bin + uf2conv-rs $< --base $(OFFSET) --output $@ -- cgit v1.2.3