* [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition
@ 2016-06-29 10:01 Teresa Remmet
2016-06-29 10:01 ` [PATCH 2/4] OMAP: xload: nand: Check for redundant barebox partition Teresa Remmet
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Teresa Remmet @ 2016-06-29 10:01 UTC (permalink / raw)
To: barebox
Remove code duplication of reading images out of mtd partitions.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
arch/arm/mach-omap/xload.c | 71 ++++++++++++++--------------------------------
1 file changed, 22 insertions(+), 49 deletions(-)
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 7793819..91890b2 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -36,7 +36,7 @@ static void *read_image_head(const char *name)
cdev = cdev_open(name, O_RDONLY);
if (!cdev) {
- printf("failed to open partition\n");
+ printf("failed to open %s\n", name);
return NULL;
}
@@ -44,7 +44,7 @@ static void *read_image_head(const char *name)
cdev_close(cdev);
if (ret != ARM_HEAD_SIZE) {
- printf("failed to read from partition\n");
+ printf("failed to read from %s\n", name);
return NULL;
}
@@ -63,18 +63,14 @@ static unsigned int get_image_size(void *head)
return ret;
}
-static void *omap_xload_boot_nand(int offset, int part_size)
+static void *read_mtd_barebox(const char *partition)
{
int ret;
int size;
void *to, *header;
struct cdev *cdev;
- devfs_add_partition("nand0", offset, part_size,
- DEVFS_PARTITION_FIXED, "x");
- dev_add_bb_dev("x", "bbx");
-
- header = read_image_head("bbx");
+ header = read_image_head(partition);
if (header == NULL)
return NULL;
@@ -86,21 +82,30 @@ static void *omap_xload_boot_nand(int offset, int part_size)
to = xmalloc(size);
- cdev = cdev_open("bbx", O_RDONLY);
+ cdev = cdev_open(partition, O_RDONLY);
if (!cdev) {
- printf("failed to open nand\n");
+ printf("failed to open partition\n");
return NULL;
}
ret = cdev_read(cdev, to, size, 0, 0);
if (ret != size) {
- printf("failed to read from nand\n");
+ printf("failed to read from partition\n");
return NULL;
}
return to;
}
+static void *omap_xload_boot_nand(struct omap_barebox_part *part)
+{
+ 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");
+}
+
static void *omap_xload_boot_mmc(void)
{
int ret;
@@ -138,41 +143,12 @@ static void *omap_xload_boot_mmc(void)
return buf;
}
-static void *omap_xload_boot_spi(int offset, int part_size)
+static void *omap_xload_boot_spi(struct omap_barebox_part *part)
{
- int ret;
- int size;
- void *to, *header;
- struct cdev *cdev;
-
- devfs_add_partition("m25p0", offset, part_size,
+ devfs_add_partition("m25p0", part->nor_offset, part->nor_size,
DEVFS_PARTITION_FIXED, "x");
- header = read_image_head("x");
- if (header == NULL)
- return NULL;
-
- size = get_image_size(header);
- if (!size) {
- printf("failed to get image size\n");
- return NULL;
- }
-
- to = xmalloc(size);
-
- cdev = cdev_open("x", O_RDONLY);
- if (!cdev) {
- printf("failed to open spi flash\n");
- return NULL;
- }
-
- ret = cdev_read(cdev, to, size, 0, 0);
- if (ret != size) {
- printf("failed to read from spi flash\n");
- return NULL;
- }
-
- return to;
+ return read_mtd_barebox("x");
}
static void *omap4_xload_boot_usb(void){
@@ -323,13 +299,11 @@ static __noreturn int omap_xload(void)
break;
case BOOTSOURCE_NAND:
printf("booting from NAND\n");
- func = omap_xload_boot_nand(barebox_part->nand_offset,
- barebox_part->nand_size);
+ func = omap_xload_boot_nand(barebox_part);
break;
case BOOTSOURCE_SPI:
printf("booting from SPI\n");
- func = omap_xload_boot_spi(barebox_part->nor_offset,
- barebox_part->nor_size);
+ func = omap_xload_boot_spi(barebox_part);
break;
case BOOTSOURCE_SERIAL:
if (IS_ENABLED(CONFIG_OMAP_SERIALBOOT)) {
@@ -347,8 +321,7 @@ static __noreturn int omap_xload(void)
}
default:
printf("unknown boot source. Fall back to nand\n");
- func = omap_xload_boot_nand(barebox_part->nand_offset,
- barebox_part->nand_size);
+ func = omap_xload_boot_nand(barebox_part);
break;
}
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] OMAP: xload: nand: Check for redundant barebox partition
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
2016-06-29 10:01 ` [PATCH 3/4] OMAP: am33xx_bbu_nand: Extent barebox update handler Teresa Remmet
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Teresa Remmet @ 2016-06-29 10:01 UTC (permalink / raw)
To: barebox
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] OMAP: am33xx_bbu_nand: Extent barebox update handler
2016-06-29 10:01 [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition Teresa Remmet
2016-06-29 10:01 ` [PATCH 2/4] OMAP: xload: nand: Check for redundant barebox partition Teresa Remmet
@ 2016-06-29 10:01 ` 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
3 siblings, 0 replies; 5+ messages in thread
From: Teresa Remmet @ 2016-06-29 10:01 UTC (permalink / raw)
To: barebox
Make it possible to write barebox image to multiple partitions
like xload partitions.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
arch/arm/boards/phytec-som-am335x/board.c | 7 ++++-
arch/arm/mach-omap/am33xx_bbu_nand.c | 50 +++++++++++++++++--------------
arch/arm/mach-omap/include/mach/bbu.h | 7 +++--
3 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c
index ca325b5..d5c27e2 100644
--- a/arch/arm/boards/phytec-som-am335x/board.c
+++ b/arch/arm/boards/phytec-som-am335x/board.c
@@ -60,6 +60,10 @@ static char *xloadslots[] = {
"/dev/nand0.xload_backup3.bb"
};
+static char *nandslots[] = {
+ "/dev/nand0.barebox.bb",
+};
+
static int physom_devices_init(void)
{
if (!of_machine_is_compatible("phytec,am335x-som"))
@@ -105,7 +109,8 @@ static int physom_devices_init(void)
am33xx_bbu_spi_nor_register_handler("spi", "/dev/m25p0.barebox");
am33xx_bbu_nand_xloadslots_register_handler("MLO.nand",
xloadslots, ARRAY_SIZE(xloadslots));
- am33xx_bbu_nand_register_handler("nand", "/dev/nand0.barebox.bb");
+ am33xx_bbu_nand_slots_register_handler("nand", nandslots,
+ ARRAY_SIZE(nandslots));
if (IS_ENABLED(CONFIG_SHELL_NONE))
return am33xx_of_register_bootdevice();
diff --git a/arch/arm/mach-omap/am33xx_bbu_nand.c b/arch/arm/mach-omap/am33xx_bbu_nand.c
index 25f0e79..7785d40 100644
--- a/arch/arm/mach-omap/am33xx_bbu_nand.c
+++ b/arch/arm/mach-omap/am33xx_bbu_nand.c
@@ -62,21 +62,15 @@ static int write_image(const char *devfile, const void *image, size_t size)
}
/*
- * This handler updates all given xload slots in nand with an image.
+ * Upate given nand partitions with an image
*/
-static int nand_xloadslots_update_handler(struct bbu_handler *handler,
- struct bbu_data *data)
+static int nand_slot_update_handler(struct bbu_handler *handler,
+ struct bbu_data *data)
{
- int ret = 0;
+ int ret, i;
+ struct nand_bbu_handler *nh;
const void *image = data->image;
size_t size = data->len;
- struct nand_bbu_handler *nh;
- int i = 0;
-
- if (file_detect_type(image, size) != filetype_ch_image) {
- pr_err("%s is not a valid ch-image\n", data->imagefile);
- return -EINVAL;
- }
nh = container_of(handler, struct nand_bbu_handler, bbu_handler);
@@ -100,6 +94,23 @@ static int nand_xloadslots_update_handler(struct bbu_handler *handler,
return 0;
}
+/*
+ * This handler updates all given xload slots in nand with an image.
+ */
+static int nand_xloadslots_update_handler(struct bbu_handler *handler,
+ struct bbu_data *data)
+{
+ const void *image = data->image;
+ size_t size = data->len;
+
+ if (file_detect_type(image, size) != filetype_ch_image) {
+ pr_err("%s is not a valid ch-image\n", data->imagefile);
+ return -EINVAL;
+ }
+
+ return nand_slot_update_handler(handler, data);
+}
+
int am33xx_bbu_nand_xloadslots_register_handler(const char *name,
char **devicefile,
int num_devicefiles)
@@ -124,32 +135,27 @@ int am33xx_bbu_nand_xloadslots_register_handler(const char *name,
static int nand_update_handler(struct bbu_handler *handler,
struct bbu_data *data)
{
- int ret = 0;
const void *image = data->image;
size_t size = data->len;
- struct nand_bbu_handler *nh;
if (file_detect_type(image, size) != filetype_arm_barebox) {
pr_err("%s is not a valid barebox image\n", data->imagefile);
return -EINVAL;
}
- nh = container_of(handler, struct nand_bbu_handler, bbu_handler);
-
- ret = bbu_confirm(data);
- if (ret != 0)
- return ret;
-
- return write_image(data->devicefile, image, size);
+ return nand_slot_update_handler(handler, data);
}
-int am33xx_bbu_nand_register_handler(const char *name, char *devicefile)
+int am33xx_bbu_nand_slots_register_handler(const char *name, char **devicefile,
+ int num_devicefiles)
{
struct nand_bbu_handler *handler;
int ret;
handler = xzalloc(sizeof(*handler));
- handler->bbu_handler.devicefile = devicefile;
+ handler->devicefile = devicefile;
+ handler->num_devicefiles = num_devicefiles;
+ handler->bbu_handler.devicefile = devicefile[0];
handler->bbu_handler.handler = nand_update_handler;
handler->bbu_handler.name = name;
diff --git a/arch/arm/mach-omap/include/mach/bbu.h b/arch/arm/mach-omap/include/mach/bbu.h
index 7c5dcbd..c8b0a55 100644
--- a/arch/arm/mach-omap/include/mach/bbu.h
+++ b/arch/arm/mach-omap/include/mach/bbu.h
@@ -21,7 +21,8 @@ static inline int am33xx_bbu_spi_nor_register_handler(const char *name, char *de
int am33xx_bbu_nand_xloadslots_register_handler(const char *name,
char **devicefile,
int num_devicefiles);
-int am33xx_bbu_nand_register_handler(const char *name, char *devicefile);
+int am33xx_bbu_nand_slots_register_handler(const char *name, char **devicefile,
+ int num_devicefiles);
#else
static inline int am33xx_bbu_nand_xloadslots_register_handler(const char *name,
char **devicefile,
@@ -30,7 +31,9 @@ static inline int am33xx_bbu_nand_xloadslots_register_handler(const char *name,
return 0;
}
-static inline int am33xx_bbu_nand_register_handler(const char *name, char *devicefile)
+static inline int am33xx_bbu_nand_slots_register_handler(const char *name,
+ char **devicefile,
+ int num_devicefiles)
{
return 0;
}
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] ARM: phytec-som-am335x: Add backup partition for barebox
2016-06-29 10:01 [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition Teresa Remmet
2016-06-29 10:01 ` [PATCH 2/4] OMAP: xload: nand: Check for redundant barebox partition Teresa Remmet
2016-06-29 10:01 ` [PATCH 3/4] OMAP: am33xx_bbu_nand: Extent barebox update handler Teresa Remmet
@ 2016-06-29 10:01 ` Teresa Remmet
2016-06-30 6:37 ` [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Teresa Remmet @ 2016-06-29 10:01 UTC (permalink / raw)
To: barebox
Add a redundant barebox partition to improve nand safety at
least a little bit.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
arch/arm/boards/phytec-som-am335x/board.c | 1 +
arch/arm/dts/am335x-phytec-phycard-som.dtsi | 23 ++++++++++++++++-------
arch/arm/dts/am335x-phytec-phycore-som.dtsi | 19 ++++++++++++-------
arch/arm/dts/am335x-phytec-phyflex-som.dtsi | 23 ++++++++++++++++-------
4 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c
index d5c27e2..7f62453 100644
--- a/arch/arm/boards/phytec-som-am335x/board.c
+++ b/arch/arm/boards/phytec-som-am335x/board.c
@@ -62,6 +62,7 @@ static char *xloadslots[] = {
static char *nandslots[] = {
"/dev/nand0.barebox.bb",
+ "/dev/nand0.barebox_backup.bb",
};
static int physom_devices_init(void)
diff --git a/arch/arm/dts/am335x-phytec-phycard-som.dtsi b/arch/arm/dts/am335x-phytec-phycard-som.dtsi
index f052f0c..3dd9cad 100644
--- a/arch/arm/dts/am335x-phytec-phycard-som.dtsi
+++ b/arch/arm/dts/am335x-phytec-phycard-som.dtsi
@@ -206,23 +206,32 @@
};
partition@100000 {
+ label = "barebox_backup";
+ reg = <0x100000 0x80000>;
+ };
+
+ partition@180000 {
label = "bareboxenv";
- reg = <0x100000 0x40000>;
+ reg = <0x180000 0x40000>;
};
- partition@140000 {
+ partition@1C0000 {
label = "oftree";
- reg = <0x140000 0x40000>;
+ reg = <0x1C0000 0x40000>;
};
- partition@180000 {
+ partition@200000 {
label = "kernel";
- reg = <0x180000 0x800000>;
+ reg = <0x200000 0x800000>;
};
- partition@980000 {
+ partition@A00000 {
label = "root";
- reg = <0x980000 0x0>;
+ /*
+ * Size 0x0 extends partition to
+ * end of nand flash.
+ */
+ reg = <0xA00000 0x0>;
};
};
};
diff --git a/arch/arm/dts/am335x-phytec-phycore-som.dtsi b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
index e48d545..0fc3c96 100644
--- a/arch/arm/dts/am335x-phytec-phycore-som.dtsi
+++ b/arch/arm/dts/am335x-phytec-phycore-som.dtsi
@@ -290,27 +290,32 @@
};
partition@100000 {
+ label = "barebox_backup";
+ reg = <0x100000 0x80000>;
+ };
+
+ partition@180000 {
label = "bareboxenv";
- reg = <0x100000 0x40000>;
+ reg = <0x180000 0x40000>;
};
- partition@140000 {
+ partition@1C0000 {
label = "oftree";
- reg = <0x140000 0x40000>;
+ reg = <0x1C0000 0x40000>;
};
- partition@180000 {
+ partition@200000 {
label = "kernel";
- reg = <0x180000 0x800000>;
+ reg = <0x200000 0x800000>;
};
- partition@980000 {
+ partition@A00000 {
label = "root";
/*
* Size 0x0 extends partition to
* end of nand flash.
*/
- reg = <0x980000 0x0>;
+ reg = <0xA00000 0x0>;
};
};
};
diff --git a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi
index 6561625..db78cb1 100644
--- a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi
+++ b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi
@@ -304,23 +304,32 @@
};
partition@100000 {
+ label = "barebox_backup";
+ reg = <0x100000 0x80000>;
+ };
+
+ partition@180000 {
label = "bareboxenv";
- reg = <0x100000 0x40000>;
+ reg = <0x180000 0x40000>;
};
- partition@140000 {
+ partition@1C0000 {
label = "oftree";
- reg = <0x140000 0x40000>;
+ reg = <0x1C0000 0x40000>;
};
- partition@180000 {
+ partition@200000 {
label = "kernel";
- reg = <0x180000 0x800000>;
+ reg = <0x200000 0x800000>;
};
- partition@980000 {
+ partition@A00000 {
label = "root";
- reg = <0x980000 0x0>;
+ /*
+ * Size 0x0 extends partition to
+ * end of nand flash.
+ */
+ reg = <0xA00000 0x0>;
};
};
};
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition
2016-06-29 10:01 [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition Teresa Remmet
` (2 preceding siblings ...)
2016-06-29 10:01 ` [PATCH 4/4] ARM: phytec-som-am335x: Add backup partition for barebox Teresa Remmet
@ 2016-06-30 6:37 ` Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2016-06-30 6:37 UTC (permalink / raw)
To: Teresa Remmet; +Cc: barebox
On Wed, Jun 29, 2016 at 12:01:05PM +0200, Teresa Remmet wrote:
> Remove code duplication of reading images out of mtd partitions.
>
> Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
> ---
> arch/arm/mach-omap/xload.c | 71 ++++++++++++++--------------------------------
> 1 file changed, 22 insertions(+), 49 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> index 7793819..91890b2 100644
> --- a/arch/arm/mach-omap/xload.c
> +++ b/arch/arm/mach-omap/xload.c
> @@ -36,7 +36,7 @@ static void *read_image_head(const char *name)
>
> cdev = cdev_open(name, O_RDONLY);
> if (!cdev) {
> - printf("failed to open partition\n");
> + printf("failed to open %s\n", name);
> return NULL;
> }
>
> @@ -44,7 +44,7 @@ static void *read_image_head(const char *name)
> cdev_close(cdev);
>
> if (ret != ARM_HEAD_SIZE) {
> - printf("failed to read from partition\n");
> + printf("failed to read from %s\n", name);
> return NULL;
> }
>
> @@ -63,18 +63,14 @@ static unsigned int get_image_size(void *head)
> return ret;
> }
>
> -static void *omap_xload_boot_nand(int offset, int part_size)
> +static void *read_mtd_barebox(const char *partition)
> {
> int ret;
> int size;
> void *to, *header;
> struct cdev *cdev;
>
> - devfs_add_partition("nand0", offset, part_size,
> - DEVFS_PARTITION_FIXED, "x");
> - dev_add_bb_dev("x", "bbx");
> -
> - header = read_image_head("bbx");
> + header = read_image_head(partition);
> if (header == NULL)
> return NULL;
>
> @@ -86,21 +82,30 @@ static void *omap_xload_boot_nand(int offset, int part_size)
>
> to = xmalloc(size);
>
> - cdev = cdev_open("bbx", O_RDONLY);
> + cdev = cdev_open(partition, O_RDONLY);
> if (!cdev) {
> - printf("failed to open nand\n");
> + printf("failed to open partition\n");
> return NULL;
> }
>
> ret = cdev_read(cdev, to, size, 0, 0);
> if (ret != size) {
> - printf("failed to read from nand\n");
> + printf("failed to read from partition\n");
> return NULL;
> }
>
> return to;
> }
>
> +static void *omap_xload_boot_nand(struct omap_barebox_part *part)
> +{
> + 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");
> +}
> +
> static void *omap_xload_boot_mmc(void)
> {
> int ret;
> @@ -138,41 +143,12 @@ static void *omap_xload_boot_mmc(void)
> return buf;
> }
>
> -static void *omap_xload_boot_spi(int offset, int part_size)
> +static void *omap_xload_boot_spi(struct omap_barebox_part *part)
> {
> - int ret;
> - int size;
> - void *to, *header;
> - struct cdev *cdev;
> -
> - devfs_add_partition("m25p0", offset, part_size,
> + devfs_add_partition("m25p0", part->nor_offset, part->nor_size,
> DEVFS_PARTITION_FIXED, "x");
>
> - header = read_image_head("x");
> - if (header == NULL)
> - return NULL;
> -
> - size = get_image_size(header);
> - if (!size) {
> - printf("failed to get image size\n");
> - return NULL;
> - }
> -
> - to = xmalloc(size);
> -
> - cdev = cdev_open("x", O_RDONLY);
> - if (!cdev) {
> - printf("failed to open spi flash\n");
> - return NULL;
> - }
> -
> - ret = cdev_read(cdev, to, size, 0, 0);
> - if (ret != size) {
> - printf("failed to read from spi flash\n");
> - return NULL;
> - }
> -
> - return to;
> + return read_mtd_barebox("x");
> }
>
> static void *omap4_xload_boot_usb(void){
> @@ -323,13 +299,11 @@ static __noreturn int omap_xload(void)
> break;
> case BOOTSOURCE_NAND:
> printf("booting from NAND\n");
> - func = omap_xload_boot_nand(barebox_part->nand_offset,
> - barebox_part->nand_size);
> + func = omap_xload_boot_nand(barebox_part);
> break;
> case BOOTSOURCE_SPI:
> printf("booting from SPI\n");
> - func = omap_xload_boot_spi(barebox_part->nor_offset,
> - barebox_part->nor_size);
> + func = omap_xload_boot_spi(barebox_part);
> break;
> case BOOTSOURCE_SERIAL:
> if (IS_ENABLED(CONFIG_OMAP_SERIALBOOT)) {
> @@ -347,8 +321,7 @@ static __noreturn int omap_xload(void)
> }
> default:
> printf("unknown boot source. Fall back to nand\n");
> - func = omap_xload_boot_nand(barebox_part->nand_offset,
> - barebox_part->nand_size);
> + func = omap_xload_boot_nand(barebox_part);
> break;
> }
>
> --
> 1.9.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-06-30 6:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29 10:01 [PATCH 1/4] OMAP: xload: Factor out reading image from mtd partition Teresa Remmet
2016-06-29 10:01 ` [PATCH 2/4] OMAP: xload: nand: Check for redundant barebox partition Teresa Remmet
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox