mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Teresa Remmet <t.remmet@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/4] OMAP: xload: nand: Check for redundant barebox partition
Date: Wed, 29 Jun 2016 12:01:06 +0200	[thread overview]
Message-ID: <1467194468-31049-2-git-send-email-t.remmet@phytec.de> (raw)
In-Reply-To: <1467194468-31049-1-git-send-email-t.remmet@phytec.de>

Add a support for a redundant barebox backup partition if loading
barebox image from first barebox partitions fails.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
 arch/arm/boards/phytec-som-am335x/board.c |  2 ++
 arch/arm/mach-omap/include/mach/generic.h |  2 ++
 arch/arm/mach-omap/xload.c                | 17 ++++++++++++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c
index 7a87841..ca325b5 100644
--- a/arch/arm/boards/phytec-som-am335x/board.c
+++ b/arch/arm/boards/phytec-som-am335x/board.c
@@ -47,6 +47,8 @@ coredevice_initcall(physom_coredevice_init);
 static struct omap_barebox_part physom_barebox_part = {
 	.nand_offset = SZ_512K,
 	.nand_size = SZ_512K,
+	.nand_bkup_offset = SZ_1M,
+	.nand_bkup_size = SZ_512K,
 	.nor_offset = SZ_128K,
 	.nor_size = SZ_512K,
 };
diff --git a/arch/arm/mach-omap/include/mach/generic.h b/arch/arm/mach-omap/include/mach/generic.h
index a2a48cc..fe194b3 100644
--- a/arch/arm/mach-omap/include/mach/generic.h
+++ b/arch/arm/mach-omap/include/mach/generic.h
@@ -55,6 +55,8 @@ extern unsigned int __omap_cpu_type;
 struct omap_barebox_part {
 	unsigned int nand_offset;
 	unsigned int nand_size;
+	unsigned int nand_bkup_offset;
+	unsigned int nand_bkup_size;
 	unsigned int nor_offset;
 	unsigned int nor_size;
 };
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 91890b2..14a631e 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -24,6 +24,8 @@ struct omap_barebox_part *barebox_part;
 static struct omap_barebox_part default_part = {
 	.nand_offset = SZ_128K,
 	.nand_size = SZ_1M,
+	.nand_bkup_offset = 0,
+	.nand_bkup_size = 0,
 	.nor_offset = SZ_128K,
 	.nor_size = SZ_1M,
 };
@@ -99,11 +101,24 @@ static void *read_mtd_barebox(const char *partition)
 
 static void *omap_xload_boot_nand(struct omap_barebox_part *part)
 {
+	void *to;
+
 	devfs_add_partition("nand0", part->nand_offset, part->nand_size,
 					DEVFS_PARTITION_FIXED, "x");
 	dev_add_bb_dev("x", "bbx");
 
-	return read_mtd_barebox("bbx");
+	to = read_mtd_barebox("bbx");
+	if (to == NULL && part->nand_bkup_size != 0) {
+		printf("trying to load image from backup partition.\n");
+		devfs_add_partition("nand0", part->nand_bkup_offset,
+				part->nand_bkup_size,
+				DEVFS_PARTITION_FIXED, "x_bkup");
+		dev_add_bb_dev("x_bkup", "bbx_bkup");
+
+		to = read_mtd_barebox("bbx_bkup");
+	}
+
+	return to;
 }
 
 static void *omap_xload_boot_mmc(void)
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2016-06-29 10:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 10:01 [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition Teresa Remmet
2016-06-29 10:01 ` Teresa Remmet [this message]
2016-06-29 10:01 ` [PATCH 3/4] OMAP: am33xx_bbu_nand: Extent barebox update handler Teresa Remmet
2016-06-29 10:01 ` [PATCH 4/4] ARM: phytec-som-am335x: Add backup partition for barebox Teresa Remmet
2016-06-30  6:37 ` [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467194468-31049-2-git-send-email-t.remmet@phytec.de \
    --to=t.remmet@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox