"defines": [],
"compilerPath": "/usr/bin/avr-gcc",
"compilerArgs": [
- "-mmcu=atmega644p",
+ "-mmcu=atmega1284p",
"-Os",
"-DF_CPU=12000000",
"-DBAUD_RATE=115200",
-#.PHONY: all info flash picocom clean
-#$(shell mkdir -p dist >/dev/null)
-#$(shell mkdir -p build >/dev/null)
-#$(shell mkdir -p sim >/dev/null)
-
-#NAME="bootloader-arduino_nano-644"
-#DEVICE="atmega644p"
-#SRC= $(wildcard src/*.c)
-#OBJ = $(SRC:src/%.c=build/%.o)
-#OBJ_SIM = $(SRC:src/%.c=sim/%.o)
-
-#CC= avr-gcc
-#CFLAGS_DEFINES= -DF_CPU=12000000 -DBAUD_RATE=115200 -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4'
-#LFLAGS_DEFINES= -DF_CPU=12000000
-#CFLAGS= -Wall -mmcu=$(DEVICE) -Os $(CFLAGS_DEFINES) -c
-#LFLAGS= -Wall -mmcu=$(DEVICE) -Os $(LFLAGS_DEFINES) -Wl,--section-start=.text=0xe000
-
-#CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -O1 $(CFLAGS_DEFINES) -g -c
-#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -O1 $(LFLAGS_DEFINES) -g -Wl,--section-start=.text=0xe000
-
.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-644"
+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_SIM_CPP = $(SRC:src/%.cpp=sim/build/%.o)
OBJ_SIM = $(OBJ_SIM_CPP:src/%.c=sim/build/%.o)
-DEVICE=atmega644p
+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=0xe000
+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=0xe000
+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
@avr-size --mcu=$(DEVICE) --format=avr dist/$(NAME).elf
.depend: $(SRC) $(HDR)
- $(CC) --mcu=$(DEVICE) -MM $(SRC) | sed --regexp-extended 's/^(.*\.o)\: src\/(.*)(\.cpp|\.c) (.*)/build\/\2\.o\: src\/\2\3 \4/g' > .depend
+ $(CC) -mmcu=$(DEVICE) -MM $(SRC) | sed --regexp-extended 's/^(.*\.o)\: src\/(.*)(\.cpp|\.c) (.*)/build\/\2\.o\: src\/\2\3 \4/g' > .depend
-include .depend
gdb: sim/$(NAME).elf
avr-gdb $<
-isp-644p:
- avrdude -c usbasp -p m644p
+isp-1284p:
+ avrdude -c usbasp -p m1284p
-isp-flash-644p: dist/$(NAME).elf all
- avrdude -c usbasp -p m644p -e -U flash:w:$<
+isp-flash-1284p: dist/$(NAME).elf all
+ avrdude -c usbasp -p m1284p -e -U flash:w:$<
-flash-644p: dist/$(NAME).elf all
- avrdude -c arduino -p m644p -P /dev/ttyUSB0 -b 115200 -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-644p:
- avrdude -c usbasp -p m644p -e
+isp-erase-1284p:
+ avrdude -c usbasp -p m1284p -e
-isp-fuse-644p:
- #avrdude -c usbasp -p m644p -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFF:m -U lock:w:0xFF:m
- #avrdude -c usbasp -p m644p -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m
- # LFUSE=0xEE -> startuptime 1K CLOCKS + 0ms -> 83us
- #avrdude -c usbasp -p m644p -U lfuse:w:0xEE:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m
+isp-fuse-1284p:
# LFUSE=0xE7 -> startuptime 16K CLOCKS + 4.1ms -> 5.4ms
- avrdude -c usbasp -p m644p -U lfuse:w:0xE7:m -U hfuse:w:0xD8:m -U efuse:w:0xFE:m -U lock:w:0xEF:m
+ 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
-# Arduino-Bootloader (STK500) für Nano-644
+# 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-644 Boards.
+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 Atmega644P (mit 64KiB Flash, davon die hinteren 8KiB für den Bootloader)
+* 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-644.elf](release/bootloader-arduino_nano-644.elf)
-* [release/bootloader-arduino_nano-644.hex](release/bootloader-arduino_nano-644.hex)
+* [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
UART-Schnittstelle (Option `-P`) und Name der ELF-Programmdatei (nach `flash:w:`) sind anzupassen...
```sh
-avrdude -c arduino -p m644p -P /dev/ttyUSB0 -b 115200 -e -U flash:w:programm.elf
+avrdude -c arduino -p m1284p -P /dev/ttyUSB0 -b 115200 -e -U flash:w:programm.elf
```
## Einbindung in die Arduino IDE
/usr/share/arduino/hardware/arduino/avr
```
-Dort im Unterordner `bootloaders` einen Ordner `atmeg644` anlegen und darin die Intel-Hex Datei des Bootloaders ablegen.
+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/atmega644
-cp dist/bootloader-arduino_nano-644.hex /usr/share/arduino/hardware/arduino/avr/bootloaders/atmega644/
+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:
```
#########################################################
-nano644.name=Nano-644
-
-nano644.vid.0=0x1a86
-nano644.pid.0=0x7522
-nano644.upload_port.0.vid=0x1a86
-nano644.upload_port.0.pid=0x7522
-
-nano644.upload.tool=avrdude
-nano644.upload.tool.default=avrdude
-nano644.upload.tool.network=arduino_ota
-nano644.upload.protocol=arduino
-nano644.upload.maximum_size=57344
-nano644.upload.maximum_data_size=4096
-nano644.upload.speed=115200
-
-nano644.bootloader.tool=avrdude
-nano644.bootloader.tool.default=avrdude
-nano644.bootloader.low_fuses=0xFF
-nano644.bootloader.high_fuses=0xD8
-nano644.bootloader.extended_fuses=0xFF
-nano644.bootloader.unlock_bits=0xFE
-nano644.bootloader.lock_bits=0xEF
-nano644.bootloader.file=atmega644/bootloader-arduino_nano-644.hex
-
-nano644.build.mcu=atmega644p
-nano644.build.f_cpu=12000000L
-nano644.build.board=AVR_NANO644
-nano644.build.core=arduino
-nano644.build.variant=standard
+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-644*** gewählt werden
+* über das Menü *Werkzeuge->Board* das ***Nano-1284*** gewählt werden
* über das Menü *Werkzeuge->Programmer* der ***ArduinoISP*** gewählt werden
+++ /dev/null
-:10E000000C943E700C9450700C9450700C945070A2\r
-:10E010000C9450700C9450700C9450700C94507080\r
-:10E020000C9450700C9450700C9450700C94507070\r
-:10E030000C9450700C9450700C9450700C94507060\r
-:10E040000C9450700C9450700C9450700C94507050\r
-:10E050000C9450700C9450700C9450700C94507040\r
-:10E060000C9450700C9450700C9450700C94507030\r
-:10E070000C9450700C9450700C94507011241FBE6E\r
-:10E08000CFEFD0E1DEBFCDBF22E0A0E0B1E001C024\r
-:10E090001D92AC30B207E1F70E9435710C94FC720E\r
-:10E0A0000C9400709091C00095FFFCCF8093C60047\r
-:10E0B0000895CF93982F8595859585958595805D55\r
-:10E0C0009F709A3014F0C7E501C0C0E3C90F0E94E9\r
-:10E0D00052708C2FCF910C945270CF92DF92EF92AE\r
-:10E0E000FF92C12CD12C76018091C00087FD15C014\r
-:10E0F0008FEFC81AD80AE80AF80A81EBC81681E738\r
-:10E10000D8068BE0E806F10478F317B818B8E09168\r
-:10E110000001F09101010995E7CF8091C600FF90C1\r
-:10E12000EF90DF90CF900895CF930E946D70C82F2D\r
-:10E130000E945270C13614F089EA03C0C0331CF04B\r
-:10E1400080ED8C0F01C08C2FCF910895CF930E944A\r
-:10E150009470C82F0E94947090E1C99F800D112483\r
-:10E16000CF910895CF93C82FCC2321F00E946D70DA\r
-:10E17000C150FACFCF910895CF93C82F0E946D70F0\r
-:10E18000803251F484E10E9452708C2F0E945270B0\r
-:10E1900080E1CF910C945270809102018F5F809347\r
-:10E1A0000201853041F417B818B8E0910001F091F0\r
-:10E1B0000101CF910994CF9108950E946D70803232\r
-:10E1C00031F484E10E94527080E10C94527080918D\r
-:10E1D00002018F5F80930201853039F417B818B8B7\r
-:10E1E000E0910001F091010109940895CF93DF932C\r
-:10E1F00000D000D0CDB7DEB719821A821B821C82F4\r
-:10E2000089819A81AB81BC8181159042A140B10581\r
-:10E2100080F48091C00087FD0CC089819A81AB8118\r
-:10E22000BC810196A11DB11D89839A83AB83BC83F8\r
-:10E23000E7CF0F900F900F900F90DF91CF9108953F\r
-:10E24000CF93C82F429A0E94F670439A0E94F670AC\r
-:10E2500018B8CC2341F0449A0E94F67044980E946A\r
-:10E26000F670C150F6CFCF91089500008CE187B9C8\r
-:10E2700018B882E08093C0008CE08093C4001092B4\r
-:10E28000C50088E18093C10086E08093C20098E0D9\r
-:10E290009093C9008093CA0084E00E94207113E02B\r
-:10E2A00001E0E5E0FE2EF1E1EF2E0E946D7080337B\r
-:10E2B00009F447C0813319F50E946D708032B9F4BA\r
-:10E2C00084E10E94527081E40E94527086E50E94AF\r
-:10E2D000527082E50E94527080E20E94527089E47E\r
-:10E2E0000E94527083E50E94527080E56CC180915B\r
-:10E2F00002018F5F809302018530B9F671C18034CD\r
-:10E3000039F40E946D708638E0F00E946D7019C07B\r
-:10E31000813491F40E946D70803811F481EF44C013\r
-:10E32000813811F481E040C0823811F480E13CC0B2\r
-:10E330008839C9F583E038C0823431F484E10E9421\r
-:10E34000B2700E94DD70B1CF853411F485E0F7CF53\r
-:10E35000982F9D7F9035A9F3813599F3853549F440\r
-:10E360000E946D70809304010E946D70809305017E\r
-:10E37000E8CF8635E1F40E946D70803389F40E9405\r
-:10E380006D700E946D70C82F0E946D70C11102C027\r
-:10E390008EE10AC0C13011F486E906C08AE004C0EB\r
-:10E3A00083E00E94B27080E00E94BC707ECF843611\r
-:10E3B00009F0A5C00E946D70809308020E946D70E4\r
-:10E3C0008093070280910B028E7F80930B020E9444\r
-:10E3D0006D70853429F480910B02816080930B026B\r
-:10E3E000C6E0D1E06E012091070230910802C6011B\r
-:10E3F000865091408217930730F40E946D70F601A9\r
-:10E4000081936F01F0CF0E946D70803209F0E1C0FE\r
-:10E4100020910B028091040190910501880F991FB2\r
-:10E42000909305018093040120FF23C0E6E0F1E012\r
-:10E430002091070230910802CF0186509140821747\r
-:10E44000930708F05AC0F999FECF8091040190918A\r
-:10E45000050192BD81BD819180BDFA9AF99A8091A2\r
-:10E4600004019091050101969093050180930401A8\r
-:10E47000DFCF8091070280FF09C080910702909151\r
-:10E48000080201969093080280930702F894409145\r
-:10E49000040150910501F999FECF07B600FCFDCFAC\r
-:10E4A000FA0110935700E89507B600FCFDCF20E075\r
-:10E4B00030E0FA01E20FF31F898190E0982F88275E\r
-:10E4C0006881860F911D0C0100935700E895112477\r
-:10E4D0002E5F3F4F22962115F1E03F0751F7309311\r
-:10E4E0000A0220930902FA01F0925700E89507B654\r
-:10E4F00000FCFDCFE0925700E89584E164C08437CA\r
-:10E5000009F051C00E946D70809308020E946D70E6\r
-:10E51000809307028091040190910501880F991F53\r
-:10E5200090930501809304010E946D7090910B02FD\r
-:10E53000853411F4916001C09E7F90930B020E947C\r
-:10E540006D70803209F041C084E10E945270C0E0D9\r
-:10E55000D0E08091070290910802C817D907A8F56A\r
-:10E5600080910B0280FF0BC0F999FECF80910401CE\r
-:10E570009091050192BD81BDF89A80B507C081FDDB\r
-:10E5800007C0E0910401F091050184910E9452704E\r
-:10E59000809104019091050101969093050180936B\r
-:10E5A00004012196D6CF853719F50E946D7080320F\r
-:10E5B00081F484E10E9452708EE10E94527086E9DB\r
-:10E5C0000E9452708AE00E94527080E10E94527054\r
-:10E5D0006CCE809102018F5F80930201853009F437\r
-:10E5E00017B818B8E0910001F091010109955DCECE\r
-:0CE5F000863709F05ACED7CEF894FFCF42\r
-:040000030000E00019\r
-:00000001FF\r
// Write to FLASH one page at a time
if (address.byte[1] > 127) {
//Only possible with m128, m256 will need 3rd address byte. FIXME
- // RAMPZ = 0x01;
+ RAMPZ = 0x01;
} else {
- // RAMPZ = 0x00;
+ RAMPZ = 0x00;
}
// address * 2 -> byte location
else {
if (!flags.rampz) {
putch(pgm_read_byte_near(address.word));
- // putch(pgm_read_byte_far(address.word + 0x10000));
- }
+ } else {
+ putch(pgm_read_byte_far(address.word + 0x10000));
+ }
address.word++;
}
}