From: Manfred Steiner Date: Thu, 5 Sep 2024 11:35:19 +0000 (+0200) Subject: software/nano-1284/bootloader-arduino (release/2024-09-05_120945) X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=3e670e44763c283cc5df9f89942b3be8165a5abf;p=nano-x.git software/nano-1284/bootloader-arduino (release/2024-09-05_120945) --- diff --git a/software/bootloader-arduino/.gdb_history b/software/bootloader-arduino/.gdb_history deleted file mode 100644 index 3339046..0000000 --- a/software/bootloader-arduino/.gdb_history +++ /dev/null @@ -1,9 +0,0 @@ -target remote :1234 -layout split -stepi -quit -target remote :1234 -layout split -stepi -b *main+9 -quit diff --git a/software/bootloader-arduino/.gdbinit b/software/bootloader-arduino/.gdbinit deleted file mode 100644 index a8c4b59..0000000 --- a/software/bootloader-arduino/.gdbinit +++ /dev/null @@ -1,5 +0,0 @@ -set history save on -set history size 1000 -set history remove-duplicates 2 -set history filename .gdb_history - diff --git a/software/bootloader-arduino/.gitignore b/software/bootloader-arduino/.gitignore deleted file mode 100644 index a959910..0000000 --- a/software/bootloader-arduino/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.depend -**/build -**/dist -**/sim diff --git a/software/bootloader-arduino/.vscode/c_cpp_properties.json b/software/bootloader-arduino/.vscode/c_cpp_properties.json deleted file mode 100644 index 773ff69..0000000 --- a/software/bootloader-arduino/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux AVR", - "includePath": [ - "/usr/lib/avr/include/**", - "/usr/lib/gcc/avr/**" - ], - "defines": [], - "compilerPath": "/usr/bin/avr-gcc", - "compilerArgs": [ - "-mmcu=atmega1284p", - "-Os", - "-DF_CPU=12000000", - "-DBAUD_RATE=115200", - "-DDOUBLE_SPEED", - "-DNUM_LED_FLASHES=4", - "-DMAX_TIME_COUNT=F_CPU>>4" - ], - "cStandard": "gnu11", - "cppStandard": "gnu++11", - "intelliSenseMode": "linux-gcc-x64" - } - ], - "version": 4 -} diff --git a/software/bootloader-arduino/.vscode/launch.json b/software/bootloader-arduino/.vscode/launch.json deleted file mode 100644 index f29cf2e..0000000 --- a/software/bootloader-arduino/.vscode/launch.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Build", - // "request": "launch", - "type": "node-terminal", - "preLaunchTask": "build" - },{ - "name": "Flash", - // "request": "launch", - "type": "node-terminal", - "preLaunchTask": "flash" - },{ - "name": "Clean", - // "request": "launch", - "type": "node-terminal", - "preLaunchTask": "clean" - },{ - // es muss mit simuc --board arduino dist/programm.elf der Simulator - // gestartet werden. Dessen gdb-stub öffnet auf localhost:1234 einen Port - "name": "Debug (simuc)", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/sim/atmega328p.elf", - "cwd": "${workspaceFolder}", - "externalConsole": false, - "MIMode": "gdb", - "miDebuggerPath": "/usr/bin/avr-gdb", - "miDebuggerServerAddress": ":1234", - "preLaunchTask": "build" - } - ] -} diff --git a/software/bootloader-arduino/.vscode/settings.json b/software/bootloader-arduino/.vscode/settings.json deleted file mode 100644 index 114a717..0000000 --- a/software/bootloader-arduino/.vscode/settings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "[c]": { - "editor.insertSpaces": true, - "editor.tabSize": 3, - "editor.detectIndentation": false - }, - "[h]": { - "editor.insertSpaces": true, - "editor.tabSize": 3, - "editor.detectIndentation": false - }, - "cSpell.words": [], - "cSpell.ignorePaths": [ - "**/*.json", "**/*.c", "**/*.h", "**/Makefile" - ], - "files.associations": { - "delay.h": "c", - "boot.h": "c", - "stdio.h": "c" - } -} diff --git a/software/bootloader-arduino/.vscode/tasks.json b/software/bootloader-arduino/.vscode/tasks.json deleted file mode 100644 index 74fb1c7..0000000 --- a/software/bootloader-arduino/.vscode/tasks.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [{ - "label": "build", - "type": "shell", - "command": "make", - "problemMatcher":[ - "$gcc" - ] - },{ - "label": "clean", - "type": "shell", - "command": "make", - "args": [ "clean" ], - },{ - "label": "flash", - "type": "shell", - "command": "make", - "args": [ "flash" ], - }] -} \ No newline at end of file diff --git a/software/bootloader-arduino/Makefile b/software/bootloader-arduino/Makefile deleted file mode 100644 index 665918a..0000000 --- a/software/bootloader-arduino/Makefile +++ /dev/null @@ -1,118 +0,0 @@ -.PHONY: all info flash picocom clean -$(shell mkdir -p dist >/dev/null) -$(shell mkdir -p build >/dev/null) -$(shell mkdir -p sim >/dev/null) -$(shell mkdir -p sim/build >/dev/null) - -NAME="bootloader-arduino_nano-1284" -SRC= $(wildcard src/*.c src/*.cpp src/*/*.c src/*/*.cpp) -HDR= $(wildcard src/*.h src/*.hpp src/*/*.h src/*/*.hpp) -OBJ_CPP = $(SRC:src/%.cpp=build/%.o) -OBJ = $(OBJ_CPP:src/%.c=build/%.o) -OBJ_SIM_CPP = $(SRC:src/%.cpp=sim/build/%.o) -OBJ_SIM = $(OBJ_SIM_CPP:src/%.c=sim/build/%.o) - -DEVICE=atmega1284p - -CC= avr-g++ -CFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c -#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -Wl,-u,vfprintf -lprintf_flt -lm -LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -Wl,--section-start=.text=0x1e000 - -CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c -#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -Wl,-u,vfprintf -lprintf_flt -lm -LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -Wl,--section-start=.text=0x1e000 - - -all: dist/$(NAME).elf dist/$(NAME).s dist/$(NAME).hex sim/$(NAME).elf sim/$(NAME).s info - -dbg: - @echo --HDR--------------------------------- - @echo $(HDR) - @echo --SRC--------------------------------- - @echo $(SRC) - @echo --OBJ--------------------------------- - @echo $(OBJ) - @echo --OBJ_CPP----------------------------- - @echo $(OBJ_CPP) - @echo --OBJ--------------------------------- - @echo $(OBJ) - @echo =================================== - @echo - -info: - @avr-size --mcu=$(DEVICE) --format=avr dist/$(NAME).elf - -.depend: $(SRC) $(HDR) - $(CC) -mmcu=$(DEVICE) -MM $(SRC) | sed --regexp-extended 's/^(.*\.o)\: src\/(.*)(\.cpp|\.c) (.*)/build\/\2\.o\: src\/\2\3 \4/g' > .depend - --include .depend - -# .depend solte auch auf Header Files achten! - -dist/$(NAME).elf: .depend $(OBJ) - $(CC) $(LFLAGS) -o $@ $(OBJ) - -dist/%.s: dist/%.elf - avr-objdump -d $< > $@ - -dist/%.hex: dist/%.elf - #avr-objcopy -j .text -j .data -O ihex $< $@ - avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ - -sim/$(NAME).elf: .depend $(OBJ_SIM) - $(CC) $(LFLAGS_SIM) -o $@ $(OBJ_SIM) - - -build/%.o: src/%.c - @mkdir -p $(dir $@) - $(CC) $(CFLAGS) -o $@ $< - -build/%.o: src/%.cpp - @mkdir -p $(dir $@) - $(CC) $(CFLAGS) -o $@ $< - -sim/build/%.o: src/%.c - @mkdir -p $(dir $@) - $(CC) $(CFLAGS_SIM) -o $@ $< - -sim/build/%.o: src/%.cpp - @mkdir -p $(dir $@) - $(CC) $(CFLAGS_SIM) -o $@ $< - -sim/%.s: sim/%.elf - avr-objdump -d $< > $@ - -simuc: sim/$(NAME).elf - simuc --board arduino $< - -gdb: sim/$(NAME).elf - avr-gdb $< - -isp-1284p: - avrdude -c usbasp -p m1284p - -isp-flash-1284p: dist/$(NAME).elf all - avrdude -c usbasp -p m1284p -e -U flash:w:$< - -flash-1284p: dist/$(NAME).elf all - avrdude -c arduino -p m1284p -P /dev/ttyUSB0 -b 115200 -e -U flash:w:$< - - -picocom: - # picocom sends CR for ENTER -> convert cr (\r) to lf (\n) - picocom -b 115200 --omap crlf /dev/ttyUSB0 - -isp-erase-1284p: - avrdude -c usbasp -p m1284p -e - -isp-fuse-1284p: - # LFUSE=0xE7 -> startuptime 16K CLOCKS + 4.1ms -> 5.4ms - avrdude -c usbasp -p m1284p -U lfuse:w:0xEF:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m - -clean: - @rm -r dist - @rm -r build - @rm -r sim - @find . -type f -name ".depend" -exec rm {} \; - @echo "clean done" diff --git a/software/bootloader-arduino/README.md b/software/bootloader-arduino/README.md deleted file mode 100644 index 81b4a47..0000000 --- a/software/bootloader-arduino/README.md +++ /dev/null @@ -1,109 +0,0 @@ -# Arduino-Bootloader (STK500) für Nano-1284 - -Dieser Bootloader ermöglicht die Programmierung über das "Arduino-System". Als Kommunikationsprotokoll kommt das [STK500 Protokoll]( https://www.microchip.com/content/dam/mchp/documents/OTH/ApplicationNotes/ApplicationNotes/doc2525.pdf) zur Anwendung (Kommunikationsablauf siehe Datei [protocol](protocol)). - -Beim Bootloader in [src/main.c](src/main.c) handelt es sich um eine Anpassung von [https://github.com/arduino/ArduinoCore-avr/blob/master/bootloaders/atmega/ATmegaBOOT_168.c](https://github.com/arduino/ArduinoCore-avr/blob/master/bootloaders/atmega/ATmegaBOOT_168.c) an die Hardware des Nano-1284 Boards. - -Diese Anpassung der Quelltext-Datei umfasst: -* Microcontroller ATmega1284P (mit 128KiB Flash, davon die hinteren 8KiB für den Bootloader) -* Frequenz 12MHz -* 3 LEDs (rot, gelb, grün) -* Assembler-Anweisungen durch Macros aus `avr/boot.h` ersetzt -* Quelltextkorrekturen, damit der Bootloader auch bei einer Page-Size von 256 Byte funktioniert - -Der Bootloader kann entweder selbst aus der Quelltextdatei erzeugt werden (siehe [Übersetzung](#%C3%BCbersetzung)), oder es wird eine der bereits fertigen Dateien im Ordner [release](release) verwendet: -* [release/bootloader-arduino_nano-1284.elf](release/bootloader-arduino_nano-1284.elf) -* [release/bootloader-arduino_nano-1284.hex](release/bootloader-arduino_nano-1284.hex) - -## Übersetzung - -Folgende Tools sind erforderlich: -* avr-gcc -* avrdude - -Auf einem Linux-Debian System müssen daher folgende Pakete installiert sein: -```sh -sudo apt update -sudo apt install gcc-avr avr-libc binutils-avr avrdude -``` - -Die Übersetzung erfolgt dann mit dem Kommando `make`. - -## Download auf den µC - -Die korrekte Programmierung der Fuses sowie der Download des Bootloaders in den Bootloader-Bereich des µC-Flash kann mit Hilfe eines [USBasp-Programmiergeräts](https://www.fischl.de/usbasp/) mit folgenden Kommandos erfolgen: - -```sh -make isp-fuse -make isp-flash -``` - -Nach der Programmierung sollten die drei LEDs den Start des Bootloader anzeigen (rot -> rot+orange -> grün -> grün blinken). - - -## Download von Programmen mit Hilfe des Bootloaders - -Sobald sich am µC ein Bootloader befindet ist kein Programmiergerät mehr erforderlich. Das Programm wird über die serielle UART-Schnittstelle (via USB-Schnittstelle) in den Flash gespeichert. - -UART-Schnittstelle (Option `-P`) und Name der ELF-Programmdatei (nach `flash:w:`) sind anzupassen... - -```sh -avrdude -c arduino -p m1284p -P /dev/ttyUSB0 -b 115200 -e -U flash:w:programm.elf -``` - -## Einbindung in die Arduino IDE - -Zunächst den Ordner mit der Arduino Installation finden. Unter Linux ist das der Pfad: -``` -/usr/share/arduino/hardware/arduino/avr -``` - -Dort im Unterordner `bootloaders` einen Ordner `atmeg1284` anlegen und darin die Intel-Hex Datei des Bootloaders ablegen. - -```sh -make -sudo mkdir /usr/share/arduino/hardware/arduino/avr/bootloaders/atmega1284 -cp dist/bootloader-arduino_nano-1284.hex /usr/share/arduino/hardware/arduino/avr/bootloaders/atmega1284/ -``` - -Danach in der Datei `/usr/share/arduino/hardware/arduino/avr/boards.txt` folgende Einträge ergänzen: -``` -######################################################### - -nano1284.name=Nano-1284 - -nano1284.vid.0=0x1a86 -nano1284.pid.0=0x7522 -nano1284.upload_port.0.vid=0x1a86 -nano1284.upload_port.0.pid=0x7522 - -nano1284.upload.tool=avrdude -nano1284.upload.tool.default=avrdude -nano1284.upload.tool.network=arduino_ota -nano1284.upload.protocol=arduino -nano1284.upload.maximum_size=122880 -nano1284.upload.maximum_data_size=16384 -nano1284.upload.speed=115200 - -nano1284.bootloader.tool=avrdude -nano1284.bootloader.tool.default=avrdude -nano1284.bootloader.low_fuses=0xEF -nano1284.bootloader.high_fuses=0xD8 -nano1284.bootloader.extended_fuses=0xFE -nano1284.bootloader.unlock_bits=0xFE -nano1284.bootloader.lock_bits=0xEF -nano1284.bootloader.file=atmega1284/bootloader-arduino_nano-1284.hex - -nano1284.build.mcu=atmega1284p -nano1284.build.f_cpu=12000000L -nano1284.build.board=AVR_NANO1284 -nano1284.build.core=arduino -nano1284.build.variant=standard - -############################################################## -``` - -Nach dem Start der Arduino-IDE kann: -* über das Menü *Werkzeuge->Board* das ***Nano-1284*** gewählt werden -* über das Menü *Werkzeuge->Programmer* der ***ArduinoISP*** gewählt werden - diff --git a/software/bootloader-arduino/protocol b/software/bootloader-arduino/protocol deleted file mode 100644 index 8c0ea61..0000000 --- a/software/bootloader-arduino/protocol +++ /dev/null @@ -1,323 +0,0 @@ - 0.552750 --> 2: 3020 - 0.555474 <-- 2: 1410 - 0.803623 --> 2: 3020 - 0.806825 <-- 2: 1410 - 1.054395 --> 2: 3020 - 1.057282 <-- 2: 1410 - - 1.057514 --> 3: 4181 20 - 1.060837 <-- 3: 1401 10 - 1.061061 --> 3: 4182 20 - 1.063819 <-- 3: 1410 10 - 1.064049 --> 22: 4282 0000 0101 0101 03ff ffff ff01 0008 0000 0100 0020 - 1.068274 <-- 2: 1410 - 1.068436 --> 7: 4505 08d7 a000 20 - 1.071346 <-- 2: 1410 - 1.071432 --> 2: 5020 - 1.074021 <-- 2: 1410 - 1.084349 --> 2: 7520 - 1.087176 <-- 5: 141e 960a 10 - 1.087341 --> 6: 5650 0000 0020 - 1.090435 <-- 3: 1400 10 - 1.090608 --> 6: 5650 0000 0020 - 1.093517 <-- 3: 1400 10 - 1.093662 --> 6: 5650 0000 0020 - 1.096678 <-- 3: 1400 10 - 1.096838 --> 6: 5658 0800 0020 - 1.099974 <-- 3: 1400 10 - 1.100216 --> 6: 5658 0800 0020 - 1.103433 <-- 3: 1400 10 - 1.103621 --> 6: 5658 0800 0020 - 1.106596 <-- 3: 1400 10 - 1.106798 --> 6: 5650 0800 0020 - 1.109878 <-- 3: 1400 10 - 1.110108 --> 6: 5650 0800 0020 - 1.113015 <-- 3: 1400 10 - 1.113141 --> 6: 5650 0800 0020 - 1.116120 <-- 3: 1400 10 - 1.116256 --> 6: 56ac 8000 0020 - 1.119179 <-- 3: 1400 10 - 1.174951 --> 3: 4181 20 - 1.177570 <-- 3: 1401 10 - 1.177770 --> 3: 4182 20 - 1.180450 <-- 3: 1410 10 - 1.180666 --> 22: 4282 0000 0101 0101 03ff ffff ff01 0008 0000 0100 0020 - 1.184868 <-- 2: 1410 - 1.185056 --> 7: 4505 08d7 a000 20 - 1.187956 <-- 2: 1410 - 1.188059 --> 2: 5020 - 1.190517 <-- 2: 1410 - - 1.191326 --> 4: 5500 0020 - 1.193964 <-- 2: 1410 - - 1.194133 --> 32: 6401 0046 0c94 3e00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 - 1.194154 --> 32: 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 ad00 0c94 5b00 - 1.194285 --> 32: 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 7d00 0c94 5b00 0c94 5b00 - 1.194310 --> 32: 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 9c00 0c94 5b00 0c94 5b00 - 1.197469 --> 32: 1124 1fbe cfef d0e1 debf cdbf 11e0 a0e0 b1e0 e8e2 f8e0 02c0 0590 0d92 aa34 b107 - 1.199991 --> 32: d9f7 21e0 aae4 b1e0 01c0 1d92 a235 b207 e1f7 0e94 d100 0c94 1204 0c94 0000 0f93 - 1.202760 --> 32: 1f93 cf93 c82f 8b01 8a30 19f4 8de0 0e94 5d00 8091 c000 85ff fccf 8091 4e01 9091 - 1.205599 --> 32: 4f01 0817 1907 19f4 c093 c600 02c0 c093 ce00 80e0 90e0 cf91 1f91 0f91 0895 1f92 - 1.208326 --> 5: 0f92 0fb6 20 - 1.255493 <-- 2: 1410 - - 1.255743 --> 4: 5580 0020 - 1.258608 <-- 2: 1410 - - 1.258821 --> 32: 6401 0046 0f92 1124 8f93 9f93 ef93 ff93 98b1 88e0 8927 88b9 8091 c600 8093 ce00 - 1.258842 --> 32: e0e0 f1e0 90e2 9083 8483 ff91 ef91 9f91 8f91 0f90 0fbe 0f90 1f90 1895 1f92 0f92 - 1.258964 --> 32: 0fb6 0f92 1124 8f93 8091 ce00 8032 09f4 429a 8f91 0f90 0fbe 0f90 1f90 1895 1f92 - 1.258995 --> 32: 0f92 0fb6 0f92 1124 2f93 8f93 9f93 8091 4a01 9091 4b01 0196 9093 4b01 8093 4a01 - 1.262021 --> 32: 883e 9340 40f0 98b1 80e1 8927 88b9 1092 4b01 1092 4a01 9f91 8f91 2f91 0f90 0fbe - 1.264633 --> 32: 0f90 1f90 1895 8ce1 87b9 8ce3 88b9 8ae0 8093 8100 8ced 95e0 9093 8900 8093 8800 - 1.267379 --> 32: 82e0 8093 6f00 8093 c000 38e9 3093 c100 26e0 2093 c200 1092 c500 9ce0 9093 c400 - 1.270166 --> 32: 8093 c800 3093 c900 2093 ca00 1092 cd00 9093 cc00 84e1 91e0 9093 4f01 8093 4e01 - 1.272904 --> 5: 86e0 91e0 20 - 1.320139 <-- 2: 1410 - - 1.320378 --> 4: 5500 0120 - 1.323002 <-- 2: 1410 - - 1.323205 --> 32: 6401 0046 9093 5101 8093 5001 1092 0001 7894 80e0 90e0 c0e0 d1e0 0ee2 11e0 359b - 1.323226 --> 32: 03c0 28e4 31e0 02c0 22e2 31e0 7c01 4fef e41a f40a 3f93 2f93 df93 cf93 9f93 8f93 - 1.323364 --> 32: 1f93 0f93 0e94 3401 8db7 9eb7 0896 0fb6 f894 9ebf 0fbe 8dbf 359b 4298 8fe2 95e7 - 1.323390 --> 32: 0197 f1f7 00c0 0000 c701 d9cf a0e0 b0e0 eae3 f1e0 0c94 eb03 ae01 4b5f 5f4f fa01 - 1.326221 --> 32: 6191 7191 af01 8091 4e01 9091 4f01 0e94 4a01 e2e0 0c94 0704 abe0 b0e0 e0e5 f1e0 - 1.329091 --> 32: 0c94 db03 6c01 7b01 8a01 fc01 1782 1682 8381 81ff ccc1 ce01 0196 3c01 f601 9381 - 1.331759 --> 32: f701 93fd 8591 93ff 8191 7f01 8823 09f4 bac1 8532 39f4 93fd 8591 93ff 8191 7f01 - 1.334544 --> 32: 8532 29f4 b601 90e0 0e94 4103 e7cf 912c 212c 312c ffe1 f315 d8f0 8b32 79f0 38f4 - 1.337305 --> 5: 8032 79f0 20 - 1.384623 <-- 2: 1410 - - 1.384878 --> 4: 5580 0120 - 1.387608 <-- 2: 1410 - - 1.387773 --> 32: 6401 0046 8332 a1f4 232d 2061 1dc0 8d32 61f0 8033 69f4 232d 2160 16c0 832d 8260 - 1.387789 --> 32: 382e e32d e460 3e2e 2ac0 f32d f860 1dc0 37fc 2dc0 20ed 280f 2a30 40f0 8e32 b9f4 - 1.387862 --> 32: 36fc 81c1 232d 2064 322e 19c0 36fe 06c0 8ae0 989e 200d 1124 922e 11c0 eae0 2e9e - 1.387921 --> 32: 200d 1124 222e f32d f062 3f2e 08c0 8c36 21f4 832d 8068 382e 02c0 8836 41f4 f701 - 1.390834 --> 32: 93fd 8591 93ff 8191 7f01 8111 b3cf 982f 9f7d 9554 9330 28f4 0c5f 1f4f 9fe3 9983 - 1.393604 --> 32: 0dc0 8336 31f0 8337 71f0 8335 09f0 59c0 21c0 f801 8081 8983 0e5f 1f4f 8824 8394 - 1.396338 --> 32: 912c 5301 13c0 2801 f2e0 4f0e 511c f801 a080 b180 36fe 03c0 692d 70e0 02c0 6fef - 1.399072 --> 32: 7fef c501 0e94 3603 4c01 8201 f32d ff77 3f2e 16c0 2801 22e0 420e 511c f801 a080 - 1.401922 --> 5: b180 36fe 20 - 1.448945 <-- 2: 1410 - - 1.449212 --> 4: 5500 0220 - 1.451904 <-- 2: 1410 - - 1.452121 --> 32: 6401 0046 03c0 692d 70e0 02c0 6fef 7fef c501 0e94 2b03 4c01 f32d f068 3f2e 8201 - 1.452143 --> 32: 33fc 1bc0 822d 90e0 8816 9906 b0f4 b601 80e2 90e0 0e94 4103 2a94 f4cf f501 37fc - 1.452282 --> 32: 8591 37fe 8191 5f01 b601 90e0 0e94 4103 2110 2a94 21e0 821a 9108 8114 9104 71f7 - 1.452308 --> 32: e8c0 8436 11f0 8936 41f5 f801 37fe 07c0 6081 7181 8281 9381 0c5f 1f4f 08c0 6081 - 1.455454 --> 32: 7181 072e 000c 880b 990b 0e5f 1f4f f32d ff76 3f2e 97ff 09c0 9095 8095 7095 6195 - 1.457980 --> 32: 7f4f 8f4f 9f4f f068 3f2e 2ae0 30e0 a301 0e94 7d03 882e 8618 45c0 8537 31f4 232d - 1.460725 --> 32: 2f7e b22e 2ae0 30e0 25c0 932d 997f b92e 8f36 c1f0 18f4 8835 79f0 b5c0 8037 19f0 - 1.463464 --> 32: 8837 21f0 b0c0 e92f e061 be2e b4fe 0dc0 fb2d f460 bf2e 09c0 34fe 0ac0 292f 2660 - 1.466235 --> 5: b22e 06c0 20 - 1.513447 <-- 2: 1410 - - 1.513715 --> 4: 5580 0220 - 1.516432 <-- 2: 1410 - - 1.516636 --> 32: 6401 0046 28e0 30e0 05c0 20e1 30e0 02c0 20e1 32e0 f801 b7fe 07c0 6081 7181 8281 - 1.516663 --> 32: 9381 0c5f 1f4f 06c0 6081 7181 80e0 90e0 0e5f 1f4f a301 0e94 7d03 882e 8618 fb2d - 1.516831 --> 32: ff77 3f2e 36fe 0dc0 232d 2e7f a22e 8914 58f4 34fe 0bc0 32fc 09c0 832d 8e7e a82e - 1.516877 --> 32: 05c0 b82c a32c 03c0 b82c 01c0 b92c a4fe 0fc0 fe01 e80d f11d 8081 8033 21f4 9a2d - 1.519644 --> 32: 997e a92e 09c0 a2fe 06c0 b394 b394 04c0 8a2d 8678 09f0 b394 a3fc 11c0 a0fe 06c0 - 1.522490 --> 32: b214 88f4 280c 922c 9b18 0ec0 b214 60f4 b601 80e2 90e0 0e94 4103 b394 f7cf b214 - 1.525257 --> 32: 18f4 2b18 02c0 982c 212c a4fe 10c0 b601 80e3 90e0 0e94 4103 a2fe 17c0 a1fc 03c0 - 1.527986 --> 32: 88e7 90e0 02c0 88e5 90e0 b601 0cc0 8a2d 8678 59f0 a1fe 02c0 8be2 01c0 80e2 a7fc - 1.530784 --> 5: 8de2 b601 20 - 1.577915 <-- 2: 1410 - - 1.578186 --> 4: 5500 0320 - 1.580952 <-- 2: 1410 - - 1.581190 --> 32: 6401 0046 90e0 0e94 4103 8914 38f4 b601 80e3 90e0 0e94 4103 9a94 f7cf 8a94 f301 - 1.581212 --> 32: e80d f11d 8081 b601 90e0 0e94 4103 8110 f5cf 2220 09f4 42ce b601 80e2 90e0 0e94 - 1.581358 --> 32: 4103 2a94 f6cf f601 8681 9781 02c0 8fef 9fef 2b96 e2e1 0c94 f703 fc01 0590 6150 - 1.581385 --> 32: 7040 0110 d8f7 8095 9095 8e0f 9f1f 0895 fc01 6150 7040 0190 0110 d8f7 8095 9095 - 1.584265 --> 32: 8e0f 9f1f 0895 0f93 1f93 cf93 df93 fb01 2381 21fd 03c0 8fef 9fef 2cc0 22ff 16c0 - 1.587011 --> 32: 4681 5781 2481 3581 4217 5307 44f4 a081 b181 9d01 2f5f 3f4f 3183 2083 8c93 2681 - 1.589734 --> 32: 3781 2f5f 3f4f 3783 2683 14c0 8b01 ec01 fb01 0084 f185 e02d 0995 892b e1f6 d801 - 1.592493 --> 32: 1696 8d91 9c91 1797 0196 1796 9c93 8e93 1697 ce01 df91 cf91 1f91 0f91 0895 fa01 - 1.595249 --> 5: aa27 2830 20 - 1.642464 <-- 2: 1410 - - 1.642718 --> 4: 5580 0320 - 1.645473 <-- 2: 1410 - - 1.645679 --> 32: 6401 0046 51f1 2031 81f1 e894 6f93 6e7f 6e5f 7f4f 8f4f 9f4f af4f b1e0 3ed0 b4e0 - 1.645701 --> 32: 3cd0 670f 781f 891f 9a1f a11d 680f 791f 8a1f 911d a11d 6a0f 711d 811d 911d a11d - 1.645848 --> 32: 20d0 09f4 6894 3f91 2ae0 269f 1124 3019 305d 3193 def6 cf01 0895 462f 4770 405d - 1.645887 --> 32: 4193 b3e0 0fd0 c9f7 f6cf 462f 4f70 405d 4a33 18f0 495d 31fd 4052 4193 02d0 a9f7 - 1.648691 --> 32: eacf b4e0 a695 9795 8795 7795 6795 ba95 c9f7 0097 6105 7105 0895 9b01 ac01 0a2e - 1.651486 --> 32: 0694 5795 4795 3795 2795 ba95 c9f7 620f 731f 841f 951f a01d 0895 2f92 3f92 4f92 - 1.654229 --> 32: 5f92 6f92 7f92 8f92 9f92 af92 bf92 cf92 df92 ef92 ff92 0f93 1f93 cf93 df93 cdb7 - 1.657068 --> 32: deb7 ca1b db0b 0fb6 f894 debf 0fbe cdbf 0994 2a88 3988 4888 5f84 6e84 7d84 8c84 - 1.659779 --> 5: 9b84 aa84 20 - 1.706941 <-- 2: 1410 - - 1.707172 --> 4: 5500 0420 - 1.709845 <-- 2: 1410 - - 1.710064 --> 32: 6401 0046 b984 c884 df80 ee80 fd80 0c81 1b81 aa81 b981 ce0f d11d 0fb6 f894 debf - 1.710085 --> 32: 0fbe cdbf ed01 0895 f894 ffcf 202d 3e20 5800 0000 0002 0000 0000 5d00 0000 0000 - 1.710260 --> 32: 0000 0002 0000 0000 5d00 0000 0000 5357 3220 7072 6573 7365 6400 2530 3478 3a20 - 1.710304 --> 32: 4865 6c6c 6f20 776f 726c 6425 7320 2025 3132 730d 0000 ffff ffff ffff ffff ffff - 1.713085 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 1.715997 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 1.718639 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 1.721439 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 1.724135 --> 5: ffff ffff 20 - 1.771467 <-- 2: 1410 - - 1.772647 --> 4: 5500 0020 - 1.775440 <-- 2: 1410 - - 1.775659 --> 5: 7401 0046 20 - 1.779386 <-- 32: 140c 943e 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b - 1.781924 <-- 32: 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b 000c 94ad 000c 945b 000c 945b - 1.784614 <-- 32: 000c 945b 000c 945b 000c 945b 000c 945b 000c 947d 000c 945b 000c 945b 000c 945b - 1.787364 <-- 32: 000c 945b 000c 945b 000c 945b 000c 945b 000c 949c 000c 945b 000c 945b 0011 241f - 1.790456 <-- 32: becf efd0 e1de bfcd bf11 e0a0 e0b1 e0e8 e2f8 e002 c005 900d 92aa 34b1 07d9 f721 - 1.792965 <-- 32: e0aa e4b1 e001 c01d 92a2 35b2 07e1 f70e 94d1 000c 9412 040c 9400 000f 931f 93cf - 1.795688 <-- 32: 93c8 2f8b 018a 3019 f48d e00e 945d 0080 91c0 0085 fffc cf80 914e 0190 914f 0108 - 1.798432 <-- 32: 1719 0719 f4c0 93c6 0002 c0c0 93ce 0080 e090 e0cf 911f 910f 9108 951f 920f 920f - 1.800632 <-- 2: b610 - - 1.800878 --> 4: 5580 0020 - 1.803619 <-- 2: 1410 - - 1.803814 --> 5: 7401 0046 20 - 1.807479 <-- 32: 140f 9211 248f 939f 93ef 93ff 9398 b188 e089 2788 b980 91c6 0080 93ce 00e0 e0f1 - 1.809984 <-- 32: e090 e290 8384 83ff 91ef 919f 918f 910f 900f be0f 901f 9018 951f 920f 920f b60f - 1.812844 <-- 32: 9211 248f 9380 91ce 0080 3209 f442 9a8f 910f 900f be0f 901f 9018 951f 920f 920f - 1.815639 <-- 32: b60f 9211 242f 938f 939f 9380 914a 0190 914b 0101 9690 934b 0180 934a 0188 3e93 - 1.818304 <-- 32: 4040 f098 b180 e189 2788 b910 924b 0110 924a 019f 918f 912f 910f 900f be0f 901f - 1.821082 <-- 32: 9018 958c e187 b98c e388 b98a e080 9381 008c ed95 e090 9389 0080 9388 0082 e080 - 1.823911 <-- 32: 936f 0080 93c0 0038 e930 93c1 0026 e020 93c2 0010 92c5 009c e090 93c4 0080 93c8 - 1.826612 <-- 32: 0030 93c9 0020 93ca 0010 92cd 0090 93cc 0084 e191 e090 934f 0180 934e 0186 e091 - 1.828744 <-- 2: e010 - - 1.828876 --> 4: 5500 0120 - 1.831444 <-- 2: 1410 - - 1.831620 --> 5: 7401 0046 20 - 1.835129 <-- 32: 1490 9351 0180 9350 0110 9200 0178 9480 e090 e0c0 e0d1 e00e e211 e035 9b03 c028 - 1.837845 <-- 32: e431 e002 c022 e231 e07c 014f efe4 1af4 0a3f 932f 93df 93cf 939f 938f 931f 930f - 1.840579 <-- 32: 930e 9434 018d b79e b708 960f b6f8 949e bf0f be8d bf35 9b42 988f e295 e701 97f1 - 1.843432 <-- 32: f700 c000 00c7 01d9 cfa0 e0b0 e0ea e3f1 e00c 94eb 03ae 014b 5f5f 4ffa 0161 9171 - 1.846426 <-- 32: 91af 0180 914e 0190 914f 010e 944a 01e2 e00c 9407 04ab e0b0 e0e0 e5f1 e00c 94db - 1.848837 <-- 32: 036c 017b 018a 01fc 0117 8216 8283 8181 ffcc c1ce 0101 963c 01f6 0193 81f7 0193 - 1.851649 <-- 32: fd85 9193 ff81 917f 0188 2309 f4ba c185 3239 f493 fd85 9193 ff81 917f 0185 3229 - 1.854442 <-- 32: f4b6 0190 e00e 9441 03e7 cf91 2c21 2c31 2cff e1f3 15d8 f08b 3279 f038 f480 3279 - 1.856623 <-- 2: f010 - - 1.856748 --> 4: 5580 0120 - 1.859363 <-- 2: 1410 - - 1.859447 --> 5: 7401 0046 20 - 1.862911 <-- 32: 1483 32a1 f423 2d20 611d c08d 3261 f080 3369 f423 2d21 6016 c083 2d82 6038 2ee3 - 1.865610 <-- 32: 2de4 603e 2e2a c0f3 2df8 601d c037 fc2d c020 ed28 0f2a 3040 f08e 32b9 f436 fc81 - 1.868409 <-- 32: c123 2d20 6432 2e19 c036 fe06 c08a e098 9e20 0d11 2492 2e11 c0ea e02e 9e20 0d11 - 1.871210 <-- 32: 2422 2ef3 2df0 623f 2e08 c08c 3621 f483 2d80 6838 2e02 c088 3641 f4f7 0193 fd85 - 1.873963 <-- 32: 9193 ff81 917f 0181 11b3 cf98 2f9f 7d95 5493 3028 f40c 5f1f 4f9f e399 830d c083 - 1.876709 <-- 32: 3631 f083 3771 f083 3509 f059 c021 c0f8 0180 8189 830e 5f1f 4f88 2483 9491 2c53 - 1.879571 <-- 32: 0113 c028 01f2 e04f 0e51 1cf8 01a0 80b1 8036 fe03 c069 2d70 e002 c06f ef7f efc5 - 1.882458 <-- 32: 010e 9436 034c 0182 01f3 2dff 773f 2e16 c028 0122 e042 0e51 1cf8 01a0 80b1 8036 - 1.884340 <-- 2: fe10 - - 1.884567 --> 4: 5500 0220 - 1.887255 <-- 2: 1410 - - 1.887443 --> 5: 7401 0046 20 - 1.890818 <-- 32: 1403 c069 2d70 e002 c06f ef7f efc5 010e 942b 034c 01f3 2df0 683f 2e82 0133 fc1b - 1.893598 <-- 32: c082 2d90 e088 1699 06b0 f4b6 0180 e290 e00e 9441 032a 94f4 cff5 0137 fc85 9137 - 1.896393 <-- 32: fe81 915f 01b6 0190 e00e 9441 0321 102a 9421 e082 1a91 0881 1491 0471 f7e8 c084 - 1.899280 <-- 32: 3611 f089 3641 f5f8 0137 fe07 c060 8171 8182 8193 810c 5f1f 4f08 c060 8171 8107 - 1.902001 <-- 32: 2e00 0c88 0b99 0b0e 5f1f 4ff3 2dff 763f 2e97 ff09 c090 9580 9570 9561 957f 4f8f - 1.904757 <-- 32: 4f9f 4ff0 683f 2e2a e030 e0a3 010e 947d 0388 2e86 1845 c085 3731 f423 2d2f 7eb2 - 1.907577 <-- 32: 2e2a e030 e025 c093 2d99 7fb9 2e8f 36c1 f018 f488 3579 f0b5 c080 3719 f088 3721 - 1.910469 <-- 32: f0b0 c0e9 2fe0 61be 2eb4 fe0d c0fb 2df4 60bf 2e09 c034 fe0a c029 2f26 60b2 2e06 - 1.912524 <-- 2: c010 - - 1.912815 --> 4: 5580 0220 - 1.915611 <-- 2: 1410 - - 1.915811 --> 5: 7401 0046 20 - 1.919244 <-- 32: 1428 e030 e005 c020 e130 e002 c020 e132 e0f8 01b7 fe07 c060 8171 8182 8193 810c - 1.921988 <-- 32: 5f1f 4f06 c060 8171 8180 e090 e00e 5f1f 4fa3 010e 947d 0388 2e86 18fb 2dff 773f - 1.924734 <-- 32: 2e36 fe0d c023 2d2e 7fa2 2e89 1458 f434 fe0b c032 fc09 c083 2d8e 7ea8 2e05 c0b8 - 1.927531 <-- 32: 2ca3 2c03 c0b8 2c01 c0b9 2ca4 fe0f c0fe 01e8 0df1 1d80 8180 3321 f49a 2d99 7ea9 - 1.930309 <-- 32: 2e09 c0a2 fe06 c0b3 94b3 9404 c08a 2d86 7809 f0b3 94a3 fc11 c0a0 fe06 c0b2 1488 - 1.933091 <-- 32: f428 0c92 2c9b 180e c0b2 1460 f4b6 0180 e290 e00e 9441 03b3 94f7 cfb2 1418 f42b - 1.935886 <-- 32: 1802 c098 2c21 2ca4 fe10 c0b6 0180 e390 e00e 9441 03a2 fe17 c0a1 fc03 c088 e790 - 1.938647 <-- 32: e002 c088 e590 e0b6 010c c08a 2d86 7859 f0a1 fe02 c08b e201 c080 e2a7 fc8d e2b6 - 1.940863 <-- 2: 0110 - - 1.941071 --> 4: 5500 0320 - 1.943869 <-- 2: 1410 - - 1.944088 --> 5: 7401 0046 20 - 1.947433 <-- 32: 1490 e00e 9441 0389 1438 f4b6 0180 e390 e00e 9441 039a 94f7 cf8a 94f3 01e8 0df1 - 1.950256 <-- 32: 1d80 81b6 0190 e00e 9441 0381 10f5 cf22 2009 f442 ceb6 0180 e290 e00e 9441 032a - 1.953054 <-- 32: 94f6 cff6 0186 8197 8102 c08f ef9f ef2b 96e2 e10c 94f7 03fc 0105 9061 5070 4001 - 1.955732 <-- 32: 10d8 f780 9590 958e 0f9f 1f08 95fc 0161 5070 4001 9001 10d8 f780 9590 958e 0f9f - 1.958565 <-- 32: 1f08 950f 931f 93cf 93df 93fb 0123 8121 fd03 c08f ef9f ef2c c022 ff16 c046 8157 - 1.961369 <-- 32: 8124 8135 8142 1753 0744 f4a0 81b1 819d 012f 5f3f 4f31 8320 838c 9326 8137 812f - 1.964157 <-- 32: 5f3f 4f37 8326 8314 c08b 01ec 01fb 0100 84f1 85e0 2d09 9589 2be1 f6d8 0116 968d - 1.966902 <-- 32: 919c 9117 9701 9617 969c 938e 9316 97ce 01df 91cf 911f 910f 9108 95fa 01aa 2728 - 1.969047 <-- 2: 3010 - - 1.969248 --> 4: 5580 0320 - 1.972047 <-- 2: 1410 - - 1.972246 --> 5: 7401 0046 20 - 1.975748 <-- 32: 1451 f120 3181 f1e8 946f 936e 7f6e 5f7f 4f8f 4f9f 4faf 4fb1 e03e d0b4 e03c d067 - 1.978498 <-- 32: 0f78 1f89 1f9a 1fa1 1d68 0f79 1f8a 1f91 1da1 1d6a 0f71 1d81 1d91 1da1 1d20 d009 - 1.981514 <-- 32: f468 943f 912a e026 9f11 2430 1930 5d31 93de f6cf 0108 9546 2f47 7040 5d41 93b3 - 1.983891 <-- 32: e00f d0c9 f7f6 cf46 2f4f 7040 5d4a 3318 f049 5d31 fd40 5241 9302 d0a9 f7ea cfb4 - 1.986799 <-- 32: e0a6 9597 9587 9577 9567 95ba 95c9 f700 9761 0571 0508 959b 01ac 010a 2e06 9457 - 1.989512 <-- 32: 9547 9537 9527 95ba 95c9 f762 0f73 1f84 1f95 1fa0 1d08 952f 923f 924f 925f 926f - 1.992260 <-- 32: 927f 928f 929f 92af 92bf 92cf 92df 92ef 92ff 920f 931f 93cf 93df 93cd b7de b7ca - 1.995029 <-- 32: 1bdb 0b0f b6f8 94de bf0f becd bf09 942a 8839 8848 885f 846e 847d 848c 849b 84aa - 1.997163 <-- 2: 8410 - - 1.997338 --> 4: 5500 0420 - 2.000161 <-- 2: 1410 - - 2.000367 --> 5: 7401 0046 20 - 2.003803 <-- 32: 14b9 84c8 84df 80ee 80fd 800c 811b 81aa 81b9 81ce 0fd1 1d0f b6f8 94de bf0f becd - 2.006477 <-- 32: bfed 0108 95f8 94ff cf20 2d3e 2058 0000 0000 0200 0000 005d 0000 0000 0000 0000 - 2.009429 <-- 32: 0200 0000 005d 0000 0000 0053 5732 2070 7265 7373 6564 0025 3034 783a 2048 656c - 2.012149 <-- 32: 6c6f 2077 6f72 6c64 2573 2020 2531 3273 0d00 00ff ffff ffff ffff ffff ffff ffff - 2.014971 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 2.017659 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 2.020387 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 2.023167 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff - 2.025368 <-- 2: ff10 - - 2.025949 --> 6: 5650 0000 0020 - 2.028775 <-- 3: 1400 10 - 2.028918 --> 6: 5650 0000 0020 - 2.031848 <-- 3: 1400 10 - 2.031977 --> 6: 5650 0000 0020 - 2.034973 <-- 3: 1400 10 - 2.035141 --> 6: 5658 0800 0020 - 2.038215 <-- 3: 1400 10 - 2.038413 --> 6: 5658 0800 0020 - 2.041454 <-- 3: 1400 10 - 2.041646 --> 6: 5658 0800 0020 - 2.044533 <-- 3: 1400 10 - 2.044682 --> 6: 5650 0800 0020 - 2.047749 <-- 3: 1400 10 - 2.047987 --> 6: 5650 0800 0020 - 2.050921 <-- 3: 1400 10 - 2.051154 --> 6: 5650 0800 0020 - 2.054178 <-- 3: 1400 10 - - 2.054415 --> 2: 5120 - 2.056864 <-- 2: 1410 diff --git a/software/bootloader-arduino/release/.gitkeep b/software/bootloader-arduino/release/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/software/bootloader-arduino/src/main.c b/software/bootloader-arduino/src/main.c deleted file mode 100644 index 08cebfe..0000000 --- a/software/bootloader-arduino/src/main.c +++ /dev/null @@ -1,516 +0,0 @@ -/*************************************************************************************************/ -/* Serial Bootloader for Atmel megaAVR Controllers */ -/* */ -/* Source-code taken from: */ -/* https://github.com/arduino/ArduinoCore-avr/blob/master/bootloaders/atmega/ATmegaBOOT_168.c */ -/* Branch@hash: master@321fca0b */ -/* */ -/* Licence can be viewed at http://www.fsf.org/licenses/gpl.txt */ -/* */ -/*************************************************************************************************/ - -#include - -#include -#include -#include -#include -#include -// #include - -// #define DEBUG_UART1 -#ifdef DEBUG_UART1 - #include -#endif - -// after this many errors give up and launch application -#define MAX_ERROR_COUNT 5 - -#define HW_VER 0xF1 -#define SW_MAJOR 0x01 -#define SW_MINOR 0x10 - -// onboard LED is used to indicate, that the bootloader was entered -#define SET_LED_RED (PORTC |= (1 << PC2)) -#define CLR_LED_RED (PORTC &= ~(1 << PC2)) -#define SET_LED_ORANGE (PORTC |= (1 << PC3)) -#define CLR_LED_ORANGE (PORTC &= ~(1 << PC3)) -#define SET_LED_GREEN (PORTC |= (1 << PC4)) -#define CLR_LED_GREEN (PORTC &= ~(1 << PC4)) - -// define various device id's -// manufacturer byte is always the same -#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :( -#define SIG2 0x97 -#define SIG3 0x05 -#define PAGE_SIZE 0x80U // 128 words - -// function prototypes -void putch(char); -char getch(void); -void getNch(uint8_t); -void byte_response(uint8_t); -void nothing_response(void); -char gethex(void); -void puthex(char); -void flash_led(uint8_t); - -#ifdef DEBUG_UART1 - int uart_putchar(char c, FILE *stream) { - if (c == '\n') { - uart_putchar('\r', stream); - } - loop_until_bit_is_set(UCSR1A, UDRE1); - UDR1 = c; - return 0; - } - - static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); -#endif - -// some variables -union address_union { - uint16_t word; - uint8_t byte[2]; -} address; - -union length_union { - uint16_t word; - uint8_t byte[2]; -} length; - -struct flags_struct { - unsigned eeprom : 1; - unsigned rampz : 1; -} flags; - -uint8_t buff[SPM_PAGESIZE + 1]; -// uint8_t address_high; -// uint8_t pagesz=0x80; - -uint16_t i; -uint8_t bootuart = 0; - -uint8_t error_count = 0; - -void (*app_start)(void) = 0x0000; - -int main () { - uint8_t ch, ch2; - uint16_t w; - - #ifdef WATCHDOG_MODS - ch = MCUSR; - MCUSR = 0; - - WDTCSR |= _BV(WDCE) | _BV(WDE); - WDTCSR = 0; - - // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot. - if (! (ch & _BV(EXTRF))) // if its a not an external reset... - app_start(); // skip bootloader - #else - asm volatile("nop\n\t"); - #endif - - // LED ports output and off, ensure that Q1 (battery power) on (PC7) - PORTC = 0; - DDRC = (1 << PC7) | (1 << PC4) | (1 << PC3) |(1 << PC2); - - - #ifdef DOUBLE_SPEED - UCSR0A = (1 << U2X0); // Double speed mode USART0 - UBRR0L = (uint8_t)(F_CPU / (BAUD_RATE *8L) - 1); - UBRR0H = (F_CPU / (BAUD_RATE * 8L) - 1) >> 8; - #ifdef DEBUG_UART1 - UCSR1A = (1 << U2X1); // Double speed mode USART0 - UBRR1L = (uint8_t)(F_CPU / (BAUD_RATE *8L) - 1); - UBRR1H = (F_CPU / (BAUD_RATE * 8L) - 1) >> 8; - #endif - #else - UBRR0L = (uint8_t)(F_CPU / (BAUD_RATE * 16L) - 1); - UBRR0H = (F_CPU / (BAUD_RATE*16L)-1) >> 8; - #ifdef DEBUG_UART1 - UBRR1L = (uint8_t)(F_CPU / (BAUD_RATE * 16L) - 1); - UBRR1H = (F_CPU / (BAUD_RATE*16L)-1) >> 8; - #endif - #endif - - UCSR0B = (1< 0x85) getch(); - nothing_response(); - - // ***************************** - // AVR ISP/STK500 board requests - // ***************************** - - } else if (ch == 'A') { // 0x41 - ch2 = getch(); - if (ch2 == 0x80) { - byte_response(HW_VER); // Hardware version - } else if (ch2 == 0x81) { - byte_response(SW_MAJOR); // Software major version - } else if(ch2 == 0x82) { - byte_response(SW_MINOR); // Software minor version - } else if(ch2==0x98) { - byte_response(0x03); // Unknown but seems to be required by avr studio 3.56 - } else { - byte_response(0x00); // Covers various unnecessary responses we don't care about - } - - } else if (ch == 'B') { // B: 0x42 - // Device Parameters DON'T CARE, DEVICE IS FIXED - getNch(20); - nothing_response(); - - - } else if (ch == 'E') { // E: 0x45 - // Parallel programming stuff DON'T CARE - getNch(5); - nothing_response(); - - } else if (ch == 'P' || ch == 'R') { // P: 0x50, R: 0x52 - // P: Enter programming mode - // R: Erase device, don't care as we will erase one page at a time anyway. - nothing_response(); - - } else if (ch == 'Q') { // Q: 0x51 - // Leave programming mode - nothing_response(); - #ifdef WATCHDOG_MODS - // autoreset via watchdog (sneaky!) - WDTCSR = _BV(WDE); - while (1); // 16 ms - #endif - - } else if(ch == 'U') { // U: 0x55 - // Set address, little endian. EEPROM in bytes, FLASH in words - // Perhaps extra address bytes may be added in future to support > 128kB FLASH. - // This might explain why little endian was used here, big endian used everywhere else. - address.byte[0] = getch(); - address.byte[1] = getch(); - nothing_response(); - - - } else if (ch == 'V') { // V: 0x56 - // Universal SPI programming command, disabled. Would be used for fuses and lock bits. - if (getch() == 0x30) { - getch(); - ch = getch(); - getch(); - if (ch == 0) { - byte_response(SIG1); - } else if (ch == 1) { - byte_response(SIG2); - } else { - byte_response(SIG3); - } - } else { - getNch(3); - byte_response(0x00); - } - - } else if (ch == 'd') { // d: 0x64 - // Write memory, length is big endian and is in bytes - length.byte[1] = getch(); - length.byte[0] = getch(); - flags.eeprom = 0; - if (getch() == 'E') { - flags.eeprom = 1; - } - for (w = 0; w < length.word; w++) { - // Store data in buffer, can't keep up with serial data stream whilst programming pages - buff[w] = getch(); - } - if (getch() == ' ') { - if (flags.eeprom) { - // Write to EEPROM one byte at a time - address.word <<= 1; - for(w = 0; w < length.word; w++) { - while(EECR & (1< 127) { - //Only possible with m128, m256 will need 3rd address byte. FIXME - RAMPZ = 0x01; - } else { - RAMPZ = 0x00; - } - - // address * 2 -> byte location - address.word = address.word << 1; - if ((length.byte[0] & 0x01)) { - // Even up an odd number of bytes - length.word++; - } - cli(); - - uint16_t addr = address.word; - #ifdef DEBUG_UART1 - printf("Programming: address=0x%04x length=0x%04x\n", addr, length.word); - printf(" eeprom_busy_wait() ..."); - #endif - eeprom_busy_wait(); - boot_spm_busy_wait(); - #ifdef DEBUG_UART1 - printf("done\n"); - printf(" boot_page_erase(0x%04x)...", address.word); - #endif - boot_page_erase(addr); - boot_spm_busy_wait (); - #ifdef DEBUG_UART1 - printf("done\n"); - printf(" boot_page_fill(0x%04x, ...): ", address.word); - #endif - for (i = 0; i < SPM_PAGESIZE; i += 2) { - uint16_t w = buff[i] + (buff[i + 1] << 8); - #ifdef DEBUG_UART1 - printf("."); - #endif - boot_page_fill(addr + i, w); - } - #ifdef DEBUG_UART1 - printf("\n boot_page_write(0x%04x)...", address.word); - #endif - boot_page_write(addr); - boot_spm_busy_wait(); - #ifdef DEBUG_UART1 - printf("done\n"); - printf(" boot_rww_enable()\n"); - #endif - boot_rww_enable(); - } - putch(0x14); - putch(0x10); - - } else { - if (++error_count == MAX_ERROR_COUNT) - DDRC = 0; PORTC = 0; - app_start(); - } - - } else if (ch == 't') { // t: 0x74 - // Read memory block mode, length is big endian. */ - length.byte[1] = getch(); - length.byte[0] = getch(); - // if (address.word>0x7FFF) flags.rampz = 1; // No go with m256, FIXME - // else flags.rampz = 0; - address.word = address.word << 1; // address * 2 -> byte location - if (getch() == 'E') { - flags.eeprom = 1; - } else { - flags.eeprom = 0; - } - if (getch() == ' ') { - // Command terminator - putch(0x14); - for (w = 0; w < length.word; w++) { - // Can handle odd and even lengths okay - if (flags.eeprom) { // Byte access EEPROM read - while(EECR & (1<= 'a') { - return (a - 'a' + 0x0a); - } else if (a >= '0') { - return (a - '0'); - } - return a; -} - - -char gethex () { - return (gethexnib() << 4) + gethexnib(); -} - - -void puthex (char ch) { - char ah; - - ah = ch >> 4; - if(ah >= 0x0a) { - ah = ah - 0x0a + 'a'; - } else { - ah += '0'; - } - - ch &= 0x0f; - if(ch >= 0x0a) { - ch = ch - 0x0a + 'a'; - } else { - ch += '0'; - } - - putch(ah); - putch(ch); -} - - -void putch (char ch) { - while (!(UCSR0A & _BV(UDRE0))); - UDR0 = ch; -} - - -char getch () { - uint32_t count = 0; - while( !(UCSR0A & _BV(RXC0)) ) { - count++; - if (count > MAX_TIME_COUNT) { - DDRC = 0; PORTC = 0; - app_start(); - } - } - return UDR0; -} - - -void getNch (uint8_t count) { - while(count--) { - getch(); - } -} - - -void byte_response (uint8_t val) { - if (getch() == ' ') { - putch(0x14); - putch(val); - putch(0x10); - } else if (++error_count == MAX_ERROR_COUNT) { - DDRC = 0; PORTC = 0; - app_start(); - } -} - -void nothing_response () { - if (getch() == ' ') { - putch(0x14); - putch(0x10); - } else if (++error_count == MAX_ERROR_COUNT) { - DDRC = 0; PORTC = 0; - app_start(); - } -} - -void delay () { - // app. 200ms - for (volatile uint32_t timer = 0; timer < 0x12000; timer++) { - if (UCSR0A & _BV(RXC0)) { - return; - } - } -} - -void flash_led (uint8_t count) { - SET_LED_RED; - delay(); - SET_LED_ORANGE; - delay(); - PORTC = 0; - - while (count--) { - SET_LED_GREEN; - delay(); - CLR_LED_GREEN; - delay(); - } -} diff --git a/software/nano-1284/bootloader-arduino/.gdb_history b/software/nano-1284/bootloader-arduino/.gdb_history new file mode 100644 index 0000000..3339046 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/.gdb_history @@ -0,0 +1,9 @@ +target remote :1234 +layout split +stepi +quit +target remote :1234 +layout split +stepi +b *main+9 +quit diff --git a/software/nano-1284/bootloader-arduino/.gdbinit b/software/nano-1284/bootloader-arduino/.gdbinit new file mode 100644 index 0000000..a8c4b59 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/.gdbinit @@ -0,0 +1,5 @@ +set history save on +set history size 1000 +set history remove-duplicates 2 +set history filename .gdb_history + diff --git a/software/nano-1284/bootloader-arduino/.gitignore b/software/nano-1284/bootloader-arduino/.gitignore new file mode 100644 index 0000000..a959910 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/.gitignore @@ -0,0 +1,4 @@ +.depend +**/build +**/dist +**/sim diff --git a/software/nano-1284/bootloader-arduino/.vscode/c_cpp_properties.json b/software/nano-1284/bootloader-arduino/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..773ff69 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/.vscode/c_cpp_properties.json @@ -0,0 +1,26 @@ +{ + "configurations": [ + { + "name": "Linux AVR", + "includePath": [ + "/usr/lib/avr/include/**", + "/usr/lib/gcc/avr/**" + ], + "defines": [], + "compilerPath": "/usr/bin/avr-gcc", + "compilerArgs": [ + "-mmcu=atmega1284p", + "-Os", + "-DF_CPU=12000000", + "-DBAUD_RATE=115200", + "-DDOUBLE_SPEED", + "-DNUM_LED_FLASHES=4", + "-DMAX_TIME_COUNT=F_CPU>>4" + ], + "cStandard": "gnu11", + "cppStandard": "gnu++11", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} diff --git a/software/nano-1284/bootloader-arduino/.vscode/launch.json b/software/nano-1284/bootloader-arduino/.vscode/launch.json new file mode 100644 index 0000000..f29cf2e --- /dev/null +++ b/software/nano-1284/bootloader-arduino/.vscode/launch.json @@ -0,0 +1,37 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Build", + // "request": "launch", + "type": "node-terminal", + "preLaunchTask": "build" + },{ + "name": "Flash", + // "request": "launch", + "type": "node-terminal", + "preLaunchTask": "flash" + },{ + "name": "Clean", + // "request": "launch", + "type": "node-terminal", + "preLaunchTask": "clean" + },{ + // es muss mit simuc --board arduino dist/programm.elf der Simulator + // gestartet werden. Dessen gdb-stub öffnet auf localhost:1234 einen Port + "name": "Debug (simuc)", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/sim/atmega328p.elf", + "cwd": "${workspaceFolder}", + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/avr-gdb", + "miDebuggerServerAddress": ":1234", + "preLaunchTask": "build" + } + ] +} diff --git a/software/nano-1284/bootloader-arduino/.vscode/settings.json b/software/nano-1284/bootloader-arduino/.vscode/settings.json new file mode 100644 index 0000000..1d7e197 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "[c]": { + "editor.insertSpaces": true, + "editor.tabSize": 3, + "editor.detectIndentation": false + }, + "[h]": { + "editor.insertSpaces": true, + "editor.tabSize": 3, + "editor.detectIndentation": false + }, + "cSpell.words": [], + "cSpell.ignorePaths": [ + "**/*.json", "**/*.c", "**/*.h", "**/Makefile" + ] +} diff --git a/software/nano-1284/bootloader-arduino/.vscode/tasks.json b/software/nano-1284/bootloader-arduino/.vscode/tasks.json new file mode 100644 index 0000000..74fb1c7 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [{ + "label": "build", + "type": "shell", + "command": "make", + "problemMatcher":[ + "$gcc" + ] + },{ + "label": "clean", + "type": "shell", + "command": "make", + "args": [ "clean" ], + },{ + "label": "flash", + "type": "shell", + "command": "make", + "args": [ "flash" ], + }] +} \ No newline at end of file diff --git a/software/nano-1284/bootloader-arduino/Makefile b/software/nano-1284/bootloader-arduino/Makefile new file mode 100644 index 0000000..bd4e491 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/Makefile @@ -0,0 +1,124 @@ +.PHONY: all info flash picocom clean +$(shell mkdir -p dist >/dev/null) +$(shell mkdir -p build >/dev/null) +$(shell mkdir -p sim >/dev/null) +$(shell mkdir -p sim/build >/dev/null) + +NAME="bootloader-arduino_nano-1284" +SRC= $(wildcard src/*.c src/*.cpp src/*/*.c src/*/*.cpp) +HDR= $(wildcard src/*.h src/*.hpp src/*/*.h src/*/*.hpp) +OBJ_CPP = $(SRC:src/%.cpp=build/%.o) +OBJ = $(OBJ_CPP:src/%.c=build/%.o) +OBJ_SIM_CPP = $(SRC:src/%.cpp=sim/build/%.o) +OBJ_SIM = $(OBJ_SIM_CPP:src/%.c=sim/build/%.o) + +DEVICE=atmega1284p + +CC= avr-g++ +CFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c +#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -Wl,-u,vfprintf -lprintf_flt -lm +LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=12000000 -Wl,--section-start=.text=0x1e000 + +CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c +#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -Wl,-u,vfprintf -lprintf_flt -lm +LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=12000000 -g -Wl,--section-start=.text=0x1e000 + + +all: dist/$(NAME).elf dist/$(NAME).s dist/$(NAME).hex sim/$(NAME).elf sim/$(NAME).s info + +dbg: + @echo --HDR--------------------------------- + @echo $(HDR) + @echo --SRC--------------------------------- + @echo $(SRC) + @echo --OBJ--------------------------------- + @echo $(OBJ) + @echo --OBJ_CPP----------------------------- + @echo $(OBJ_CPP) + @echo --OBJ--------------------------------- + @echo $(OBJ) + @echo =================================== + @echo + +info: + @avr-size --mcu=$(DEVICE) --format=avr dist/$(NAME).elf + +.depend: $(SRC) $(HDR) + $(CC) -mmcu=$(DEVICE) -MM $(SRC) | sed --regexp-extended 's/^(.*\.o)\: src\/(.*)(\.cpp|\.c) (.*)/build\/\2\.o\: src\/\2\3 \4/g' > .depend + +-include .depend + +# .depend solte auch auf Header Files achten! + +dist/$(NAME).elf: .depend $(OBJ) + $(CC) $(LFLAGS) -o $@ $(OBJ) + +dist/%.s: dist/%.elf + avr-objdump -d $< > $@ + +dist/%.hex: dist/%.elf + #avr-objcopy -j .text -j .data -O ihex $< $@ + avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ + +sim/$(NAME).elf: .depend $(OBJ_SIM) + $(CC) $(LFLAGS_SIM) -o $@ $(OBJ_SIM) + + +build/%.o: src/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) -o $@ $< + +build/%.o: src/%.cpp + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) -o $@ $< + +sim/build/%.o: src/%.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS_SIM) -o $@ $< + +sim/build/%.o: src/%.cpp + @mkdir -p $(dir $@) + $(CC) $(CFLAGS_SIM) -o $@ $< + +sim/%.s: sim/%.elf + avr-objdump -d $< > $@ + +simuc: sim/$(NAME).elf + simuc --board arduino $< + +gdb: sim/$(NAME).elf + avr-gdb $< + +isp-1284p: + avrdude -c usbasp -p m1284p + +isp-flash-1284p: dist/$(NAME).elf all + avrdude -c usbasp -p m1284p -e -U flash:w:$< + +isp-flash-1284p-latest-release: + avrdude -c usbasp -p m1284p -e -U flash:w:release/$(shell ls -A release | tail -n 1)/$(NAME).elf + +isp-read-flash-1284p: + avrdude -c usbasp -p m1284p -U flash:r:/tmp/flash-nano-1284__$(shell date +"%Y-%m-%d_%H%M%S") + +flash-1284p: dist/$(NAME).elf all + avrdude -c arduino -p m1284p -P /dev/ttyUSB0 -b 115200 -e -U flash:w:$< + + +picocom: + # picocom sends CR for ENTER -> convert cr (\r) to lf (\n) + picocom -b 115200 --omap crlf /dev/ttyUSB0 + +isp-erase-1284p: + avrdude -c usbasp -p m1284p -e + +isp-fuse-1284p: + # LFUSE=0xE7 -> startuptime 16K CLOCKS + 4.1ms -> 5.4ms + avrdude -c usbasp -p m1284p -U lfuse:w:0xEF:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m + +clean: + @rm -r dist + @rm -r build + @rm -r sim + @find . -type f -name ".depend" -exec rm {} \; + @echo "clean done" diff --git a/software/nano-1284/bootloader-arduino/README.md b/software/nano-1284/bootloader-arduino/README.md new file mode 100644 index 0000000..64a8d3f --- /dev/null +++ b/software/nano-1284/bootloader-arduino/README.md @@ -0,0 +1,111 @@ +# Arduino-Bootloader (STK500) für Nano-1284 + +Dieser Bootloader ermöglicht die Programmierung über das "Arduino-System". Als Kommunikationsprotokoll kommt das [STK500 Protokoll]( https://www.microchip.com/content/dam/mchp/documents/OTH/ApplicationNotes/ApplicationNotes/doc2525.pdf) zur Anwendung (Kommunikationsablauf siehe Datei [protocol](protocol)). + +Beim Bootloader in [src/main.c](src/main.c) handelt es sich um eine Anpassung von [https://github.com/arduino/ArduinoCore-avr/blob/master/bootloaders/atmega/ATmegaBOOT_168.c](https://github.com/arduino/ArduinoCore-avr/blob/master/bootloaders/atmega/ATmegaBOOT_168.c) an die Hardware des Nano-1284 Boards. + +Diese Anpassung der Quelltext-Datei umfasst: +* Microcontroller ATmega1284P (mit 128KiB Flash, davon die hinteren 8KiB für den Bootloader) +* Frequenz 12MHz +* 3 LEDs (rot, gelb, grün) +* Assembler-Anweisungen durch Macros aus `avr/boot.h` ersetzt +* Quelltextkorrekturen, damit der Bootloader auch bei einer Page-Size von 256 Byte funktioniert + +Der Bootloader kann entweder selbst aus der Quelltextdatei erzeugt werden (siehe [Übersetzung](#%C3%BCbersetzung)), oder es wird eine der bereits fertigen Dateien im Ordner [release](release) verwendet: +* [release/2024-09-05_120945/bootloader-arduino_nano-1284.elf](release/2024-09-05_120945/bootloader-arduino_nano-1284.elf) +* [release/2024-09-05_120945/bootloader-arduino_nano-1284.hex](release/2024-09-05_120945/bootloader-arduino_nano-1284.hex) + +## Übersetzung + +Folgende Tools sind erforderlich: +* avr-gcc +* avrdude + +Auf einem Linux-Debian System müssen daher folgende Pakete installiert sein: +```sh +sudo apt update +sudo apt install gcc-avr avr-libc binutils-avr avrdude +``` + +Die Übersetzung erfolgt dann mit dem Kommando `make`. + +## Download auf den µC + +Die korrekte Programmierung der Fuses sowie der Download des Bootloaders in den Bootloader-Bereich des µC-Flash kann mit Hilfe eines [USBasp-Programmiergeräts](https://www.fischl.de/usbasp/) mit folgenden Kommandos erfolgen: + +... oder die aktuellste Version im UNterordner [release](release) ... + +```sh +make isp-fuse-1284p +make isp-flash-1284p-latest-release: +``` + +Nach der Programmierung sollten die drei LEDs den Start des Bootloader anzeigen (rot -> rot+orange -> grün -> grün blinken). + + +## Download von Programmen mit Hilfe des Bootloaders + +Sobald sich am µC ein Bootloader befindet ist kein Programmiergerät mehr erforderlich. Das Programm wird über die serielle UART-Schnittstelle (via USB-Schnittstelle) in den Flash gespeichert. + +UART-Schnittstelle (Option `-P`) und Name der ELF-Programmdatei (nach `flash:w:`) sind anzupassen... + +```sh +avrdude -c arduino -p m1284p -P /dev/ttyUSB0 -b 115200 -e -U flash:w:programm.elf +``` + +## Einbindung in die Arduino IDE + +Zunächst den Ordner mit der Arduino Installation finden. Unter Linux ist das der Pfad: +``` +/usr/share/arduino/hardware/arduino/avr +``` + +Dort im Unterordner `bootloaders` einen Ordner `atmeg1284` anlegen und darin die Intel-Hex Datei des Bootloaders ablegen. + +```sh +make +sudo mkdir /usr/share/arduino/hardware/arduino/avr/bootloaders/atmega1284 +cp dist/bootloader-arduino_nano-1284.hex /usr/share/arduino/hardware/arduino/avr/bootloaders/atmega1284/ +``` + +Danach in der Datei `/usr/share/arduino/hardware/arduino/avr/boards.txt` folgende Einträge ergänzen: +``` +######################################################### + +nano1284.name=Nano-1284 + +nano1284.vid.0=0x1a86 +nano1284.pid.0=0x7522 +nano1284.upload_port.0.vid=0x1a86 +nano1284.upload_port.0.pid=0x7522 + +nano1284.upload.tool=avrdude +nano1284.upload.tool.default=avrdude +nano1284.upload.tool.network=arduino_ota +nano1284.upload.protocol=arduino +nano1284.upload.maximum_size=122880 +nano1284.upload.maximum_data_size=16384 +nano1284.upload.speed=115200 + +nano1284.bootloader.tool=avrdude +nano1284.bootloader.tool.default=avrdude +nano1284.bootloader.low_fuses=0xEF +nano1284.bootloader.high_fuses=0xD8 +nano1284.bootloader.extended_fuses=0xFE +nano1284.bootloader.unlock_bits=0xFE +nano1284.bootloader.lock_bits=0xEF +nano1284.bootloader.file=atmega1284/bootloader-arduino_nano-1284.hex + +nano1284.build.mcu=atmega1284p +nano1284.build.f_cpu=12000000L +nano1284.build.board=AVR_NANO1284 +nano1284.build.core=arduino +nano1284.build.variant=standard + +############################################################## +``` + +Nach dem Start der Arduino-IDE kann: +* über das Menü *Werkzeuge->Board* das ***Nano-1284*** gewählt werden +* über das Menü *Werkzeuge->Programmer* der ***ArduinoISP*** gewählt werden + diff --git a/software/nano-1284/bootloader-arduino/protocol b/software/nano-1284/bootloader-arduino/protocol new file mode 100644 index 0000000..8c0ea61 --- /dev/null +++ b/software/nano-1284/bootloader-arduino/protocol @@ -0,0 +1,323 @@ + 0.552750 --> 2: 3020 + 0.555474 <-- 2: 1410 + 0.803623 --> 2: 3020 + 0.806825 <-- 2: 1410 + 1.054395 --> 2: 3020 + 1.057282 <-- 2: 1410 + + 1.057514 --> 3: 4181 20 + 1.060837 <-- 3: 1401 10 + 1.061061 --> 3: 4182 20 + 1.063819 <-- 3: 1410 10 + 1.064049 --> 22: 4282 0000 0101 0101 03ff ffff ff01 0008 0000 0100 0020 + 1.068274 <-- 2: 1410 + 1.068436 --> 7: 4505 08d7 a000 20 + 1.071346 <-- 2: 1410 + 1.071432 --> 2: 5020 + 1.074021 <-- 2: 1410 + 1.084349 --> 2: 7520 + 1.087176 <-- 5: 141e 960a 10 + 1.087341 --> 6: 5650 0000 0020 + 1.090435 <-- 3: 1400 10 + 1.090608 --> 6: 5650 0000 0020 + 1.093517 <-- 3: 1400 10 + 1.093662 --> 6: 5650 0000 0020 + 1.096678 <-- 3: 1400 10 + 1.096838 --> 6: 5658 0800 0020 + 1.099974 <-- 3: 1400 10 + 1.100216 --> 6: 5658 0800 0020 + 1.103433 <-- 3: 1400 10 + 1.103621 --> 6: 5658 0800 0020 + 1.106596 <-- 3: 1400 10 + 1.106798 --> 6: 5650 0800 0020 + 1.109878 <-- 3: 1400 10 + 1.110108 --> 6: 5650 0800 0020 + 1.113015 <-- 3: 1400 10 + 1.113141 --> 6: 5650 0800 0020 + 1.116120 <-- 3: 1400 10 + 1.116256 --> 6: 56ac 8000 0020 + 1.119179 <-- 3: 1400 10 + 1.174951 --> 3: 4181 20 + 1.177570 <-- 3: 1401 10 + 1.177770 --> 3: 4182 20 + 1.180450 <-- 3: 1410 10 + 1.180666 --> 22: 4282 0000 0101 0101 03ff ffff ff01 0008 0000 0100 0020 + 1.184868 <-- 2: 1410 + 1.185056 --> 7: 4505 08d7 a000 20 + 1.187956 <-- 2: 1410 + 1.188059 --> 2: 5020 + 1.190517 <-- 2: 1410 + + 1.191326 --> 4: 5500 0020 + 1.193964 <-- 2: 1410 + + 1.194133 --> 32: 6401 0046 0c94 3e00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 + 1.194154 --> 32: 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 ad00 0c94 5b00 + 1.194285 --> 32: 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 7d00 0c94 5b00 0c94 5b00 + 1.194310 --> 32: 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 5b00 0c94 9c00 0c94 5b00 0c94 5b00 + 1.197469 --> 32: 1124 1fbe cfef d0e1 debf cdbf 11e0 a0e0 b1e0 e8e2 f8e0 02c0 0590 0d92 aa34 b107 + 1.199991 --> 32: d9f7 21e0 aae4 b1e0 01c0 1d92 a235 b207 e1f7 0e94 d100 0c94 1204 0c94 0000 0f93 + 1.202760 --> 32: 1f93 cf93 c82f 8b01 8a30 19f4 8de0 0e94 5d00 8091 c000 85ff fccf 8091 4e01 9091 + 1.205599 --> 32: 4f01 0817 1907 19f4 c093 c600 02c0 c093 ce00 80e0 90e0 cf91 1f91 0f91 0895 1f92 + 1.208326 --> 5: 0f92 0fb6 20 + 1.255493 <-- 2: 1410 + + 1.255743 --> 4: 5580 0020 + 1.258608 <-- 2: 1410 + + 1.258821 --> 32: 6401 0046 0f92 1124 8f93 9f93 ef93 ff93 98b1 88e0 8927 88b9 8091 c600 8093 ce00 + 1.258842 --> 32: e0e0 f1e0 90e2 9083 8483 ff91 ef91 9f91 8f91 0f90 0fbe 0f90 1f90 1895 1f92 0f92 + 1.258964 --> 32: 0fb6 0f92 1124 8f93 8091 ce00 8032 09f4 429a 8f91 0f90 0fbe 0f90 1f90 1895 1f92 + 1.258995 --> 32: 0f92 0fb6 0f92 1124 2f93 8f93 9f93 8091 4a01 9091 4b01 0196 9093 4b01 8093 4a01 + 1.262021 --> 32: 883e 9340 40f0 98b1 80e1 8927 88b9 1092 4b01 1092 4a01 9f91 8f91 2f91 0f90 0fbe + 1.264633 --> 32: 0f90 1f90 1895 8ce1 87b9 8ce3 88b9 8ae0 8093 8100 8ced 95e0 9093 8900 8093 8800 + 1.267379 --> 32: 82e0 8093 6f00 8093 c000 38e9 3093 c100 26e0 2093 c200 1092 c500 9ce0 9093 c400 + 1.270166 --> 32: 8093 c800 3093 c900 2093 ca00 1092 cd00 9093 cc00 84e1 91e0 9093 4f01 8093 4e01 + 1.272904 --> 5: 86e0 91e0 20 + 1.320139 <-- 2: 1410 + + 1.320378 --> 4: 5500 0120 + 1.323002 <-- 2: 1410 + + 1.323205 --> 32: 6401 0046 9093 5101 8093 5001 1092 0001 7894 80e0 90e0 c0e0 d1e0 0ee2 11e0 359b + 1.323226 --> 32: 03c0 28e4 31e0 02c0 22e2 31e0 7c01 4fef e41a f40a 3f93 2f93 df93 cf93 9f93 8f93 + 1.323364 --> 32: 1f93 0f93 0e94 3401 8db7 9eb7 0896 0fb6 f894 9ebf 0fbe 8dbf 359b 4298 8fe2 95e7 + 1.323390 --> 32: 0197 f1f7 00c0 0000 c701 d9cf a0e0 b0e0 eae3 f1e0 0c94 eb03 ae01 4b5f 5f4f fa01 + 1.326221 --> 32: 6191 7191 af01 8091 4e01 9091 4f01 0e94 4a01 e2e0 0c94 0704 abe0 b0e0 e0e5 f1e0 + 1.329091 --> 32: 0c94 db03 6c01 7b01 8a01 fc01 1782 1682 8381 81ff ccc1 ce01 0196 3c01 f601 9381 + 1.331759 --> 32: f701 93fd 8591 93ff 8191 7f01 8823 09f4 bac1 8532 39f4 93fd 8591 93ff 8191 7f01 + 1.334544 --> 32: 8532 29f4 b601 90e0 0e94 4103 e7cf 912c 212c 312c ffe1 f315 d8f0 8b32 79f0 38f4 + 1.337305 --> 5: 8032 79f0 20 + 1.384623 <-- 2: 1410 + + 1.384878 --> 4: 5580 0120 + 1.387608 <-- 2: 1410 + + 1.387773 --> 32: 6401 0046 8332 a1f4 232d 2061 1dc0 8d32 61f0 8033 69f4 232d 2160 16c0 832d 8260 + 1.387789 --> 32: 382e e32d e460 3e2e 2ac0 f32d f860 1dc0 37fc 2dc0 20ed 280f 2a30 40f0 8e32 b9f4 + 1.387862 --> 32: 36fc 81c1 232d 2064 322e 19c0 36fe 06c0 8ae0 989e 200d 1124 922e 11c0 eae0 2e9e + 1.387921 --> 32: 200d 1124 222e f32d f062 3f2e 08c0 8c36 21f4 832d 8068 382e 02c0 8836 41f4 f701 + 1.390834 --> 32: 93fd 8591 93ff 8191 7f01 8111 b3cf 982f 9f7d 9554 9330 28f4 0c5f 1f4f 9fe3 9983 + 1.393604 --> 32: 0dc0 8336 31f0 8337 71f0 8335 09f0 59c0 21c0 f801 8081 8983 0e5f 1f4f 8824 8394 + 1.396338 --> 32: 912c 5301 13c0 2801 f2e0 4f0e 511c f801 a080 b180 36fe 03c0 692d 70e0 02c0 6fef + 1.399072 --> 32: 7fef c501 0e94 3603 4c01 8201 f32d ff77 3f2e 16c0 2801 22e0 420e 511c f801 a080 + 1.401922 --> 5: b180 36fe 20 + 1.448945 <-- 2: 1410 + + 1.449212 --> 4: 5500 0220 + 1.451904 <-- 2: 1410 + + 1.452121 --> 32: 6401 0046 03c0 692d 70e0 02c0 6fef 7fef c501 0e94 2b03 4c01 f32d f068 3f2e 8201 + 1.452143 --> 32: 33fc 1bc0 822d 90e0 8816 9906 b0f4 b601 80e2 90e0 0e94 4103 2a94 f4cf f501 37fc + 1.452282 --> 32: 8591 37fe 8191 5f01 b601 90e0 0e94 4103 2110 2a94 21e0 821a 9108 8114 9104 71f7 + 1.452308 --> 32: e8c0 8436 11f0 8936 41f5 f801 37fe 07c0 6081 7181 8281 9381 0c5f 1f4f 08c0 6081 + 1.455454 --> 32: 7181 072e 000c 880b 990b 0e5f 1f4f f32d ff76 3f2e 97ff 09c0 9095 8095 7095 6195 + 1.457980 --> 32: 7f4f 8f4f 9f4f f068 3f2e 2ae0 30e0 a301 0e94 7d03 882e 8618 45c0 8537 31f4 232d + 1.460725 --> 32: 2f7e b22e 2ae0 30e0 25c0 932d 997f b92e 8f36 c1f0 18f4 8835 79f0 b5c0 8037 19f0 + 1.463464 --> 32: 8837 21f0 b0c0 e92f e061 be2e b4fe 0dc0 fb2d f460 bf2e 09c0 34fe 0ac0 292f 2660 + 1.466235 --> 5: b22e 06c0 20 + 1.513447 <-- 2: 1410 + + 1.513715 --> 4: 5580 0220 + 1.516432 <-- 2: 1410 + + 1.516636 --> 32: 6401 0046 28e0 30e0 05c0 20e1 30e0 02c0 20e1 32e0 f801 b7fe 07c0 6081 7181 8281 + 1.516663 --> 32: 9381 0c5f 1f4f 06c0 6081 7181 80e0 90e0 0e5f 1f4f a301 0e94 7d03 882e 8618 fb2d + 1.516831 --> 32: ff77 3f2e 36fe 0dc0 232d 2e7f a22e 8914 58f4 34fe 0bc0 32fc 09c0 832d 8e7e a82e + 1.516877 --> 32: 05c0 b82c a32c 03c0 b82c 01c0 b92c a4fe 0fc0 fe01 e80d f11d 8081 8033 21f4 9a2d + 1.519644 --> 32: 997e a92e 09c0 a2fe 06c0 b394 b394 04c0 8a2d 8678 09f0 b394 a3fc 11c0 a0fe 06c0 + 1.522490 --> 32: b214 88f4 280c 922c 9b18 0ec0 b214 60f4 b601 80e2 90e0 0e94 4103 b394 f7cf b214 + 1.525257 --> 32: 18f4 2b18 02c0 982c 212c a4fe 10c0 b601 80e3 90e0 0e94 4103 a2fe 17c0 a1fc 03c0 + 1.527986 --> 32: 88e7 90e0 02c0 88e5 90e0 b601 0cc0 8a2d 8678 59f0 a1fe 02c0 8be2 01c0 80e2 a7fc + 1.530784 --> 5: 8de2 b601 20 + 1.577915 <-- 2: 1410 + + 1.578186 --> 4: 5500 0320 + 1.580952 <-- 2: 1410 + + 1.581190 --> 32: 6401 0046 90e0 0e94 4103 8914 38f4 b601 80e3 90e0 0e94 4103 9a94 f7cf 8a94 f301 + 1.581212 --> 32: e80d f11d 8081 b601 90e0 0e94 4103 8110 f5cf 2220 09f4 42ce b601 80e2 90e0 0e94 + 1.581358 --> 32: 4103 2a94 f6cf f601 8681 9781 02c0 8fef 9fef 2b96 e2e1 0c94 f703 fc01 0590 6150 + 1.581385 --> 32: 7040 0110 d8f7 8095 9095 8e0f 9f1f 0895 fc01 6150 7040 0190 0110 d8f7 8095 9095 + 1.584265 --> 32: 8e0f 9f1f 0895 0f93 1f93 cf93 df93 fb01 2381 21fd 03c0 8fef 9fef 2cc0 22ff 16c0 + 1.587011 --> 32: 4681 5781 2481 3581 4217 5307 44f4 a081 b181 9d01 2f5f 3f4f 3183 2083 8c93 2681 + 1.589734 --> 32: 3781 2f5f 3f4f 3783 2683 14c0 8b01 ec01 fb01 0084 f185 e02d 0995 892b e1f6 d801 + 1.592493 --> 32: 1696 8d91 9c91 1797 0196 1796 9c93 8e93 1697 ce01 df91 cf91 1f91 0f91 0895 fa01 + 1.595249 --> 5: aa27 2830 20 + 1.642464 <-- 2: 1410 + + 1.642718 --> 4: 5580 0320 + 1.645473 <-- 2: 1410 + + 1.645679 --> 32: 6401 0046 51f1 2031 81f1 e894 6f93 6e7f 6e5f 7f4f 8f4f 9f4f af4f b1e0 3ed0 b4e0 + 1.645701 --> 32: 3cd0 670f 781f 891f 9a1f a11d 680f 791f 8a1f 911d a11d 6a0f 711d 811d 911d a11d + 1.645848 --> 32: 20d0 09f4 6894 3f91 2ae0 269f 1124 3019 305d 3193 def6 cf01 0895 462f 4770 405d + 1.645887 --> 32: 4193 b3e0 0fd0 c9f7 f6cf 462f 4f70 405d 4a33 18f0 495d 31fd 4052 4193 02d0 a9f7 + 1.648691 --> 32: eacf b4e0 a695 9795 8795 7795 6795 ba95 c9f7 0097 6105 7105 0895 9b01 ac01 0a2e + 1.651486 --> 32: 0694 5795 4795 3795 2795 ba95 c9f7 620f 731f 841f 951f a01d 0895 2f92 3f92 4f92 + 1.654229 --> 32: 5f92 6f92 7f92 8f92 9f92 af92 bf92 cf92 df92 ef92 ff92 0f93 1f93 cf93 df93 cdb7 + 1.657068 --> 32: deb7 ca1b db0b 0fb6 f894 debf 0fbe cdbf 0994 2a88 3988 4888 5f84 6e84 7d84 8c84 + 1.659779 --> 5: 9b84 aa84 20 + 1.706941 <-- 2: 1410 + + 1.707172 --> 4: 5500 0420 + 1.709845 <-- 2: 1410 + + 1.710064 --> 32: 6401 0046 b984 c884 df80 ee80 fd80 0c81 1b81 aa81 b981 ce0f d11d 0fb6 f894 debf + 1.710085 --> 32: 0fbe cdbf ed01 0895 f894 ffcf 202d 3e20 5800 0000 0002 0000 0000 5d00 0000 0000 + 1.710260 --> 32: 0000 0002 0000 0000 5d00 0000 0000 5357 3220 7072 6573 7365 6400 2530 3478 3a20 + 1.710304 --> 32: 4865 6c6c 6f20 776f 726c 6425 7320 2025 3132 730d 0000 ffff ffff ffff ffff ffff + 1.713085 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 1.715997 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 1.718639 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 1.721439 --> 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 1.724135 --> 5: ffff ffff 20 + 1.771467 <-- 2: 1410 + + 1.772647 --> 4: 5500 0020 + 1.775440 <-- 2: 1410 + + 1.775659 --> 5: 7401 0046 20 + 1.779386 <-- 32: 140c 943e 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b + 1.781924 <-- 32: 000c 945b 000c 945b 000c 945b 000c 945b 000c 945b 000c 94ad 000c 945b 000c 945b + 1.784614 <-- 32: 000c 945b 000c 945b 000c 945b 000c 945b 000c 947d 000c 945b 000c 945b 000c 945b + 1.787364 <-- 32: 000c 945b 000c 945b 000c 945b 000c 945b 000c 949c 000c 945b 000c 945b 0011 241f + 1.790456 <-- 32: becf efd0 e1de bfcd bf11 e0a0 e0b1 e0e8 e2f8 e002 c005 900d 92aa 34b1 07d9 f721 + 1.792965 <-- 32: e0aa e4b1 e001 c01d 92a2 35b2 07e1 f70e 94d1 000c 9412 040c 9400 000f 931f 93cf + 1.795688 <-- 32: 93c8 2f8b 018a 3019 f48d e00e 945d 0080 91c0 0085 fffc cf80 914e 0190 914f 0108 + 1.798432 <-- 32: 1719 0719 f4c0 93c6 0002 c0c0 93ce 0080 e090 e0cf 911f 910f 9108 951f 920f 920f + 1.800632 <-- 2: b610 + + 1.800878 --> 4: 5580 0020 + 1.803619 <-- 2: 1410 + + 1.803814 --> 5: 7401 0046 20 + 1.807479 <-- 32: 140f 9211 248f 939f 93ef 93ff 9398 b188 e089 2788 b980 91c6 0080 93ce 00e0 e0f1 + 1.809984 <-- 32: e090 e290 8384 83ff 91ef 919f 918f 910f 900f be0f 901f 9018 951f 920f 920f b60f + 1.812844 <-- 32: 9211 248f 9380 91ce 0080 3209 f442 9a8f 910f 900f be0f 901f 9018 951f 920f 920f + 1.815639 <-- 32: b60f 9211 242f 938f 939f 9380 914a 0190 914b 0101 9690 934b 0180 934a 0188 3e93 + 1.818304 <-- 32: 4040 f098 b180 e189 2788 b910 924b 0110 924a 019f 918f 912f 910f 900f be0f 901f + 1.821082 <-- 32: 9018 958c e187 b98c e388 b98a e080 9381 008c ed95 e090 9389 0080 9388 0082 e080 + 1.823911 <-- 32: 936f 0080 93c0 0038 e930 93c1 0026 e020 93c2 0010 92c5 009c e090 93c4 0080 93c8 + 1.826612 <-- 32: 0030 93c9 0020 93ca 0010 92cd 0090 93cc 0084 e191 e090 934f 0180 934e 0186 e091 + 1.828744 <-- 2: e010 + + 1.828876 --> 4: 5500 0120 + 1.831444 <-- 2: 1410 + + 1.831620 --> 5: 7401 0046 20 + 1.835129 <-- 32: 1490 9351 0180 9350 0110 9200 0178 9480 e090 e0c0 e0d1 e00e e211 e035 9b03 c028 + 1.837845 <-- 32: e431 e002 c022 e231 e07c 014f efe4 1af4 0a3f 932f 93df 93cf 939f 938f 931f 930f + 1.840579 <-- 32: 930e 9434 018d b79e b708 960f b6f8 949e bf0f be8d bf35 9b42 988f e295 e701 97f1 + 1.843432 <-- 32: f700 c000 00c7 01d9 cfa0 e0b0 e0ea e3f1 e00c 94eb 03ae 014b 5f5f 4ffa 0161 9171 + 1.846426 <-- 32: 91af 0180 914e 0190 914f 010e 944a 01e2 e00c 9407 04ab e0b0 e0e0 e5f1 e00c 94db + 1.848837 <-- 32: 036c 017b 018a 01fc 0117 8216 8283 8181 ffcc c1ce 0101 963c 01f6 0193 81f7 0193 + 1.851649 <-- 32: fd85 9193 ff81 917f 0188 2309 f4ba c185 3239 f493 fd85 9193 ff81 917f 0185 3229 + 1.854442 <-- 32: f4b6 0190 e00e 9441 03e7 cf91 2c21 2c31 2cff e1f3 15d8 f08b 3279 f038 f480 3279 + 1.856623 <-- 2: f010 + + 1.856748 --> 4: 5580 0120 + 1.859363 <-- 2: 1410 + + 1.859447 --> 5: 7401 0046 20 + 1.862911 <-- 32: 1483 32a1 f423 2d20 611d c08d 3261 f080 3369 f423 2d21 6016 c083 2d82 6038 2ee3 + 1.865610 <-- 32: 2de4 603e 2e2a c0f3 2df8 601d c037 fc2d c020 ed28 0f2a 3040 f08e 32b9 f436 fc81 + 1.868409 <-- 32: c123 2d20 6432 2e19 c036 fe06 c08a e098 9e20 0d11 2492 2e11 c0ea e02e 9e20 0d11 + 1.871210 <-- 32: 2422 2ef3 2df0 623f 2e08 c08c 3621 f483 2d80 6838 2e02 c088 3641 f4f7 0193 fd85 + 1.873963 <-- 32: 9193 ff81 917f 0181 11b3 cf98 2f9f 7d95 5493 3028 f40c 5f1f 4f9f e399 830d c083 + 1.876709 <-- 32: 3631 f083 3771 f083 3509 f059 c021 c0f8 0180 8189 830e 5f1f 4f88 2483 9491 2c53 + 1.879571 <-- 32: 0113 c028 01f2 e04f 0e51 1cf8 01a0 80b1 8036 fe03 c069 2d70 e002 c06f ef7f efc5 + 1.882458 <-- 32: 010e 9436 034c 0182 01f3 2dff 773f 2e16 c028 0122 e042 0e51 1cf8 01a0 80b1 8036 + 1.884340 <-- 2: fe10 + + 1.884567 --> 4: 5500 0220 + 1.887255 <-- 2: 1410 + + 1.887443 --> 5: 7401 0046 20 + 1.890818 <-- 32: 1403 c069 2d70 e002 c06f ef7f efc5 010e 942b 034c 01f3 2df0 683f 2e82 0133 fc1b + 1.893598 <-- 32: c082 2d90 e088 1699 06b0 f4b6 0180 e290 e00e 9441 032a 94f4 cff5 0137 fc85 9137 + 1.896393 <-- 32: fe81 915f 01b6 0190 e00e 9441 0321 102a 9421 e082 1a91 0881 1491 0471 f7e8 c084 + 1.899280 <-- 32: 3611 f089 3641 f5f8 0137 fe07 c060 8171 8182 8193 810c 5f1f 4f08 c060 8171 8107 + 1.902001 <-- 32: 2e00 0c88 0b99 0b0e 5f1f 4ff3 2dff 763f 2e97 ff09 c090 9580 9570 9561 957f 4f8f + 1.904757 <-- 32: 4f9f 4ff0 683f 2e2a e030 e0a3 010e 947d 0388 2e86 1845 c085 3731 f423 2d2f 7eb2 + 1.907577 <-- 32: 2e2a e030 e025 c093 2d99 7fb9 2e8f 36c1 f018 f488 3579 f0b5 c080 3719 f088 3721 + 1.910469 <-- 32: f0b0 c0e9 2fe0 61be 2eb4 fe0d c0fb 2df4 60bf 2e09 c034 fe0a c029 2f26 60b2 2e06 + 1.912524 <-- 2: c010 + + 1.912815 --> 4: 5580 0220 + 1.915611 <-- 2: 1410 + + 1.915811 --> 5: 7401 0046 20 + 1.919244 <-- 32: 1428 e030 e005 c020 e130 e002 c020 e132 e0f8 01b7 fe07 c060 8171 8182 8193 810c + 1.921988 <-- 32: 5f1f 4f06 c060 8171 8180 e090 e00e 5f1f 4fa3 010e 947d 0388 2e86 18fb 2dff 773f + 1.924734 <-- 32: 2e36 fe0d c023 2d2e 7fa2 2e89 1458 f434 fe0b c032 fc09 c083 2d8e 7ea8 2e05 c0b8 + 1.927531 <-- 32: 2ca3 2c03 c0b8 2c01 c0b9 2ca4 fe0f c0fe 01e8 0df1 1d80 8180 3321 f49a 2d99 7ea9 + 1.930309 <-- 32: 2e09 c0a2 fe06 c0b3 94b3 9404 c08a 2d86 7809 f0b3 94a3 fc11 c0a0 fe06 c0b2 1488 + 1.933091 <-- 32: f428 0c92 2c9b 180e c0b2 1460 f4b6 0180 e290 e00e 9441 03b3 94f7 cfb2 1418 f42b + 1.935886 <-- 32: 1802 c098 2c21 2ca4 fe10 c0b6 0180 e390 e00e 9441 03a2 fe17 c0a1 fc03 c088 e790 + 1.938647 <-- 32: e002 c088 e590 e0b6 010c c08a 2d86 7859 f0a1 fe02 c08b e201 c080 e2a7 fc8d e2b6 + 1.940863 <-- 2: 0110 + + 1.941071 --> 4: 5500 0320 + 1.943869 <-- 2: 1410 + + 1.944088 --> 5: 7401 0046 20 + 1.947433 <-- 32: 1490 e00e 9441 0389 1438 f4b6 0180 e390 e00e 9441 039a 94f7 cf8a 94f3 01e8 0df1 + 1.950256 <-- 32: 1d80 81b6 0190 e00e 9441 0381 10f5 cf22 2009 f442 ceb6 0180 e290 e00e 9441 032a + 1.953054 <-- 32: 94f6 cff6 0186 8197 8102 c08f ef9f ef2b 96e2 e10c 94f7 03fc 0105 9061 5070 4001 + 1.955732 <-- 32: 10d8 f780 9590 958e 0f9f 1f08 95fc 0161 5070 4001 9001 10d8 f780 9590 958e 0f9f + 1.958565 <-- 32: 1f08 950f 931f 93cf 93df 93fb 0123 8121 fd03 c08f ef9f ef2c c022 ff16 c046 8157 + 1.961369 <-- 32: 8124 8135 8142 1753 0744 f4a0 81b1 819d 012f 5f3f 4f31 8320 838c 9326 8137 812f + 1.964157 <-- 32: 5f3f 4f37 8326 8314 c08b 01ec 01fb 0100 84f1 85e0 2d09 9589 2be1 f6d8 0116 968d + 1.966902 <-- 32: 919c 9117 9701 9617 969c 938e 9316 97ce 01df 91cf 911f 910f 9108 95fa 01aa 2728 + 1.969047 <-- 2: 3010 + + 1.969248 --> 4: 5580 0320 + 1.972047 <-- 2: 1410 + + 1.972246 --> 5: 7401 0046 20 + 1.975748 <-- 32: 1451 f120 3181 f1e8 946f 936e 7f6e 5f7f 4f8f 4f9f 4faf 4fb1 e03e d0b4 e03c d067 + 1.978498 <-- 32: 0f78 1f89 1f9a 1fa1 1d68 0f79 1f8a 1f91 1da1 1d6a 0f71 1d81 1d91 1da1 1d20 d009 + 1.981514 <-- 32: f468 943f 912a e026 9f11 2430 1930 5d31 93de f6cf 0108 9546 2f47 7040 5d41 93b3 + 1.983891 <-- 32: e00f d0c9 f7f6 cf46 2f4f 7040 5d4a 3318 f049 5d31 fd40 5241 9302 d0a9 f7ea cfb4 + 1.986799 <-- 32: e0a6 9597 9587 9577 9567 95ba 95c9 f700 9761 0571 0508 959b 01ac 010a 2e06 9457 + 1.989512 <-- 32: 9547 9537 9527 95ba 95c9 f762 0f73 1f84 1f95 1fa0 1d08 952f 923f 924f 925f 926f + 1.992260 <-- 32: 927f 928f 929f 92af 92bf 92cf 92df 92ef 92ff 920f 931f 93cf 93df 93cd b7de b7ca + 1.995029 <-- 32: 1bdb 0b0f b6f8 94de bf0f becd bf09 942a 8839 8848 885f 846e 847d 848c 849b 84aa + 1.997163 <-- 2: 8410 + + 1.997338 --> 4: 5500 0420 + 2.000161 <-- 2: 1410 + + 2.000367 --> 5: 7401 0046 20 + 2.003803 <-- 32: 14b9 84c8 84df 80ee 80fd 800c 811b 81aa 81b9 81ce 0fd1 1d0f b6f8 94de bf0f becd + 2.006477 <-- 32: bfed 0108 95f8 94ff cf20 2d3e 2058 0000 0000 0200 0000 005d 0000 0000 0000 0000 + 2.009429 <-- 32: 0200 0000 005d 0000 0000 0053 5732 2070 7265 7373 6564 0025 3034 783a 2048 656c + 2.012149 <-- 32: 6c6f 2077 6f72 6c64 2573 2020 2531 3273 0d00 00ff ffff ffff ffff ffff ffff ffff + 2.014971 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 2.017659 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 2.020387 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 2.023167 <-- 32: ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff + 2.025368 <-- 2: ff10 + + 2.025949 --> 6: 5650 0000 0020 + 2.028775 <-- 3: 1400 10 + 2.028918 --> 6: 5650 0000 0020 + 2.031848 <-- 3: 1400 10 + 2.031977 --> 6: 5650 0000 0020 + 2.034973 <-- 3: 1400 10 + 2.035141 --> 6: 5658 0800 0020 + 2.038215 <-- 3: 1400 10 + 2.038413 --> 6: 5658 0800 0020 + 2.041454 <-- 3: 1400 10 + 2.041646 --> 6: 5658 0800 0020 + 2.044533 <-- 3: 1400 10 + 2.044682 --> 6: 5650 0800 0020 + 2.047749 <-- 3: 1400 10 + 2.047987 --> 6: 5650 0800 0020 + 2.050921 <-- 3: 1400 10 + 2.051154 --> 6: 5650 0800 0020 + 2.054178 <-- 3: 1400 10 + + 2.054415 --> 2: 5120 + 2.056864 <-- 2: 1410 diff --git a/software/nano-1284/bootloader-arduino/release/2024-09-05_120945/bootloader-arduino_nano-1284.elf b/software/nano-1284/bootloader-arduino/release/2024-09-05_120945/bootloader-arduino_nano-1284.elf new file mode 100755 index 0000000..955f52f Binary files /dev/null and b/software/nano-1284/bootloader-arduino/release/2024-09-05_120945/bootloader-arduino_nano-1284.elf differ diff --git a/software/nano-1284/bootloader-arduino/release/2024-09-05_120945/bootloader-arduino_nano-1284.hex b/software/nano-1284/bootloader-arduino/release/2024-09-05_120945/bootloader-arduino_nano-1284.hex new file mode 100644 index 0000000..4db935b --- /dev/null +++ b/software/nano-1284/bootloader-arduino/release/2024-09-05_120945/bootloader-arduino_nano-1284.hex @@ -0,0 +1,106 @@ +:020000021000EC +:10E000000C9451F00C9463F00C9463F00C9463F056 +:10E010000C9463F00C9463F00C9463F00C9463F034 +:10E020000C9463F00C9463F00C9463F00C9463F024 +:10E030000C9463F00C9463F00C9463F00C9463F014 +:10E040000C9463F00C9463F00C9463F00C9463F004 +:10E050000C9463F00C9463F00C9463F00C9463F0F4 +:10E060000C9463F00C9463F00C9463F00C9463F0E4 +:10E070000C9463F00C9463F00C9463F00C9463F0D4 +:10E080000C9463F00C9463F00C9463F031323A30EA +:10E09000393A34350053657020203520323032341F +:10E0A000000011241FBECFEFD0E4DEBFCDBF22E0C1 +:10E0B000A0E0B1E001C01D92AC30B207E1F70E94D0 +:10E0C00048F10C9436F30C9400F09091C00095FF49 +:10E0D000FCCF8093C6000895CF93982F85958595A2 +:10E0E00085958595805D9F709A3014F0C7E501C0D5 +:10E0F000C0E3C90F0E9465F08C2FCF910C9465F09E +:10E10000CF92DF92EF92FF92C12CD12C76018091B9 +:10E11000C00087FD15C08FEFC81AD80AE80AF80AB0 +:10E1200081EBC81681E7D8068BE0E806F10478F3A6 +:10E1300017B818B8E0910001F09101010995E7CFF7 +:10E140008091C600FF90EF90DF90CF900895CF931D +:10E150000E9480F0C82F0E9465F0C13614F089EA51 +:10E1600003C0C0331CF080ED8C0F01C08C2FCF9109 +:10E170000895CF930E94A7F0C82F0E94A7F090E1C6 +:10E18000C99F800D1124CF910895CF93C82FCC2320 +:10E1900021F00E9480F0C150FACFCF910895CF9323 +:10E1A000C82F0E9480F0803251F484E10E9465F013 +:10E1B0008C2F0E9465F080E1CF910C9465F08091E6 +:10E1C00002018F5F80930201853041F417B818B8BF +:10E1D000E0910001F0910101CF910994CF91089550 +:10E1E0000E9480F0803231F484E10E9465F080E189 +:10E1F0000C9465F0809102018F5F8093020185305D +:10E2000039F417B818B8E0910001F09101010994B0 +:10E210000895CF93DF9300D000D0CDB7DEB7198239 +:10E220001A821B821C8289819A81AB81BC818115F3 +:10E230009042A140B10580F48091C00087FD0CC0E0 +:10E2400089819A81AB81BC810196A11DB11D898311 +:10E250009A83AB83BC83E7CF0F900F900F900F9002 +:10E26000DF91CF910895CF93C82F429A0E9409F170 +:10E27000439A0E9409F118B8CC2341F0449A0E94B5 +:10E2800009F144980E9409F1C150F6CFCF91089549 +:10E29000000018B88CE987B982E08093C0008CE058 +:10E2A0008093C4001092C50088E18093C10086E08D +:10E2B0008093C20098E09093C9008093CA0084E0E4 +:10E2C0000E9433F103E011E0B1E1FB2E0E9480F0E7 +:10E2D000803309F447C0813319F50E9480F0803201 +:10E2E000B9F484E10E9465F081E40E9465F086E55E +:10E2F0000E9465F082E50E9465F080E20E9465F070 +:10E3000089E40E9465F083E50E9465F080E595C18F +:10E31000809102018F5F809302018530B9F69AC126 +:10E32000803439F40E9480F08638E0F00E9480F05A +:10E3300019C0813491F40E9480F0803811F481EF8B +:10E3400044C0813811F481E040C0823811F480E18A +:10E350003CC08839C9F583E038C0823431F484E1A7 +:10E360000E94C5F00E94F0F0B1CF853411F485E031 +:10E37000F7CF982F9D7F9035A9F3813599F3853597 +:10E3800049F40E9480F080930A020E9480F08093FA +:10E390000B02E8CF8635E1F40E9480F0803389F4E7 +:10E3A0000E9480F00E9480F0C82F0E9480F0C1116E +:10E3B00002C08EE10AC0C13011F487E906C085E0D1 +:10E3C00004C083E00E94C5F080E00E94CFF07ECFC1 +:10E3D000843609F0C5C00E9480F0809309020E9433 +:10E3E00080F080930802809107028E7F809307025D +:10E3F0000E9480F0853429F4809107028160809327 +:10E400000702C6E0D1E06E012091080230910902B6 +:10E41000C601865091408217930730F40E9480F025 +:10E42000F60181936F01F0CF0E9480F0803209F0F5 +:10E430000AC18091070280FF2DC080910A0290914D +:10E440000B02880F991F90930B0280930A02E6E05B +:10E45000F1E02091080230910902CF0186509140ED +:10E460008217930708F07AC0F999FECF80910A02CB +:10E4700090910B0292BD81BD819180BDFA9AF99A6B +:10E4800080910A0290910B02019690930B02809367 +:10E490000A02DFCF80910B0287FF02C01BBF01C0C1 +:10E4A0001BBE80910A0290910B02880F991F9093D6 +:10E4B0000B0280930A028091080280FF09C08091BC +:10E4C0000802909109020196909309028093080234 +:10E4D000F894A0910A02B0910B02F999FECF07B609 +:10E4E00000FCFDCF429A4D01A12CB12CF401A09269 +:10E4F0005B0000935700E89507B600FCFDCF4298FB +:10E5000020E030E0AD01420F531F60E070E08981F0 +:10E5100090E0982F8827E8818E0F911D0C01FA0159 +:10E5200060935B0010935700E89511242E5F3F4FD6 +:10E5300022962115F1E03F0729F73093050120933A +:10E54000040185E0F401A0925B0080935700E895F8 +:10E5500007B600FCFDCFF0925700E89584E16DC04E +:10E56000843709F05AC00E9480F0809309020E940B +:10E5700080F08093080280910A0290910B02880F2C +:10E58000991F90930B0280930A020E9480F0909151 +:10E590000702853411F4916001C09E7F90930702B9 +:10E5A0000E9480F0803209F04AC084E10E9465F048 +:10E5B000C0E0D0E08091080290910902C817D90705 +:10E5C00008F03DC08091070280FF0BC0F999FECF93 +:10E5D00080910A0290910B0292BD81BDF89A80B59C +:10E5E0000FC0E0910A02F0910B0281FD02C08491FC +:10E5F00007C0CF01A0E0B0E01196ABBFFC0187914E +:10E600000E9465F080910A0290910B02019690930E +:10E610000B0280930A022196CDCF853719F50E940F +:10E6200080F0803281F484E10E9465F08EE10E94E6 +:10E6300065F087E90E9465F085E00E9465F080E161 +:10E640000E9465F043CE809102018F5F80930201AA +:10E65000853009F417B818B8E0910001F091010174 +:10E66000099534CE863709F031CEAECEF894FFCF7F +:040000031000E00009 +:00000001FF diff --git a/software/nano-1284/bootloader-arduino/src/main.c b/software/nano-1284/bootloader-arduino/src/main.c new file mode 100644 index 0000000..3162adc --- /dev/null +++ b/software/nano-1284/bootloader-arduino/src/main.c @@ -0,0 +1,520 @@ +/*************************************************************************************************/ +/* Serial Bootloader for Atmel megaAVR Controllers */ +/* */ +/* Source-code taken from: */ +/* https://github.com/arduino/ArduinoCore-avr/blob/master/bootloaders/atmega/ATmegaBOOT_168.c */ +/* Branch@hash: master@321fca0b */ +/* */ +/* Licence can be viewed at http://www.fsf.org/licenses/gpl.txt */ +/* */ +/*************************************************************************************************/ + +#include + +#include +#include +#include +#include +#include +// #include + +// #define DEBUG_UART1 +#ifdef DEBUG_UART1 + #include +#endif + +// after this many errors give up and launch application +#define MAX_ERROR_COUNT 5 + +#define HW_VER 0xF1 +#define SW_MAJOR 0x01 +#define SW_MINOR 0x10 + +// onboard LED is used to indicate, that the bootloader was entered +#define SET_LED_RED (PORTC |= (1 << PC2)) +#define CLR_LED_RED (PORTC &= ~(1 << PC2)) +#define SET_LED_ORANGE (PORTC |= (1 << PC3)) +#define CLR_LED_ORANGE (PORTC &= ~(1 << PC3)) +#define SET_LED_GREEN (PORTC |= (1 << PC4)) +#define CLR_LED_GREEN (PORTC &= ~(1 << PC4)) + +// function prototypes +void putch(char); +char getch(void); +void getNch(uint8_t); +void byte_response(uint8_t); +void nothing_response(void); +char gethex(void); +void puthex(char); +void flash_led(uint8_t); + +volatile const char DATE [] PROGMEM = __DATE__; +volatile const char TIME [] PROGMEM = __TIME__; + +#ifdef DEBUG_UART1 + int uart_putchar(char c, FILE *stream) { + if (c == '\n') { + uart_putchar('\r', stream); + } + loop_until_bit_is_set(UCSR1A, UDRE1); + UDR1 = c; + return 0; + } + + static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); +#endif + +// some variables +union address_union { + uint16_t word; + uint8_t byte[2]; +} address; + +union length_union { + uint16_t word; + uint8_t byte[2]; +} length; + +struct flags_struct { + unsigned eeprom : 1; + unsigned rampz : 1; +} flags; + +uint8_t buff[SPM_PAGESIZE + 1]; +// uint8_t address_high; +// uint8_t pagesz=0x80; + +uint16_t i; +uint8_t bootuart = 0; + +uint8_t error_count = 0; + +void (*app_start)(void) = 0x0000; + +int main () { + uint8_t ch, ch2; + uint16_t w; + + #ifdef WATCHDOG_MODS + ch = MCUSR; + MCUSR = 0; + + WDTCSR |= _BV(WDCE) | _BV(WDE); + WDTCSR = 0; + + // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot. + if (! (ch & _BV(EXTRF))) // if its a not an external reset... + app_start(); // skip bootloader + #else + asm volatile("nop\n\t"); + #endif + + // LED ports output and off, ensure that Q1 (battery power) on (PC7) + PORTC = 0; + DDRC = (1 << PC7) | (1 << PC4) | (1 << PC3) |(1 << PC2); + + + #ifdef DOUBLE_SPEED + UCSR0A = (1 << U2X0); // Double speed mode USART0 + UBRR0L = (uint8_t)(F_CPU / (BAUD_RATE *8L) - 1); + UBRR0H = (F_CPU / (BAUD_RATE * 8L) - 1) >> 8; + #ifdef DEBUG_UART1 + UCSR1A = (1 << U2X1); // Double speed mode USART0 + UBRR1L = (uint8_t)(F_CPU / (BAUD_RATE *8L) - 1); + UBRR1H = (F_CPU / (BAUD_RATE * 8L) - 1) >> 8; + #endif + #else + UBRR0L = (uint8_t)(F_CPU / (BAUD_RATE * 16L) - 1); + UBRR0H = (F_CPU / (BAUD_RATE*16L)-1) >> 8; + #ifdef DEBUG_UART1 + UBRR1L = (uint8_t)(F_CPU / (BAUD_RATE * 16L) - 1); + UBRR1H = (F_CPU / (BAUD_RATE*16L)-1) >> 8; + #endif + #endif + + UCSR0B = (1< 0x85) getch(); + nothing_response(); + + // ***************************** + // AVR ISP/STK500 board requests + // ***************************** + + } else if (ch == 'A') { // 0x41 + ch2 = getch(); + if (ch2 == 0x80) { + byte_response(HW_VER); // Hardware version + } else if (ch2 == 0x81) { + byte_response(SW_MAJOR); // Software major version + } else if(ch2 == 0x82) { + byte_response(SW_MINOR); // Software minor version + } else if(ch2==0x98) { + byte_response(0x03); // Unknown but seems to be required by avr studio 3.56 + } else { + byte_response(0x00); // Covers various unnecessary responses we don't care about + } + + } else if (ch == 'B') { // B: 0x42 + // Device Parameters DON'T CARE, DEVICE IS FIXED + getNch(20); + nothing_response(); + + + } else if (ch == 'E') { // E: 0x45 + // Parallel programming stuff DON'T CARE + getNch(5); + nothing_response(); + + } else if (ch == 'P' || ch == 'R') { // P: 0x50, R: 0x52 + // P: Enter programming mode + // R: Erase device, don't care as we will erase one page at a time anyway. + nothing_response(); + + } else if (ch == 'Q') { // Q: 0x51 + // Leave programming mode + nothing_response(); + #ifdef WATCHDOG_MODS + // autoreset via watchdog (sneaky!) + WDTCSR = _BV(WDE); + while (1); // 16 ms + #endif + + } else if(ch == 'U') { // U: 0x55 + // Set address, little endian. EEPROM in bytes, FLASH in words + // Perhaps extra address bytes may be added in future to support > 128kB FLASH. + // This might explain why little endian was used here, big endian used everywhere else. + address.byte[0] = getch(); + address.byte[1] = getch(); + nothing_response(); + + + } else if (ch == 'V') { // V: 0x56 + // Universal SPI programming command, disabled. Would be used for fuses and lock bits. + if (getch() == 0x30) { + getch(); + ch = getch(); + getch(); + if (ch == 0) { + byte_response(SIGNATURE_0); + } else if (ch == 1) { + byte_response(SIGNATURE_1); + } else { + byte_response(SIGNATURE_2); + } + } else { + getNch(3); + byte_response(0x00); + } + + } else if (ch == 'd') { // d: 0x64 + // Write memory, length is big endian and is in bytes + length.byte[1] = getch(); + length.byte[0] = getch(); + flags.eeprom = 0; + if (getch() == 'E') { + flags.eeprom = 1; + } + for (w = 0; w < length.word; w++) { + // Store data in buffer, can't keep up with serial data stream whilst programming pages + buff[w] = getch(); + } + if (getch() == ' ') { + if (flags.eeprom) { + // Write to EEPROM one byte at a time + address.word <<= 1; + for(w = 0; w < length.word; w++) { + while(EECR & (1< 127) { + //Only possible with m128, m256 will need 3rd address byte. FIXME + RAMPZ = 0x01; + } else { + RAMPZ = 0x00; + } + #endif + + // address * 2 -> byte location + address.word = address.word << 1; + if ((length.byte[0] & 0x01)) { + // Even up an odd number of bytes + length.word++; + } + cli(); + + uint16_t addr = address.word; + #ifdef DEBUG_UART1 + printf("Programming: address=0x%04x length=0x%04x\n", addr, length.word); + printf(" eeprom_busy_wait() ..."); + #endif + eeprom_busy_wait(); + boot_spm_busy_wait(); + #ifdef DEBUG_UART1 + printf("done\n"); + printf(" boot_page_erase(0x%04x)...", address.word); + #endif + SET_LED_RED; + boot_page_erase(addr); + boot_spm_busy_wait (); + CLR_LED_RED; + #ifdef DEBUG_UART1 + printf("done\n"); + printf(" boot_page_fill(0x%04x, ...): ", address.word); + #endif + for (i = 0; i < SPM_PAGESIZE; i += 2) { + uint16_t w = buff[i] + (buff[i + 1] << 8); + #ifdef DEBUG_UART1 + printf("."); + #endif + boot_page_fill(addr + i, w); + } + #ifdef DEBUG_UART1 + printf("\n boot_page_write(0x%04x)...", address.word); + #endif + boot_page_write(addr); + boot_spm_busy_wait(); + #ifdef DEBUG_UART1 + printf("done\n"); + printf(" boot_rww_enable()\n"); + #endif + boot_rww_enable(); + } + putch(0x14); + putch(0x10); + + } else { + if (++error_count == MAX_ERROR_COUNT) + DDRC = 0; PORTC = 0; + app_start(); + } + + } else if (ch == 't') { // t: 0x74 + // Read memory block mode, length is big endian. */ + length.byte[1] = getch(); + length.byte[0] = getch(); + // if (address.word>0x7FFF) flags.rampz = 1; // No go with m256, FIXME + // else flags.rampz = 0; + address.word = address.word << 1; // address * 2 -> byte location + if (getch() == 'E') { + flags.eeprom = 1; + } else { + flags.eeprom = 0; + } + if (getch() == ' ') { + // Command terminator + putch(0x14); + for (w = 0; w < length.word; w++) { + // Can handle odd and even lengths okay + if (flags.eeprom) { // Byte access EEPROM read + while(EECR & (1<= 'a') { + return (a - 'a' + 0x0a); + } else if (a >= '0') { + return (a - '0'); + } + return a; +} + + +char gethex () { + return (gethexnib() << 4) + gethexnib(); +} + + +void puthex (char ch) { + char ah; + + ah = ch >> 4; + if(ah >= 0x0a) { + ah = ah - 0x0a + 'a'; + } else { + ah += '0'; + } + + ch &= 0x0f; + if(ch >= 0x0a) { + ch = ch - 0x0a + 'a'; + } else { + ch += '0'; + } + + putch(ah); + putch(ch); +} + + +void putch (char ch) { + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = ch; +} + + +char getch () { + uint32_t count = 0; + while( !(UCSR0A & _BV(RXC0)) ) { + count++; + if (count > MAX_TIME_COUNT) { + DDRC = 0; PORTC = 0; + app_start(); + } + } + return UDR0; +} + + +void getNch (uint8_t count) { + while(count--) { + getch(); + } +} + + +void byte_response (uint8_t val) { + if (getch() == ' ') { + putch(0x14); + putch(val); + putch(0x10); + } else if (++error_count == MAX_ERROR_COUNT) { + DDRC = 0; PORTC = 0; + app_start(); + } +} + +void nothing_response () { + if (getch() == ' ') { + putch(0x14); + putch(0x10); + } else if (++error_count == MAX_ERROR_COUNT) { + DDRC = 0; PORTC = 0; + app_start(); + } +} + +void delay () { + // app. 200ms + for (volatile uint32_t timer = 0; timer < 0x12000; timer++) { + if (UCSR0A & _BV(RXC0)) { + return; + } + } +} + +void flash_led (uint8_t count) { + SET_LED_RED; + delay(); + SET_LED_ORANGE; + delay(); + PORTC = 0; + + while (count--) { + SET_LED_GREEN; + delay(); + CLR_LED_GREEN; + delay(); + } +}