Skip to content

drivers: flash: Add support for Atmel AT25 SPI flash variant #92980

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Liam-Ogletree
Copy link

@Liam-Ogletree Liam-Ogletree commented Jul 10, 2025

The AT25XV021A variant is a flash variant of Atmel's AT25 family that adds extra protections, requiring additional writes to the device to program or erase data.

This commit adds a flash driver for AT25XV021A devices instead of modifying (1) the existing AT45 SPI flash driver or (2) the existing AT24/25 EEPROM driver because this variant poses fundamental changes that affect all aspects of the driver.

Notably,

  • AT25XV021A includes a second status register, and the format and functions of the existing status register is changed from the existing drivers.
  • AT25XV021A requires executing page or chip erase commands before writing, making it incompatible with the existing AT24/25 EEPROM driver.
  • AT25XV021A adds a software protection layer that requires extra writes before executing program or erase commands.

Tested writing to and erasing from an AT25XV021A device. Tested reading from an AT25XV021A device across page boundaries. Tested chip erase function. Tested driver initialization from varying initial hardware states.

@github-actions github-actions bot added area: Flash platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) labels Jul 10, 2025
Copy link

Hello @Liam-Ogletree, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch from d9a8fa6 to 938b962 Compare July 10, 2025 18:55
@rriveramcrus
Copy link
Contributor

rriveramcrus commented Jul 10, 2025

It would be good to add an entry to tests/drivers/build_all/flash/spi.dtsi

@Liam-Ogletree
Copy link
Author

It would be good to add an entry to tests/drivers/build_all/flash/spi.dtsi

Added an entry to /spi.dtsi for this flash driver.

@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch from 938b962 to aca63fe Compare July 11, 2025 14:16
@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch 2 times, most recently from 09c8642 to 2199a6a Compare July 11, 2025 21:10
@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch from 2199a6a to 0ddd3bf Compare July 14, 2025 00:47
@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch from 0ddd3bf to f3aaef6 Compare July 14, 2025 14:41
@Liam-Ogletree Liam-Ogletree requested a review from pdgendt July 14, 2025 14:49
Liam-Ogletree pushed a commit to Liam-Ogletree/zephyr that referenced this pull request Jul 14, 2025
Depends on in-progress pull request zephyrproject-rtos#92980 adding support for
AT25XV021A driver. Dummy values mirror at45 and spi-nor
implementation.

Signed-off-by: Liam Ogletree <liam.ogletree@cirrus.com>
@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch from f3aaef6 to db24d89 Compare July 14, 2025 16:08
@Liam-Ogletree Liam-Ogletree requested a review from pdgendt July 14, 2025 16:13
pdgendt
pdgendt previously approved these changes Jul 14, 2025
Copy link
Contributor

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Liam-Ogletree
Copy link
Author

Liam-Ogletree commented Jul 14, 2025

Thanks!

Erroneous _ in spi.dtsi, updated from page_size to page-size as a result of failed twister test (one of 8)

@Liam-Ogletree Liam-Ogletree requested a review from pdgendt July 14, 2025 17:29
pdgendt
pdgendt previously approved these changes Jul 14, 2025
Copy link
Contributor

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write should not do erase.
Write should not potentially destroy existing data.
Write block size is not 1 and it is not clearly visible, from user perspective, that selected wbs reduces significantly endurance of a device from the one stated in datasheet.

@Liam-Ogletree
Copy link
Author

Write should not do erase. Write should not potentially destroy existing data. Write block size is not 1 and it is not clearly visible, from user perspective, that selected wbs reduces significantly endurance of a device from the one stated in datasheet.

Hi @de-nordic

Thank you for the review! I updated both erase and write to no longer implicitly write and erase, respectively, and added checks for page size alignment where appropriate. Additionally, I added a compile-time check for read-only and hid most functions and some config variables behind #if !(DEV_READ_ONLY) macros to reduce code size in case of read only. Finally, updated write_block_size to equal DEV_PAGE_SIZE.

Appreciate your time!
Liam

@Liam-Ogletree Liam-Ogletree requested a review from de-nordic July 15, 2025 18:11
@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch from 1a323c3 to 0570b3c Compare July 15, 2025 18:17
The AT25XV021A variant is a flash variant of Atmel's AT25 family
that adds extra protections, requiring additional writes to the
device to program or erase data.

This commit adds a flash driver for AT25XV021A devices instead of
modifying (1) the existing AT45 SPI flash driver or (2) the
existing AT24/25 EEPROM driver because this variant poses
fundamental changes that affect all aspects of the driver.

Notably,
 - AT25XV021A includes a second status register, and the format
	and functions of the existing status register is
	changed from the existing drivers.
 - AT25XV021A requires executing page or chip erase commands
	before writing, making it incompatible with the
	existing AT24/25 EEPROM driver.
 - AT25XV021A adds a software protection layer that requires
	extra writes before executing program or erase commands.

Tested writing to and erasing from an AT25XV021A device. Tested
reading from an AT25XV021A device across page boundaries. Tested
chip erase function. Tested driver initialization from varying
initial hardware states.

Signed-off-by: Liam Ogletree <liam.ogletree@cirrus.com>
Dummy values mirror at25 and spi-nor implementation.

Signed-off-by: Liam Ogletree <liam.ogletree@cirrus.com>
@Liam-Ogletree Liam-Ogletree force-pushed the add_drivers_flash_at25xv021a branch from 0570b3c to 3a033d7 Compare July 16, 2025 18:39
Copy link

@Liam-Ogletree Liam-Ogletree requested a review from pdgendt July 22, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Flash platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants