I am having some issue writing to flash memory on Arduino Uno.

I burned the optiboot bootloader that ships with the IDE 1.8.3 to the chip, then uploaded the test_dospm sketch to write content to flash memory but appears to reset the device instead.

Any idea why this might be happening?


The bootloader which ships with Arduino IDE is version 4 which was already in the Uno from factory. To use the do_spm function you need Optiboot 8 build with this support enabled. It is not enabled in the default builds, because it doesn't fit in the usual Optiboot size for Uno.

The hex file of the bootloader is here. Simply replace the hex file in AVR boards package with this one.

  • I can add more details or even build and test the bootloader and provide boards.txt settings since I have this on my TODO list.
    – Juraj
    May 28 '20 at 12:05
  • Thanks @Juraj, that would be helpful! I am currently diving in the source code/makefile to see what are the option I need to enable to build the bootloader and you were right about the do_spm not being enabled by default. May 28 '20 at 20:51
  • @FallaCoulibaly, I discovered that do_spm is in the normal build of Optiboot8. BIGBOOT is not required. I modified the answer.
    – Juraj
    May 30 '20 at 17:24
  • Thanks, that did the trick Jun 4 '20 at 8:58
  • but if somebody ever needs the big version of Optiboot including my copy_flash_pages function, here it is github.com/jandrassy/my_boards. about copy_flash_pages: github.com/Optiboot/optiboot/pull/269
    – Juraj
    Jun 4 '20 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.