All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] arm: spl: Fix SPL booting for OMAP3
Date: Thu, 20 Jun 2013 20:28:01 +0200	[thread overview]
Message-ID: <51C349B1.90604@denx.de> (raw)
In-Reply-To: <20130620195114.1ff10aef@lilith>

Hi Albert,

On 20.06.2013 19:51, Albert ARIBAUD wrote:
>>> The correct fix (read: the one I won't NAK) is thus to add a #else
>>> clause in the code above, in which r8 will be set to =gdata, and to
>>> remove the corresponding assignments in the various places where they
>>> reside.
>>
>> Here's the problem. Setting r8 in _main is too late. As it has already
>> been used (in the current implementation) to store some data (e.g.
>> clocks for baudrate generation etc). Here the code from
>> arch/arm/cpu/armv7/omap3/board.c:s_init():
>>
>> #ifdef CONFIG_SPL_BUILD
>> 	gd = &gdata;
>>
>> 	preloader_console_init();
>>
>> 	timer_init();
>> #endif
>>
>> Note that this is done *before* _main() is called (we are talking about
>> SPL for OMAP here).
> 
> Yes, it is done before _main... right before it. Like, really *right*
> *before* *it*. Like, s_init is called at the very end of lowlevel_init,
> which was branched straight into from cpu_init_crit which itself is
> called just before _main.
> 
> In other words, after s_init(), _main immediately kicks in, sets up sp
> and r8 (which was done also in lowlevel_init and will thus be a no-op
> once gdata is handled in crt0.S too) and calls board_init_f().
> 
> So, calling s_init() last in lowlevel_init() would be the same as
> calling it first in board_init_f().
>
> The difference with the current situation is, s_init() is C code, and C
> runtime is supposed not to be available until just before entering
> board_init_f(). This is the only reason why sp and r8 are set up in
> lowlevel_init: because s_init() is called at a time when C runtime is
> not officially set up yet.
> 
> Note that as far as setting the C runtime environment is concerned,
> crt0.S does *exactly* the same thing as lowlevel_init -- or will, once
> the gdata stuff is added in crt0.S as I suggest.
> 
> --- 8< ---
> So you just need to add the gdata stuff in crt0.S as I previously
> suggested, move the s_init() call in crt0.S (conditioned on building
> SPL) just before the call to board_init_f(), and then make
> lowlevel_init empty since it would then be useless.
> --- 8< ---

Useless? Its still calling cpy_clk_code(). Isn't this needed anymore?

>> And it did cost me quite some time to find this
>> problem, that r8 was re-configured in _main() and all the already set
>> values disappeared again (no serial output etc).
> 
> Actually your trouble precisely shows why gd/r8 should only be touched
> in a single file and nowhere else: because it is set in many places,
> its value was hard to control.

Full ack on this.

>> Yes, this needs some cleanup/fixup. Unfortunately I won't find the time
>> to look into such a cleanup in the next days. Perhaps somebody else
>> might jump in...
> 
> There'll have to be a V2 for this patch anyway.
> 
> Here's my offer: you submit V2 of this patch as described above between
> the '--- 8< ---' markers, and I handle the scrubbing of all spurious
> assignments to gd myself. Deal?

Yes, I'll try to squeeze a few cycles from the other projects to get
this done hopefully tomorrow.

Thanks,
Stefan

  reply	other threads:[~2013-06-20 18:28 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14  8:54 [U-Boot] [PATCH 1/3] arm: spl: Fix SPL booting for OMAP3 Stefan Roese
2013-06-14  8:55 ` [U-Boot] [PATCH 2/3] arm: omap3: spl: Fix problem with 8bit NAND devices Stefan Roese
2013-07-30 13:25   ` [U-Boot] [U-Boot, " Tom Rini
2013-06-14  8:55 ` [U-Boot] [PATCH 3/3] arm: omap3: Add SPL support to cm_t35 Stefan Roese
2013-06-17 11:53   ` Igor Grinberg
2013-06-17 12:38     ` Tom Rini
2013-06-17 13:38       ` Igor Grinberg
2013-06-17 13:52         ` Stefan Roese
2013-06-17 14:03   ` [U-Boot] [PATCH v2 " Stefan Roese
2013-06-18  6:14     ` Nikita Kiryanov
2013-07-30 10:52   ` [U-Boot] [PATCH v3 " Stefan Roese
2013-07-30 12:10     ` Albert ARIBAUD
2013-07-30 12:14       ` Stefan Roese
2013-11-15  7:51   ` [U-Boot] [PATCH v4] " Stefan Roese
     [not found]     ` <5288BBAC.2020307@compulab.co.il>
     [not found]       ` <5295BF6C.20902@compulab.co.il>
     [not found]         ` <5295C3F8.50101@denx.de>
     [not found]           ` <529E01B7.4070402@compulab.co.il>
2013-12-04 11:38             ` [U-Boot] Fwd: " Stefan Roese
2013-12-04 11:57               ` Tom Rini
2013-12-04 12:02                 ` Stefan Roese
2013-12-04 12:15               ` Gupta, Pekon
2013-12-04 12:38                 ` Stefan Roese
2013-06-20 16:42 ` [U-Boot] [PATCH 1/3] arm: spl: Fix SPL booting for OMAP3 Albert ARIBAUD
2013-06-20 17:01   ` Stefan Roese
2013-06-20 17:51     ` Albert ARIBAUD
2013-06-20 18:28       ` Stefan Roese [this message]
2013-06-20 19:18         ` Albert ARIBAUD
2013-06-21  2:13 ` [U-Boot] [PATCH v2 " Stefan Roese
2013-06-21  8:57   ` Albert ARIBAUD
2013-06-21  9:10 ` [U-Boot] [PATCH v3 " Stefan Roese
2013-06-21 10:30   ` Albert ARIBAUD
2013-06-21 10:39     ` Stefan Roese
2013-06-21 10:42 ` [U-Boot] [PATCH v4 " Stefan Roese
2013-06-21 11:02   ` Albert ARIBAUD
2013-06-25  7:14 ` [U-Boot] [PATCH v5 " Stefan Roese
2013-06-27  8:27   ` Albert ARIBAUD
2013-07-03 19:47     ` Tom Rini
2013-07-04 11:58       ` Albert ARIBAUD
2013-07-15 14:33 ` [U-Boot] [PATCH " Tom Rini
2013-07-16  6:24   ` Stefan Roese
2013-07-16 14:36     ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C349B1.90604@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.