I have a couple of Nanos with the old bootloader, which is problematic for a number of reasons...
All the data/info that I am seeing on uploading the bootloader says to connect my Nano to an UNO to do the programming...
This is problematic for me as they are soldered on another board and the programming interface is not easely available... And I do not have an UNO available...
Is there a reason why one could not write a program that will run ON the Nano and update the bootloader (with the obvious risks in case of power failure)?
A quick glance at the atmel documentation does seem to indicate that a program in flash can reprogram other parts of the flash (this is in essence what the bootloader is doing)...
Or am I missing something?
If yes, where can I find the binary for the bootloader? and is there a library for flash programming that I can find?
As far as I can tell this example (ArduinoISP) allows to turn another Arduino (all the doc seems to refer to an UNO) into a programming tool for reprogramming an Arduino Nano bootloader...
Is there no way to put a program in a NANO that will update it's own flash directly?
nonsense.
i recommend to you not to fear and prepare one arduino as ArduinoISP programer, with it reflash new BL version to all other Nano, then turn one of new into programer and reflash that last one, that was the programer as first.
Can you please explain why this is the case?
I mean the the bootloader, which runs ON the Nano can program others parts of the flash.
Why is it that a program running in that other part of flash can not program the part of the flash where the bootloader is?
You will need to consult the atmega328 manual, I think the bootloader section is protected from being erased/written by the code. There is a fuse setting that controls this, but changing the fuses would require an ISP programmer.
No. But a Nano is pretty much equivalent to an Uno, so you can certainly use a Nano with the Arduino as ISP sketch to program new bootloaders into OTHER nanos.
Are there any connections to the SPI bus pins (11, 12, 13)? That could cause problems when attempting to burn the bootloader.
The connection for burning the bootloader can be made at the ICSP header instead of the pins along the edge of the board. If your Nano does not have the ICSP header installed, you can get programming cables that have pogo pins, spring loaded pins designed to make contact when held down to the solder holes for the header pins.
The binary file for the bootloader is included with the board package when you installed the Arduino IDE, although I'm not familiar with its exactly location on a Windows computer.
The new Nano bootloader is the same as that used for the UNO, only difference is that 2K bytes of flash memory are allocated for the bootloader on the Nano, while only 512 bytes are used on the UNO. This leads to many people selecting "UNO" in the IDE when burning the bootloader to the Nano, which frees up the wasted 1.5K of flash memory for use by the sketch, as long as you remember to select "UNO" when compiling for the board.
Indeed, on my board, I already have a device on the SPI pins and that conflicts with an outside ISP programming the Nano
As to why the old bootloader is problematic. it's beacause it has a different behavior than the new one. Among other things when it comes to reset/default state of the serial port. The net result is that I HAVE to use the Serial library with the old bootloader, but I can use my much simpler (and smaller) version with the new bootloader. Since my sketch is flash limited, this means that I have to remove features in the old bootloader version
This makes perfect sense and is most likely the reason why I can not do a direct flash write of the bootloader using a sketch (which I tried)...