summaryrefslogtreecommitdiff
path: root/ubi-utils/src/reader.c
diff options
context:
space:
mode:
authorFrank Haverkamp <haver@vnet.ibm.com>2006-07-10 15:47:05 +0200
committerFrank Haverkamp <haver@vnet.ibm.com>2006-10-31 15:06:07 +0100
commit02e51e7e0b4c50d900d3a246b2bce73df3a191ee (patch)
tree42b80dc4a076300cc17f7e9d2f5739470abefab3 /ubi-utils/src/reader.c
parentc474d44341b1ab9b1b39cf2bbf8686a610b54614 (diff)
[MTD] UBI: Fixed 16 KiB blocksize problem.
Diffstat (limited to 'ubi-utils/src/reader.c')
-rw-r--r--ubi-utils/src/reader.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/ubi-utils/src/reader.c b/ubi-utils/src/reader.c
index e4a8ceb..5de06d5 100644
--- a/ubi-utils/src/reader.c
+++ b/ubi-utils/src/reader.c
@@ -34,8 +34,9 @@
#include "reader.h"
/* @FIXME hard coded offsets right now - get them from Artem? */
-#define NAND_DEFAULT_VID_HDR_OFF 1984
-#define NOR_DEFAULT_VID_HDR_OFF 64
+#define NAND2048_DEFAULT_VID_HDR_OFF 1984
+#define NAND512_DEFAULT_VID_HDR_OFF 448
+#define NOR_DEFAULT_VID_HDR_OFF 64
#define EBUF_PFI(fmt...) \
do { int i = snprintf(err_buf, err_buf_size, "%s\n", label); \
@@ -74,8 +75,27 @@ read_pdd_data(FILE* fp_pdd, pdd_data_t* pdd_data,
}
if (strcmp(value, "NAND") == 0) {
+
+ rc = bootenv_get_num(pdd, "flash_page_size",
+ &(res->flash_page_size));
+ if (rc != 0) {
+ EBUF("Cannot read 'flash_page_size' from pdd.");
+ goto err;
+ }
res->flash_type = NAND_FLASH;
- res->vid_hdr_offset = NAND_DEFAULT_VID_HDR_OFF;
+
+ switch (res->flash_page_size) {
+ case 512:
+ res->vid_hdr_offset = NAND512_DEFAULT_VID_HDR_OFF;
+ break;
+ case 2048:
+ res->vid_hdr_offset = NAND2048_DEFAULT_VID_HDR_OFF;
+ break;
+ default:
+ EBUF("Unsupported 'flash_page_size' %d.",
+ res->flash_page_size);
+ goto err;
+ }
}
else if (strcmp(value, "NOR") == 0){
res->flash_type = NOR_FLASH;
@@ -113,11 +133,6 @@ read_pdd_data(FILE* fp_pdd, pdd_data_t* pdd_data,
return rc;
}
-/**
- * FIXME enhance flasing raw PFI content e.g. IPLs for NAND and NOR.
- * Here is one of the only places where the flash type and its special
- * handling is exposed to the users.
- */
int
read_pfi_raw(pfi_header pfi_hd, FILE* fp_pfi __unused, pfi_raw_t* pfi_raw,
const char* label, char* err_buf, size_t err_buf_size)
@@ -175,10 +190,6 @@ read_pfi_raw(pfi_header pfi_hd, FILE* fp_pfi __unused, pfi_raw_t* pfi_raw,
return rc;
}
-/**
- * FIXME Enhance reading raw PFI sections, e.g. IPL. See comment at
- * write_pfi_ubi.
- */
int
read_pfi_ubi(pfi_header pfi_hd, FILE* fp_pfi __unused, pfi_ubi_t* pfi_ubi,
const char *label, char* err_buf, size_t err_buf_size)