public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Nikolay Dimitrov <picmaster@mail.bg>
To: u-boot@lists.denx.de
Subject: [U-Boot] porting u-boot, few final questions
Date: Mon, 10 Nov 2014 19:54:40 +0200	[thread overview]
Message-ID: <5460FBE0.3070506@mail.bg> (raw)
In-Reply-To: <CAOMZO5Cum=pEtGvOk3x1SrpuGSt=BreNGG7A8xhotFyJP41BJA@mail.gmail.com>

Hi gents,

On 11/10/2014 06:04 PM, Fabio Estevam wrote:
> On Mon, Nov 10, 2014 at 1:47 PM, Wolfgang Denk <wd@denx.de> wrote:
>> Dear Fabio Estevam,
>>
>> In message <CAOMZO5AiJtDt_CZrO6gzU=JiPp_2-etPiGFcK7ZhFhNNzxp3_A@mail.gmail.com> you wrote:
>>>
>>>> 1. How come setenv is not working in the board file? I tried setenv in
>>>> different locations of board_early_init_f(), board_init(), board_late_init()
>>>> and checkboard(), but it's not working. Did something change?
>>>
>>> Haven't tried it, but if this does not work, then it is a bug that
>>> needs to be fixed. Do you have access to a mx53 qsb board? Does it
>>> work there?
>>
>> Suffix _f trditionally means "running from flash", i. e. this is
>> before relocation to RAM. Here we have usually only a read-ony data
>> segment, no BSS at all, and only limted stack.  All complicated stuff
>> like setenv is only supposed to be available after relocation.
>
> Just tested on real hardware and the below change works:
>
> --- a/board/freescale/mx53loco/mx53loco.c
> +++ b/board/freescale/mx53loco/mx53loco.c
> @@ -404,6 +404,12 @@ int board_late_init(void)
>          return 0;
>   }
>
> +int misc_init_r(void)
> +{
> +       setenv("myvar", "123456");
> +       return 0;
> +}
> +
>   int checkboard(void)
>   {
>          puts("Board: MX53 LOCO\n");
> diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h
> index a74508c..8f692d7 100644
> --- a/include/configs/mx53loco.h
> +++ b/include/configs/mx53loco.h
> @@ -29,6 +29,7 @@
>
>   #define CONFIG_BOARD_EARLY_INIT_F
>   #define CONFIG_BOARD_LATE_INIT
> +#define CONFIG_MISC_INIT_R
>   #define CONFIG_MXC_GPIO
>   #define CONFIG_REVISION_TAG
>
>>
>>> On mx6 we have several boards calling setenv from the board files.
>>
>> Actual behaviour is hardware-dependent, but it's better not to make
>> any such guesses.
>
> Yes, but not sure how a mx6 can differ from a mx5 in getting setenv to work.

Please correct me if I'm wrong, but setting env-vars shouldn't work
before the environment is initialized. This initialization happens when
the initr_env() is called according the order in init_sequence_r[].

@Dave - the easiest way to verify when your code (which tries to work
with the env-vars) is executed and when the actual environment is
initialized, is to enable debugging in
lib/initcall.c:initcall_run_list(), see the pointers of the called
functions and check them in the System.map. The env is initialized in
the call tree below initr_env(), so your code should use the env after
that.

Regards,
Nikolay

  reply	other threads:[~2014-11-10 17:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05 16:36 [U-Boot] porting u-boot, MMU question DaveKucharczyk
2014-11-05 16:58 ` Stefano Babic
2014-11-05 17:16   ` DaveKucharczyk
2014-11-05 21:04     ` Stefano Babic
2014-11-05 21:24       ` Otavio Salvador
2014-11-06 20:03         ` DaveKucharczyk
2014-11-10 15:14           ` [U-Boot] porting u-boot, few final questions DaveKucharczyk
2014-11-10 15:30             ` Fabio Estevam
2014-11-10 15:47               ` Wolfgang Denk
2014-11-10 16:04                 ` Fabio Estevam
2014-11-10 17:54                   ` Nikolay Dimitrov [this message]
2014-11-10 20:45                     ` DaveKucharczyk
2014-11-10 22:21                       ` DaveKucharczyk
2014-11-11 17:39                         ` DaveKucharczyk

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=5460FBE0.3070506@mail.bg \
    --to=picmaster@mail.bg \
    --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