All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] Separately compile Master boot loader
Date: Thu, 11 Jul 2013 10:35:07 +0200	[thread overview]
Message-ID: <20130711103507.48bd224f@lilith> (raw)
In-Reply-To: <CAONsvZW=XsMPEXixipn5-gnMnpn7R5en_4Pwfj1r+3fuCbxsmw@mail.gmail.com>

Hi Rajdeep,

On Thu, 11 Jul 2013 10:57:44 +0530, Rajdeep Vaghasia
<rajdeep.vaghasia@gmail.com> wrote:

> Hi Albert,
> 
> I would like to explain you my exact idea.
> For that, The Partition layout is:
> 1) Master u-boot
> 2) u-boot-1
> 3) u-boot-2
> 4) kernel
> 5) filesystem
> 6) data
> 
> Sometimes, When we may require to update with a new u-boot(to provide some
> additional support), we have to overwrite the existing u-boot.
> I don't want to overwrite the existing u-boot.
> Instead, I want to keep a separate partition for new u-boot.
> 
> *Here is the whole procedure:*
> I will maintain one environment variable(say "*safe_u-boot*"), which will
> be used to point to the current 'working u-boot' partition(means, *u-boot-1*
> ).
> 
> I will develop one simple user space application.
> Whenever a new u-boot is available, It will be first copied into the SDRAM
> by this application.
> Then, This application will check the environment variable "*new_u-boot*"
> which will be pointing to second u-boot partition("u-boot-2") in flash.
> And then, it will copy the new u-boot from SDRAM to *NOR flash* on the
> partition pointed to by the "*new_u-boot*" environment variable, and then
> mark one update flag(say, *u_boot_UPDATE*) as '*1*' and reboot the system.
> This update flag is readable/writable by u-boot, kernel and user
> application.
> 
> On reboot,
> master u-boot(on every reboot or system power-up) will check this *
> U_boot_UPDATE* flag  status.
> If it is *set*, then Master u-boot will *first clear* that flag and then,
> will load the u-boot from the partition pointed to by the "new_u-boot" env
> variable.
> 
> case-1:
> If the system is up successfully, the user space application will set the "*
> safe_u-boot*" env variable to point the new partition(which was pointed to
> by "*new_u-boot*") and set "*new_u-boot*" env variable to point to the
> first u-boot partition(which was pointed to by "*safe_u-boot*"). (In short,
> swapping of these environment variables). So, that on second time, when
> system reboots, Master u-boot will see the *U_boot_UPDATE* flag *cleared*,
> and will load the u-boot from the partition pointed to by "*safe_u-boot*",
> which now contains the updated new u-boot.
> 
> case-2:
> If the system fails and can not come up successfully with new u-boot, then
> on *manual reboot*, Master u-boot will check the "*U_boot_UPDATE*" flag,
> which will be in cleared state. (Because during update process, as soon as
> Master U-boot reads this flag as set, it clears the flag). So, Master
> U-boot will load the u-boot from the partition pointed to by the "*
> safe_u-boot*" env variable(which is the working u-boot not updated
> one.(say, u-boot-1)). As the swapping of these environment variables is
> done by user application on successful update, this will not be the case
> with this unsuccessful system up.
> 
> I hope everything is clear, now.
> *So, in this overall implementation*,

Thank you -- now your goals are clear and your question can be answered
in a more detailed manner.

> I want to keep a little code of Master u-boot, which initializes SDRAM, and
> copies secondary u-boot from flash to SDRAM. In addition to these, it keeps
> track of two env variables.
> 
> Is there any separate source code available for this kind of Master U-boot?
> *Or*
> Can we compile the existing u-boot source code such that it will generate
> only a small binary with these little functionalities?
> *Or*
> Can we compile the existing u-boot source code such that it will generate
> both the binaries separately(master u-boot+secondary u-boot)?
>
> Of course, even if Master u-boot is available, I will have to change that a
> bit to implement those environment variable stuff in Master u-boot.
> 
> But this will be very helpful to me, if I get help from you.
> 
> I would like to remind again that, I want to implement this on *NOR Flash*.

There is no separate source code for your "Master U-Boot" concept, nor
is there currently a way to build several U-Boots in one go. The best
match in U-Boot to your "small binary" is SPL, which is intended to be
run first when the whole of U-boot cannot be run directly.

But...

SPL has never been used for NOR FLASH booting, since basically if you
have NOR, then you can start U-boot directly from there whatever its
size, and the first thing it does is setting up DDR and relocating
there; therefore there is (currently) no need for SPL with NOR.

So you would have to:

- make the SPL framework able to run from NOR and chain-load U-boot from
  NOR too;

- make SPL able to select the U-Boot it chainloads to, for instance
  through env variables that override the SPL defaults (maybe looking
  at the Falcon mode might give you ideas on how to best do this);

- configure your target to use SPL with NOR support, with a default
  environment that will load u-boot-1 rather than u-boot-2.

The very first build would produce SPL as your initial (and hopefully
final, too) "Master -U-Boot", and U-Boot as your initial, u-boot-1,
payload. This, flashed onto your target, should boot.

The subsequent builds would build newer SPL (arguably useless if same
as the previous one) and newer U-boot (which would be the "upgrade"
one). You could then, from the u-boot-1 prompt, manually flash this
'new' u-boot-2 and set the environment for an upgrade, then reboot and
test your upgrade procedure.

If rebuilding SPL when not needed is really a pain to you despite not
being the most time-critical task in your overall process, you could
also patch the U-boot build system to allow skipping the SPL build.
Maybe some other boards would be interested in that too, BTW.

> Regards,
> Rajdeep

Amicalement,
-- 
Albert.

  reply	other threads:[~2013-07-11  8:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 10:42 [U-Boot] Separately compile Master boot loader Rajdeep Vaghasia
2013-07-09 12:01 ` Albert ARIBAUD
2013-07-10  9:34 ` Rajdeep Vaghasia
2013-07-10 12:23   ` Albert ARIBAUD
2013-07-11  5:27     ` Rajdeep Vaghasia
2013-07-11  8:35       ` Albert ARIBAUD [this message]
2013-07-11  9:11         ` [U-Boot] [RFC] Multiple binaries per U-Boot target (was: Separately compile Master boot loader) Albert ARIBAUD
2013-07-19 15:27           ` [U-Boot] [RFC] Multiple binaries per U-Boot target Sascha Silbe
2013-07-19 16:53             ` Simon Glass
2013-07-19 18:12               ` Albert ARIBAUD
2013-07-19 18:14                 ` Simon Glass
2013-07-19 19:27                 ` Wolfgang Denk
2013-07-19 21:09                   ` Albert ARIBAUD
2013-07-19 22:32                     ` Wolfgang Denk
2013-07-20  7:15                       ` Albert ARIBAUD
2013-07-19 19:26             ` Wolfgang Denk
2013-07-11 10:08         ` [U-Boot] Separately compile Master boot loader Wolfgang Denk
2013-07-11 10:25           ` Albert ARIBAUD
2013-07-11  9:58       ` Wolfgang Denk

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=20130711103507.48bd224f@lilith \
    --to=albert.u.boot@aribaud.net \
    --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.