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

How does partial erase work? #35

Open
mithro opened this issue May 13, 2020 · 1 comment
Open

How does partial erase work? #35

mithro opened this issue May 13, 2020 · 1 comment
Labels

Comments

@mithro
Copy link
Contributor

mithro commented May 13, 2020

Originally posted by @DurandA in enjoy-digital/litex#522 (comment)

@mithro Thanks! Strangely, LiteSPI doesn't define a sector size so I wonder how partial erase is done.

@kowalewskijan
Copy link
Contributor

kowalewskijan commented May 21, 2020

In MMAP mode we have only preconfigured read commands. To erase a sector, block etc. user must enter the Master mode and write a proper command. Using CSRs this procedure should look like this:
spiflash_mmap_cfg_write(1); // switch to Master mode
spiflash_mmap_master_cs_write(1); // CS on
spiflash_mmap_master_phyconfig_write(0x010108); // xfer_len=8, xfer_width=1, xfer_mask=1
spiflash_mmap_master_rxtx_write(SECTOR_ERASE_CMD); // send erase command
spiflash_mmap_master_cs_write(0); // CS off
spiflash_mmap_cfg_write(0); // switch to MMAP mode

Function names are taken from genereated csr.h when you build Arty example.

edit: this is of course for offset 0x0, so to erase a particular data, there should be an address provided after the instruction byte.

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

No branches or pull requests

3 participants