summaryrefslogtreecommitdiffstats
path: root/usb/Makefile
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-11 19:01:34 -0400
committerBrian Cully <bjc@kublai.com>2019-08-11 19:01:34 -0400
commit7fdc6a2c1b5799221f5d89d5f935cfe7dad4ccd2 (patch)
tree3ac13da04997361ddb688d2f666298d075aa14e2 /usb/Makefile
parentcceebb087a7a8afc41e0523f6e98be2301ff3af1 (diff)
downloadbleusb-7fdc6a2c1b5799221f5d89d5f935cfe7dad4ccd2.tar.gz
bleusb-7fdc6a2c1b5799221f5d89d5f935cfe7dad4ccd2.zip
Move usb controller stuff to usb directory.
Diffstat (limited to 'usb/Makefile')
-rw-r--r--usb/Makefile55
1 files changed, 55 insertions, 0 deletions
diff --git a/usb/Makefile b/usb/Makefile
new file mode 100644
index 0000000..6d420d1
--- /dev/null
+++ b/usb/Makefile
@@ -0,0 +1,55 @@
+# 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
+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
+ feather-cmd r
+ sleep 2
+ feather-cmd dfu
+ sleep 2
+ $(BOSSAC) -R -e -w -v -o$(OFFSET) -p`./find-serial-port $(USBVID) $(USBPID)` $<
+
+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 $@