Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Block erase #37

Open
davidlattimore opened this issue Sep 3, 2021 · 0 comments
Open

Block erase #37

davidlattimore opened this issue Sep 3, 2021 · 0 comments

Comments

@davidlattimore
Copy link

For a flash chip I'm using, the time to do a 64KB block erase is significantly faster than a whole series of sector erase commands. For 1MB, this is about 800ms vs 7500ms.

I'd be happy to send a PR to add support for erasing blocks, but wanted to first check your thoughts on API.

One option would be to add a new method that just erases a 64KB block. e.g.:

    fn erase_64k_block(&mut self, addr: u32) -> Result<(), Error<SPI, CS>> {
        self.write_enable()?;

        let mut cmd_buf = [
            Opcode::BlockErase as u8,
            (addr >> 16) as u8,
            (addr >> 8) as u8,
            addr as u8,
        ];
        self.command(&mut cmd_buf)?;
        self.wait_done()
    }

Another option would be to change erase_sectors to check if you're erasing all the sectors in a block and if so, erase that block instead. This has the advantage that it doesn't add to the API, but it does make the implementation of erase_sectors more complex. Any preference?

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

No branches or pull requests

1 participant