mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Heartbeat LED during init script
@ 2021-02-17 12:22 barebox+mailing
  2021-02-17 12:35 ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: barebox+mailing @ 2021-02-17 12:22 UTC (permalink / raw)
  To: barebox

Hey everyone,

we use the barebox bootloader in on of our products.
Because of some norms we need to make a memtest of the RAM. To do that, we use the provided memtest tool.
So one of our our scripts is `/env/init/10-memtest`, which has just `memtest -tc` in it.


The other script is `/env/init/05-heartbeat` which contains 

#!/bin/sh

led -b board-red 100 1000

So, at first the 05 script is executed, afterwards the memtest script.

The problem is, that during the memtest the led does not blink, but flashes red the whole time. After the memtest is done, the blinking is done perfectly fine, but not during the memtest.

I create a small video to showcase this exact problem: https://imgur.com/a/9sxHTcm

Can anybody tell me why the barebox isn't able to keep up with the blinking as well as how to mitigate that?

Greetings,
Marcel

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

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

* Re: Heartbeat LED during init script
  2021-02-17 12:22 Heartbeat LED during init script barebox+mailing
@ 2021-02-17 12:35 ` Sascha Hauer
  2021-02-17 12:44   ` barebox+mailing
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2021-02-17 12:35 UTC (permalink / raw)
  To: barebox+mailing; +Cc: barebox

On Wed, Feb 17, 2021 at 01:22:32PM +0100, barebox+mailing@cookiesoft.de wrote:
> Hey everyone,
> 
> we use the barebox bootloader in on of our products.
> Because of some norms we need to make a memtest of the RAM. To do that, we use the provided memtest tool.
> So one of our our scripts is `/env/init/10-memtest`, which has just `memtest -tc` in it.
> 
> 
> The other script is `/env/init/05-heartbeat` which contains 
> 
> #!/bin/sh
> 
> led -b board-red 100 1000
> 
> So, at first the 05 script is executed, afterwards the memtest script.
> 
> The problem is, that during the memtest the led does not blink, but flashes red the whole time. After the memtest is done, the blinking is done perfectly fine, but not during the memtest.
> 
> I create a small video to showcase this exact problem: https://imgur.com/a/9sxHTcm
> 
> Can anybody tell me why the barebox isn't able to keep up with the blinking as well as how to mitigate that?

barebox doesn't support interrupts. LED blinking is done in pollers,
that are little function that run each time a timing related function is
called. What you can do is to add for example add a ctrlc() call to your
memtester code inside some loop. That will cause the poller to run.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 7+ messages in thread

* Re: Heartbeat LED during init script
  2021-02-17 12:35 ` Sascha Hauer
@ 2021-02-17 12:44   ` barebox+mailing
  2021-02-17 13:17     ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: barebox+mailing @ 2021-02-17 12:44 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hey Sasha,

thanks for the answer.

> barebox doesn't support interrupts. LED blinking is done in pollers

That explains the obversation.

> add a ctrlc() call to your memtester code inside some loop.
> That will cause the poller to run.

I'm not entirely sure, if I understand you correctly or you didn't understand me.

I use the memtest command[0] from barebox so there is nothing custom written or any loop that I can control.
However, if I understand you correctly one could add the `ctrlc` command in all of these[1] three loops inside the `mem_test_moving_inversions` function. Is that correct? Or is there an other way to not listen on ctrl+c but let the poller itself run?

Greetings,
Marcel

[0]: https://barebox.org/doc/latest/commands/mem/memtest.html
[1]: https://git.pengutronix.de/cgit/barebox/tree/common/memtest.c#n387

> Sascha Hauer <sha@pengutronix.de> hat am 17.02.2021 13:35 geschrieben:
> 
>  
> On Wed, Feb 17, 2021 at 01:22:32PM +0100, barebox+mailing@cookiesoft.de wrote:
> > Hey everyone,
> > 
> > we use the barebox bootloader in on of our products.
> > Because of some norms we need to make a memtest of the RAM. To do that, we use the provided memtest tool.
> > So one of our our scripts is `/env/init/10-memtest`, which has just `memtest -tc` in it.
> > 
> > 
> > The other script is `/env/init/05-heartbeat` which contains 
> > 
> > #!/bin/sh
> > 
> > led -b board-red 100 1000
> > 
> > So, at first the 05 script is executed, afterwards the memtest script.
> > 
> > The problem is, that during the memtest the led does not blink, but flashes red the whole time. After the memtest is done, the blinking is done perfectly fine, but not during the memtest.
> > 
> > I create a small video to showcase this exact problem: https://imgur.com/a/9sxHTcm
> > 
> > Can anybody tell me why the barebox isn't able to keep up with the blinking as well as how to mitigate that?
> 
> barebox doesn't support interrupts. LED blinking is done in pollers,
> that are little function that run each time a timing related function is
> called. What you can do is to add for example add a ctrlc() call to your
> memtester code inside some loop. That will cause the poller to run.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 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] 7+ messages in thread

* Re: Heartbeat LED during init script
  2021-02-17 12:44   ` barebox+mailing
@ 2021-02-17 13:17     ` Sascha Hauer
  2021-02-18  8:00       ` Marcel Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2021-02-17 13:17 UTC (permalink / raw)
  To: barebox+mailing; +Cc: barebox

On Wed, Feb 17, 2021 at 01:44:59PM +0100, barebox+mailing@cookiesoft.de wrote:
> Hey Sasha,
> 
> thanks for the answer.
> 
> > barebox doesn't support interrupts. LED blinking is done in pollers
> 
> That explains the obversation.
> 
> > add a ctrlc() call to your memtester code inside some loop.
> > That will cause the poller to run.
> 
> I'm not entirely sure, if I understand you correctly or you didn't understand me.
> 
> I use the memtest command[0] from barebox so there is nothing custom written or any loop that I can control.

Ok, somehow I thought you added some memtest code yourself. I was
mistaken.

> However, if I understand you correctly one could add the `ctrlc`
> command in all of these[1] three loops inside the
> `mem_test_moving_inversions` function. Is that correct? 

Yes, correct.

> Or is there an
> other way to not listen on ctrl+c but let the poller itself run?

You could add poller_call() directly. The idea of adding ctrlc() is just
that this way you could also make the memtest interruptible for the
user.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 7+ messages in thread

* Re: Heartbeat LED during init script
  2021-02-17 13:17     ` Sascha Hauer
@ 2021-02-18  8:00       ` Marcel Hellwig
  2021-02-18  8:34         ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Marcel Hellwig @ 2021-02-18  8:00 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hey Sasha,

I have a slight problem here:
This is what I think:

Because the memtest gets called in the init routine, the `ctrl` is completly ignored, at least I can't interrupt it nor the LED blinks.
But if I insert `poller_call`, the led blinks, but the memtest is painfully slow (like 10x slower at least).

I don't think that this will work for me, but I have to accept, that the LED doesn't blink while doing a memtest.

But an interruptable memtest would be nice at least for the user, so my patch I sent yesterday still remains ;)

Greetings,
Marcel

> Sascha Hauer <sha@pengutronix.de> hat am 17.02.2021 14:17 geschrieben:
> 
>  
> On Wed, Feb 17, 2021 at 01:44:59PM +0100, barebox+mailing@cookiesoft.de wrote:
> > Hey Sasha,
> > 
> > thanks for the answer.
> > 
> > > barebox doesn't support interrupts. LED blinking is done in pollers
> > 
> > That explains the obversation.
> > 
> > > add a ctrlc() call to your memtester code inside some loop.
> > > That will cause the poller to run.
> > 
> > I'm not entirely sure, if I understand you correctly or you didn't understand me.
> > 
> > I use the memtest command[0] from barebox so there is nothing custom written or any loop that I can control.
> 
> Ok, somehow I thought you added some memtest code yourself. I was
> mistaken.
> 
> > However, if I understand you correctly one could add the `ctrlc`
> > command in all of these[1] three loops inside the
> > `mem_test_moving_inversions` function. Is that correct? 
> 
> Yes, correct.
> 
> > Or is there an
> > other way to not listen on ctrl+c but let the poller itself run?
> 
> You could add poller_call() directly. The idea of adding ctrlc() is just
> that this way you could also make the memtest interruptible for the
> user.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 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] 7+ messages in thread

* Re: Heartbeat LED during init script
  2021-02-18  8:00       ` Marcel Hellwig
@ 2021-02-18  8:34         ` Sascha Hauer
  2021-02-18  9:01           ` Ahmad Fatoum
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2021-02-18  8:34 UTC (permalink / raw)
  To: Marcel Hellwig; +Cc: barebox

On Thu, Feb 18, 2021 at 09:00:42AM +0100, Marcel Hellwig wrote:
> Hey Sasha,
> 
> I have a slight problem here:
> This is what I think:
> 
> Because the memtest gets called in the init routine, the `ctrl` is
> completly ignored, at least I can't interrupt it nor the LED blinks.

Yes, ctrlc() is allowed only after startup. We could move calling
poller_call() up, before we test if ctrlc is allowed.

> But if I insert `poller_call`, the led blinks, but the memtest is
> painfully slow (like 10x slower at least).

poller_call() takes some time. A solution might be to call poller_call()
just every thousand times or so in memtest loop.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 7+ messages in thread

* Re: Heartbeat LED during init script
  2021-02-18  8:34         ` Sascha Hauer
@ 2021-02-18  9:01           ` Ahmad Fatoum
  0 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2021-02-18  9:01 UTC (permalink / raw)
  To: Sascha Hauer, Marcel Hellwig; +Cc: barebox

Helo,

On 18.02.21 09:34, Sascha Hauer wrote:
> On Thu, Feb 18, 2021 at 09:00:42AM +0100, Marcel Hellwig wrote:
>> Hey Sasha,
>>
>> I have a slight problem here:
>> This is what I think:
>>
>> Because the memtest gets called in the init routine, the `ctrl` is
>> completly ignored, at least I can't interrupt it nor the LED blinks.
> 
> Yes, ctrlc() is allowed only after startup. We could move calling
> poller_call() up, before we test if ctrlc is allowed.

I believe that's the correct thing to do.
See my "[PATCH 2/3] console: unconditionally run poller_call in ctrlc()"
from a few days ago. You can cherry pick that now if you like.

> 
>> But if I insert `poller_call`, the led blinks, but the memtest is
>> painfully slow (like 10x slower at least).
> 
> poller_call() takes some time. A solution might be to call poller_call()
> just every thousand times or so in memtest loop.
> 
> Sascha
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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] 7+ messages in thread

end of thread, other threads:[~2021-02-18  9:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 12:22 Heartbeat LED during init script barebox+mailing
2021-02-17 12:35 ` Sascha Hauer
2021-02-17 12:44   ` barebox+mailing
2021-02-17 13:17     ` Sascha Hauer
2021-02-18  8:00       ` Marcel Hellwig
2021-02-18  8:34         ` Sascha Hauer
2021-02-18  9:01           ` Ahmad Fatoum

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