* [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl
@ 2015-02-24 14:53 Michael Olbrich
2015-02-24 14:53 ` [PATCH 2/3] friendlyarm-mini2440: add support for the W35 display Michael Olbrich
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Michael Olbrich @ 2015-02-24 14:53 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich
This was broken in 558d72dc5116 (ARM Samsung: fix booting from NAND with
pbl). '_text' is TEXT_BASE when building without pbl and (TEXT_BASE -
SZ_2M) when building with pbl, so this works in both cases.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
I hope I understood how this should work and this is correct now. It worked
for me with and without pbl. Anything else that could mess this up?
Michael
arch/arm/mach-samsung/lowlevel-s3c24x0.S | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-samsung/lowlevel-s3c24x0.S b/arch/arm/mach-samsung/lowlevel-s3c24x0.S
index 626ad0418778..d43cdff52863 100644
--- a/arch/arm/mach-samsung/lowlevel-s3c24x0.S
+++ b/arch/arm/mach-samsung/lowlevel-s3c24x0.S
@@ -15,7 +15,6 @@
*/
#include <config.h>
-#include <linux/sizes.h>
#include <mach/s3c-iomap.h>
.section ".text_bare_init.s3c24x0_disable_wd","ax"
@@ -251,7 +250,7 @@ s3c24x0_nand_boot:
beq 2f
mov pc, lr /* NOR case: nothing to do here */
-2: ldr sp, =(TEXT_BASE - SZ_2M) /* Setup a temporary stack in SDRAM */
+2: ldr sp, =_text /* Setup a temporary stack in SDRAM */
/*
* We still run at a location we are not linked to. But lets still running
* from the internal SRAM, this may speed up the boot
@@ -262,7 +261,7 @@ s3c24x0_nand_boot:
/*
* Adjust the return address to the correct address in SDRAM
*/
- ldr r1, =(TEXT_BASE - SZ_2M)
+ ldr r1, =_text
add lr, lr, r1
mov pc, lr
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] friendlyarm-mini2440: add support for the W35 display
2015-02-24 14:53 [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl Michael Olbrich
@ 2015-02-24 14:53 ` Michael Olbrich
2015-02-25 7:36 ` Sascha Hauer
2015-02-24 14:53 ` [PATCH 3/3] ARM Samsung: add simple NAND barebox update handler Michael Olbrich
2015-02-25 7:31 ` [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl Sascha Hauer
2 siblings, 1 reply; 8+ messages in thread
From: Michael Olbrich @ 2015-02-24 14:53 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
I'm not quite sure about the sync flags. I tried to match what the kernel
does and it looks correct here.
Michael
arch/arm/boards/friendlyarm-mini2440/Kconfig | 6 ++++++
arch/arm/boards/friendlyarm-mini2440/mini2440.c | 17 +++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/arch/arm/boards/friendlyarm-mini2440/Kconfig b/arch/arm/boards/friendlyarm-mini2440/Kconfig
index a8e79b3b076b..feb905e96e33 100644
--- a/arch/arm/boards/friendlyarm-mini2440/Kconfig
+++ b/arch/arm/boards/friendlyarm-mini2440/Kconfig
@@ -25,4 +25,10 @@ config MINI2440_VIDEO_SVGA
help
This adds support for MINI2440 SVGA (1024x768) video output adapter.
+config MINI2440_VIDEO_W35
+ bool "Support W35 display (320x240)"
+ select MINI2440_VIDEO
+ help
+ This adds support for Sharp 3.5 inch TFT display.
+
endif
diff --git a/arch/arm/boards/friendlyarm-mini2440/mini2440.c b/arch/arm/boards/friendlyarm-mini2440/mini2440.c
index 2dcb7db4dbde..af6da72d3a2f 100644
--- a/arch/arm/boards/friendlyarm-mini2440/mini2440.c
+++ b/arch/arm/boards/friendlyarm-mini2440/mini2440.c
@@ -116,6 +116,23 @@ static struct fb_videomode s3c24x0_fb_modes[] = {
.vmode = FB_VMODE_NONINTERLACED,
},
#endif
+#ifdef CONFIG_MINI2440_VIDEO_W35
+ {
+ .name = "W35",
+ .refresh = 60,
+ .xres = 320,
+ .left_margin = 68,
+ .right_margin = 66,
+ .hsync_len = 4,
+ .yres = 240,
+ .upper_margin = 4,
+ .lower_margin = 4,
+ .vsync_len = 9,
+ .pixclock = 115913,
+ .sync = FB_SYNC_USE_PWREN | FB_SYNC_CLK_INVERT,
+ .vmode = FB_VMODE_NONINTERLACED,
+ },
+#endif
};
static struct s3c_fb_platform_data s3c24x0_fb_data = {
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] ARM Samsung: add simple NAND barebox update handler
2015-02-24 14:53 [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl Michael Olbrich
2015-02-24 14:53 ` [PATCH 2/3] friendlyarm-mini2440: add support for the W35 display Michael Olbrich
@ 2015-02-24 14:53 ` Michael Olbrich
2015-02-25 7:34 ` Sascha Hauer
2015-02-25 7:31 ` [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl Sascha Hauer
2 siblings, 1 reply; 8+ messages in thread
From: Michael Olbrich @ 2015-02-24 14:53 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
I'm not sure if writing to /dev/nand0.barebox.bb is correct. But from what
I can tell, the nand boot code cannot handle bad blocks, so it probably
doesn't matter anyways.
Michael
arch/arm/boards/friendlyarm-mini2440/mini2440.c | 3 +
arch/arm/mach-samsung/Kconfig | 6 ++
arch/arm/mach-samsung/Makefile | 1 +
arch/arm/mach-samsung/bbu-nand-s3c24x0.c | 84 +++++++++++++++++++++++++
arch/arm/mach-samsung/include/mach/bbu.h | 20 ++++++
5 files changed, 114 insertions(+)
create mode 100644 arch/arm/mach-samsung/bbu-nand-s3c24x0.c
create mode 100644 arch/arm/mach-samsung/include/mach/bbu.h
diff --git a/arch/arm/boards/friendlyarm-mini2440/mini2440.c b/arch/arm/boards/friendlyarm-mini2440/mini2440.c
index af6da72d3a2f..b59c8367f306 100644
--- a/arch/arm/boards/friendlyarm-mini2440/mini2440.c
+++ b/arch/arm/boards/friendlyarm-mini2440/mini2440.c
@@ -29,6 +29,7 @@
#include <asm/sections.h>
#include <io.h>
#include <gpio.h>
+#include <mach/bbu.h>
#include <mach/iomux.h>
#include <mach/s3c-iomap.h>
#include <mach/devices-s3c24xx.h>
@@ -317,6 +318,8 @@ static int mini2440_devices_init(void)
devfs_del_partition("env_raw");
devfs_add_partition("nand0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
+
+ s3c24x0_bbu_nand_register_handler();
#endif
s3c24xx_add_mci(&mci_data);
s3c24xx_add_fb(&s3c24x0_fb_data);
diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig
index 13dac29dcc88..8f421bb83970 100644
--- a/arch/arm/mach-samsung/Kconfig
+++ b/arch/arm/mach-samsung/Kconfig
@@ -166,6 +166,12 @@ config S3C_NAND_BOOT
Add generic support to boot from NAND flash. Image loading will be
skipped if the code is running from NOR or already from SDRAM.
+config BAREBOX_UPDATE_NAND_S3C24XX
+ bool
+ depends on BAREBOX_UPDATE
+ depends on S3C_NAND_BOOT
+ default y
+
endmenu
endif
diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile
index 46393e17257c..284c80a2ad43 100644
--- a/arch/arm/mach-samsung/Makefile
+++ b/arch/arm/mach-samsung/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o clocks-s3c24xx.o mem-s3c24x0.o
obj-$(CONFIG_ARCH_S3C64xx) += gpio-s3c64xx.o clocks-s3c64xx.o mem-s3c64xx.o
obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o
pbl-$(CONFIG_ARCH_S5PCxx) += mem-s5pcxx.o
+obj-$(CONFIG_BAREBOX_UPDATE_NAND_S3C24XX) += bbu-nand-s3c24x0.o
obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y)
diff --git a/arch/arm/mach-samsung/bbu-nand-s3c24x0.c b/arch/arm/mach-samsung/bbu-nand-s3c24x0.c
new file mode 100644
index 000000000000..6009151c88be
--- /dev/null
+++ b/arch/arm/mach-samsung/bbu-nand-s3c24x0.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2014 Michael Olbrich, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation.
+ *
+ */
+
+#define DEBUG
+#include <common.h>
+#include <malloc.h>
+#include <bbu.h>
+#include <fs.h>
+#include <fcntl.h>
+
+static int nand_update(struct bbu_handler *handler, struct bbu_data *data)
+{
+ int fd, ret;
+
+ if (file_detect_type(data->image, data->len) != filetype_arm_barebox &&
+ !bbu_force(data, "Not an ARM barebox image"))
+ return -EINVAL;
+
+ ret = bbu_confirm(data);
+ if (ret)
+ return ret;
+
+ fd = open(data->devicefile, O_WRONLY);
+ if (fd < 0)
+ return fd;
+
+ debug("%s: eraseing %s from 0 to 0x%08x\n", __func__,
+ data->devicefile, data->len);
+ ret = erase(fd, data->len, 0);
+ if (ret) {
+ printf("erasing %s failed with %s\n", data->devicefile,
+ strerror(-ret));
+ goto err_close;
+ }
+
+ ret = write(fd, data->image, data->len);
+ if (ret < 0)
+ goto err_close;
+
+ ret = 0;
+
+err_close:
+ close(fd);
+
+ return ret;
+}
+
+/*
+ * Register a s3c24x0 update handler for NAND
+ */
+int s3c24x0_bbu_nand_register_handler(void)
+{
+ struct bbu_handler *handler;
+ int ret;
+
+ handler = xzalloc(sizeof(*handler));
+ handler->devicefile = "/dev/nand0.barebox.bb";
+ handler->name = "nand";
+ handler->handler = nand_update;
+ handler->flags = BBU_HANDLER_FLAG_DEFAULT;
+
+ ret = bbu_register_handler(handler);
+ if (ret)
+ free(handler);
+
+ return ret;
+}
+
diff --git a/arch/arm/mach-samsung/include/mach/bbu.h b/arch/arm/mach-samsung/include/mach/bbu.h
new file mode 100644
index 000000000000..2a3e25cb666e
--- /dev/null
+++ b/arch/arm/mach-samsung/include/mach/bbu.h
@@ -0,0 +1,20 @@
+
+#ifndef __MACH_BBU_H
+#define __MACH_BBU_H
+
+#include <bbu.h>
+#include <errno.h>
+
+struct imx_dcd_entry;
+struct imx_dcd_v2_entry;
+
+#ifdef CONFIG_BAREBOX_UPDATE_NAND_S3C24XX
+int s3c24x0_bbu_nand_register_handler(void);
+#else
+static inline int s3c24x0_bbu_nand_register_handler(void)
+{
+ return -ENOSYS;
+}
+#endif
+
+#endif
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl
2015-02-24 14:53 [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl Michael Olbrich
2015-02-24 14:53 ` [PATCH 2/3] friendlyarm-mini2440: add support for the W35 display Michael Olbrich
2015-02-24 14:53 ` [PATCH 3/3] ARM Samsung: add simple NAND barebox update handler Michael Olbrich
@ 2015-02-25 7:31 ` Sascha Hauer
2 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2015-02-25 7:31 UTC (permalink / raw)
To: Michael Olbrich; +Cc: barebox
On Tue, Feb 24, 2015 at 03:53:48PM +0100, Michael Olbrich wrote:
> This was broken in 558d72dc5116 (ARM Samsung: fix booting from NAND with
> pbl). '_text' is TEXT_BASE when building without pbl and (TEXT_BASE -
> SZ_2M) when building with pbl, so this works in both cases.
>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
>
> I hope I understood how this should work and this is correct now. It worked
> for me with and without pbl. Anything else that could mess this up?
>
> Michael
>
> arch/arm/mach-samsung/lowlevel-s3c24x0.S | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-samsung/lowlevel-s3c24x0.S b/arch/arm/mach-samsung/lowlevel-s3c24x0.S
> index 626ad0418778..d43cdff52863 100644
> --- a/arch/arm/mach-samsung/lowlevel-s3c24x0.S
> +++ b/arch/arm/mach-samsung/lowlevel-s3c24x0.S
> @@ -15,7 +15,6 @@
> */
>
> #include <config.h>
> -#include <linux/sizes.h>
> #include <mach/s3c-iomap.h>
>
> .section ".text_bare_init.s3c24x0_disable_wd","ax"
> @@ -251,7 +250,7 @@ s3c24x0_nand_boot:
> beq 2f
> mov pc, lr /* NOR case: nothing to do here */
>
> -2: ldr sp, =(TEXT_BASE - SZ_2M) /* Setup a temporary stack in SDRAM */
> +2: ldr sp, =_text /* Setup a temporary stack in SDRAM */
> /*
> * We still run at a location we are not linked to. But lets still running
> * from the internal SRAM, this may speed up the boot
> @@ -262,7 +261,7 @@ s3c24x0_nand_boot:
> /*
> * Adjust the return address to the correct address in SDRAM
> */
> - ldr r1, =(TEXT_BASE - SZ_2M)
> + ldr r1, =_text
Since nand_boot() copies the image to _text I believe this is the
correct address in all cases. Applied, thanks
Sascha
--
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] 8+ messages in thread
* Re: [PATCH 3/3] ARM Samsung: add simple NAND barebox update handler
2015-02-24 14:53 ` [PATCH 3/3] ARM Samsung: add simple NAND barebox update handler Michael Olbrich
@ 2015-02-25 7:34 ` Sascha Hauer
2015-02-25 16:48 ` [PATCH] " Michael Olbrich
0 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2015-02-25 7:34 UTC (permalink / raw)
To: Michael Olbrich; +Cc: barebox
On Tue, Feb 24, 2015 at 03:53:50PM +0100, Michael Olbrich wrote:
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
>
> I'm not sure if writing to /dev/nand0.barebox.bb is correct. But from what
> I can tell, the nand boot code cannot handle bad blocks, so it probably
> doesn't matter anyways.
So when the boot code can't handle bad blocks I think you should use the
non bb device. Then you'll realize during writing that it won't work,
not only during booting
Sascha
--
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] 8+ messages in thread
* Re: [PATCH 2/3] friendlyarm-mini2440: add support for the W35 display
2015-02-24 14:53 ` [PATCH 2/3] friendlyarm-mini2440: add support for the W35 display Michael Olbrich
@ 2015-02-25 7:36 ` Sascha Hauer
0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2015-02-25 7:36 UTC (permalink / raw)
To: Michael Olbrich; +Cc: barebox
On Tue, Feb 24, 2015 at 03:53:49PM +0100, Michael Olbrich wrote:
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
>
> I'm not quite sure about the sync flags. I tried to match what the kernel
> does and it looks correct here.
>
> Michael
>
> arch/arm/boards/friendlyarm-mini2440/Kconfig | 6 ++++++
> arch/arm/boards/friendlyarm-mini2440/mini2440.c | 17 +++++++++++++++++
> 2 files changed, 23 insertions(+)
Applied, thanks
Sascha
--
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] 8+ messages in thread
* [PATCH] ARM Samsung: add simple NAND barebox update handler
2015-02-25 7:34 ` Sascha Hauer
@ 2015-02-25 16:48 ` Michael Olbrich
2015-02-26 5:58 ` Sascha Hauer
0 siblings, 1 reply; 8+ messages in thread
From: Michael Olbrich @ 2015-02-25 16:48 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
v2: write to the non bb device.
That means, write() will fail, when it hits a bad block, right?
Michael
arch/arm/boards/friendlyarm-mini2440/mini2440.c | 3 +
arch/arm/mach-samsung/Kconfig | 6 ++
arch/arm/mach-samsung/Makefile | 1 +
arch/arm/mach-samsung/bbu-nand-s3c24x0.c | 87 +++++++++++++++++++++++++
arch/arm/mach-samsung/include/mach/bbu.h | 20 ++++++
5 files changed, 117 insertions(+)
create mode 100644 arch/arm/mach-samsung/bbu-nand-s3c24x0.c
create mode 100644 arch/arm/mach-samsung/include/mach/bbu.h
diff --git a/arch/arm/boards/friendlyarm-mini2440/mini2440.c b/arch/arm/boards/friendlyarm-mini2440/mini2440.c
index 2dcb7db4dbde..b9e1b6bb9d52 100644
--- a/arch/arm/boards/friendlyarm-mini2440/mini2440.c
+++ b/arch/arm/boards/friendlyarm-mini2440/mini2440.c
@@ -29,6 +29,7 @@
#include <asm/sections.h>
#include <io.h>
#include <gpio.h>
+#include <mach/bbu.h>
#include <mach/iomux.h>
#include <mach/s3c-iomap.h>
#include <mach/devices-s3c24xx.h>
@@ -300,6 +301,8 @@ static int mini2440_devices_init(void)
devfs_del_partition("env_raw");
devfs_add_partition("nand0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
+
+ s3c24x0_bbu_nand_register_handler();
#endif
s3c24xx_add_mci(&mci_data);
s3c24xx_add_fb(&s3c24x0_fb_data);
diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig
index 13dac29dcc88..8f421bb83970 100644
--- a/arch/arm/mach-samsung/Kconfig
+++ b/arch/arm/mach-samsung/Kconfig
@@ -166,6 +166,12 @@ config S3C_NAND_BOOT
Add generic support to boot from NAND flash. Image loading will be
skipped if the code is running from NOR or already from SDRAM.
+config BAREBOX_UPDATE_NAND_S3C24XX
+ bool
+ depends on BAREBOX_UPDATE
+ depends on S3C_NAND_BOOT
+ default y
+
endmenu
endif
diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile
index 46393e17257c..284c80a2ad43 100644
--- a/arch/arm/mach-samsung/Makefile
+++ b/arch/arm/mach-samsung/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o clocks-s3c24xx.o mem-s3c24x0.o
obj-$(CONFIG_ARCH_S3C64xx) += gpio-s3c64xx.o clocks-s3c64xx.o mem-s3c64xx.o
obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o
pbl-$(CONFIG_ARCH_S5PCxx) += mem-s5pcxx.o
+obj-$(CONFIG_BAREBOX_UPDATE_NAND_S3C24XX) += bbu-nand-s3c24x0.o
obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y)
diff --git a/arch/arm/mach-samsung/bbu-nand-s3c24x0.c b/arch/arm/mach-samsung/bbu-nand-s3c24x0.c
new file mode 100644
index 000000000000..f3584eaa5a0c
--- /dev/null
+++ b/arch/arm/mach-samsung/bbu-nand-s3c24x0.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2014 Michael Olbrich, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation.
+ *
+ */
+
+#define DEBUG
+#include <common.h>
+#include <malloc.h>
+#include <bbu.h>
+#include <fs.h>
+#include <fcntl.h>
+
+static int nand_update(struct bbu_handler *handler, struct bbu_data *data)
+{
+ int fd, ret;
+
+ if (file_detect_type(data->image, data->len) != filetype_arm_barebox &&
+ !bbu_force(data, "Not an ARM barebox image"))
+ return -EINVAL;
+
+ ret = bbu_confirm(data);
+ if (ret)
+ return ret;
+
+ fd = open(data->devicefile, O_WRONLY);
+ if (fd < 0)
+ return fd;
+
+ debug("%s: eraseing %s from 0 to 0x%08x\n", __func__,
+ data->devicefile, data->len);
+ ret = erase(fd, data->len, 0);
+ if (ret) {
+ printf("erasing %s failed with %s\n", data->devicefile,
+ strerror(-ret));
+ goto err_close;
+ }
+
+ ret = write(fd, data->image, data->len);
+ if (ret < 0) {
+ printf("writing update to %s failed with %s\n", data->devicefile,
+ strerror(-ret));
+ goto err_close;
+ }
+
+ ret = 0;
+
+err_close:
+ close(fd);
+
+ return ret;
+}
+
+/*
+ * Register a s3c24x0 update handler for NAND
+ */
+int s3c24x0_bbu_nand_register_handler(void)
+{
+ struct bbu_handler *handler;
+ int ret;
+
+ handler = xzalloc(sizeof(*handler));
+ handler->devicefile = "/dev/nand0.barebox";
+ handler->name = "nand";
+ handler->handler = nand_update;
+ handler->flags = BBU_HANDLER_FLAG_DEFAULT;
+
+ ret = bbu_register_handler(handler);
+ if (ret)
+ free(handler);
+
+ return ret;
+}
+
diff --git a/arch/arm/mach-samsung/include/mach/bbu.h b/arch/arm/mach-samsung/include/mach/bbu.h
new file mode 100644
index 000000000000..2a3e25cb666e
--- /dev/null
+++ b/arch/arm/mach-samsung/include/mach/bbu.h
@@ -0,0 +1,20 @@
+
+#ifndef __MACH_BBU_H
+#define __MACH_BBU_H
+
+#include <bbu.h>
+#include <errno.h>
+
+struct imx_dcd_entry;
+struct imx_dcd_v2_entry;
+
+#ifdef CONFIG_BAREBOX_UPDATE_NAND_S3C24XX
+int s3c24x0_bbu_nand_register_handler(void);
+#else
+static inline int s3c24x0_bbu_nand_register_handler(void)
+{
+ return -ENOSYS;
+}
+#endif
+
+#endif
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ARM Samsung: add simple NAND barebox update handler
2015-02-25 16:48 ` [PATCH] " Michael Olbrich
@ 2015-02-26 5:58 ` Sascha Hauer
0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2015-02-26 5:58 UTC (permalink / raw)
To: Michael Olbrich; +Cc: barebox
On Wed, Feb 25, 2015 at 05:48:42PM +0100, Michael Olbrich wrote:
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
> v2: write to the non bb device.
>
> That means, write() will fail, when it hits a bad block, right?
Yes, right.
> +
> +#define DEBUG
Removed this while applying.
> +
> +struct imx_dcd_entry;
> +struct imx_dcd_v2_entry;
And this aswell
Sascha
--
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] 8+ messages in thread
end of thread, other threads:[~2015-02-26 5:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-24 14:53 [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl Michael Olbrich
2015-02-24 14:53 ` [PATCH 2/3] friendlyarm-mini2440: add support for the W35 display Michael Olbrich
2015-02-25 7:36 ` Sascha Hauer
2015-02-24 14:53 ` [PATCH 3/3] ARM Samsung: add simple NAND barebox update handler Michael Olbrich
2015-02-25 7:34 ` Sascha Hauer
2015-02-25 16:48 ` [PATCH] " Michael Olbrich
2015-02-26 5:58 ` Sascha Hauer
2015-02-25 7:31 ` [PATCH 1/3] ARM Samsung: fix booting from NAND without pbl Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox