From patchwork Fri Feb 3 11:23:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fuchs X-Patchwork-Id: 139355 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D84DA104792 for ; Fri, 3 Feb 2012 22:24:07 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 83EAF280E2; Fri, 3 Feb 2012 12:24:06 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aNvL55ocqyqH; Fri, 3 Feb 2012 12:24:06 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6D436280D7; Fri, 3 Feb 2012 12:24:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CB6C280D7 for ; Fri, 3 Feb 2012 12:24:03 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VD37vBjaZg02 for ; Fri, 3 Feb 2012 12:24:03 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by theia.denx.de (Postfix) with ESMTP id 2A903280D5 for ; Fri, 3 Feb 2012 12:24:01 +0100 (CET) Received: from comm-neu.esd (a89-182-187-55.net-htp.de [89.182.187.55]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MWORa-1S3iQd0vEo-00X6gp; Fri, 03 Feb 2012 12:24:01 +0100 Received: from [10.0.18.3] (pc-matthias.esd [10.0.18.3]) by comm-neu.esd (Postfix) with ESMTP id 1C1CB1362CC; Fri, 3 Feb 2012 12:22:59 +0100 (CET) Message-ID: <4F2BC39A.6050108@esd.eu> Date: Fri, 03 Feb 2012 12:23:06 +0100 From: Matthias Fuchs User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 To: u-boot@lists.denx.de References: <4F27F4CB.8090306@esd.eu> In-Reply-To: <4F27F4CB.8090306@esd.eu> X-Enigmail-Version: 1.3.5 X-Provags-ID: V02:K0:t33f5n2xi9l3DL+C7Tby/yN/7hgwmzewsSUOeaaDgyI Q8ULB91RmE1+7UHprSqt5t6+uoqwYDn/3VgP6FSjEv8TSYqnEb dRCDgt1LhcYRNunEhyetgX54jZmI7N9mlmarMILflJoTaXAApt KXKTMZiI+Gz0RaYq6l6pH3mo/xeQ1n5cnlgysn6V5euMRxGa5B hMNUiDpf/8gnskly/ILxr+GHUHixkqu67gIJyO5ZmUmSKXbyTv pqI6aRVS8RWOyYPHp6S5EoLWhok1Wirf6m3Q6wB4K91c5yJ3zC 1pnxI1BTV7/pECV1IvYqiY178/BpxN/mHvCwOy0ZUdozzZXgg= = Subject: Re: [U-Boot] mx28: booting u-boot via USB X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de On 31.01.2012 15:03, Matthias Fuchs wrote: > Hi, > > I have a problem booting the current u-boot-imx version > on a MX28EVK via USB. The i.MX28 CPU supports a special boot mode > where the image (sb boot stream) is downloaded via USB device > (all DIP switches in position 'off' on the EVK). The > CPU's internal bootrom implements a HID device in this mode. > Freescale provides a download tool "sb_loader" for this purpose. > There is also a GPL'd implementation based on libusb. > > So back to my problem: > > I build u-boot from the u-boot-imx repository. This runs fine > when booting from SD/MMC or SPI-flash. But the console stays dark > when using the USB download mode. USB download works fine with the > Freescale provided U-Boot sources together with the imx-bootlets > SPL code. > > Now I digged a little bit deeper to find out the cause: > > When downloading via USB I saw the SPL running correctly. > board_init_ll() (arch/arm/cpu/arm926ejs/mx28/start.S) runs through > correctly. Then control is passed back to the bootrom. That's > where things end as far as I can see. > > The 2nd stage of u-boot is not started. > > The USB boot mechanism is not documented that detailed. > Is it possible that the SPL code overwrites the bootroms ivt and > in consequence crashes the bootrom's USB code? Any further ideas? It figured out a (dirty) fix for my issue. It really seems that the mx28 bootrom is unhappy with the state of the CPU after the SPL code ran through. There are two things that make the bootrom more happy and finally start u-boot from RAM: 1) cpu_init_crit() from arch/arm/cpu/arm926ejs/mx28/start.S must not be called. 2) The ARMs fast interrupt mode must not be enabled when passing control back to the bootrom. The latter is easy to fix. Either we turn it off at the end of _reset or we do not even turn it on when switching to SVC32 mode. BTW, the bootrom calls _reset already in SVC32 mode, so we could kick those lines away. Disabling cpu_init_crit() has a sideeffect on get_ram_size() in mx28_mem_get_size(). Without disabling caches get_ram_size() freezes. Using a fixed RAM size works. Also calling get_ram_size with a max. of 0x20000000 (instead of the default 1GB) works. Hmm. Idea ideas how to fix this? Best things would be to revert the changes cpu_init_crit() does. Or we could move the get_ram_size() call to the 2nd stage when U-Boot is started in RAM from bootrom (before relocation). In this case we must modfiy get_Ram_size to start just behind u-boot code in RAM. Here are my current modifications: Matthias diff --git a/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c b/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c index 00493b8..257db6b 100644 --- a/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c +++ b/arch/arm/cpu/arm926ejs/mx28/spl_mem_init.c @@ -182,7 +182,11 @@ void mx28_mem_get_size(void) da = vt[4]; vt[4] = (uint32_t)&data_abort_memdetect_handler; - sz = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); + /* + * without start.S:cpu_init_crit() get_ram_size does not work + * with PHYS_SDRAM_1_SIZE = 0x40000000 + */ + sz = get_ram_size((long *)PHYS_SDRAM_1, 0x20000000); /* PHYS_SDRAM_1_SIZE);*/ writel(sz, HW_DIGCTRL_SCRATCH0); writel(sz, HW_DIGCTRL_SCRATCH1); diff --git a/arch/arm/cpu/arm926ejs/mx28/start.S b/arch/arm/cpu/arm926ejs/mx28/start.S index 2cd4d73..ba48fed 100644 --- a/arch/arm/cpu/arm926ejs/mx28/start.S +++ b/arch/arm/cpu/arm926ejs/mx28/start.S @@ -180,11 +180,26 @@ _reset: * not when booting from ram! */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT - bl cpu_init_crit +/* + * not fine for bootrom in USB mode mode but required for get_mem_size() + * in mx28_mem_init() + */ +/* bl cpu_init_crit */ #endif bl board_init_ll + /* + * turn of fast interrupt mode + * TODO: alternatively we can disable the code above (set cpu to + * SVC32 mode) because the bootrom already setup cpsr to 0x53 + * I don't expect that the SPL code requires the fast interrupt + * mode at all. + */ + mrs r0,cpsr + bic r0,r0,#0x80 + msr cpsr,r0 + pop {r0-r12,r14} bx lr