pylink
pylink copied to clipboard
Best method to erase code flash memory?
Hi, On my device, flash memory is from 0x00000000 to 0x1fffffff. Flash allocated to source code is only from 0x00000000 to 0x00100000. erase() method will erase the whole flash memory. What it the best method to only clear flash dedicated to source code?
Here is the source code I am using. flash_address, flash_size = self.get_radio_board_flash_info() data = [0xFF] * flash_size self.jlink.flash_bytes(data, flash_address)
Hm. I'm not sure what the best way is. What happens if you try the aforementioned?
As you know, when a flash is erased, all the bits are set to 1. So writing 0xFF everywhere gives the same result as erase operation. self.get_radio_board_flash_info() returns the start address and size of the flash dedicated to source code. After running my source code, the flash contents is erased as expected but the execution takes very long.
- compare
- clear
- write
Instead of one erase operation. I'm surprised to be the only one concerned.
Looks like #154 is related to this.
I'm not sure. My question is, what is the best way to erase only part of the flash memory? The jlink.erase() method will erase the whole flash memory, and this is not what I want, because of bootloader...
@chanqueo https://github.com/square/pylink/pull/155 should fix this. It causes flash to only erase the target area, leaving the bootloader (and other permanent data) untouched.
Also, apologies for opening a duplicate issue. I should've checked beforehand.
Remedy should be available in v1.0.0 thanks to @denravonska.