Old thread, and I see that Reed's code has been tweaked to fit into Nano even with the bloated 1.8.13;
But cold rainy day, and I did mention using an Arduino Uno as an ISP yesterday; so gave it a whirl.
This may be of interest if you need more usable flash space on a Nano project /want to update the bootloader for some other reason/ bricked your Nano /
store EEPROM or flash to a file without changing application code / make a clone, etc.? Otherwise this is boring documentation.
I edited?
hardware/arduino/avr/boards.txt, to take advantage of the reduced bootloader size.
An oversight/ mistake in the Arduino IDE? Fuse/size settings where not updated to take advantage of the smaller size of the new bootloader.
I used the settings for the UNO and added a new board variation.? (following the same style Arduino uses for their Nano variations)
//begin boards snip
## Arduino Nano w/ ATmega328P OPTIBOOT size optimized AG5TX
## --------------------------
nano.menu.cpu.atmega328opt=ATmega328P (opt OPTIBOOT)
?
nano.menu.cpu.atmega328opt.upload.maximum_size=32256
nano.menu.cpu.atmega328opt.upload.maximum_data_size=2048
nano.menu.cpu.atmega328opt.upload.speed=115200
?
nano.menu.cpu.atmega328opt.bootloader.low_fuses=0xFF
nano.menu.cpu.atmega328opt.bootloader.high_fuses=0xDE
nano.menu.cpu.atmega328opt.bootloader.extended_fuses=0xFD
nano.menu.cpu.atmega328opt.bootloader.file=optiboot/optiboot_atmega328.hex
?
nano.menu.cpu.atmega328opt.build.mcu=atmega328p
//end boards snip
In the Arduino IDE, I "Burn(ed) Bootloader"? to a 'clone' Nano? using? ' Programmer: "Arduino as ISP" '
the hardware programmer was the Uno R3 with the Example:ArduinoISP" sketch loaded.?
I did use the 'old wire method' by?
#define USE_OLD_STYLE_WIRING
(as I really didn't want to burn time thinking about it at this point in time)
I used 6 wires:
UNO? ? ? ? NANO
----------------------
5V? ? ? ? ? VIN
GND? ? ? GND
D10? ? ? ? RST
D11? ? ? ? D11
D12? ? ? ? D12
D13? ? ? ? D13
It is recommended to place a 10uF cap from the UNO RST to GND.? ( I did not have anything in that order that was handy, no cap and worked fine)
I programed the Nano with Reed's latest code on github.
Sketch uses 30664 bytes (95%) of program storage space. Maximum is 32256 bytes.
Global variables use 819 bytes (39%) of dynamic memory, leaving 1229 bytes for local variables. Maximum is 2048 bytes.
I used the avrdude program with the UNO-ISP and dumped the FLASH to a binary file.
Then a dump of the file.? You can see where Reed's code ends and the bootloader starts:
?
0077c0 13 57 08 10 17 0f 17 00 ff ff ff ff ff ff ff ff
0077d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
*
007e00 11 24 84 b7 14 be 81 ff f0 d0 85 e0 80 93 81 00
007e10 82 e0 80 93 c0 00 88 e1 80 93 c1 00 86 e0 80 93
?
0x77c8 is 306644
Bootloader starts at 0x7e00,
Had it been either the old or the new bootloader without the fuse/size setting corrections in boards.txt the bootloader would start at 0x7800
that's 1536 extra bytes of space.
As far as using avrdude.? It comes with the Arduino IDE. avrdude needs to know the path to avrdude.conf since it is not in the same directory.
My quick and dirty portable solution was to make a new directory with everything I need local (similar to the XLoader program)
avrdude.exe avrdude.conf libusb0.dll
Then from a command line, my UNO was on com9
avrdude.exe -c arduino -P com9 -p ATMEGA328P -b 19200 -U flash:r:reed_flash.bin:r
I also dumped the EEPROM from the Nano on my uBITX V3
avrdude.exe -c arduino -P com9 -p ATMEGA328P -b 19200 -U eeprom:r:backup_eprom.bin:r
$ od -t x1 -Ax -w16? backup_eprom.bin
000000 ec 9d 02 00 ff ff ff ff 72 08 b7 00 ff ff ff ff
000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
od is octal dump.? I'm on a Win10 machine, but I use a cycgwin shell.?
You can also write to flash, eeprom, etc. Read the documentation on avrdude if you have more interest.
Rgds
Gary
AG5TX
?