Am I missing something w.r.t. the complexity of the project?Is it not just a matter of using a digital pin to trigger the reset, the streaming the .hex file over Serial?Franck
I have my doubts; look at the code for optiboot (used in newer Unos and Nanos). You will have to provide the reverse using a programmer if you want to use USB/Serial. And next consider that there are different bootloaders (older Nanos used e.g. something else).Your best bet might be a Raspberry Pi in some elementary form (few buttons, 16x2 display) that can run avrdude commands.
Serial uploader starting...Found sketch binary: TESTTY~1.HEXResetting target board... done.AVR device initialized and ready to accept instructions.Device signature: 0x1E 0x95 0xFBootloader version: 4.4Writing flash...2030 bytes of flash written.Verifying flash memory against the sketch...2030 bytes of flash verified.Programming done, thank you.
Serial upload sketch for Arduino.This sketch turns your Arduino into a standalone serial programmer.How to use:1. Prepare a programmer board with an SD card2. Set up preferences in SerialUploader.h3. Upload the SerialUploader.ino sketch to your programmer board4. Compile the sketch you want to program (e.g. using the Arduino IDE) (_Remember to adjust the IDE board settings for the target board!_)5. Locate the generated <sketch>.ino.hex file on your file system, and copy it to the SD card6. Move the SD card over to the programmer board7. Connect the programmer board to the target board: - programmer -> target - Vin -> Vin - Gnd -> Gnd - PIN_RESET -> Rst - SERIAL_TARGET Rx pin -> target's Tx pin - SERIAL_TARGET Tx pin -> target's Rx pin8. Reset the programmer to start the upload sketchThe built-in led on the programmer will show:- steady light while the upload is in progress- sequences of 2 quick blinks if the upload succeeded- sequences of 5 quick blinks if the upload failedThe sketch will try standard upload speeds down from 115200 bps. This works well, but as an alternative you can add aboards.txt file on the SD card: the sketch will find the first occurence of "upload.speed=" in the file, and will usethe upload speed specified there.Sample file: # Upload speed for serial uploader optibootm32.upload.speed=38400The sketch appends to an upload.log file on the SD card: you can check that on the computer to see what happened.Tested configurations:- mega2560 clone programmer uploading through Serial1- (coming next) Uno programmer uploading through Serial- Uno target board, optiboot, 115200- Pro mini target board @ 8MHz, minicore, 38400
I would like to auto detect whether the bootloader expects stk500 or stk500v2, however I don't see anything obvious in the specs to reliably make the call?
for one doesn't implement v1's get signon (0x31)
avrdude: Send: 0   avrdude: Recv: . 
and 0x31 is leave programming mode in v2, so not great as a test cmd.