Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nand-image-builder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Broadcom
nand-image-builder
Commits
06a23b1c
"README.md" did not exist on "cc00602238a1279d0e901b83db2f779b946eeb9d"
Commit
06a23b1c
authored
4 years ago
by
Benjamin Larsson
Browse files
Options
Downloads
Patches
Plain Diff
Remove debug output and add a little documentation
parent
cf231eba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nand-image-builder.c
+15
-5
15 additions, 5 deletions
nand-image-builder.c
with
15 additions
and
5 deletions
nand-image-builder.c
+
15
−
5
View file @
06a23b1c
...
...
@@ -54,12 +54,20 @@ int page_size = 2048;
/**
*
* This program reads raw NAND image from standard input and updates ECC bytes in the OOB block for each sector.
* Data layout is as following:
* Data layout is as following
(listing only tested geometrys)
:
*
* 2 KB page, consisting of 4 x 512 B sectors
* 64 bytes OOB, consisting of 4 x 16 B OOB regions, one for each sector
*
* In each OOB region, the first 9 1/2 bytes are user defined and the remaining 6 1/2 bytes are ECC.
* ./nand-image-builder -i infile -o outfile -b 131072 -p 2048 -s 64 -e 4 -m 14
*
* or
*
* 2 KB page, consisting of 4 x 512 B sectors
* 128 bytes OOB, consisting of 4 x 32 B OOB regions, one for each sector
* in this case only 4 x 27 bytes are used as spare area
*
* ./nand-image-builder -i infile -o outfile -b 131072 -p 2048 -s 128 -e 8 -m 14
*
*/
...
...
@@ -76,6 +84,8 @@ void print_usage(void)
printf
(
"
\t
-m field order
\n
"
);
printf
(
"Default command is:
\n
"
);
printf
(
"./nand-image-builder -i infile -o outfile -b 131072 -p 2048 -s 64 -e 4 -m 14
\n
"
);
printf
(
"Example command is:
\n
"
);
printf
(
"./nand-image-builder -i infile -o outfile -b 131072 -p 2048 -s 128 -e 8 -m 14
\n
"
);
return
;
}
...
...
@@ -225,6 +235,7 @@ int main(int argc, char **argv)
/* Number of ecc_code bytes, v = ceil(p/8) = ceil(m*t/8) = p_partial_page_size+s-u */
oob_ecc_len
=
(
sector_sz
+
oob_sz
)
-
data_bytes
;
/* Number of ecc bytes per sector (sub page) depending on the ecc level */
if
(
ecc_level
==
4
)
{
oob_ecc_sz
=
16
;
}
else
if
(
ecc_level
==
8
)
{
...
...
@@ -294,10 +305,10 @@ int main(int argc, char **argv)
numBytesRead
=
fread
(
page_buffer
,
(
size_t
)
1
,
(
sector_sz
)
*
SECTORS_PER_PAGE
,
in_file
);
totalBytesRead
+=
numBytesRead
;
printf
(
"Fread %d
\n
"
,
totalBytesRead
);
if
(
numBytesRead
==
0
)
{
printf
(
"Fread failed or file size is zero
\r\n
"
);
printf
(
"Fread failed or file size is zero
or out of data
\r\n
"
);
goto
exit
;
}
...
...
@@ -321,7 +332,6 @@ int main(int argc, char **argv)
{
const
uint8_t
*
sector_data
=
page_buffer
+
sector_sz
*
i
;
uint8_t
*
sector_oob
=
page_buffer
+
sector_sz
*
SECTORS_PER_PAGE
+
oob_ecc_sz
*
i
;
printf
(
"offset %d
\n
"
,
sector_sz
*
SECTORS_PER_PAGE
+
oob_ecc_sz
*
i
);
if
(
erase_block
)
{
...
...
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