diff --git a/.gitignore b/.gitignore index 45659593d7500b3cea7e5b4f12c7807e6df684c7..0ee7f0217c84947d6c2335a24b8117c5e58396c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*/avr/compiled \ No newline at end of file +*/avr/compiled +*~ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..a95c9078cc83e2aac008afa78d1bcc310011a578 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +all: + @echo "Do 'make PROCESS.LOAD' or 'make PROCESS.FUSE'" >&2 + @echo "where PROCESS is one of" >&2 + @for m in */*/Makefile ; do \ + echo " $$(dirname $$(dirname $$m))" >&2 \ + ; done + @echo >&2 + @exit 1 + +%.LOAD: + make -C $*/avr $@ + +%.FUSE: + make -C $*/avr $@ diff --git a/README.md b/README.md index 44d0bc580168de924911a8d38f92126ac7afe292..5411b86b9004f4ef09b26cd1599ea8692abb7052 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ Software for processes used at Department of Automatic Control ============================================================== +batch-2002 + + +How to (re)program a chip +========================= + +Clone this repository and change to the top level directory, then + + * If it's the first time this chip is programmed, the fuse bits + need to be programmed, this is done by running `make PROCESS_NAME.FUSE` + + * Program the chip by running `make PROCESS_NAME.LOAD` diff --git a/lib/avr/Makefile.common b/lib/avr/Makefile.common index cc9828b9fde5dfdbe8c035d192164289b81f213e..159b24db12603b8b8a15bba5974a02e51ead34bc 100644 --- a/lib/avr/Makefile.common +++ b/lib/avr/Makefile.common @@ -68,12 +68,27 @@ OBJECTS=$($(1).C:%=compiled/$(1)/%.o) -U flash:w:compiled/$(TARGET)/$*.sr:s %.FUSE: - [ -n "$($(TARGET).FUSE_L)" ] && avrdude -P usb -c avrisp2 -p $(CHIP) \ - -U lfuse:w:$($(TARGET).FUSE_L):m || true - [ -n "$($(TARGET).FUSE_H)" ] && avrdude -P usb -c avrisp2 -p $(CHIP) \ - -U hfuse:w:$($(TARGET).FUSE_H):m || true - [ -n "$($(TARGET).FUSE_E)" ] && avrdude -P usb -c avrisp2 -p $(CHIP) \ - -U efuse:w:$($(TARGET).FUSE_E):m || true + @if [ -n "$($(TARGET).FUSE_L)" ] ; then \ + echo avrdude -P usb -c avrisp2 -p $(CHIP) \ + -U lfuse:w:$($(TARGET).FUSE_L):m >&2 \ + ; avrdude -qq -P usb -c avrisp2 -p $(CHIP) \ + -U lfuse:w:$($(TARGET).FUSE_L):m \ + || (echo "failed to program FUSE_L with $($(TARGET).FUSE_L)" >&2 && exit 1) \ + ; fi + @if [ -n "$($(TARGET).FUSE_H)" ] ; then \ + echo avrdude -P usb -c avrisp2 -p $(CHIP) \ + -U hfuse:w:$($(TARGET).FUSE_H):m >&2 \ + ; avrdude -qq -P usb -c avrisp2 -p $(CHIP) \ + -U hfuse:w:$($(TARGET).FUSE_H):m \ + || (echo "failed to program FUSE_H with $($(TARGET).FUSE_H)" >&2 && exit 1) \ + ; fi + @if [ -n "$($(TARGET).FUSE_E)" ] ; then \ + echo avrdude -P usb -c avrisp2 -p $(CHIP) \ + -U efuse:w:$($(TARGET).FUSE_E):m >&2 \ + ; avrdude -qq -P usb -c avrisp2 -p $(CHIP) \ + -U efuse:w:$($(TARGET).FUSE_E):m \ + || (echo "failed to program FUSE_E with $($(TARGET).FUSE_E)" >&2 && exit 1) \ + ; fi %.FUSE_uisp: exit 1