-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (41 loc) · 1 KB
/
Makefile
File metadata and controls
54 lines (41 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
MAYBE_MODEM := $(word 1, $(wildcard /dev/tty.usbmodem*))
MODEM := $(if $(MAYBE_MODEM),$(MAYBE_MODEM),$(error "modem not found"))
BAUD := 19200
PART := m328pb
PROGRAMMER := avrisp
AVRDUDE := avrdude -c $(PROGRAMMER) -p $(PART) -P $(MODEM) -b $(BAUD)
DEBUG_SPI ?= 0
ifeq ("$(DEBUG_SPI)","0")
FEATURES :=
else
FEATURES := --features=debug_spi
endif
.PHONY: all
all: hex text
.PHONY: hex
hex: firmware.hex
.PHONY: text
text: firmware.txt
.PHONY: flash
flash: firmware.hex
$(AVRDUDE) -U flash:w:$^
# program fuse bytes
# low fuse: all defaults + CKDIV8 (set frequency to 8MHz from internal oscillator)
.PHONY: fuse
fuse:
$(AVRDUDE) -U lfuse:w:0xE2:m
.PHONY: read
read:
$(AVRDUDE) -U flash:r:/dev/null:h
.PHONY: clean
clean:
rm -f firmware.hex
rm -f firmware.txt
cargo clean
ELF := target/atmega328p/release/firmware.elf
firmware.hex: $(ELF)
avr-objcopy -j .text -j .data -O ihex $^ $@
firmware.txt: $(ELF)
avr-objdump -Sd $^ > $@
$(ELF): */src/*.rs Cargo.toml */Cargo.toml
cargo build --release $(FEATURES)