write an alternate bootstream with kobs-ng

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

write an alternate bootstream with kobs-ng

Jump to solution
2,091 Views
bba
Contributor III

Reading the iMX28 Reference Manual, it should be possible to load an alternate bootimage using the ROM_SECONDARY_BOOT persistent bit. The normal write prozess with kobs-ng always write both bootimages.

root@imx28evk /boot$ kobs-ng -z -v imx28_ivt_linux.sb

...

mtd: opened '/dev/mtd0' - '(null)'

mtd: max_boot_stream_size_in_bytes = 9961472

mtd: boot_stream_size_in_bytes = 2529872

mtd: #1 0x00100000 - 0x00a80000 (0x00369a50)

mtd: #2 0x00a80000 - 0x01400000 (0x00ce9a50)

  m_u32Checksum = 0

  m_u32FingerPrint = 541213510

  m_u32Version = 16777216

FCB

...

Firmware: image #0 @ 0x100000 size 0x26a000 - available 0x980000

Firmware: image #1 @ 0xa80000 size 0x26a000 - available 0x980000

...

mtd: Writing FCB3 @0:0x60000(840)

mtd_commit_bcb(FCB): status 0

...

mtd: Writing DBBT3 @0:0xe0000(800)

mtd_commit_bcb(DBBT): status 0

...

mtd: Writting firmware image #0 @0: 0x00100000 - 0x0036a000

...

mtd: Writting firmware image #1 @0: 0x00a80000 - 0x00cea000

But we want to write different images as bootstream 0 and bootstream1 using

root@imx28evk /boot$ kobs-ng update -z -1 imx28_ivt_linux.sb

mtd: fingerprints mismatch @0:0x0

mtd: fingerprints mismatch @0:0x20000

mtd: fingerprints mismatch @0:0x40000

mtd: fingerprints mismatch @0:0x60000

mtd: NCB0 not found

mtd: fingerprints mismatch @0:0x80000

mtd: fingerprints mismatch @0:0xa0000

mtd: fingerprints mismatch @0:0xc0000

mtd: fingerprints mismatch @0:0xe0000

mtd: NCB1 not found

mtd: neither NCB1 or NCB2 found ERROR

Unable to load boot structures

Unable to perform bootstream update

These failes. Here we got the same errors like "kobs-ng dump"

What can we do? Is there an updated kobs-ng version available? We are using kobs-ng from L2.6.35_1.1.0_130130_source.

Regards,

Birger

Labels (2)
1 Solution
802 Views
bba
Contributor III

It seams to me that version kobs-ng-3.0.0 has some problems on iMX28. I'm using kobs-ng-3.0.35-4.0.0 from the OpenWrt repository

http://repository.timesys.com/buildsources/k/kobs-ng/

These version works well with the imx28 evaluationboard.

diff -rupN kobs-ng-3.0.35-4.0.0-org/src/main.c kobs-ng-3.0.35-4.0.0/src/main.c

--- kobs-ng-3.0.35-4.0.0-org/src/main.c    2013-09-04 15:02:02.521560820 +0200

+++ kobs-ng-3.0.35-4.0.0/src/main.c    2013-09-04 14:49:10.681579437 +0200

@@ -586,6 +586,7 @@ static char *padding_1k_in_head(char *fi

int init_main(int argc, char **argv)

{

+    int mask = UPDATE_ALL;

     int i, j, r;

     struct mtd_data *md;

     int flags, image;

@@ -626,6 +627,12 @@ int init_main(int argc, char **argv)

         }

         switch (argv[i][1]) {

+            case '0':

+                mask = UPDATE_BS0;

+                break;

+            case '1':

+                mask = UPDATE_BS1;

+                break;

             case 'b':

                 badlist = &argv[i][2];

                 if (*badlist == '\0') {

@@ -735,7 +742,7 @@ int init_main(int argc, char **argv)

         mtd_dump_structure(md);

     if (!dryrun) {

-        r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_ALL);

+        r = plat_config_data->rom_mtd_commit_structures(md, infp, mask);

         if (r < 0) {

             fprintf(stderr, "FAILED to commit structures\n");

             exit(5);

diff -rupN kobs-ng-3.0.35-4.0.0-org/src/mtd.c kobs-ng-3.0.35-4.0.0/src/mtd.c

--- kobs-ng-3.0.35-4.0.0-org/src/mtd.c    2012-12-18 07:37:40.000000000 +0100

+++ kobs-ng-3.0.35-4.0.0/src/mtd.c    2013-09-04 15:03:59.217558007 +0200

@@ -2337,7 +2337,7 @@ int mtd_commit_bcb(struct mtd_data *md,

     return err;

}

-int write_boot_stream(struct mtd_data *md, FILE *fp)

+int write_boot_stream(struct mtd_data *md, FILE *fp, int flags)

{

     int startpage, start, size;

     loff_t ofs, end;

@@ -2347,7 +2347,7 @@ int write_boot_stream(struct mtd_data *m

     vp(md, "---------- Start to write the [ %s ]----\n", (char*)md->private);

     for (i = 0; i < 2; i++) {

-        if (fp == NULL)

+        if (fp == NULL || (flags & UPDATE_BS(i)) == 0)

             continue;

         if (i == 0) {

@@ -2660,7 +2660,7 @@ int v1_rom_mtd_commit_structures(struct

     write_dbbt(md, 1); /* only write the DBBT for nand0 */

     /* write the boot image. */

-    return write_boot_stream(md, fp);

+    return write_boot_stream(md, fp, flags);

}

int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)

@@ -2891,7 +2891,7 @@ int v4_rom_mtd_commit_structures(struct

     }

     /* [3] Write the two boot streams. */

-    return write_boot_stream(md, fp);

+    return write_boot_stream(md, fp, flags);

}

#undef ARG

View solution in original post

0 Kudos
2 Replies
802 Views
bba
Contributor III

Hello, I found an solution for these problem and have modified the init function with two additional parameters -0 and -1.

The normal init prozess writes Bootstream 0 and 1 as well as FCB and DBBT Block

    root@imx28evk ~$ kobs-ng init -v -d /boot/imx28_ivt_linux.sb

Than these only writes Bootstream 0.

    root@imx28evk ~$ kobs-ng init -v -d -0 /boot/imx28_ivt_linux.sb

and finaly these only writes Bootstream 1.

    root@imx28evk ~$ kobs-ng init -v -d -1 /boot/imx28_ivt_linux.sb

Than the used Bootstream can be selected with the ROM_SECONDARY_BOOT bit using memtools from imx-tests.

root@imx28evk ~$ /unit_tests/memtool 80056070=2

Writing 32-bit value 0x2 to address 0x80056070                    => selecting secondary bootstream

or

root@imx28evk ~$ /unit_tests/memtool 80056070=0

Writing 32-bit value 0x0 to address 0x80056070                   => selecting primary bootstream

Regards,

Birger

***********************************************************************************************************************************************

diff -rupN kobs-ng-3.0.0.org/src/main.c kobs-ng-3.0.0/src/main.c

--- kobs-ng-3.0.0.org/src/main.c    2012-08-30 08:58:49.000000000 +0200

+++ kobs-ng-3.0.0/src/main.c    2013-09-06 11:55:46.422945623 +0200

@@ -555,6 +555,7 @@ int update_main(int argc, char **argv)

int init_main(int argc, char **argv)

{

+    int mask = UPDATE_ALL;

     int i, j, r;

     struct mtd_data *md;

     int flags, image;

@@ -594,6 +595,12 @@ int init_main(int argc, char **argv)

         }

         switch (argv[i][1]) {

+            case '0':

+                mask = UPDATE_BS0;

+                break;

+            case '1':

+                mask = UPDATE_BS1;

+                break;

             case 'b':

                 badlist = &argv[i][2];

                 if (*badlist == '\0') {

@@ -687,7 +694,7 @@ int init_main(int argc, char **argv)

         mtd_dump_structure(md);

     if (!dryrun) {

-        r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_ALL);

+        r = plat_config_data->rom_mtd_commit_structures(md, infp, mask);

         if (r < 0) {

             fprintf(stderr, "FAILED to commit structures\n");

             exit(5);

diff -rupN kobs-ng-3.0.0.org/src/mtd.c kobs-ng-3.0.0/src/mtd.c

--- kobs-ng-3.0.0.org/src/mtd.c    2012-08-30 08:58:49.000000000 +0200

+++ kobs-ng-3.0.0/src/mtd.c    2013-09-06 11:56:35.594944436 +0200

@@ -2289,7 +2289,7 @@ int mtd_commit_bcb(struct mtd_data *md,

     return err;

}

-int write_boot_stream(struct mtd_data *md, FILE *fp)

+int write_boot_stream(struct mtd_data *md, FILE *fp, int flags)

{

     int startpage, start, size;

     loff_t ofs, end;

@@ -2299,7 +2299,7 @@ int write_boot_stream(struct mtd_data *m

     vp(md, "---------- Start to write the [ %s ]----\n", (char*)md->private);

     for (i = 0; i < 2; i++) {

-        if (fp == NULL)

+        if (fp == NULL || (flags & UPDATE_BS(i)) == 0)

             continue;

         if (i == 0) {

@@ -2562,7 +2562,7 @@ int v1_rom_mtd_commit_structures(struct

     mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);

     /* write the boot image. */

-    return write_boot_stream(md, fp);

+    return write_boot_stream(md, fp, flags);

}

int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)

@@ -2793,7 +2793,7 @@ int v4_rom_mtd_commit_structures(struct

     }

     /* [3] Write the two boot streams. */

-    return write_boot_stream(md, fp);

+    return write_boot_stream(md, fp, flags);

}

#undef ARG

0 Kudos
803 Views
bba
Contributor III

It seams to me that version kobs-ng-3.0.0 has some problems on iMX28. I'm using kobs-ng-3.0.35-4.0.0 from the OpenWrt repository

http://repository.timesys.com/buildsources/k/kobs-ng/

These version works well with the imx28 evaluationboard.

diff -rupN kobs-ng-3.0.35-4.0.0-org/src/main.c kobs-ng-3.0.35-4.0.0/src/main.c

--- kobs-ng-3.0.35-4.0.0-org/src/main.c    2013-09-04 15:02:02.521560820 +0200

+++ kobs-ng-3.0.35-4.0.0/src/main.c    2013-09-04 14:49:10.681579437 +0200

@@ -586,6 +586,7 @@ static char *padding_1k_in_head(char *fi

int init_main(int argc, char **argv)

{

+    int mask = UPDATE_ALL;

     int i, j, r;

     struct mtd_data *md;

     int flags, image;

@@ -626,6 +627,12 @@ int init_main(int argc, char **argv)

         }

         switch (argv[i][1]) {

+            case '0':

+                mask = UPDATE_BS0;

+                break;

+            case '1':

+                mask = UPDATE_BS1;

+                break;

             case 'b':

                 badlist = &argv[i][2];

                 if (*badlist == '\0') {

@@ -735,7 +742,7 @@ int init_main(int argc, char **argv)

         mtd_dump_structure(md);

     if (!dryrun) {

-        r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_ALL);

+        r = plat_config_data->rom_mtd_commit_structures(md, infp, mask);

         if (r < 0) {

             fprintf(stderr, "FAILED to commit structures\n");

             exit(5);

diff -rupN kobs-ng-3.0.35-4.0.0-org/src/mtd.c kobs-ng-3.0.35-4.0.0/src/mtd.c

--- kobs-ng-3.0.35-4.0.0-org/src/mtd.c    2012-12-18 07:37:40.000000000 +0100

+++ kobs-ng-3.0.35-4.0.0/src/mtd.c    2013-09-04 15:03:59.217558007 +0200

@@ -2337,7 +2337,7 @@ int mtd_commit_bcb(struct mtd_data *md,

     return err;

}

-int write_boot_stream(struct mtd_data *md, FILE *fp)

+int write_boot_stream(struct mtd_data *md, FILE *fp, int flags)

{

     int startpage, start, size;

     loff_t ofs, end;

@@ -2347,7 +2347,7 @@ int write_boot_stream(struct mtd_data *m

     vp(md, "---------- Start to write the [ %s ]----\n", (char*)md->private);

     for (i = 0; i < 2; i++) {

-        if (fp == NULL)

+        if (fp == NULL || (flags & UPDATE_BS(i)) == 0)

             continue;

         if (i == 0) {

@@ -2660,7 +2660,7 @@ int v1_rom_mtd_commit_structures(struct

     write_dbbt(md, 1); /* only write the DBBT for nand0 */

     /* write the boot image. */

-    return write_boot_stream(md, fp);

+    return write_boot_stream(md, fp, flags);

}

int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)

@@ -2891,7 +2891,7 @@ int v4_rom_mtd_commit_structures(struct

     }

     /* [3] Write the two boot streams. */

-    return write_boot_stream(md, fp);

+    return write_boot_stream(md, fp, flags);

}

#undef ARG

0 Kudos