Hi Sascha,<br> I've been playing with passing some data from first to second stage using Jan's patches.<br>It worked fine, but in my case I want to store this data on a global variable, which is cleared as it's in the BSS.<br>
There is a clean workarround to this issue?<br><br>Thanks,<br> Vicente.<br><br><div class="gmail_quote">On Wed, Sep 26, 2012 at 9:45 AM, Sascha Hauer <span dir="ltr"><<a href="mailto:s.hauer@pengutronix.de" target="_blank">s.hauer@pengutronix.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Sep 26, 2012 at 12:59:51AM +0200, vj wrote:<br>
> ---<br>
> arch/arm/cpu/cpu.c | 1 +<br>
> arch/arm/lib/barebox.lds.S | 10 +<br>
> arch/arm/mach-omap/Kconfig | 21 +<br>
> arch/arm/mach-omap/Makefile | 1 +<br>
> arch/arm/mach-omap/include/mach/omap4_rom_usb.h | 146 +++++<br>
> arch/arm/mach-omap/omap4_generic.c | 2 +<br>
> arch/arm/mach-omap/omap4_rom_usb.c | 189 ++++++<br>
> arch/arm/mach-omap/xload.c | 26 +<br>
> scripts/.gitignore | 1 +<br>
> scripts/Makefile | 3 +<br>
> scripts/usbboot.c | 797 ++++++++++++++++++++++++<br>
> 11 files changed, 1197 insertions(+)<br>
> create mode 100644 arch/arm/mach-omap/include/mach/omap4_rom_usb.h<br>
> create mode 100644 arch/arm/mach-omap/omap4_rom_usb.c<br>
> create mode 100644 scripts/usbboot.c<br>
><br>
> diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c<br>
> index 71ef8c0..05343de 100644<br>
> --- a/arch/arm/cpu/cpu.c<br>
> +++ b/arch/arm/cpu/cpu.c<br>
> @@ -89,6 +89,7 @@ void arch_shutdown(void)<br>
> : "r0", "r1", "r2", "r3", "r6", "r10", "r12", "lr", "cc", "memory"<br>
> );<br>
> #endif<br>
> + __asm__ __volatile__ ("cpsid i\n");<br>
> }<br>
><br>
> #ifdef CONFIG_THUMB2_BAREBOX<br>
> diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S<br>
> index a69013f..ff7b63d 100644<br>
> --- a/arch/arm/lib/barebox.lds.S<br>
> +++ b/arch/arm/lib/barebox.lds.S<br>
> @@ -97,6 +97,16 @@ SECTIONS<br>
> __bss_start = .;<br>
> .bss : { *(.bss*) }<br>
> __bss_stop = .;<br>
> +#ifdef CONFIG_SHARE_USB_HANDLE<br>
> + /*<br>
> + * Reserve space for the USB handle<br>
> + */<br>
> + . = CONFIG_USB_HANDLE_HANDOVER;<br>
> + . = ALIGN(4);<br>
> + __usb_handle = .;<br>
> + /* . += sizeof(struct usb); */<br>
> + . += 84;<br>
> +#endif<br>
<br>
</div></div>If I understand correctly the first stage loader puts some data here<br>
where a second stage barebox (configured with the same value for<br>
CONFIG_USB_HANDLE_HANDOVER) will pick it up.<br>
<br>
This seems to be a bit fragile. Fortunately Jan has posted a series<br>
that gives the control of the reset vector to the boards, which means<br>
that both stages do not have to agree on an addres, but instead a<br>
pointer can be passed from the first to the second stage.<br>
<br>
> +int usb_open(void)<br>
<br>
So this uses the OMAP4 ROM to do USB communication, right? The functions<br>
should have a omap_rom_* prefix then, otherwise it's not clear for a<br>
reader which context these functions have.<br>
<br>
The calling of the ROM code btw explains why the setting of VBAR breaks<br>
USB boot. The ROM probably uses the vectors.<br>
<div class="im"><br>
> +<br>
> + n = rom_get_per_driver(&pusb->io, boot->device_type);<br>
> + if (n)<br>
> + return n;<br>
> +<br>
> + pusb->dread.xfer_mode = boot->xfer_mode;<br>
> + pusb->dread.options = boot->options;<br>
> + pusb->dread.device_type = boot->device_type;<br>
> +<br>
> + pusb->dwrite.xfer_mode = boot->xfer_mode;<br>
> + pusb->dwrite.options = boot->options;<br>
> + pusb->dwrite.device_type = boot->device_type;<br>
> +#else<br>
> +#ifdef CONFIG_MMU<br>
> +#error USB communications not working under MMU<br>
<br>
</div>You can add the following to CONFIG_OMAP4_USB_BOOT instead:<br>
<br>
depends on !MMU<br>
<br>
So that an invalid config is not allowed in the first place.<br>
<br>
<br>
> diff --git a/scripts/usbboot.c b/scripts/usbboot.c<br>
<br>
This should also be named omap4-usbboot.c, or maybe, if the works on<br>
other OMAPs, just omap-usboot.c<br>
<span class="HOEnZb"><font color="#888888"><br>
Sascha<br>
<br>
--<br>
Pengutronix e.K. | |<br>
Industrial Linux Solutions | <a href="http://www.pengutronix.de/" target="_blank">http://www.pengutronix.de/</a> |<br>
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |<br>
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |<br>
</font></span></blockquote></div><br>