meta-digi-bsp: remove old kobs-ng 10.12.01 version

This version does not properly work with v3.10 kernel, while
the newer version 3.0.35-4.1.0 does work for old and new
kernels.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Reviewed-by: Javier Viguera <javier.viguera@digi.com>

https://jira.digi.com/browse/DEL-797
This commit is contained in:
Hector Palacios 2013-10-18 14:23:45 +02:00
parent 03848a9fd3
commit 071cdf9b7b
9 changed files with 0 additions and 1083 deletions

View File

@ -1,264 +0,0 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Fri, 1 Apr 2011 14:45:52 +0200
Subject: [PATCH] dump v1 boot structures
The kobs-ng that we received from Freescale did not support reading the
boot structures on the mx28. It could write them, but the function that
reads them was never updated to handle the updated structures used by
the mx28. This change adds basic support for reading these structures,
enough so that the dump command works. I would not recommend using
any of the other functions, such as extract or update though.
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
src/main.c | 6 ++-
src/mtd.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
src/mtd.h | 1 +
3 files changed, 174 insertions(+), 4 deletions(-)
diff --git a/src/main.c b/src/main.c
index 0b83828..c21dece 100644
--- a/src/main.c
+++ b/src/main.c
@@ -146,7 +146,11 @@ int dump_main(int argc, char **argv)
if (flags & F_VERBOSE)
mtd_dump(md);
- r = mtd_load_all_boot_structures(md);
+ if (rom_version == ROM_Version_1) {
+ r = mtd_load_v1_boot_structures(md);
+ } else {
+ r = mtd_load_all_boot_structures(md);
+ }
if (r != 0) {
fprintf(stderr, "Unable to load boot structures\n");
exit(5);
diff --git a/src/mtd.c b/src/mtd.c
index b827a80..bcbb8d3 100644
--- a/src/mtd.c
+++ b/src/mtd.c
@@ -65,6 +65,11 @@ const struct mtd_config default_mtd_config = {
.boot_stream_2_address = 0,
};
+
+static int mtd_read_bcb(struct mtd_data *md, char *bcb_name,
+ loff_t ofs1, loff_t ofs2, loff_t ofs_mchip,
+ loff_t end, size_t size, int ecc);
+
static inline int multichip(struct mtd_data *md)
{
return md->flags & F_MULTICHIP;
@@ -932,6 +937,32 @@ void *mtd_load_boot_structure(struct mtd_data *md, int chip, loff_t *ofsp, loff_
return md->buf;
}
+// This function is a hack by Digi, written because the original code from
+// Freescale did not support reading the v1 boot structures at all. Do not
+// use the results from this function for anything other than browsing the
+// boot structures.
+int mtd_load_v1_boot_structures(struct mtd_data *md)
+{
+ int err = 0;
+
+ err = mtd_read_bcb(md, "FCB", 0, 0, 0, 1, mtd_writesize(md) + mtd_oobsize(md), false);
+
+ memcpy(&md->fcb, md->buf, sizeof(md->fcb));
+ //----------------------------------------------------------------------
+ // read the DBBT search area.
+ //----------------------------------------------------------------------
+
+ err |= mtd_read_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);
+
+ memcpy(&md->dbbt28, md->buf, sizeof(md->dbbt28));
+
+ if ((err != 0) || (md->dbbt28.m_u32FingerPrint != DBBT_FINGERPRINT2)) {
+ err = -1;
+ }
+
+ return err;
+}
+
/* single chip version */
int mtd_load_all_boot_structures(struct mtd_data *md)
{
@@ -1754,7 +1785,7 @@ int v1_rom_mtd_init(struct mtd_data *md, FILE *fp)
}
-v2_rom_mtd_init(struct mtd_data *md, FILE *fp)
+int v2_rom_mtd_init(struct mtd_data *md, FILE *fp)
{
unsigned int stride_size_in_bytes;
unsigned int search_area_size_in_bytes;
@@ -1774,7 +1805,7 @@ v2_rom_mtd_init(struct mtd_data *md, FILE *fp)
// Compute the geometry of a search area.
//----------------------------------------------------------------------
- stride_size_in_bytes = mtd_erasesize;
+ stride_size_in_bytes = mtd_erasesize(md);
search_area_size_in_bytes = 4 * stride_size_in_bytes;
search_area_size_in_pages = search_area_size_in_bytes / mtd_writesize(md);
@@ -2053,6 +2084,140 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
return err;
}
+
+//------------------------------------------------------------------------------
+// This function is a hack written by Digi because the original code from
+// Freescale did not supporting reading the bootlet structures at all.
+//
+// This function reads the search areas for a given BCB. It will read the first
+// search area and use it if the read succeeds. If the read fails, then it will
+// try again with the second search area.
+//
+// md A pointer to the current struct mtd_data.
+// bcb_name A pointer to a human-readable string that indicates what kind of
+// BCB we're reading. This string will only be used in log messages.
+// ofs1 If there is one chips, the index of the search area to read
+// ofs2
+// ofs_mchip If there are multiple chips, the index of the search area to read
+// on both chips.
+// end The number of consecutive search areas to be read.
+// size The size of the BCB data to be read.
+// ecc Indicates whether or not to use hardware ECC.
+//------------------------------------------------------------------------------
+int mtd_read_bcb(struct mtd_data *md, char *bcb_name,
+ loff_t ofs1, loff_t ofs2, loff_t ofs_mchip,
+ loff_t end, size_t size, int ecc)
+{
+ int chip;
+ loff_t end_index, search_area_indices[2], o;
+ int r;
+ int i;
+ int j;
+ unsigned stride_size_in_bytes;
+ unsigned search_area_size_in_strides;
+ unsigned search_area_size_in_bytes;
+
+ //----------------------------------------------------------------------
+ // Compute some important facts about geometry.
+ //----------------------------------------------------------------------
+ if (rom_version == ROM_Version_2) {
+
+ stride_size_in_bytes = mtd_erasesize(md);
+ search_area_size_in_strides = 4;
+ search_area_size_in_bytes = search_area_size_in_strides * stride_size_in_bytes;
+
+ } else {
+ stride_size_in_bytes = PAGES_PER_STRIDE * mtd_writesize(md);
+ search_area_size_in_strides = 1 << md->cfg.search_exponent;
+ search_area_size_in_bytes = search_area_size_in_strides * stride_size_in_bytes;
+ }
+
+ //----------------------------------------------------------------------
+ // Check whether there are multiple chips and set up the two search area
+ // indices accordingly.
+ //----------------------------------------------------------------------
+
+ if (multichip(md))
+ search_area_indices[0] = search_area_indices[1] = ofs_mchip;
+ else {
+ search_area_indices[0] = ofs1;
+ search_area_indices[1] = ofs2;
+ }
+
+ //----------------------------------------------------------------------
+ // Loop over search areas for this BCB.
+ //----------------------------------------------------------------------
+
+ for (i = 0; i < 2; i++) {
+
+ //--------------------------------------------------------------
+ // Compute the search area index that marks the end of the
+ // writing on this chip.
+ //--------------------------------------------------------------
+
+ end_index = search_area_indices[i] + end;
+
+ //--------------------------------------------------------------
+ // Figure out which chip we're writing.
+ //--------------------------------------------------------------
+
+ chip = multichip(md) ? i : 0;
+
+ //--------------------------------------------------------------
+ // Loop over consecutive search areas to write.
+ //--------------------------------------------------------------
+
+ for (; search_area_indices[i] < end_index; search_area_indices[i]++) {
+
+ //------------------------------------------------------
+ // Compute the byte offset of the beginning of this
+ // search area.
+ //------------------------------------------------------
+
+ o = search_area_indices[i] * search_area_size_in_bytes;
+
+ //------------------------------------------------------
+ // Loop over strides in this search area.
+ //------------------------------------------------------
+
+ for (j = 0; j < search_area_size_in_strides; j++, o += stride_size_in_bytes) {
+
+ //----------------------------------------------
+ // If we're crossing into a new block, erase it
+ // first.
+ //----------------------------------------------
+
+ //----------------------------------------------
+ // Write the page.
+ //----------------------------------------------
+
+ if (md->flags & F_VERBOSE)
+ printf("mtd: Reading %s%d @%d:0x%llx(%x)\n",
+ bcb_name, j, chip, o, size);
+
+/*int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
+ loff_t ofs1, loff_t ofs2, loff_t ofs_mchip,
+ loff_t end, size_t size, int ecc) */
+/* mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false); */
+ r = mtd_read_page(md, chip, o, ecc);
+ if (r != size) {
+ fprintf(stderr, "\n%s r = 0x%8.8X, size = 0x%8.8X\n", __func__, r, size);
+ fprintf(stderr, "mtd: Failed to read %s @%d: 0x%llx (%d)\n",
+ bcb_name, chip, o, r);
+ } else {
+ break;
+ }
+
+ }
+
+ }
+
+ }
+
+ return !(r == size);
+}
+
+
int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
{
int startpage, start, size;
@@ -2367,7 +2532,7 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
}
-v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
{
int startpage, start, size;
unsigned int search_area_size_in_bytes, stride_size_in_bytes;
diff --git a/src/mtd.h b/src/mtd.h
index b5c866e..cff09af 100644
--- a/src/mtd.h
+++ b/src/mtd.h
@@ -254,6 +254,7 @@ void *mtd_load_boot_structure(struct mtd_data *md, int chip, loff_t *ofsp, loff_
uint32_t magic1, uint32_t magic2, uint32_t magic3, int use_ecc,
int magic_offset);
int mtd_load_all_boot_structures(struct mtd_data *md);
+int mtd_load_v1_boot_structures(struct mtd_data *md);
int mtd_dump_structure(struct mtd_data *md);
int v0_rom_mtd_init(struct mtd_data *md, FILE *fp);

View File

@ -1,77 +0,0 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Fri, 1 Apr 2011 14:53:24 +0200
Subject: [PATCH] rom version
Add ROM version for the CPX2
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
src/main.c | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/src/main.c b/src/main.c
index c21dece..eb9504d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -795,7 +795,9 @@ void discover_boot_rom_version(void)
{
FILE *cpuinfo;
char line_buffer[100];
- static char *banner = "Hardware\t: Freescale MX";
+ static char *banner_hw = "Hardware\t:";
+ static char *banner = "Hardware\t: Freescale MX";
+ static char *banner_digi_x2 = "Hardware\t: Digi ConnectPort X2";
static char *v0_rom_tag = "23";
static char *v1_rom_tag = "28";
static char *v2_rom_tag = "53";
@@ -828,31 +830,31 @@ void discover_boot_rom_version(void)
//--------------------------------------------------------------
// Check if the current line contains the information we need.
//--------------------------------------------------------------
-
- if (strncmp(line_buffer, banner, strlen(banner))) {
+ if (strncmp(line_buffer, banner_hw, strlen(banner_hw))) {
continue;
}
- //--------------------------------------------------------------
- // If control arrives here, we found what we're looking for.
- // Extract the information we need.
- //--------------------------------------------------------------
-
- if (!strncmp(line_buffer + strlen(banner), v0_rom_tag, strlen(v0_rom_tag))) {
- rom_version = ROM_Version_0;
- break;
+ if ( !strncmp(line_buffer, banner, strlen(banner)) ) {
+ if (!strncmp(line_buffer + strlen(banner), v0_rom_tag, strlen(v0_rom_tag))) {
+ rom_version = ROM_Version_0;
+ break;
+ }
+ else
+ if (!strncmp(line_buffer + strlen(banner), v1_rom_tag, strlen(v1_rom_tag))) {
+ rom_version = ROM_Version_1;
+ break;
+ }
+ else
+ if (!strncmp(line_buffer + strlen(banner), v2_rom_tag, strlen(v2_rom_tag))) {
+ rom_version = ROM_Version_2;
+ break;
+ }
}
- else
- if (!strncmp(line_buffer + strlen(banner), v1_rom_tag, strlen(v1_rom_tag))) {
+
+ if ( !strncmp(line_buffer, banner_digi_x2, strlen(banner_digi_x2)) ) {
+ // The CPX2 has a ROM version 1
rom_version = ROM_Version_1;
- break;
}
- else
- if (!strncmp(line_buffer + strlen(banner), v2_rom_tag, strlen(v2_rom_tag))) {
- rom_version = ROM_Version_2;
- break;
- }
-
}
//----------------------------------------------------------------------

View File

@ -1,34 +0,0 @@
From: Hector Palacios <hector.palacios@digi.com>
Date: Tue, 19 Apr 2011 11:55:31 +0200
Subject: [PATCH] ncb: fixed transposed parameters in memset
Doesn't seem to be critical, but we'd better have the buffer with zeros
than with data.
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
src/ncb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ncb.c b/src/ncb.c
index 927ca01..6e6f21d 100644
--- a/src/ncb.c
+++ b/src/ncb.c
@@ -332,7 +332,7 @@ int ncb_encrypt(BootBlockStruct_t *ncb, void *target, size_t size, int version)
assert(version == 0 || version == 1 || version == 3);
assert(size >= sizeof(BootBlockStruct_t));
- memset(target, size, 0);
+ memset(target, 0, size);
switch (version)
{
@@ -377,7 +377,7 @@ int fcb_encrypt(V1_ROM_BootBlockStruct_t *fcb, void *target, size_t size, int ve
// Clear out the target.
//----------------------------------------------------------------------
- memset(target, size, 0);
+ memset(target, 0, size);
//----------------------------------------------------------------------
// Compute the checksum.

View File

@ -1,323 +0,0 @@
From: Hector Palacios <hector.palacios@digi.com>
Date: Tue, 19 Apr 2011 13:45:53 +0200
Subject: [PATCH] added verification of written data (only for v1 ROM)
Added new option to verify data committed to flash right after writing.
After each BCB or bootstream page write, the data is read back from flash
and verified against the written buffer in RAM.
If the verification fails the program exits.
Only added for v1_rom_mtd_commit_structures() -> MX28 arch.
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
src/main.c | 25 ++++++++++++++++-------
src/mtd.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
src/mtd.h | 6 +++---
3 files changed, 75 insertions(+), 21 deletions(-)
diff --git a/src/main.c b/src/main.c
index eb9504d..bd0bac0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -76,10 +76,12 @@ void usage(void)
" -v .................................... Verbose mode\n"
" -n .................................... Dry run (don't commit to flash)\n"
" -w .................................... Commit to flash\n"
+ " -c .................................... Check committed data in flash\n"
"\n"
" update [-v] [KEY] [KOBS] [-0|1] <file> .. Update a single bootstream\n"
" -v .................................... Verbose mode\n"
" -0|1 .................................. Update specified bootstream #\n"
+ " -c .................................... Check committed data in flash\n"
"\n"
" extract [-v] [KEY] [KOBS] [-0|1] <file> . Extract a bootstream from flash\n"
" -v .................................... Verbose mode\n"
@@ -378,7 +380,7 @@ int extract_main(int argc, char **argv)
return 0;
}
-static int perform_bootstream_update(struct mtd_data *md, FILE *infp, int image_mask)
+static int perform_bootstream_update(struct mtd_data *md, FILE *infp, int image_mask, int check)
{
int i, r;
unsigned int size, start, avail, end, update;
@@ -423,7 +425,7 @@ static int perform_bootstream_update(struct mtd_data *md, FILE *infp, int image_
update |= UPDATE_BS(i);
}
- r = v0_rom_mtd_commit_structures(md, infp, UPDATE_LDLB | update);
+ r = v0_rom_mtd_commit_structures(md, infp, UPDATE_LDLB | update, check);
if (r < 0) {
fprintf(stderr, "FAILED to commit structures\n");
return -1;
@@ -445,6 +447,7 @@ int update_main(int argc, char **argv)
char ascii[20 * 2 + 1];
int device_key;
uint8_t *keyp;
+ int check;
memset(key, 0, sizeof(key));
device_key = 0;
@@ -461,6 +464,7 @@ int update_main(int argc, char **argv)
image_mask = 0; /* no image */
flags = 0;
j = 0;
+ check = 0;
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
@@ -488,6 +492,9 @@ int update_main(int argc, char **argv)
exit(5);
}
break;
+ case 'c':
+ check = 1;
+ break;
case 'v':
flags |= F_VERBOSE;
break;
@@ -533,7 +540,7 @@ int update_main(int argc, char **argv)
if (flags & F_VERBOSE)
mtd_dump(md);
- r = perform_bootstream_update(md, infp, image_mask);
+ r = perform_bootstream_update(md, infp, image_mask, check);
if (r != 0) {
fprintf(stderr, "Unable to perform bootstream update\n");
usage();
@@ -555,7 +562,7 @@ int init_main(int argc, char **argv)
char *badlist = NULL;
FILE *infp;
loff_t ofs;
- int dryrun;
+ int dryrun, check;
struct mtd_config cfg;
uint8_t key[16];
char ascii[20 * 2 + 1];
@@ -577,6 +584,7 @@ int init_main(int argc, char **argv)
image = 0; /* first image */
flags = 0;
dryrun = 0;
+ check = 0;
j = 0;
for (i = 1; i < argc; i++) {
@@ -598,6 +606,9 @@ int init_main(int argc, char **argv)
case 'w':
dryrun = 0;
break;
+ case 'c':
+ check = 1;
+ break;
case 'n':
dryrun = 1;
break;
@@ -692,13 +703,13 @@ int init_main(int argc, char **argv)
if (!dryrun) {
switch (rom_version) {
case ROM_Version_0:
- r = v0_rom_mtd_commit_structures(md, infp, UPDATE_ALL);
+ r = v0_rom_mtd_commit_structures(md, infp, UPDATE_ALL, check);
break;
case ROM_Version_1:
- r = v1_rom_mtd_commit_structures(md, infp, UPDATE_ALL);
+ r = v1_rom_mtd_commit_structures(md, infp, UPDATE_ALL, check);
break;
case ROM_Version_2:
- r = v2_rom_mtd_commit_structures(md, infp, UPDATE_ALL);
+ r = v2_rom_mtd_commit_structures(md, infp, UPDATE_ALL, check);
break;
default:
fprintf(stderr, "Unknown ROM version: %d\n", rom_version);
diff --git a/src/mtd.c b/src/mtd.c
index bcbb8d3..4dbb878 100644
--- a/src/mtd.c
+++ b/src/mtd.c
@@ -1967,7 +1967,7 @@ int v2_rom_mtd_init(struct mtd_data *md, FILE *fp)
int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
loff_t ofs1, loff_t ofs2, loff_t ofs_mchip,
- loff_t end, size_t size, int ecc)
+ loff_t end, size_t size, int ecc, int verify)
{
int chip;
loff_t end_index, search_area_indices[2], o;
@@ -1977,6 +1977,13 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
unsigned stride_size_in_bytes;
unsigned search_area_size_in_strides;
unsigned search_area_size_in_bytes;
+ char *readbuf = NULL;
+
+ if (verify) {
+ readbuf = malloc(mtd_writesize(md));
+ if (NULL == readbuf)
+ return -1;
+ }
//----------------------------------------------------------------------
// Compute some important facts about geometry.
@@ -2072,6 +2079,21 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
err ++;
}
+ if (verify) {
+ //------------------------------------------------------
+ // Verify the written data
+ //------------------------------------------------------
+ r = pread(md->part[chip].fd, readbuf, mtd_writesize(md), o);
+ if (r != mtd_writesize(md)) {
+ fprintf(stderr, "mtd: Failed to read @0x%llx (%d)\n", o, r);
+ return -1;
+ }
+ if (memcmp(md->buf, readbuf, mtd_writesize(md))) {
+ fprintf(stderr, "mtd: Verification error @0x%llx\n", o);
+ return -1;
+ }
+ }
+
}
}
@@ -2218,7 +2240,7 @@ int mtd_read_bcb(struct mtd_data *md, char *bcb_name,
}
-int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify)
{
int startpage, start, size;
unsigned int search_area_sz, stride;
@@ -2317,7 +2339,7 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
if (r < 0)
return r;
- mtd_commit_bcb(md, "NCB", 0, 1, 0, 1, size, false);
+ mtd_commit_bcb(md, "NCB", 0, 1, 0, 1, size, false, verify);
}
if (flags & UPDATE_LDLB) {
@@ -2326,7 +2348,7 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, md->curr_ldlb, sizeof(*md->curr_ldlb));
- mtd_commit_bcb(md, "LDLB", 2, 3, 1, 1, mtd_writesize(md), true);
+ mtd_commit_bcb(md, "LDLB", 2, 3, 1, 1, mtd_writesize(md), true, verify);
}
if (flags & UPDATE_DBBT) {
@@ -2335,7 +2357,7 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, md->curr_dbbt, sizeof(*md->curr_dbbt));
- mtd_commit_bcb(md, "DBBT", 4, 5, 2, 1, mtd_writesize(md), true);
+ mtd_commit_bcb(md, "DBBT", 4, 5, 2, 1, mtd_writesize(md), true, verify);
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
if (md->flags & F_MULTICHIP) {
@@ -2369,14 +2391,20 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
return 0;
}
-int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify)
{
int startpage, start, size;
unsigned int search_area_size_in_bytes, stride_size_in_bytes;
int i, r, chunk;
loff_t ofs, end;
int chip = 0;
+ char *readbuf = NULL;
+ if (verify) {
+ readbuf = malloc(mtd_writesize(md));
+ if (NULL == readbuf)
+ return -1;
+ }
//----------------------------------------------------------------------
// Compute some important facts about geometry.
//----------------------------------------------------------------------
@@ -2403,7 +2431,7 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
// Write the FCB search area.
//----------------------------------------------------------------------
- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false);
+ mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false, verify);
//----------------------------------------------------------------------
// Write the DBBT search area.
@@ -2412,7 +2440,7 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, &(md->dbbt28), sizeof(md->dbbt28));
- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);
+ mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true, verify);
//----------------------------------------------------------------------
// Loop over the two boot streams.
@@ -2512,6 +2540,21 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
if (r != mtd_writesize(md)) {
fprintf(stderr, "mtd: Failed to write BS @0x%llx (%d)\n", ofs, r);
}
+
+ if (verify) {
+ //------------------------------------------------------
+ // Verify the written data
+ //------------------------------------------------------
+ r = pread(md->part[chip].fd, readbuf, mtd_writesize(md), ofs);
+ if (r != mtd_writesize(md)) {
+ fprintf(stderr, "mtd: Failed to read BS @0x%llx (%d)\n", ofs, r);
+ return -1;
+ }
+ if (memcmp(md->buf, readbuf, mtd_writesize(md))) {
+ fprintf(stderr, "mtd: Verification error @0x%llx\n", ofs);
+ return -1;
+ }
+ }
ofs += mtd_writesize(md);
size -= chunk;
@@ -2532,7 +2575,7 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
}
-int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify)
{
int startpage, start, size;
unsigned int search_area_size_in_bytes, stride_size_in_bytes;
@@ -2569,7 +2612,7 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, &(md->fcb), sizeof(md->fcb));
- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, mtd_writesize(md), true);
+ mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, mtd_writesize(md), true, verify);
//----------------------------------------------------------------------
// Write the DBBT search area.
@@ -2578,7 +2621,7 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, &(md->dbbt28), sizeof(md->dbbt28));
- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);
+ mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true, verify);
//----------------------------------------------------------------------
// Write the DBBT table area.
diff --git a/src/mtd.h b/src/mtd.h
index cff09af..429078f 100644
--- a/src/mtd.h
+++ b/src/mtd.h
@@ -269,9 +269,9 @@ int mtd_markbad(struct mtd_data *md, int chip, loff_t ofs);
#define UPDATE_BS1 0x10
#define UPDATE_BS(x) (0x08 << ((x) & 1))
#define UPDATE_ALL (UPDATE_NCB | UPDATE_LDLB | UPDATE_DBBT | UPDATE_BS0 | UPDATE_BS1)
-int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
-int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
-int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
+int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
+int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
+int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
int mtd_set_ecc_mode(struct mtd_data *md, int ecc);
#ifndef ARRAY_SIZE

View File

@ -1,68 +0,0 @@
From b8b59262cfddf3ddc68708ce0b242781df4377ae Mon Sep 17 00:00:00 2001
From: Alex Gonzalez <alex.gonzalez@digi.com>
Date: Thu, 11 Jul 2013 17:56:40 +0200
Subject: [PATCH] Remove MEMSETOOBSEL ioctl call.
It has been removed a long time ago, it does nothing on 2.6.35, and it
was finally removed from the ABI later on so it's not available on 3.10
header.
Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
---
src/mtd.c | 23 -----------------------
1 file changed, 23 deletions(-)
diff --git a/src/mtd.c b/src/mtd.c
index 4dbb878..0ae1ece 100644
--- a/src/mtd.c
+++ b/src/mtd.c
@@ -426,8 +426,6 @@ void mtd_dump(struct mtd_data *md)
}
-static struct nand_oobinfo none_oobinfo = { .useecc = MTD_NANDECC_OFF };
-
int parse_nfc_geometry(struct mtd_data *md)
{
FILE *node;
@@ -766,8 +764,6 @@ void mtd_close(struct mtd_data *md)
mp = &md->part[i];
if (mp->fd != -1) {
- (void)ioctl(mp->fd, MEMSETOOBSEL,
- &mp->old_oobinfo);
close(mp->fd);
}
@@ -809,31 +805,12 @@ int mtd_set_ecc_mode(struct mtd_data *md, int ecc)
fprintf(stderr, "mtd: device %s can't switch to normal\n", mp->name);
continue;
}
-
- if (r == -ENOTTY) {
- r = ioctl(mp->fd, MEMSETOOBSEL, &mp->old_oobinfo);
- if (r != 0) {
- fprintf(stderr, "mtd: device %s can't ioctl MEMSETOOBSEL\n", mp->name);
- continue;
- }
- mp->oobinfochanged = 0;
- }
} else {
r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_MODE_RAW);
if (r != 0 && r != -ENOTTY) {
fprintf(stderr, "mtd: device %s can't switch to RAW\n", mp->name);
continue;
}
-
- if (r == -ENOTTY) {
- r = ioctl(mp->fd, MEMSETOOBSEL, &none_oobinfo);
- if (r != 0) {
- fprintf(stderr, "mtd: device %s can't ioctl MEMSETOOBSEL\n", mp->name);
- continue;
- }
- mp->oobinfochanged = 1;
- } else
- mp->oobinfochanged = 2;
}
mp->ecc = ecc;

View File

@ -1,41 +0,0 @@
From 3284813587c14ff30f64df56a830a48c6be8cbb2 Mon Sep 17 00:00:00 2001
From: Alex Gonzalez <alex.gonzalez@digi.com>
Date: Thu, 11 Jul 2013 18:06:41 +0200
Subject: [PATCH] Rename MTD_MODE_* to MTD_FILE_MODE_*
On the 3.10 kernel, this ioctl has changed name.
Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
---
src/mtd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/mtd.c b/src/mtd.c
index 0ae1ece..79734fb 100644
--- a/src/mtd.c
+++ b/src/mtd.c
@@ -614,7 +614,7 @@ struct mtd_data *mtd_open(const struct mtd_config *cfg, int flags)
miu = &mp->info;
- r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_MODE_NORMAL);
+ r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_FILE_MODE_NORMAL);
if (r != 0 && r != -ENOTTY) {
fprintf(stderr, "mtd: device %s can't switch to normal\n", mp->name);
goto out;
@@ -800,13 +800,13 @@ int mtd_set_ecc_mode(struct mtd_data *md, int ecc)
continue;
if (ecc == 1) {
- r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_MODE_NORMAL);
+ r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_FILE_MODE_NORMAL);
if (r != 0 && r != -ENOTTY) {
fprintf(stderr, "mtd: device %s can't switch to normal\n", mp->name);
continue;
}
} else {
- r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_MODE_RAW);
+ r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_FILE_MODE_RAW);
if (r != 0 && r != -ENOTTY) {
fprintf(stderr, "mtd: device %s can't switch to RAW\n", mp->name);
continue;

View File

@ -1,141 +0,0 @@
From: Hector Palacios <hector.palacios@digi.com>
Date: Wed, 9 Oct 2013 12:07:37 +0200
Subject: [PATCH] version: parse ROM version from FDT if available
New kernels don't get CPU information from U-Boot ATAGS and
so the /proc/cpuinfo file does not have the Hardware/Revision
lines filled in.
This patch gets the CPU model from the device tree information
at /proc/device-tree/compatible.
For backwards compatibility, if the CPU model cannot be retrieved
from this file, we try to get it from /proc/cpuinfo.
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Reviewed-by: Javier Viguera <javier.viguera@digi.com>
---
src/main.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 66 insertions(+), 7 deletions(-)
diff --git a/src/main.c b/src/main.c
index c8d4e7f..c90c452 100644
--- a/src/main.c
+++ b/src/main.c
@@ -802,7 +802,7 @@ out:
return r;
}
-void discover_boot_rom_version(void)
+int get_rom_version_from_cpuinfo(void)
{
FILE *cpuinfo;
char line_buffer[100];
@@ -811,6 +811,7 @@ void discover_boot_rom_version(void)
static char *v1_rom_tag = "28";
static char *v2_rom_tag = "53";
char *rev;
+ int version = ROM_Version_Unknown;
//----------------------------------------------------------------------
// Attempt to open /proc/cpuinfo.
@@ -847,17 +848,17 @@ void discover_boot_rom_version(void)
rev += 2;
memcpy(tmp, rev, 2);
if (!strncmp(tmp, v0_rom_tag, strlen(v0_rom_tag))) {
- rom_version = ROM_Version_0;
+ version = ROM_Version_0;
break;
}
else
if (!strncmp(tmp, v1_rom_tag, strlen(v1_rom_tag))) {
- rom_version = ROM_Version_1;
+ version = ROM_Version_1;
break;
}
else
if (!strncmp(tmp, v2_rom_tag, strlen(v2_rom_tag))) {
- rom_version = ROM_Version_2;
+ version = ROM_Version_2;
break;
}
}
@@ -867,18 +868,76 @@ void discover_boot_rom_version(void)
//----------------------------------------------------------------------
// Close /proc/cpuinfo.
//----------------------------------------------------------------------
-
fclose(cpuinfo);
+ return version;
+}
+
+#define MAX_STRLEN 256
+int get_rom_version_from_fdt(void)
+{
+ FILE *fd;
+ char *line_buffer;
+ static char *v0_rom_tag = "fsl,imx23";
+ static char *v1_rom_tag = "fsl,imx28";
+ static char *v2_rom_tag = "fsl,imx53";
+ char *rev;
+ int version = ROM_Version_Unknown;
+
+ fd = fopen("/proc/device-tree/compatible", "r");
+ if (!fd)
+ return ROM_Version_Unknown;
+
+ line_buffer = malloc(MAX_STRLEN);
+ if (!line_buffer)
+ return ROM_Version_Unknown;
+ memset(line_buffer, MAX_STRLEN, 0);
+ if (fgets(line_buffer, MAX_STRLEN, fd)) {
+ /*
+ * The compatible string can contain more than one string.
+ * Each string value is separated from the next one by a
+ * NULL char. We must check all values one by one until
+ * we find two consecutive NULL chars.
+ */
+ while (line_buffer[0] != 0) {
+ if (!strncmp(line_buffer, v0_rom_tag,
+ strlen(v0_rom_tag))) {
+ version = ROM_Version_0;
+ break;
+ }
+ else if (!strncmp(line_buffer, v1_rom_tag,
+ strlen(v1_rom_tag))) {
+ version = ROM_Version_1;
+ break;
+ }
+ else if (!strncmp(line_buffer, v2_rom_tag,
+ strlen(v2_rom_tag))) {
+ version = ROM_Version_2;
+ break;
+ }
+ /* Move string pointer to next possible value */
+ line_buffer += strlen(line_buffer) + 1;
+ }
+ }
+
+ fclose(fd);
+
+ return version;
+}
+
+void discover_boot_rom_version(void)
+{
+ rom_version = get_rom_version_from_fdt();
+ if (rom_version == ROM_Version_Unknown)
+ rom_version = get_rom_version_from_cpuinfo();
+
//----------------------------------------------------------------------
// Check if we found what we needed.
//----------------------------------------------------------------------
-
if (rom_version == ROM_Version_Unknown) {
fprintf(stderr, "Couldn't discover Boot ROM version\n");
exit(1);
}
-
}
int main(int argc, char **argv)

View File

@ -1,102 +0,0 @@
From b25a7a52f45a4961763543fc67b8ad30cfb02deb Mon Sep 17 00:00:00 2001
From: Hector Palacios <hector.palacios@digi.com>
Date: Mon, 21 May 2012 11:02:43 +0200
Subject: [PATCH 5/5] version: parse MX arch to select rom version
Parse the 'Hardware' line of /cpu/proc in search for the
string 'MX' and then parse the two numbers after it, which
will contain the architecture number (23,28,53) that
determine the rom version to use.
Notice this patch is only applicable to platforms that contain
the string 'MX25, MX28, MX53' on their platform names.
E.g.
ConnectCard Wi-i.MX28 -> OK
ConnectPort CPX2 -> NOT OK
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
src/main.c | 50 +++++++++++++++++++++++---------------------------
1 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/src/main.c b/src/main.c
index bd0bac0..c8d4e7f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -807,11 +807,10 @@ void discover_boot_rom_version(void)
FILE *cpuinfo;
char line_buffer[100];
static char *banner_hw = "Hardware\t:";
- static char *banner = "Hardware\t: Freescale MX";
- static char *banner_digi_x2 = "Hardware\t: Digi ConnectPort X2";
static char *v0_rom_tag = "23";
static char *v1_rom_tag = "28";
static char *v2_rom_tag = "53";
+ char *rev;
//----------------------------------------------------------------------
// Attempt to open /proc/cpuinfo.
@@ -834,38 +833,35 @@ void discover_boot_rom_version(void)
// Attempt to get the current line.
//--------------------------------------------------------------
- if (!fgets(line_buffer, sizeof(line_buffer), cpuinfo)) {
+ if (!fgets(line_buffer, sizeof(line_buffer), cpuinfo))
break;
- }
//--------------------------------------------------------------
// Check if the current line contains the information we need.
//--------------------------------------------------------------
- if (strncmp(line_buffer, banner_hw, strlen(banner_hw))) {
- continue;
- }
-
- if ( !strncmp(line_buffer, banner, strlen(banner)) ) {
- if (!strncmp(line_buffer + strlen(banner), v0_rom_tag, strlen(v0_rom_tag))) {
- rom_version = ROM_Version_0;
- break;
- }
- else
- if (!strncmp(line_buffer + strlen(banner), v1_rom_tag, strlen(v1_rom_tag))) {
- rom_version = ROM_Version_1;
- break;
- }
- else
- if (!strncmp(line_buffer + strlen(banner), v2_rom_tag, strlen(v2_rom_tag))) {
- rom_version = ROM_Version_2;
- break;
+ if (!strncmp(line_buffer, banner_hw, strlen(banner_hw))) {
+ rev = strstr(line_buffer, "MX");
+ if (rev) {
+ char tmp[3] = {};
+
+ rev += 2;
+ memcpy(tmp, rev, 2);
+ if (!strncmp(tmp, v0_rom_tag, strlen(v0_rom_tag))) {
+ rom_version = ROM_Version_0;
+ break;
+ }
+ else
+ if (!strncmp(tmp, v1_rom_tag, strlen(v1_rom_tag))) {
+ rom_version = ROM_Version_1;
+ break;
+ }
+ else
+ if (!strncmp(tmp, v2_rom_tag, strlen(v2_rom_tag))) {
+ rom_version = ROM_Version_2;
+ break;
+ }
}
}
-
- if ( !strncmp(line_buffer, banner_digi_x2, strlen(banner_digi_x2)) ) {
- // The CPX2 has a ROM version 1
- rom_version = ROM_Version_1;
- }
}
//----------------------------------------------------------------------
--
1.7.1

View File

@ -1,33 +0,0 @@
# Copyright 2013 Digi International. All rights reserved.
SUMMARY = "Freescale's mxs nand update utility"
SECTION = "base"
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
PR = "${DISTRO}.r0"
SRC_URI = " \
${DIGI_MIRROR}/${PN}-${PV}.tar.gz \
file://0001-dump-v1-boot-structures.patch \
file://0002-rom-version.patch \
file://0003-ncb-fixed-transposed-parameters-in-memset.patch \
file://0004-added-verification-of-written-data-only-for-v1-ROM.patch \
"
SRC_URI_append_ccardimx28js = " \
file://0005-version-parse-MX-arch-to-select-rom-version.patch \
"
SRC_URI_append = " \
file://0006-Remove-MEMSETOOBSEL-ioctl-call.patch \
file://0007-Rename-MTD_MODE_-to-MTD_FILE_MODE_.patch \
file://0008-version-parse-ROM-version-from-FDT-if-available.patch \
"
SRC_URI[md5sum] = "9fce401b6c90e851f0335b9ca3a649a9"
SRC_URI[sha256sum] = "ef25f5c9033500c236b1894436bddc4e20b90bc17585fbcdf9fe3bbbd9f15781"
inherit autotools
COMPATIBLE_MACHINE = "(mxs)"
BBCLASSEXTEND = "native"