-
Notifications
You must be signed in to change notification settings - Fork 2k
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
driver/mtd_spi_nor, pkg/littlefs: improve reliability with corrupted flash (new PR) #20589
Open
crasbe
wants to merge
10
commits into
RIOT-OS:master
Choose a base branch
from
crasbe:pr/littlefs_corrupted
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+908
−19
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d565796
mtd_spi_nor: check WEL flag for write and erase
61a03bb
littlefs: fix return code in case of corruption
216a370
littlefs2: fix return code in case of corruption
e435a37
drivers/mtd_spi_nor: removed Kconfig & added MX/ISSI security features
crasbe 8f25a37
tests/mtd_spi_nor: Added test with security features
crasbe 85d4c86
fixup! drivers/mtd_spi_nor: removed Kconfig & added MX/ISSI security …
crasbe 5cd6825
fixup! tests/mtd_spi_nor: Added test with security features
crasbe 2ab4d66
fixup! fixup! tests/mtd_spi_nor: Added test with security features
crasbe 56c28df
fixup! fixup! drivers/mtd_spi_nor: removed Kconfig & added MX/ISSI se…
crasbe 41921a7
fixup! fixup! fixup! tests/mtd_spi_nor: Added test with security feat…
crasbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
/* | ||
* Copyright (C) 2024 Technische Universität Hamburg | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser General | ||
* Public License v2.1. See the file LICENSE in the top level directory for more | ||
* details. | ||
*/ | ||
|
||
/** | ||
* @ingroup drivers_mtd_spi_nor | ||
* @{ | ||
* | ||
* @file | ||
* @brief Definitions for the MTD SPI NOR Flash driver | ||
* | ||
* @author Christopher Büchse <[email protected]> | ||
* | ||
*/ | ||
|
||
#ifndef MTD_SPI_NOR_DEFINES_H | ||
#define MTD_SPI_NOR_DEFINES_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @name Common Status Bits from the Status Register of SPI NOR Flashs | ||
* @{ | ||
*/ | ||
/** | ||
* @brief Write In Progress Flag (R) | ||
* | ||
* 0 - Device is ready | ||
* 1 - Write cycle in progress and device is busy | ||
*/ | ||
#define SPI_NOR_STATUS_WIP 0x01u | ||
|
||
/** | ||
* @brief Write Enable Latch Flag (R/W) | ||
* | ||
* 0 - Device is not write enabled | ||
* 1 - Device is write enabled | ||
*/ | ||
#define SPI_NOR_STATUS_WEL 0x02u | ||
|
||
/** | ||
* @brief Block Protection Bit 0 Flag (R/W) | ||
* | ||
* 0 - Specific blocks are not write-protected | ||
* 1 - Specific blocks are write-protected | ||
*/ | ||
#define SPI_NOR_STATUS_BP0 0x04u | ||
|
||
/** | ||
* @brief Block Protection Bit 1 Flag (R/W) | ||
* | ||
* 0 - Specific blocks are not write-protected | ||
* 1 - Specific blocks are write-protected | ||
*/ | ||
#define SPI_NOR_STATUS_BP1 0x08u | ||
|
||
/** | ||
* @brief Block Protection Bit 2 Flag (R/W) | ||
* | ||
* 0 - Specific blocks are not write-protected | ||
* 1 - Specific blocks are write-protected | ||
*/ | ||
#define SPI_NOR_STATUS_BP2 0x10u | ||
|
||
/** | ||
* @brief Block Protection Bit 3 Flag (R/W) | ||
* | ||
* 0 - Specific blocks are not write-protected | ||
* 1 - Specific blocks are write-protected | ||
*/ | ||
#define SPI_NOR_STATUS_BP3 0x20u | ||
|
||
/** | ||
* @brief Quad Enable Flag (R/W) | ||
* | ||
* 0 - Quad output function disabled | ||
* 1 - Quad output function enabled | ||
*/ | ||
#define SPI_NOR_STATUS_QE 0x40u | ||
|
||
/** | ||
* @brief Status Register Write Disable Flag (R/W) | ||
* | ||
* 0 - Status Register is not write protected | ||
* 1 - Status Register is write protected | ||
*/ | ||
#define SPI_NOR_STATUS_SRWD 0x80u | ||
|
||
/** @} */ | ||
|
||
/** | ||
* @name Macronix Style Security Register Bits | ||
* @note These flags were taken from the MX25L51245G datasheet, but probably apply | ||
* to other devices from Macronix as well. | ||
* @{ | ||
*/ | ||
/** | ||
* @brief Secured OTP Flag | ||
* | ||
* 0 - OTP area not factory locked | ||
* 1 - OTP area factory locked | ||
*/ | ||
#define MX_SECURITY_SOTP 0x01u | ||
|
||
/** | ||
* @brief Lock-down Secured OTP Flag | ||
* | ||
* 0 - OTP area not (user) locked | ||
* 1 - OTP area locked (can not be programmed/erased) | ||
*/ | ||
#define MX_SECURITY_LDSO 0x02u | ||
|
||
/** | ||
* @brief Program Suspend Flag | ||
* | ||
* 0 - Program is not suspended | ||
* 1 - Program suspended | ||
*/ | ||
#define MX_SECURITY_PSB 0x04u | ||
|
||
/** | ||
* @brief Erase Suspend Flag | ||
* | ||
* 0 - Erase is not suspended | ||
* 1 - Erase is suspended | ||
*/ | ||
#define MX_SECURITY_ESB 0x08u | ||
|
||
/** | ||
* @brief Reserved | ||
*/ | ||
#define MX_SECURITY_XXXXX 0x10u | ||
|
||
/** | ||
* @brief Program Fail Flag | ||
* | ||
* 0 - Program Operation succeeded | ||
* 1 - Program Operation failed or region is protected | ||
*/ | ||
#define MX_SECURITY_PFAIL 0x20u | ||
|
||
/** | ||
* @brief Erase Fail Flag | ||
* | ||
* 0 - Erase Operation succeeded | ||
* 1 - Erase Operation failed or region is protected | ||
*/ | ||
#define MX_SECURITY_EFAIL 0x40u | ||
|
||
/** | ||
* @brief Write Protection Selection Flag | ||
* | ||
* 0 - Normal Write Protect mode | ||
* 1 - Advanced Sector Protection mode | ||
*/ | ||
#define MX_SECURITY_WPSEL 0x80u | ||
/** @} */ | ||
|
||
/** | ||
* @name ISSI Style Security Register Bits from Extended Read Register (ERP) | ||
* @note These flags were taken from the IS25LE01G datasheet, but probably | ||
* apply to other devices from ISSI as well. | ||
* @{ | ||
*/ | ||
|
||
/** | ||
* @brief Reserved | ||
*/ | ||
#define IS_ERP_XXXXX 0x01u | ||
|
||
/** | ||
* @brief Protection Error Flag (R) | ||
* | ||
* 0 - No protection error | ||
* 1 - Protection Error occurred in program or erase | ||
*/ | ||
#define IS_ERP_PROT_E 0x02u | ||
|
||
/** | ||
* @brief Program Error Flag (R) | ||
* | ||
* 0 - Program Operation succeeded | ||
* 1 - Program Operation failed or region is protected | ||
*/ | ||
#define IS_ERP_P_ERR 0x04u | ||
|
||
/** | ||
* @brief Erase Error Flag (R) | ||
* | ||
* 0 - Erase Operation succeeded | ||
* 1 - Erase Operation failed or region is protected | ||
*/ | ||
#define IS_ERP_E_ERR 0x08u | ||
|
||
/** | ||
* @brief Data Learning Pattern Flag (R/W) | ||
* | ||
* 0 - DLP is disabled | ||
* 1 - DLP is enabled | ||
*/ | ||
#define IS_ERP_DLPEN 0x10u | ||
|
||
/** | ||
* @brief Output Driver Strength Bit 0 (R/W) | ||
*/ | ||
#define IS_ERP_ODS0 0x20u | ||
|
||
/** | ||
* @brief Output Driver Strength Bit 1 (R/W) | ||
*/ | ||
#define IS_ERP_ODS1 0x40u | ||
|
||
/** | ||
* @brief Output Driver Strength Bit 2 (R/W) | ||
*/ | ||
#define IS_ERP_ODS2 0x80u | ||
/** @} */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* MTD_SPI_NOR_DEFINES_H */ | ||
/** @} */ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like something where we could also have a software fallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, however reading back all the data that was written previously or doing a blank check after an erase operation would lead to a significant performance penalty.
That is something I would prefer to do in a second PR, separate from this.