Closed MohamedGhardallou closed 3 months ago
Are you commenting on the behaviour of flash memory itself ? Or is there some different behaviour / error code sent back by the SDK ?
For regular flash chips, the behaviour is:
@dshadoff Thank you for your response. Yes i was asking about the behavior of flash memory itself. I was not aware of this behavior and when i discovered it , i thought we may add a comment to the header file to highlight this. But then this is not necessarily as we can also program the flash without erasing if that sector bits are already ones. So no need to change the header.
Thank you again.
just stumbled over the same unexpected behavior. a hint in the header of fash.h would be nice for people not familiar with how flash cells work
Jup. Spent half a day because it's not documented. It would be very nice if it's not just a note in the header but contained in the online documentation.
re-opened to add documentation to header
One option here would be to assert in debug mode like
for (int i = 0; i < write_size; ++i) {
assert(!(writebuf[i] & ~existingbuf[i]));
}
for all bytes to be programmed. It could easily prevent accidental misuse and serve as a hint to users. I'm not sure how much the overhead y'all tolerate on debug-mode vs. release-mode builds.
Fixed by #1772
flash_range_erase must be called before calling flash_range_program. Otherwise flash_range_program will not work.
To test this behavior , just comment line 40 in flash_program example.
Could you please add a comment in the header file rp2_common/hardware_flash/include/hardware/flash.h to indicate this.
This is not obvious and it may save a lot of time to a lot of people.
Thanks