Closed wxutopia closed 2 years ago
The flash logic in the AVR can only erase full pages. If you want to modify a smaller bit of flash, you would have to read the existing flash page into a RAM copy, erase the full page, modify the bytes you wanted to change in your copy, and then write the full page.
(actually, I guess if the flash page contains 0xFF (ie "was previously erased"), you should be able to write new data without erasing the page, as long as you're overwriting only the 1 bits.)
The flash logic in the AVR can only erase full pages. If you want to modify a smaller bit of flash, you would have to read the existing flash page into a RAM copy, erase the full page, modify the bytes you wanted to change in your copy, and then write the full page.
(actually, I guess if the flash page contains 0xFF (ie "was previously erased"), you should be able to write new data without erasing the page, as long as you're overwriting only the 1 bits.)
Sounds like a good idea, thanks a lot!
Do functions boot_page_erase_short() and boot_page_erase() erase an entire flash page?
How can I write any-sized data, like 10 bytes to flash in bootloader?