diff --git a/Makefile b/Makefile index 869cc8d..832fb2d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -COMPILED:=target/avr-atmega328p/release/blink.elf +ELF:=target/avr-atmega328p/release/blink.elf HEX:=blink.hex SERIAL_PORT:=/dev/cu.usbmodem143201 @@ -6,26 +6,21 @@ RUSTFLAGS:=-Zverify-llvm-ir all: ${HEX} -.PHONY: ${COMPILED} -${COMPILED}: +.PHONY: ${ELF} +${ELF}: RUSTFLAGS=${RUSTFLAGS} cargo build -Z build-std=core --target avr-atmega328p.json --release -# Convert binary to an Intel HEX file for upload -${HEX}: ${COMPILED} - avr-objcopy -O ihex -R .eeprom $< $@ - -# Download the HEX to the board +# Download the ELF to the board .PHONY: program -program: ${HEX} - avrdude -p atmega328p -c arduino -P ${SERIAL_PORT} -U flash:w:$<:i +program: ${ELF} + avrdude -p atmega328p -c arduino -P ${SERIAL_PORT} -D -U flash:w:$< .PHONY: connect-terminal connect-terminal: picocom ${SERIAL_PORT} - .PHONY: simulate-avr -simulate-avr: ${COMPILED} +simulate-avr: ${ELF} simavr \ -m atmega328p \ -f 16000000 \ @@ -34,5 +29,5 @@ simulate-avr: ${COMPILED} $< .PHONY: simulate-gdb -simulate-gdb: ${COMPILED} +simulate-gdb: ${ELF} avr-gdb -x simulate.gdbinit -tui $<