Skip to content

Commit 2118fb7

Browse files
committed
Makefile: Changeable programmer
Can change the programmer without having to modify the Makefile by hand. Just do `make flash-<flashable-directive> PROGRAMMER=usbtiny`
1 parent 6b2f4e0 commit 2118fb7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CFLAGS=-Wall -Wextra -Werror=overflow -Werror=type-limits -std=c11 -Os -I src/usb-iface -I src/lib
2+
PROGRAMMER=avrispmkii
23

34
# Optionally add <prog>.hex here so it is built when make is invoked
45
# without arguments.
@@ -11,13 +12,13 @@ all: swsh.hex usb-iface.hex
1112
src/swsh.elf: src/swsh/swsh.o src/lib/automation.o src/lib/automation-utils.o src/lib/user-io.o
1213

1314
flash-%: %.hex
14-
avrdude -p atmega328p -c avrispmkii -P usb -U flash:w:$<:i
15+
avrdude -p atmega328p -c $(PROGRAMMER) -P usb -U flash:w:$<:i
1516

1617
flash-usb-iface: usb-iface.hex
17-
avrdude -p m16u2 -c avrispmkii -P usb -U flash:w:$< -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
18+
avrdude -p m16u2 -c $(PROGRAMMER) -P usb -U flash:w:$< -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
1819

1920
restore-usb-iface: UNO-dfu_and_usbserial_combined.hex
20-
avrdude -p m16u2 -c avrispmkii -P usb -U flash:w:$< -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
21+
avrdude -p m16u2 -c $(PROGRAMMER) -P usb -U flash:w:$< -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m
2122

2223
usb-iface.hex: lufa/.git src/usb-iface/usb-iface.c src/usb-iface/standalone-usb-iface.c src/usb-iface/usb-descriptors.c
2324
$(MAKE) -C src/usb-iface usb-iface.hex

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ file, either manually or by running `make flash-usb-iface`.
115115
Unplug the programmer and connect it to the main microcontroller’s ISCP header.
116116
Flash the `swsh.hex` file, either manually or by running `make flash-swsh`.
117117

118+
Use any programmer supported by avrdude, `avrdude -c ?`, by specifying
119+
`PROGRAMMER` when flashing. E.g. `make PROGRAMMER=usbtiny flash-swsh`.
120+
118121
Factory restore
119122
---------------
120123

0 commit comments

Comments
 (0)