Skip to content
Snippets Groups Projects
Commit 06a23b1c authored by Benjamin Larsson's avatar Benjamin Larsson
Browse files

Remove debug output and add a little documentation

parent cf231eba
Branches
No related tags found
No related merge requests found
...@@ -54,12 +54,20 @@ int page_size = 2048; ...@@ -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. * 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 * 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 * 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) ...@@ -76,6 +84,8 @@ void print_usage(void)
printf("\t -m field order\n"); printf("\t -m field order\n");
printf("Default command is:\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("./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; return;
} }
...@@ -225,6 +235,7 @@ int main(int argc, char **argv) ...@@ -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 */ /* 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; 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) { if (ecc_level == 4) {
oob_ecc_sz = 16; oob_ecc_sz = 16;
} else if (ecc_level == 8) { } else if (ecc_level == 8) {
...@@ -294,10 +305,10 @@ int main(int argc, char **argv) ...@@ -294,10 +305,10 @@ int main(int argc, char **argv)
numBytesRead = fread(page_buffer, (size_t)1, (sector_sz)*SECTORS_PER_PAGE, in_file); numBytesRead = fread(page_buffer, (size_t)1, (sector_sz)*SECTORS_PER_PAGE, in_file);
totalBytesRead += numBytesRead; totalBytesRead += numBytesRead;
printf("Fread %d\n", totalBytesRead);
if (numBytesRead == 0) 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; goto exit;
} }
...@@ -321,7 +332,6 @@ int main(int argc, char **argv) ...@@ -321,7 +332,6 @@ int main(int argc, char **argv)
{ {
const uint8_t *sector_data = page_buffer + sector_sz * i; 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; 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) if (erase_block)
{ {
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment