summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Westermann <bernd.westermann@it-west.de>2019-07-17 09:57:59 +0200
committerStefan Müller-Klieser <s.mueller-klieser@phytec.de>2019-07-17 15:21:27 +0200
commitac6f162f1f0152e7ad1b82e9504a3cb96a0e0997 (patch)
tree2a082b7a7ba58190424f7a4db094889775e7e550
parent1e4bc6ef34c1c782bf22128c04847543200fdb0c (diff)
downloadmeta-phytec-ac6f162f1f0152e7ad1b82e9504a3cb96a0e0997.tar.bz2
meta-phytec-ac6f162f1f0152e7ad1b82e9504a3cb96a0e0997.zip
UPSTREAM: recipes-bsp: imx-kobs: Add barebox compatible slot switch feature
This feature switches the firmware slot. Signed-off-by: Bernd Westermann <bernd.westermann@it-west.de> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
-rw-r--r--recipes-bsp/imx-kobs/imx-kobs/0001-Add-missing-includes-as-pointed-out-by-musl.patch32
-rw-r--r--recipes-bsp/imx-kobs/imx-kobs/0001-Slot-switch.patch140
-rw-r--r--recipes-bsp/imx-kobs/imx-kobs_git.bb4
3 files changed, 142 insertions, 34 deletions
diff --git a/recipes-bsp/imx-kobs/imx-kobs/0001-Add-missing-includes-as-pointed-out-by-musl.patch b/recipes-bsp/imx-kobs/imx-kobs/0001-Add-missing-includes-as-pointed-out-by-musl.patch
deleted file mode 100644
index 9502664..0000000
--- a/recipes-bsp/imx-kobs/imx-kobs/0001-Add-missing-includes-as-pointed-out-by-musl.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From c183a648958ab4454247cfd88d01da7730a53d19 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Thu, 11 May 2017 00:59:07 -0700
-Subject: [PATCH] Add missing includes as pointed out by musl
-
-These headers are indrectly included when building with
-glibc, this is exposed when compiling with musl systems
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- src/mtd.h | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/src/mtd.h b/src/mtd.h
-index 6cb0ca2..0eaea48 100644
---- a/src/mtd.h
-+++ b/src/mtd.h
-@@ -25,9 +25,12 @@
- #ifndef MTD_H
- #define MTD_H
-
-+#define _GNU_SOURCE
-+#include <fcntl.h>
- #include <mtd/mtd-user.h>
- #include <endian.h>
- #include <stdint.h>
-+#include <stddef.h>
-
- #include "BootControlBlocks.h"
- #include "rom_nand_hamming_code_ecc.h"
---
-2.12.2
diff --git a/recipes-bsp/imx-kobs/imx-kobs/0001-Slot-switch.patch b/recipes-bsp/imx-kobs/imx-kobs/0001-Slot-switch.patch
new file mode 100644
index 0000000..be6b9b2
--- /dev/null
+++ b/recipes-bsp/imx-kobs/imx-kobs/0001-Slot-switch.patch
@@ -0,0 +1,140 @@
+commit ab10d292ef6cafa78488832aa342febf90987e86
+Author: Bernd Westermann <bernd.westermann@it-west.de>
+Date: Mon Jan 21 20:46:33 2019 +0100
+
+ test
+
+diff --git a/src/main.c b/src/main.c
+index 74d0cb5..27f4f93 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -82,6 +82,7 @@ void usage(void)
+ " -x .................................... Add 1k-padding in the head\n"
+ " -n .................................... Dry run (don't commit to flash)\n"
+ " -w .................................... Commit to flash\n"
++ " -s .................................... Switch Firmware_startingPages 1<->2\n"
+ "\n"
+ " update [-v] [KEY] [KOBS] [-0|1] <file> .. Update a single bootstream\n"
+ " -v .................................... Verbose mode\n"
+@@ -658,6 +659,9 @@ int init_main(int argc, char **argv)
+ case 'v':
+ flags |= F_VERBOSE;
+ break;
++ case 's':
++ flags |= F_FW_SLOT_SWITCH;
++ break;
+ }
+ }
+
+diff --git a/src/mtd.c b/src/mtd.c
+index d5e6d96..517da31 100644
+--- a/src/mtd.c
++++ b/src/mtd.c
+@@ -1392,6 +1392,43 @@ void dump(const void *data, int size)
+ printf("\n");
+ }
+
++int mtd_fw_load_low(struct mtd_data *md)
++{
++ int r;
++ BCB_ROM_BootBlockStruct_t *bbs;
++
++ if (md == NULL) {
++ fprintf(stderr, "mtd: md == NULL\n");
++ return -1;
++ }
++ r = mtd_read_page(md, 0, 0, 1);
++ if (r <= 0) {
++ fprintf(stderr, "mtd: read FCB failed\n");
++ return -1;
++ }
++ switch (plat_config_data->m_u32RomVer) {
++ case ROM_Version_3:
++ bbs = md->buf + 2;
++ break;
++ case ROM_Version_5:
++ bbs = md->buf + 22;
++ break;
++ default:
++ fprintf(stderr, "mtd: Unknown RomVer.\n");
++ return -1;
++ }
++ if (FCB_FINGERPRINT != bbs->m_u32FingerPrint) {
++ fprintf(stderr, "mtd: FCB Fingerprint not found\n");
++ return -1;
++ }
++ if (bbs->FCB_Block.m_u32Firmware1_startingPage < bbs->FCB_Block.m_u32Firmware2_startingPage)
++ {
++ return 1;
++ } else {
++ return 0;
++ }
++}
++
+ void *mtd_load_boot_structure(struct mtd_data *md, int chip, loff_t *ofsp, loff_t end,
+ uint32_t magic1, uint32_t magic2, uint32_t magic3, int use_ecc,
+ int magic_offset)
+@@ -2059,6 +2096,7 @@ static int fill_fcb(struct mtd_data *md, FILE *fp)
+ unsigned int boot_stream_size_in_blocks;
+ unsigned int boot_stream1_pos;
+ unsigned int boot_stream2_pos;
++ unsigned int boot_stream_pos;
+
+ if ((cfg->search_area_size_in_bytes * 2) > mtd_size(md)) {
+ fprintf(stderr, "mtd: mtd size too small\n"
+@@ -2169,6 +2207,21 @@ static int fill_fcb(struct mtd_data *md, FILE *fp)
+ boot_stream2_pos + max_boot_stream_size_in_bytes,
+ boot_stream2_pos + boot_stream_size_in_bytes);
+
++ /* Compute slot switch feature */
++ if (md->flags & F_FW_SLOT_SWITCH) {
++ if (1 == mtd_fw_load_low(md)) {
++ vp(md,"FW slot switch to HIGH!!!\n");
++ boot_stream_pos = boot_stream1_pos;
++ boot_stream1_pos = boot_stream2_pos;
++ boot_stream2_pos = boot_stream_pos;
++ boot_stream_pos = extra_boot_stream1_pos;
++ extra_boot_stream1_pos = extra_boot_stream2_pos;
++ extra_boot_stream2_pos = boot_stream_pos;
++ } else {
++ printf("FW slot switch to LOW!!!\n");
++ }
++ }
++
+ memset(fcb, 0, sizeof(*fcb));
+
+ fcb->m_u32FingerPrint = FCB_FINGERPRINT;
+@@ -3021,11 +3074,19 @@ int write_boot_stream(struct mtd_data *md, FILE *fp)
+ if (i == 0) {
+ startpage = fcb->m_u32Firmware1_startingPage;
+ size = fcb->m_u32PagesInFirmware1;
+- end = fcb->m_u32Firmware2_startingPage;
++ if (fcb->m_u32Firmware2_startingPage > fcb->m_u32Firmware1_startingPage) {
++ end = fcb->m_u32Firmware2_startingPage;
++ } else {
++ end = mtd_size(md) / mtd_writesize(md);
++ }
+ } else {
+ startpage = fcb->m_u32Firmware2_startingPage;
+ size = fcb->m_u32PagesInFirmware2;
+- end = mtd_size(md) / mtd_writesize(md);
++ if (fcb->m_u32Firmware1_startingPage > fcb->m_u32Firmware2_startingPage) {
++ end = fcb->m_u32Firmware1_startingPage;
++ } else {
++ end = mtd_size(md) / mtd_writesize(md);
++ }
+ }
+
+ start = startpage * mtd_writesize(md);
+diff --git a/src/mtd.h b/src/mtd.h
+index 31e507b..c3e1b8b 100644
+--- a/src/mtd.h
++++ b/src/mtd.h
+@@ -47,6 +47,7 @@
+ #define F_VERBOSE 0x01
+ #define F_MULTICHIP 0x02
+ #define F_AUTO_MULTICHIP 0x04
++#define F_FW_SLOT_SWITCH 0x08
+
+ #define vp(x, ...) \
+ do { \
diff --git a/recipes-bsp/imx-kobs/imx-kobs_git.bb b/recipes-bsp/imx-kobs/imx-kobs_git.bb
index 864cbe5..c25a012 100644
--- a/recipes-bsp/imx-kobs/imx-kobs_git.bb
+++ b/recipes-bsp/imx-kobs/imx-kobs_git.bb
@@ -9,9 +9,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=393a5ca445f6965873eca0259a17f833"
PV = "5.5+git${SRCPV}"
SRC_URI = "git://github.com/NXPmicro/imx-kobs.git;protocal=https \
- file://0001-Add-missing-includes-as-pointed-out-by-musl.patch \
+ file://0001-Slot-switch.patch \
"
-SRCREV = "a0e9adce2fb7fcd57e794d7f9a5deba0f94f521b"
+SRCREV = "228dbb9b1a202892d884bd01985dd3522ad49d59"
S = "${WORKDIR}/git"
inherit autotools pkgconfig