Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
08200d8f
Commit
08200d8f
authored
9 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
S24FL1: Fix so that the driver compiles with 512 byte block support
parent
eb1191df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/mtd/s25fl1.c
+21
-4
21 additions, 4 deletions
drivers/mtd/s25fl1.c
with
21 additions
and
4 deletions
drivers/mtd/s25fl1.c
+
21
−
4
View file @
08200d8f
...
...
@@ -302,6 +302,12 @@
#define CLR_DIRTY(p) do { (p)->flags &= ~S25FL1_CACHE_DIRTY; } while (0)
#define CLR_ERASED(p) do { (p)->flags &= ~S25FL1_CACHE_DIRTY; } while (0)
/* 512 byte sector support **********************************************************/
#define S25FL1_SECTOR512_SHIFT 9
#define S25FL1_SECTOR512_SIZE (1 << 9)
#define S25FL1_ERASED_STATE 0xff
/************************************************************************************
* Private Types
************************************************************************************/
...
...
@@ -1006,9 +1012,15 @@ static int s25fl1_flush_cache(struct s25fl1_dev_s *priv)
if
(
IS_DIRTY
(
priv
)
||
IS_ERASED
(
priv
))
{
off_t
address
;
/* Convert the erase sector numuber into a FLASH address */
address
=
(
off_t
)
priv
->
esectno
<<
priv
->
sectorshift
;
/* Write entire erase block to FLASH */
ret
=
s25fl1_write_page
(
priv
,
priv
->
sector
,
1
<<
priv
->
sectorshift
);
ret
=
s25fl1_write_page
(
priv
,
priv
->
sector
,
address
,
1
<<
priv
->
sectorshift
);
if
(
ret
<
0
)
{
fdbg
(
"ERROR: s25fl1_write_page failed: %d
\n
"
,
ret
);
...
...
@@ -1061,8 +1073,8 @@ static FAR uint8_t *s25fl1_read_cache(struct s25fl1_dev_s *priv, off_t sector)
/* Read the erase block into the cache */
ret
=
s25fl1_read_byte
(
priv
,
priv
->
sector
,
(
esectno
<<
priv
->
sectorshift
)
(
1
<<
priv
->
sectorshift
));
(
esectno
<<
priv
->
sectorshift
)
,
(
1
<<
priv
->
sectorshift
));
if
(
ret
<
0
)
{
fdbg
(
"ERROR: s25fl1_read_byte failed: %d
\n
"
,
ret
);
...
...
@@ -1192,6 +1204,9 @@ static int s25fl1_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblo
{
FAR
struct
s25fl1_dev_s
*
priv
=
(
FAR
struct
s25fl1_dev_s
*
)
dev
;
size_t
blocksleft
=
nblocks
;
#ifdef CONFIG_S25FL1_SECTOR512
int
ret
;
#endif
fvdbg
(
"startblock: %08lx nblocks: %d
\n
"
,
(
long
)
startblock
,
(
int
)
nblocks
);
...
...
@@ -1232,7 +1247,9 @@ static int s25fl1_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblo
static
ssize_t
s25fl1_bread
(
FAR
struct
mtd_dev_s
*
dev
,
off_t
startblock
,
size_t
nblocks
,
FAR
uint8_t
*
buffer
)
{
#ifndef CONFIG_S25FL1_SECTOR512
FAR
struct
s25fl1_dev_s
*
priv
=
(
FAR
struct
s25fl1_dev_s
*
)
dev
;
#endif
ssize_t
nbytes
;
fvdbg
(
"startblock: %08lx nblocks: %d
\n
"
,
(
long
)
startblock
,
(
int
)
nblocks
);
...
...
@@ -1511,7 +1528,7 @@ FAR struct mtd_dev_s *s25fl1_initialize(FAR struct qspi_dev_s *qspi, bool unprot
#ifdef CONFIG_S25FL1_SECTOR512
/* Simulate a 512 byte sector */
/* Allocate a buffer for the erase block cache */
priv
->
sector
=
(
FAR
uint8_t
*
)
QSPI_ALLOC
(
1
<<
priv
->
sectorshift
);
priv
->
sector
=
(
FAR
uint8_t
*
)
QSPI_ALLOC
(
qspi
,
1
<<
priv
->
sectorshift
);
if
(
priv
->
sector
==
NULL
)
{
/* Allocation failed! Discard all of that work we just did and return NULL */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment