mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Bootchooser has unexpected changes of variable 'remaining_attempts'
@ 2017-07-24 11:28 Norbert Wiedmann
  2017-08-01 14:02 ` Norbert Wiedmann
  0 siblings, 1 reply; 4+ messages in thread
From: Norbert Wiedmann @ 2017-07-24 11:28 UTC (permalink / raw)
  To: barebox

Hi everyone,
I have an unexpected behaviour with my bootchooser framework since 
barebox version 2017.05.
 
After reflashing barebox, and cleaning the environment and the state partition,
the boot message shows:

stMyBoot: New state registered 'stMyBoot'
stMyBoot: Failed to find any valid state copy in any bucket
stMyBoot: Failed to read state with format dtb, -2
state stMyBoot.14: Failed to load persistent state, continuing with defaults,-2

Barebox continues with defaults, this seems OK.
I double checked this by printing the variables (default is 0xffffffff)

printenv stMyBoot.bootchooser.factory.remaining_attempts
stMyBoot.bootchooser.factory.remaining_attempts=4294967295

printenv stMyBoot.bootchooser.system1.remaining_attempts       
stMyBoot.bootchooser.system1.remaining_attempts=4294967295

printenv stMyBoot.bootchooser.system2.remaining_attempts
stMyBoot.bootchooser.system2.remaining_attempts=4294967295

Next, I call boot, and everything works fine, the target with the highest
priority, which is 'system1', boots.

booting 'bootchooser'
booting 'system1'

The system boots as expected. I have no modification within my linux.

The problem starts with the second boot, which fails:

barebox outputs:
stMyBoot: New state registered 'stMyBoot'
stMyBoot: Using bucket 0@0x00000000

This is OK, the bucket was written during the first boot, because the
remaining_attempts should be decreased. But, unexpectly, the bootchooser
is completly deactivated, all three boot targets have remaining_attempts=0

booting 'bootchooser'
bootchooser: No valid targets found:
system1
    id: 1
    priority: 22
    default_priority: 1
    remaining attempts: 0
    default attempts: 3
    boot: 'system1'
    disabled due to remaining attempts = 0
system2
    id: 2
    priority: 21
    default_priority: 1
    remaining attempts: 0
    default attempts: 3
    boot: 'system2'
    disabled due to remaining attempts = 0
factory
    id: 3
    priority: 10
    default_priority: 1
    remaining attempts: 0
    default attempts: 3
    boot: 'factory'
    disabled due to remaining attempts = 0
booting 'bootchooser' failed: No such file or directory

I placed a printenv in my boot entry file and, when booting the first time
after a new  reflashing, the output is
stMyBoot.bootchooser.system1.remaining_attempts=0

I looks like the bootchooser doesn't use the default/actual value for
'remaining_attempts' when saving the variables after he has decided which
boot target he will use.

Everything worked fine up to 2017.04
Behaviour as descriped tested with 2017.05, 2017.07.1
 
What is going wrong?
Thanks for your consideration in this matter.

Best regards
Norbert Wiedmann

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bootchooser has unexpected changes of variable 'remaining_attempts'
  2017-07-24 11:28 Bootchooser has unexpected changes of variable 'remaining_attempts' Norbert Wiedmann
@ 2017-08-01 14:02 ` Norbert Wiedmann
  2017-08-01 20:37   ` Robert Schwebel
  2017-08-04 13:49   ` Norbert Wiedmann
  0 siblings, 2 replies; 4+ messages in thread
From: Norbert Wiedmann @ 2017-08-01 14:02 UTC (permalink / raw)
  To: barebox

Hi again,
after debugging a while, I found the reason:
In file bootchooser.c, in funktion bootchooser_save(..) the call of

ret = pr_setenv(bc, "%s.remaining_attempts=%d",
                target->state_prefix,
                target->remaining_attempts);
creates a "xxx.remaining_attempts=-1" if the variable 'remaining_attempts'
is 0xffffffff, for example.

The type of remaining_attempts is unsigned int.

After changing the function call to
 
ret = pr_setenv(bc, "%s.remaining_attempts=%lu",   /* changed %d to %lu */
                target->state_prefix,
                target->remaining_attempts);
it works fine.
Maybe this could be fixed..., thank you.

Best regards
Norbert Wiedmann


> Norbert Wiedmann <info@n-wiedmann.de> hat am 24. Juli 2017 um 13:28
> geschrieben:
>
>
> Hi everyone,
> I have an unexpected behaviour with my bootchooser framework since
> barebox version 2017.05.
>
> After reflashing barebox, and cleaning the environment and the state
> partition,
> the boot message shows:
>
> stMyBoot: New state registered 'stMyBoot'
> stMyBoot: Failed to find any valid state copy in any bucket
> stMyBoot: Failed to read state with format dtb, -2
> state stMyBoot.14: Failed to load persistent state, continuing with
> defaults,-2
>
> Barebox continues with defaults, this seems OK.
> I double checked this by printing the variables (default is 0xffffffff)
>
> printenv stMyBoot.bootchooser.factory.remaining_attempts
> stMyBoot.bootchooser.factory.remaining_attempts=4294967295
>
> printenv stMyBoot.bootchooser.system1.remaining_attempts
> stMyBoot.bootchooser.system1.remaining_attempts=4294967295
>
> printenv stMyBoot.bootchooser.system2.remaining_attempts
> stMyBoot.bootchooser.system2.remaining_attempts=4294967295
>
> Next, I call boot, and everything works fine, the target with the highest
> priority, which is 'system1', boots.
>
> booting 'bootchooser'
> booting 'system1'
>
> The system boots as expected. I have no modification within my linux.
>
> The problem starts with the second boot, which fails:
>
> barebox outputs:
> stMyBoot: New state registered 'stMyBoot'
> stMyBoot: Using bucket 0@0x00000000
>
> This is OK, the bucket was written during the first boot, because the
> remaining_attempts should be decreased. But, unexpectly, the bootchooser
> is completly deactivated, all three boot targets have remaining_attempts=0
>
> booting 'bootchooser'
> bootchooser: No valid targets found:
> system1
> id: 1
> priority: 22
> default_priority: 1
> remaining attempts: 0
> default attempts: 3
> boot: 'system1'
> disabled due to remaining attempts = 0
> system2
> id: 2
> priority: 21
> default_priority: 1
> remaining attempts: 0
> default attempts: 3
> boot: 'system2'
> disabled due to remaining attempts = 0
> factory
> id: 3
> priority: 10
> default_priority: 1
> remaining attempts: 0
> default attempts: 3
> boot: 'factory'
> disabled due to remaining attempts = 0
> booting 'bootchooser' failed: No such file or directory
>
> I placed a printenv in my boot entry file and, when booting the first time
> after a new reflashing, the output is
> stMyBoot.bootchooser.system1.remaining_attempts=0
>
> I looks like the bootchooser doesn't use the default/actual value for
> 'remaining_attempts' when saving the variables after he has decided which
> boot target he will use.
>
> Everything worked fine up to 2017.04
> Behaviour as descriped tested with 2017.05, 2017.07.1
>
> What is going wrong?
> Thanks for your consideration in this matter.
>
> Best regards
> Norbert Wiedmann
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bootchooser has unexpected changes of variable 'remaining_attempts'
  2017-08-01 14:02 ` Norbert Wiedmann
@ 2017-08-01 20:37   ` Robert Schwebel
  2017-08-04 13:49   ` Norbert Wiedmann
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Schwebel @ 2017-08-01 20:37 UTC (permalink / raw)
  To: Norbert Wiedmann; +Cc: barebox

Hi,

On Tue, Aug 01, 2017 at 04:02:32PM +0200, Norbert Wiedmann wrote:
> after debugging a while, I found the reason:
> In file bootchooser.c, in funktion bootchooser_save(..) the call of
> 
> ret = pr_setenv(bc, "%s.remaining_attempts=%d",
>                 target->state_prefix,
>                 target->remaining_attempts);
> creates a "xxx.remaining_attempts=-1" if the variable 'remaining_attempts'
> is 0xffffffff, for example.
> 
> The type of remaining_attempts is unsigned int.
> 
> After changing the function call to
>  
> ret = pr_setenv(bc, "%s.remaining_attempts=%lu",   /* changed %d to %lu */
>                 target->state_prefix,
>                 target->remaining_attempts);
> it works fine.
> Maybe this could be fixed..., thank you.

Could you make a proper patch out of your proposal and send it here to
the mailing list? This is the usual way how change requests are reviewed
and discussed in barebox.

Thank you,

rsc
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bootchooser has unexpected changes of variable 'remaining_attempts'
  2017-08-01 14:02 ` Norbert Wiedmann
  2017-08-01 20:37   ` Robert Schwebel
@ 2017-08-04 13:49   ` Norbert Wiedmann
  1 sibling, 0 replies; 4+ messages in thread
From: Norbert Wiedmann @ 2017-08-04 13:49 UTC (permalink / raw)
  To: barebox


> Norbert Wiedmann <info@n-wiedmann.de> hat am 1. August 2017 um 16:02
> geschrieben:
>
>
> Hi again,
> after debugging a while, I found the reason:
> In file bootchooser.c, in funktion bootchooser_save(..) the call of
>
> ret = pr_setenv(bc, "%s.remaining_attempts=%d",
> target->state_prefix,
> target->remaining_attempts);
> creates a "xxx.remaining_attempts=-1" if the variable 'remaining_attempts'
> is 0xffffffff, for example.
>
> The type of remaining_attempts is unsigned int.
>
> After changing the function call to
>
> ret = pr_setenv(bc, "%s.remaining_attempts=%lu", /* changed %d to %lu */
> target->state_prefix,
> target->remaining_attempts);
> it works fine.
> Maybe this could be fixed..., thank you.
>
> Best regards
> Norbert Wiedmann
>
>
> > Norbert Wiedmann <info@n-wiedmann.de> hat am 24. Juli 2017 um 13:28
> > geschrieben:
> >
> >
> > Hi everyone,
> > I have an unexpected behaviour with my bootchooser framework since
> > barebox version 2017.05.
> >
> > After reflashing barebox, and cleaning the environment and the state
> > partition,
> > the boot message shows:
> >
> > stMyBoot: New state registered 'stMyBoot'
> > stMyBoot: Failed to find any valid state copy in any bucket
> > stMyBoot: Failed to read state with format dtb, -2
> > state stMyBoot.14: Failed to load persistent state, continuing with
> > defaults,-2
> >
> > Barebox continues with defaults, this seems OK.
> > I double checked this by printing the variables (default is 0xffffffff)
> >
> > printenv stMyBoot.bootchooser.factory.remaining_attempts
> > stMyBoot.bootchooser.factory.remaining_attempts=4294967295
> >
> > printenv stMyBoot.bootchooser.system1.remaining_attempts
> > stMyBoot.bootchooser.system1.remaining_attempts=4294967295
> >
> > printenv stMyBoot.bootchooser.system2.remaining_attempts
> > stMyBoot.bootchooser.system2.remaining_attempts=4294967295
> >
> > Next, I call boot, and everything works fine, the target with the highest
> > priority, which is 'system1', boots.
> >
> > booting 'bootchooser'
> > booting 'system1'
> >
> > The system boots as expected. I have no modification within my linux.
> >
> > The problem starts with the second boot, which fails:
> >
> > barebox outputs:
> > stMyBoot: New state registered 'stMyBoot'
> > stMyBoot: Using bucket 0@0x00000000
> >
> > This is OK, the bucket was written during the first boot, because the
> > remaining_attempts should be decreased. But, unexpectly, the bootchooser
> > is completly deactivated, all three boot targets have remaining_attempts=0
> >
> > booting 'bootchooser'
> > bootchooser: No valid targets found:
> > system1
> > id: 1
> > priority: 22
> > default_priority: 1
> > remaining attempts: 0
> > default attempts: 3
> > boot: 'system1'
> > disabled due to remaining attempts = 0
> > system2
> > id: 2
> > priority: 21
> > default_priority: 1
> > remaining attempts: 0
> > default attempts: 3
> > boot: 'system2'
> > disabled due to remaining attempts = 0
> > factory
> > id: 3
> > priority: 10
> > default_priority: 1
> > remaining attempts: 0
> > default attempts: 3
> > boot: 'factory'
> > disabled due to remaining attempts = 0
> > booting 'bootchooser' failed: No such file or directory
> >
> > I placed a printenv in my boot entry file and, when booting the first time
> > after a new reflashing, the output is
> > stMyBoot.bootchooser.system1.remaining_attempts=0
> >
> > I looks like the bootchooser doesn't use the default/actual value for
> > 'remaining_attempts' when saving the variables after he has decided which
> > boot target he will use.
> >
> > Everything worked fine up to 2017.04
> > Behaviour as descriped tested with 2017.05, 2017.07.1
> >
> > What is going wrong?
> > Thanks for your consideration in this matter.
> >
> > Best regards
> > Norbert Wiedmann
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> >
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
Hi,
this patch will fix the issue.
 
---
 common/bootchooser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/bootchooser.c b/common/bootchooser.c
index 455f290..310d237 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -501,7 +501,7 @@ int bootchooser_save(struct bootchooser *bc)
               bc->last_chosen->id);
 
     list_for_each_entry(target, &bc->targets, list) {
-        ret = pr_setenv(bc, "%s.remaining_attempts=%d",
+        ret = pr_setenv(bc, "%s.remaining_attempts=%lu",
                 target->state_prefix,
                 target->remaining_attempts);
         if (ret)
--
2.7.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-04 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-24 11:28 Bootchooser has unexpected changes of variable 'remaining_attempts' Norbert Wiedmann
2017-08-01 14:02 ` Norbert Wiedmann
2017-08-01 20:37   ` Robert Schwebel
2017-08-04 13:49   ` Norbert Wiedmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox