Lets say i have arduino with bootloader (lets say ATMegaBoot) and i want to flash new version, or completely different binary (eg. Optiboot). Usualy i use ISP programmer to do it. I have to connect programmer to ISP instead of USB and flash the bootloader.
But what if we could just use specialy crafted Arduino sketch to do this? I guess you can accidentaly overwrite bootloader when you are not careful about your sketch code. But what if we made this intentionaly to install new bootloader or install code in bootloader-less mode?
You can upload sketch that would act as ArduinoISP, but instead of bitbanging SPI pins, it would write the bootloader into the beginning of flash memory (given that such sketch would run from the end of flash, it should not be affected. if that is problem, it can copy itself to SRAM or eeprom first).
This would allow us to update bootloader using the same HW setup we use for uploading sketches. Which could lead to creating new ecosystem of bootloaders distributed as arduino sketch with binary payload, that can be automaticaly downloaded by arduino IDE and installed by single click if needed.
Also this could be used for one-time flashing of user binary once the development is over and there is no need for bootloader anymore. (personaly i don't think that there's need to do this, since optiboot is fast enogh for me, but some people might not want to ship with bootloader, or whatever)
该提问来源于开源项目:Optiboot/optiboot