Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best method to erase code flash memory? #148

Open
chanqueo opened this issue Nov 8, 2022 · 6 comments
Open

Best method to erase code flash memory? #148

chanqueo opened this issue Nov 8, 2022 · 6 comments

Comments

@chanqueo
Copy link
Contributor

chanqueo commented Nov 8, 2022

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)

@hkpeprah
Copy link
Contributor

Hm. I'm not sure what the best way is. What happens if you try the aforementioned?

@chanqueo
Copy link
Contributor Author

chanqueo commented Nov 21, 2022

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.

  1. compare
  2. clear
  3. write

Instead of one erase operation.
I'm surprised to be the only one concerned.

@hkpeprah
Copy link
Contributor

Looks like #154 is related to this.

@chanqueo
Copy link
Contributor Author

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...

denravonska added a commit to denravonska/pylink that referenced this issue Nov 25, 2022
This enables programming the chip without having to erase the entire contents.
Instead, JLink will erase where needed while retaining the data that's within
the same sectors but outside of the specified write area.

Closes square#154, square#148
denravonska added a commit to denravonska/pylink that referenced this issue Nov 25, 2022
This enables programming the chip without having to erase the entire contents.
Instead, JLink will erase where needed while retaining the data that's within
the same sectors but outside of the specified write area.

Closes square#154, square#148
denravonska added a commit to denravonska/pylink that referenced this issue Nov 25, 2022
This enables programming the chip without having to erase the entire contents.
Instead, JLink will erase where needed while retaining the data that's within
the same sectors but outside of the specified write area.

Closes square#154, square#148
denravonska added a commit to denravonska/pylink that referenced this issue Nov 25, 2022
This enables programming the chip without having to erase the entire contents.
Instead, JLink will erase where needed while retaining the data that's within
the same sectors but outside of the specified write area.

Closes square#154, square#148
@denravonska
Copy link
Contributor

@chanqueo #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.

hkpeprah pushed a commit to denravonska/pylink that referenced this issue Dec 5, 2022
This enables programming the chip without having to erase the entire contents.
Instead, JLink will erase where needed while retaining the data that's within
the same sectors but outside of the specified write area.

Closes square#154, square#148
@hkpeprah
Copy link
Contributor

hkpeprah commented Dec 8, 2022

Remedy should be available in v1.0.0 thanks to @denravonska.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants