mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v1 0/3] bootstrap support for AT91SAM9263-EK
@ 2019-01-02 20:26 Sam Ravnborg
  2019-01-02 20:26 ` [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263 Sam Ravnborg
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-02 20:26 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

This small patchset enables bootstrap support for
the Atmel AT91SAM9263-EK evaluation board.
To achive this there is one questionaable fix in
lib/bootstrap/disk.c - where a detect_all() is
used to allow us to mount the SD card.
I dunno if this is the right approach, but it was required to
mount the SD card.

The patchset is based upon the next branch and is made on top
of the previous patchset I sent with "random collection".

The only dependency is in:
arch/arm/boards/at91sam9263ek/Makefile

I am happy to finally get this working.
Considering that all the heavy lifting was done already by
Jean-Christophe this took me much more effort than
one could expect.

	Sam


Sam Ravnborg (3):
      arm: at91: fix clock to mci1 for at91sam9263
      lib: bootstrap: detect SD card before mounting
      at91sam9263ek: add bootstrap support

 arch/arm/boards/Makefile                           |  1 +
 arch/arm/boards/at91sam9263ek/Makefile             |  4 +---
 arch/arm/boards/at91sam9263ek/lowlevel_init.c      |  9 +++++++++
 arch/arm/configs/at91sam9263ek_bootstrap_defconfig | 19 +++++++++++++++++++
 arch/arm/mach-at91/Kconfig                         | 14 ++++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c           |  3 +++
 lib/bootstrap/disk.c                               |  2 ++
 7 files changed, 49 insertions(+), 3 deletions(-)

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263
  2019-01-02 20:26 [PATCH v1 0/3] bootstrap support for AT91SAM9263-EK Sam Ravnborg
@ 2019-01-02 20:26 ` Sam Ravnborg
  2019-01-06 20:39   ` Sam Ravnborg
  2019-01-07  7:29   ` Sascha Hauer
  2019-01-02 20:26 ` [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting Sam Ravnborg
  2019-01-02 20:26 ` [PATCH v1 3/3] at91sam9263ek: add bootstrap support Sam Ravnborg
  2 siblings, 2 replies; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-02 20:26 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

at91_add_device_mci() was missing configuration of PIOA6
when configuring mci1.
With this fix we can read data from SD card with at91sam9263ek,
when built without DT.
Building without a DT is required when we do a bootstrap build.

The other at91samxxx_devices was checked - only the 9263 was
missing the CLK configuration for mci1.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/mach-at91/at91sam9263_devices.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index a67345f05..c7e4962a9 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -396,6 +396,9 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 	} else {			/* MCI1 */
 		start = AT91SAM9263_BASE_MCI1;
 
+		/* CLK */
+		at91_set_A_periph(AT91_PIN_PA6, 0);
+
 		if (data->slot_b) {
 			/* CMD */
 			at91_set_A_periph(AT91_PIN_PA21, 1);
-- 
2.12.0


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
  2019-01-02 20:26 [PATCH v1 0/3] bootstrap support for AT91SAM9263-EK Sam Ravnborg
  2019-01-02 20:26 ` [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263 Sam Ravnborg
@ 2019-01-02 20:26 ` Sam Ravnborg
  2019-01-02 23:32   ` Andrey Smirnov
  2019-01-02 20:26 ` [PATCH v1 3/3] at91sam9263ek: add bootstrap support Sam Ravnborg
  2 siblings, 1 reply; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-02 20:26 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

To support bootstrap from SD card run a detect all before
mounting the SD card.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 lib/bootstrap/disk.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c
index fd016166e..77be95c2f 100644
--- a/lib/bootstrap/disk.c
+++ b/lib/bootstrap/disk.c
@@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)
 	size_t len;
 	const char *path = "/";
 
+	device_detect_all();
+
 	ret = mount(dev, fstype, path, NULL);
 	if (ret) {
 		bootstrap_err("mounting %s failed with %d\n", dev, ret);
-- 
2.12.0


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v1 3/3] at91sam9263ek: add bootstrap support
  2019-01-02 20:26 [PATCH v1 0/3] bootstrap support for AT91SAM9263-EK Sam Ravnborg
  2019-01-02 20:26 ` [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263 Sam Ravnborg
  2019-01-02 20:26 ` [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting Sam Ravnborg
@ 2019-01-02 20:26 ` Sam Ravnborg
  2019-01-03  8:16   ` Sascha Hauer
  2 siblings, 1 reply; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-02 20:26 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

Fix lowlevel init to get reset vector.

Add new MACH_AT91SAM9263EK_BOOTSTRAP config entry
used when building the bootstrap variant.
The new config entry is required as we cannot combine MULTI_IMAGE
with a bootstrap variant.
With this we have two config symbols that points to the same
board directory. This was the simple way to share the same low_level.c
implmentation.

Add at91sam9263ek_bootstrap_defconfig that can boot barebox.bin
from SD card (must be named BOOT.BIN)

Boot log:

barebox 2018.12.0-00266-g1e927dc53-dirty #41 Wed Jan 2 20:51:43 CET 2019

Board: Atmel at91sam9263-ek
Clocks: CPU 199 MHz, master 99 MHz, main 16.367 MHz
atmel_mci atmel_mci1: version: 0x210
atmel_mci atmel_mci1: registered as mci0
malloc space: 0x23be4000 -> 0x23fe3fff (size 4 MiB)
Boot from mmc
mci0: detected SD card version 2.0
mci0: registered disk0

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/boards/Makefile                           |  1 +
 arch/arm/boards/at91sam9263ek/Makefile             |  4 +---
 arch/arm/boards/at91sam9263ek/lowlevel_init.c      |  9 +++++++++
 arch/arm/configs/at91sam9263ek_bootstrap_defconfig | 19 +++++++++++++++++++
 arch/arm/mach-at91/Kconfig                         | 14 ++++++++++++++
 5 files changed, 44 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/configs/at91sam9263ek_bootstrap_defconfig

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index ab5191fe0..d09c1385c 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_MACH_ARCHOSG9)			+= archosg9/
 obj-$(CONFIG_MACH_AT91SAM9260EK)		+= at91sam9260ek/
 obj-$(CONFIG_MACH_AT91SAM9261EK)		+= at91sam9261ek/
 obj-$(CONFIG_MACH_AT91SAM9263EK)		+= at91sam9263ek/
+obj-$(CONFIG_MACH_AT91SAM9263EK_BOOTSTRAP)	+= at91sam9263ek/
 obj-$(CONFIG_MACH_AT91SAM9G10EK)		+= at91sam9261ek/
 obj-$(CONFIG_MACH_AT91SAM9G20EK)		+= at91sam9260ek/
 obj-$(CONFIG_MACH_AT91SAM9M10G45EK)		+= at91sam9m10g45ek/
diff --git a/arch/arm/boards/at91sam9263ek/Makefile b/arch/arm/boards/at91sam9263ek/Makefile
index d4d5e7639..9be057599 100644
--- a/arch/arm/boards/at91sam9263ek/Makefile
+++ b/arch/arm/boards/at91sam9263ek/Makefile
@@ -1,6 +1,4 @@
-ifeq ($(CONFIG_OFDEVICE),)
-obj-y += init.o
-endif
+obj-$(CONFIG_MACH_AT91SAM9263EK_BOOTSTRAP) += init.o
 obj-$(CONFIG_OFDEVICE) += of_init.o
 
 lwl-y += lowlevel_init.o
diff --git a/arch/arm/boards/at91sam9263ek/lowlevel_init.c b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
index f5d68cd7e..820f9123f 100644
--- a/arch/arm/boards/at91sam9263ek/lowlevel_init.c
+++ b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
@@ -115,6 +115,7 @@ static void __bare_init at91sam9263ek_init(void *fdt)
 			  fdt);
 }
 
+#ifdef CONFIG_OFDEVICE
 extern char __dtb_at91sam9263ek_start[];
 
 ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)
@@ -132,3 +133,11 @@ ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)
 
 	at91sam9263ek_init(fdt);
 }
+#else
+void __naked __bare_init barebox_arm_reset_vector(void)
+{
+	arm_cpu_lowlevel_init();
+	arm_setup_stack(AT91SAM9263_SRAM0_BASE + AT91SAM9263_SRAM0_SIZE - 16);
+	at91sam9263ek_init(NULL);
+}
+#endif
diff --git a/arch/arm/configs/at91sam9263ek_bootstrap_defconfig b/arch/arm/configs/at91sam9263ek_bootstrap_defconfig
new file mode 100644
index 000000000..6b80be373
--- /dev/null
+++ b/arch/arm/configs/at91sam9263ek_bootstrap_defconfig
@@ -0,0 +1,19 @@
+CONFIG_ARCH_AT91SAM9263=y
+CONFIG_AT91_BOOTSTRAP=y
+CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000
+CONFIG_AEABI=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_MALLOC_DUMMY=y
+CONFIG_PROMPT="9263-EK:"
+CONFIG_SHELL_NONE=y
+# CONFIG_TIMESTAMP is not set
+CONFIG_CONSOLE_SIMPLE=y
+# CONFIG_SPI is not set
+CONFIG_MCI=y
+# CONFIG_MCI_WRITE is not set
+CONFIG_MCI_ATMEL=y
+# CONFIG_FS_RAMFS is not set
+# CONFIG_FS_DEVFS is not set
+CONFIG_FS_FAT=y
+CONFIG_BOOTSTRAP_DEVFS=y
+CONFIG_BOOTSTRAP_DISK=y
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index b101e61d2..5e078cc86 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -394,6 +394,20 @@ if ARCH_AT91SAM9263
 choice
 	prompt "AT91SAM9263 Board Type"
 
+config MACH_AT91SAM9263EK_BOOTSTRAP
+	bool "Atmel AT91SAM9263-EK bootstrap"
+	depends on ARCH_AT91SAM9263
+	select HAVE_AT91_USB_CLK
+	select HAVE_NAND_ATMEL_BUSWIDTH_16
+	select HAVE_AT91_BOOTSTRAP
+	select AT91SAM926X_BOARD_INIT
+	help
+	  Say y here to build the bootstrap variant of barebox
+	  for the Atmel AT91SAM9263-EK Evaluation board.
+	  barebox.bin can be copied to a SD card, named BOOT.BIN,
+	  then ROMBOOT in the at91sam9263 will load the bootstrap
+	  and then bootstrap can load the real barebox
+
 config MACH_PM9263
 	bool "Ronetix PM9263"
 	select HAVE_AT91_BOOTSTRAP
-- 
2.12.0


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
  2019-01-02 20:26 ` [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting Sam Ravnborg
@ 2019-01-02 23:32   ` Andrey Smirnov
  2019-01-03  5:46     ` Sam Ravnborg
  0 siblings, 1 reply; 15+ messages in thread
From: Andrey Smirnov @ 2019-01-02 23:32 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Barebox List

On Wed, Jan 2, 2019 at 12:26 PM Sam Ravnborg <sam@ravnborg.org> wrote:
>
> To support bootstrap from SD card run a detect all before
> mounting the SD card.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  lib/bootstrap/disk.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c
> index fd016166e..77be95c2f 100644
> --- a/lib/bootstrap/disk.c
> +++ b/lib/bootstrap/disk.c
> @@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)
>         size_t len;
>         const char *path = "/";
>
> +       device_detect_all();
> +

Can device_detect_by_name(dev) be used here instead?

Thanks,
Andrey Smirnov

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
  2019-01-02 23:32   ` Andrey Smirnov
@ 2019-01-03  5:46     ` Sam Ravnborg
  2019-01-03 19:53       ` Sam Ravnborg
  0 siblings, 1 reply; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-03  5:46 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

Hi Andrey.

> > To support bootstrap from SD card run a detect all before
> > mounting the SD card.
> >
> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > ---
> >  lib/bootstrap/disk.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c
> > index fd016166e..77be95c2f 100644
> > --- a/lib/bootstrap/disk.c
> > +++ b/lib/bootstrap/disk.c
> > @@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)
> >         size_t len;
> >         const char *path = "/";
> >
> > +       device_detect_all();
> > +
> 
> Can device_detect_by_name(dev) be used here instead?

dev equals "disk0.0" when we call bootstrap_read_disk().
Calling device_detect_by_name("disk0.0") did not work, and then
the easy solution with device_detect_all() worked.

I could pass the dev name to bootstrap_read_disk() but
this would make the caller less general which is why I ended
up with the more brutal solution.

	Sam

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
  2019-01-02 20:26 ` [PATCH v1 3/3] at91sam9263ek: add bootstrap support Sam Ravnborg
@ 2019-01-03  8:16   ` Sascha Hauer
  2019-01-03 10:58     ` Sam Ravnborg
  0 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2019-01-03  8:16 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Barebox List

Hi Sam,

On Wed, Jan 02, 2019 at 09:26:11PM +0100, Sam Ravnborg wrote:
> Fix lowlevel init to get reset vector.
> 
> Add new MACH_AT91SAM9263EK_BOOTSTRAP config entry
> used when building the bootstrap variant.
> The new config entry is required as we cannot combine MULTI_IMAGE
> with a bootstrap variant.

Why can't that be combined?

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] 15+ messages in thread

* Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
  2019-01-03  8:16   ` Sascha Hauer
@ 2019-01-03 10:58     ` Sam Ravnborg
  2019-01-03 21:00       ` Sam Ravnborg
  0 siblings, 1 reply; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-03 10:58 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

Hi Sascha.

> > Fix lowlevel init to get reset vector.
> > 
> > Add new MACH_AT91SAM9263EK_BOOTSTRAP config entry
> > used when building the bootstrap variant.
> > The new config entry is required as we cannot combine MULTI_IMAGE
> > with a bootstrap variant.
> 
> Why can't that be combined?

The bootstrap support did not play well with the PBL support.
And MULTI_IMAGE somehow forced this on me.

I did not dive deep into why bootstrap and MULTI_IMAGE did not work.
I looked at the binraty using objdump, and could see that without

Unless there are something I missed so PBL support should work I will
update the commit message for a v2 of the pathset.

Note: I also had to disable MMU support to get bootstrap working.
With MMU enable it halted when __mmu_cache_on() was called in
mmu-early.c
I will also try to look a little deeper into this, but here I have
only limited hope as my debugging is so far limited to
using pr_info(...).

	Sam

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
  2019-01-03  5:46     ` Sam Ravnborg
@ 2019-01-03 19:53       ` Sam Ravnborg
  2019-01-04  7:46         ` Sascha Hauer
  0 siblings, 1 reply; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-03 19:53 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

Hi Andreay.

> > > To support bootstrap from SD card run a detect all before
> > > mounting the SD card.
> > >
> > > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > > ---
> > >  lib/bootstrap/disk.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c
> > > index fd016166e..77be95c2f 100644
> > > --- a/lib/bootstrap/disk.c
> > > +++ b/lib/bootstrap/disk.c
> > > @@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)
> > >         size_t len;
> > >         const char *path = "/";
> > >
> > > +       device_detect_all();
> > > +
> > 
> > Can device_detect_by_name(dev) be used here instead?
> 
> dev equals "disk0.0" when we call bootstrap_read_disk().
> Calling device_detect_by_name("disk0.0") did not work, and then
> the easy solution with device_detect_all() worked.
> 
> I could pass the dev name to bootstrap_read_disk() but
> this would make the caller less general which is why I ended
> up with the more brutal solution.

I ended up with following code in arch/arm/boards/at91sam9263ek/init.c:
#if defined(CONFIG_MCI_ATMEL)
static struct atmel_mci_platform_data __initdata ek_mci_data = {
        .devname        = "disk0",
        .bus_width      = 4,
        .detect_pin     = AT91_PIN_PE18,
        .wp_pin         = AT91_PIN_PE19,
};

When I specify "devname=disk0", then I could use
detect_by_name(dev) in bootstrap_read_disk().
No too pretty, but preferable compared to
running a loop detecting all devices.

I will include this change in v2.

	Sam

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
  2019-01-03 10:58     ` Sam Ravnborg
@ 2019-01-03 21:00       ` Sam Ravnborg
  2019-01-04  7:37         ` Sascha Hauer
  0 siblings, 1 reply; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-03 21:00 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

Hi Sascha.

Previous mail was written while being disturbed by others - sorry.
 
> > > Fix lowlevel init to get reset vector.
> > > 
> > > Add new MACH_AT91SAM9263EK_BOOTSTRAP config entry
> > > used when building the bootstrap variant.
> > > The new config entry is required as we cannot combine MULTI_IMAGE
> > > with a bootstrap variant.
> > 
> > Why can't that be combined?

> The bootstrap support did not play well with the PBL support.
> And MULTI_IMAGE somehow forced this on me.

So far I have not managed to build a barebox image that would
allow ROMBOOT to load it.
As ROMBOOT is silent about why it fails I have not too much
clue why it fails.

When I compare the disassembled image with and without
PBL support enabled they looks not exactly
the same.
One example is that barebox_image_size is wrong when
I build with PBL / MULTI_IMAGE support enabled.
I need to dig deeper to find out why.
The image size is stored at address 0x14 - but is supposed
to be used only by DataFlast, NOR-flash, so this is likely not
the root-cause. But it looks wrong so one thing to fix.

I will try to chase it a bit more to see if I can get it
to work.


> Note: I also had to disable MMU support to get bootstrap working.
> With MMU enable it halted when __mmu_cache_on() was called in
> mmu-early.c
The above was only partially correct.

If MMU is enabled then I need to comment out the call
to __mmu_cache_on() in mmu_init().
Otherwise barebox just hang right after (or in) the
call to __mmu_cache_on()
(which is a call to v7_mmu_cache_on() )

ROMBOOT will copy barebox to 0x40000 and then remap:
0x40000 => 0x0
0x0 => 0x40000

I guess there is some kind of conflict between the remapping
done by ROMBOOT and the MMU setup / cache setup done by barebox.
So far I am fully satisfied to continue with MMU disabled.

	Sam

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 3/3] at91sam9263ek: add bootstrap support
  2019-01-03 21:00       ` Sam Ravnborg
@ 2019-01-04  7:37         ` Sascha Hauer
  0 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2019-01-04  7:37 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Barebox List

On Thu, Jan 03, 2019 at 10:00:41PM +0100, Sam Ravnborg wrote:
> Hi Sascha.
> 
> Previous mail was written while being disturbed by others - sorry.
>  
> > > > Fix lowlevel init to get reset vector.
> > > > 
> > > > Add new MACH_AT91SAM9263EK_BOOTSTRAP config entry
> > > > used when building the bootstrap variant.
> > > > The new config entry is required as we cannot combine MULTI_IMAGE
> > > > with a bootstrap variant.
> > > 
> > > Why can't that be combined?
> 
> > The bootstrap support did not play well with the PBL support.
> > And MULTI_IMAGE somehow forced this on me.
> 
> So far I have not managed to build a barebox image that would
> allow ROMBOOT to load it.
> As ROMBOOT is silent about why it fails I have not too much
> clue why it fails.
> 
> When I compare the disassembled image with and without
> PBL support enabled they looks not exactly
> the same.
> One example is that barebox_image_size is wrong when
> I build with PBL / MULTI_IMAGE support enabled.
> I need to dig deeper to find out why.

Is it a wrong nonzero value or 0x0?

> The image size is stored at address 0x14 - but is supposed
> to be used only by DataFlast, NOR-flash, so this is likely not
> the root-cause. But it looks wrong so one thing to fix.

It's probably time to revise this part. We used to cat the compressed
barebox binary behind the PBL, so we had no chance to determine the
reulting image size with linker variables in the PBL. Now that we link
the compressed binary into the PBL linker variables could generally
work, so at least we have the chance to use them.

> 
> I will try to chase it a bit more to see if I can get it
> to work.
> 
> 
> > Note: I also had to disable MMU support to get bootstrap working.
> > With MMU enable it halted when __mmu_cache_on() was called in
> > mmu-early.c
> The above was only partially correct.
> 
> If MMU is enabled then I need to comment out the call
> to __mmu_cache_on() in mmu_init().
> Otherwise barebox just hang right after (or in) the
> call to __mmu_cache_on()
> (which is a call to v7_mmu_cache_on() )
> 
> ROMBOOT will copy barebox to 0x40000 and then remap:
> 0x40000 => 0x0
> 0x0 => 0x40000
> 
> I guess there is some kind of conflict between the remapping
> done by ROMBOOT and the MMU setup / cache setup done by barebox.
> So far I am fully satisfied to continue with MMU disabled.

So ROMBOOT sets up the MMU? Or is there some kind of remap register?

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] 15+ messages in thread

* Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
  2019-01-03 19:53       ` Sam Ravnborg
@ 2019-01-04  7:46         ` Sascha Hauer
  2019-01-06 20:39           ` Sam Ravnborg
  0 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2019-01-04  7:46 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Andrey Smirnov, Barebox List

On Thu, Jan 03, 2019 at 08:53:18PM +0100, Sam Ravnborg wrote:
> Hi Andreay.
> 
> > > > To support bootstrap from SD card run a detect all before
> > > > mounting the SD card.
> > > >
> > > > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > > > ---
> > > >  lib/bootstrap/disk.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c
> > > > index fd016166e..77be95c2f 100644
> > > > --- a/lib/bootstrap/disk.c
> > > > +++ b/lib/bootstrap/disk.c
> > > > @@ -21,6 +21,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype)
> > > >         size_t len;
> > > >         const char *path = "/";
> > > >
> > > > +       device_detect_all();
> > > > +
> > > 
> > > Can device_detect_by_name(dev) be used here instead?
> > 
> > dev equals "disk0.0" when we call bootstrap_read_disk().
> > Calling device_detect_by_name("disk0.0") did not work, and then
> > the easy solution with device_detect_all() worked.
> > 
> > I could pass the dev name to bootstrap_read_disk() but
> > this would make the caller less general which is why I ended
> > up with the more brutal solution.
> 
> I ended up with following code in arch/arm/boards/at91sam9263ek/init.c:
> #if defined(CONFIG_MCI_ATMEL)
> static struct atmel_mci_platform_data __initdata ek_mci_data = {
>         .devname        = "disk0",
>         .bus_width      = 4,
>         .detect_pin     = AT91_PIN_PE18,
>         .wp_pin         = AT91_PIN_PE19,
> };
> 
> When I specify "devname=disk0", then I could use
> detect_by_name(dev) in bootstrap_read_disk().
> No too pretty, but preferable compared to
> running a loop detecting all devices.

There are two other possibilities. First there is CONFIG_MCI_STARTUP
which causes the SD cards to be detected during host registration.
Another possibility would be to call device_detect_by_name() from board
code (where you implicitly know which hardware device to probe)

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] 15+ messages in thread

* Re: [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting
  2019-01-04  7:46         ` Sascha Hauer
@ 2019-01-06 20:39           ` Sam Ravnborg
  0 siblings, 0 replies; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-06 20:39 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Andrey Smirnov, Barebox List

Hi Sasha.

> There are two other possibilities. First there is CONFIG_MCI_STARTUP
> which causes the SD cards to be detected during host registration.

This one worked like a charm and I could drop my hacks - thanks!

	Sam

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263
  2019-01-02 20:26 ` [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263 Sam Ravnborg
@ 2019-01-06 20:39   ` Sam Ravnborg
  2019-01-07  7:29   ` Sascha Hauer
  1 sibling, 0 replies; 15+ messages in thread
From: Sam Ravnborg @ 2019-01-06 20:39 UTC (permalink / raw)
  To: Barebox List

Hi Sasha.

This patch is OK - but the other two are bogus.
Please apply.

	Sam

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263
  2019-01-02 20:26 ` [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263 Sam Ravnborg
  2019-01-06 20:39   ` Sam Ravnborg
@ 2019-01-07  7:29   ` Sascha Hauer
  1 sibling, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2019-01-07  7:29 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Barebox List

On Wed, Jan 02, 2019 at 09:26:09PM +0100, Sam Ravnborg wrote:
> at91_add_device_mci() was missing configuration of PIOA6
> when configuring mci1.
> With this fix we can read data from SD card with at91sam9263ek,
> when built without DT.
> Building without a DT is required when we do a bootstrap build.
> 
> The other at91samxxx_devices was checked - only the 9263 was
> missing the CLK configuration for mci1.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> ---

Applied (this one), thanks

Sascha

>  arch/arm/mach-at91/at91sam9263_devices.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
> index a67345f05..c7e4962a9 100644
> --- a/arch/arm/mach-at91/at91sam9263_devices.c
> +++ b/arch/arm/mach-at91/at91sam9263_devices.c
> @@ -396,6 +396,9 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
>  	} else {			/* MCI1 */
>  		start = AT91SAM9263_BASE_MCI1;
>  
> +		/* CLK */
> +		at91_set_A_periph(AT91_PIN_PA6, 0);
> +
>  		if (data->slot_b) {
>  			/* CMD */
>  			at91_set_A_periph(AT91_PIN_PA21, 1);
> -- 
> 2.12.0
> 
> 
> _______________________________________________
> 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] 15+ messages in thread

end of thread, other threads:[~2019-01-07  7:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-02 20:26 [PATCH v1 0/3] bootstrap support for AT91SAM9263-EK Sam Ravnborg
2019-01-02 20:26 ` [PATCH v1 1/3] arm: at91: fix clock to mci1 for at91sam9263 Sam Ravnborg
2019-01-06 20:39   ` Sam Ravnborg
2019-01-07  7:29   ` Sascha Hauer
2019-01-02 20:26 ` [PATCH v1 2/3] lib: bootstrap: detect SD card before mounting Sam Ravnborg
2019-01-02 23:32   ` Andrey Smirnov
2019-01-03  5:46     ` Sam Ravnborg
2019-01-03 19:53       ` Sam Ravnborg
2019-01-04  7:46         ` Sascha Hauer
2019-01-06 20:39           ` Sam Ravnborg
2019-01-02 20:26 ` [PATCH v1 3/3] at91sam9263ek: add bootstrap support Sam Ravnborg
2019-01-03  8:16   ` Sascha Hauer
2019-01-03 10:58     ` Sam Ravnborg
2019-01-03 21:00       ` Sam Ravnborg
2019-01-04  7:37         ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox