aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-05 09:01:05 -0400
committerBrian Cully <bjc@kublai.com>2019-08-05 09:01:10 -0400
commit5fe4d5c69fc6ae821c224e6ed4ddd86c285c5c6b (patch)
tree4f28baa83f3c02d12f5a1256d20cbbaf2182184b /Makefile
parente02128bd4d9d2716b55be5db3dccb18f92f01e9c (diff)
downloadatsamd-usb-host-5fe4d5c69fc6ae821c224e6ed4ddd86c285c5c6b.tar.gz
atsamd-usb-host-5fe4d5c69fc6ae821c224e6ed4ddd86c285c5c6b.zip
Remove .cargo/config by moving it to Makefile.
Since I'm using `make` anyway, might as well consolidate build rules there.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile38
1 files changed, 26 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 87fbc8d..26f0968 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,9 @@
+# How to compile the examples.
APP = simple
+RELEASE = debug
+TARGET = thumbv6m-none-eabi
+# VID and PID of device to flash firmware to.
USBVID = 239a
USBPID = '001e|801e'
@@ -7,32 +11,42 @@ BOSSAC = bossac
SERIAL = $(shell ./find-serial-port $(USBVID) $(USBPID) || echo 'cant-find-serial-port')
OFFSET = 0x2000
+OBJCOPY = arm-none-eabi-objcopy
+
+TARGETDIR = target/$(TARGET)
+EXAMPLEDIR = $(TARGETDIR)/$(RELEASE)/examples
+
+CARGOFLAGS = --target thumbv6m-none-eabi
+
.PHONY: all clean cargo-build target/thumbv6m-none-eabi/debug/examples/$(APP)
-all: $(APP).uf2
+all: $(EXAMPLEDIR)/$(APP)
clean:
rm -f $(APP).uf2
rm -f $(APP).bin
cargo clean
-cargo-build:
- cargo build --example $(APP)
+test:
+ cargo test
-target/thumbv6m-none-eabi/debug/examples/$(APP): cargo-build
-
-$(APP).bin: target/thumbv6m-none-eabi/debug/examples/$(APP)
- cargo objcopy --example $(APP) -- -O binary $(APP).bin
+cargo-build:
+ cargo rustc --example $(APP) $(CARGOFLAGS) -- -C link-arg=-Tlink.x
-# Requires https://github.com/sajattack/uf2conv-rs.git
-%.uf2: %.bin
- uf2conv-rs $< --base $(OFFSET) --output $@
+$(EXAMPLEDIR)/$(APP): cargo-build
flash: $(APP).bin $(SERIAL)
$(BOSSAC) -R -e -w -v -o$(OFFSET) -p$(SERIAL) $<
-qemu: target/thumbv6m-none-eabi/debug/$(APP)
+qemu: $(EXAMPLEDIR)/$(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: target/thumbv6m-none-eabi/debug/$(APP)
+gdb: $(EXAMPLEDIR)/$(APP)
gdb-multiarch -ex "target remote localhost:1234" -ex "break main" -ex "continue" $<
+
+%.bin: $(EXAMPLEDIR)/%
+ $(OBJCOPY) -O binary $< $@
+
+# Requires https://github.com/sajattack/uf2conv-rs.git
+%.uf2: %.bin
+ uf2conv-rs $< --base $(OFFSET) --output $@