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

Block erase #37

@davidlattimore

Description

@davidlattimore

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions