public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] confused by "upgrade_available=0\0" in include/configs/taurus.h
Date: Sat, 23 Jul 2016 00:01:36 +0200	[thread overview]
Message-ID: <20160722220136.5F967100539@atlas.denx.de> (raw)
In-Reply-To: <alpine.LFD.2.20.1607221529190.7337@localhost.localdomain>

Dear "Robert P. J. Day",

In message <alpine.LFD.2.20.1607221529190.7337@localhost.localdomain> you wrote:
> 
>   never embarrassed to make a fool of myself, i have to admit that,
> while crawling through examples of u-boot boards that define dual
> partitions, i am confused by the following in
> include/configs/taurus.h (only some lines reproduced):

This is your fault.  You omit the important parts, i. e. the lines
which end with a "\0" marker which will actually terminate the
definition of one variable and start the next one.

>   #define CONFIG_BOOTARGS_AXM                                           \
>         "\0"    \
>         "flash_nfs=run nand_kernel;run nfsargs;run addip;upgrade_available;"\
>         "flash_self=run nand_kernel;run setbootargs;upgrade_available;" \
>         "flash_self_test=run nand_kernel;run setbootargs addtest; "     \
>         "upgrade_available;bootm ${kernel_ram};reset\0"
>         "net_nfs=run boot_file;tftp ${kernel_ram} ${bootfile};"         \
>         "run nfsargs;run addip;upgrade_available;bootm "                \
>                 "${kernel_ram};reset\0"                                 \
> 
>         ... snip ...
> 
>         "upgrade_available=0\0"
>   #endif
> 
> what does it mean for "upgrade_available;" to be in the middle of some
> of those command definitions? it's just a variable, what does it
> represent? am i just clueless for never having noticed this sort of
> thing before?

The code really looks like that:

189         "flash_nfs=run nand_kernel;run nfsargs;run addip;upgrade_available;"\
190         "bootm ${kernel_ram};reset\0"                                   \

191         "flash_self=run nand_kernel;run setbootargs;upgrade_available;" \
192         "bootm ${kernel_ram};reset\0"                                   \

193         "flash_self_test=run nand_kernel;run setbootargs addtest; "     \
194         "upgrade_available;bootm ${kernel_ram};reset\0"                 \

So the code would run the "upgrade_available" _command_ as part of
the command sequences stored in the flash_nfs, flash_self resp.
flash_self_test environment variables.

Note that it has to be a (builtin) command, as a variable reference
would require a "$upgrade_available".

The "upgrade_available" is a board-specific command, implemented in
board/siemens/taurus/taurus.c, function do_upgrade_available().

You may also want to read the README:

 911 - Bootcount:
 ...
 917                 CONFIG_BOOTCOUNT_ENV
 918                 If no softreset save registers are found on the hardware
 919                 "bootcount" is stored in the environment. To prevent a
 920                 saveenv on all reboots, the environment variable
 921                 "upgrade_available" is used. If "upgrade_available" is
 922                 0, "bootcount" is always 0, if "upgrade_available" is
 923                 1 "bootcount" is incremented in the environment.
 924                 So the Userspace Applikation must set the "upgrade_available"
 925                 and "bootcount" variable to 0, if a boot was successfully.

This is a special measure for boards where there was no good place to
store the boot counter variable in some hardware register, so it was
instead placed in the environment.


Adding Heiko on Cc: so he might add to this explanation if I have
missed something, or interpreted the code incorrectly.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You Don't Have To Be 'Damned' To Work Here, But It Helps!!!
                                             - Terry Pratchett, _Eric_

  reply	other threads:[~2016-07-22 22:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 19:36 [U-Boot] confused by "upgrade_available=0\0" in include/configs/taurus.h Robert P. J. Day
2016-07-22 22:01 ` Wolfgang Denk [this message]
2016-07-23  4:32   ` Robert P. J. Day
2016-07-23 10:18   ` Robert P. J. Day
2016-07-23 11:42   ` Robert P. J. Day
2016-07-25  4:54     ` Wolfgang Denk
2016-07-25 10:03       ` Robert P. J. Day
2016-07-25 13:26         ` Wolfgang Denk
2016-07-25 17:24           ` [U-Boot] a few questions about saving bootcount in the environment Heiko Schocher
2016-07-26 11:02           ` [U-Boot] confused by "upgrade_available=0\0" in include/configs/taurus.h Robert P. J. Day
2016-07-26 11:22             ` Robert P. J. Day
2016-07-25 17:07         ` Heiko Schocher

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=20160722220136.5F967100539@atlas.denx.de \
    --to=wd@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox