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
37c5113c
Commit
37c5113c
authored
11 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
MTD NAND: Fix an error in the calculation of the page number
parent
b3d3f593
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/mtd/hamming.c
+12
-8
12 additions, 8 deletions
drivers/mtd/hamming.c
drivers/mtd/mtd_nand.c
+3
-3
3 additions, 3 deletions
drivers/mtd/mtd_nand.c
with
15 additions
and
11 deletions
drivers/mtd/hamming.c
+
12
−
8
View file @
37c5113c
...
...
@@ -259,8 +259,6 @@ static void hamming_compute256(FAR const uint8_t *data, FAR uint8_t *code)
code
[
0
]
=
(
~
(
uint32_t
)
code
[
0
]);
code
[
1
]
=
(
~
(
uint32_t
)
code
[
1
]);
code
[
2
]
=
(
~
(
uint32_t
)
code
[
2
]);
fvdbg
(
"Computed: %02x %02x %02x
\n
"
,
code
[
0
],
code
[
1
],
code
[
2
]);
}
/****************************************************************************
...
...
@@ -294,9 +292,6 @@ static int hamming_verify256(FAR uint8_t *data, FAR const uint8_t *original)
correction
[
1
]
=
computed
[
1
]
^
original
[
1
];
correction
[
2
]
=
computed
[
2
]
^
original
[
2
];
fvdbg
(
"Correction: %02x %02x %02x
\n
"
,
correction
[
0
],
correction
[
1
],
correction
[
2
]);
/* If all bytes are 0, there is no error */
if
((
correction
[
0
]
==
0
)
&&
(
correction
[
1
]
==
0
)
&&
(
correction
[
2
]
==
0
))
...
...
@@ -304,6 +299,15 @@ static int hamming_verify256(FAR uint8_t *data, FAR const uint8_t *original)
return
0
;
}
/* There are bit errors */
fvdbg
(
"Read: %02x %02x %02x
\n
"
,
original
[
0
],
original
[
1
],
original
[
2
]);
fvdbg
(
"Computed: %02x %02x %02x
\n
"
,
computed
[
0
],
computed
[
1
],
computed
[
2
]);
fvdbg
(
"Correction: %02x %02x %02x
\n
"
,
correction
[
0
],
correction
[
1
],
correction
[
2
]);
/* If there is a single bit error, there are 11 bits set to 1 */
if
(
hamming_bitsincode256
(
correction
)
==
11
)
...
...
@@ -339,13 +343,15 @@ static int hamming_verify256(FAR uint8_t *data, FAR const uint8_t *original)
if
(
hamming_bitsincode256
(
correction
)
==
1
)
{
fdbg
(
"ERROR: ECC has been correupted
\n
"
);
return
HAMMING_ERROR_ECC
;
}
/* Otherwise, th
is is a
multi
-
bit error */
/* Otherwise, th
ere are
multi
ple
bit error
s
*/
else
{
fdbg
(
"ERROR: Multiple bit errors
\n
"
);
return
HAMMING_ERROR_MULTIPLEBITS
;
}
}
...
...
@@ -421,8 +427,6 @@ int hamming_verify256x(FAR uint8_t *data, size_t size, FAR const uint8_t *code)
while
(
remaining
>
0
)
{
fvdbg
(
"Code: %02x %02x %02x
\n
"
,
code
[
0
],
code
[
1
],
code
[
2
]);
result
=
hamming_verify256
(
data
,
code
);
if
(
result
!=
HAMMING_SUCCESS
)
{
...
...
This diff is collapsed.
Click to expand it.
drivers/mtd/mtd_nand.c
+
3
−
3
View file @
37c5113c
...
...
@@ -609,7 +609,7 @@ static ssize_t nand_bread(struct mtd_dev_s *dev, off_t startpage,
off_t
block
;
int
ret
;
fvdbg
(
"startpage: %
08lx
npages: %d
\n
"
,
(
long
)
startpage
,
(
int
)
npages
);
fvdbg
(
"startpage: %
ld
npages: %d
\n
"
,
(
long
)
startpage
,
(
int
)
npages
);
DEBUGASSERT
(
nand
&&
nand
->
raw
);
/* Retrieve the model */
...
...
@@ -628,7 +628,7 @@ static ssize_t nand_bread(struct mtd_dev_s *dev, off_t startpage,
/* Get the block and page offset associated with the startpage */
block
=
startpage
/
pagesperblock
;
page
=
pagesperblock
%
pagesperblock
;
page
=
startpage
%
pagesperblock
;
/* Lock access to the NAND until we complete the read */
...
...
@@ -719,7 +719,7 @@ static ssize_t nand_bwrite(struct mtd_dev_s *dev, off_t startpage,
/* Get the block and page offset associated with the startpage */
block
=
startpage
/
pagesperblock
;
page
=
pagesperblock
%
pagesperblock
;
page
=
startpage
%
pagesperblock
;
/* Lock access to the NAND until we complete the write */
...
...
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