All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Recommended way to auto-reconnect wifi?
@ 2021-09-22  0:16 Jeremy Fleischman
  2021-09-22  8:19 ` Nicolas Cavallari
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Fleischman @ 2021-09-22  0:16 UTC (permalink / raw)
  To: buildroot


[-- Attachment #1.1: Type: text/plain, Size: 1684 bytes --]

I've been happily using buildroot for a growing number of Raspberry PIs at
home. However, I've noticed that whenever our wifi cuts out, they do not
reconnect when it comes back.

I've got them configured using BusyBox init + mdev + ifupdown +
wpa_supplicant. I've skimmed through /etc/inittab, and I think I understand
how everything is wired together:

  - /etc/init.d/S10mdev: mdev starts up, and asynchronously starts
discovering devices.
  - /etc/init.d/S40network: This runs /sbin/ifup -a. I think this runs
while mdev is still discovering devices, which is fine, because there's a
wait-delay configured in /etc/network/interfaces:

# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp
    hostname thermometer
    pre-up wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
    post-down killall -q wpa_supplicant
    *wait-delay 15*

iface default inet dhcp

As far as I can tell, this all only ever happens at startup, and there
isn't any mechanism that would attempt to reconnect to a wifi network after
a disconnect. I've done some googling, and here's what I've learned:

  - I'm pretty sure that wpa_supplicant is not supposed to handle this.
  - It looks like some people write scripts to handle this for themselves.
See this SO answer <https://raspberrypi.stackexchange.com/a/5121> and
this dweeber/WiFi_Check
repo <https://github.com/dweeber/WiFi_Check>.

Am I correct that this is something I should fix by adding some sort of
background/cron process to do something like the WiFi_Check script above?
Or is this something buildroot does have baked in support for, and I just
haven't found it yet?

Thanks,
Jeremy

[-- Attachment #1.2: Type: text/html, Size: 2095 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
buildroot mailing list
buildroot@lists.buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] Recommended way to auto-reconnect wifi?
  2021-09-22  0:16 [Buildroot] Recommended way to auto-reconnect wifi? Jeremy Fleischman
@ 2021-09-22  8:19 ` Nicolas Cavallari
  2021-09-22 17:40   ` Peter Seiderer
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Cavallari @ 2021-09-22  8:19 UTC (permalink / raw)
  To: Jeremy Fleischman, buildroot

On 22/09/2021 02:16, Jeremy Fleischman wrote:
> I've been happily using buildroot for a growing number of Raspberry PIs at
> home. However, I've noticed that whenever our wifi cuts out, they do not
> reconnect when it comes back.
> 
> I've got them configured using BusyBox init + mdev + ifupdown +
> wpa_supplicant. I've skimmed through /etc/inittab, and I think I understand
> how everything is wired together:
> 
>    - /etc/init.d/S10mdev: mdev starts up, and asynchronously starts
> discovering devices.
>    - /etc/init.d/S40network: This runs /sbin/ifup -a. I think this runs
> while mdev is still discovering devices, which is fine, because there's a
> wait-delay configured in /etc/network/interfaces:
> 
> # cat /etc/network/interfaces
> auto lo
> iface lo inet loopback
> 
> auto wlan0
> iface wlan0 inet dhcp
>      hostname thermometer
>      pre-up wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
>      post-down killall -q wpa_supplicant
>      *wait-delay 15*
> 
> iface default inet dhcp
> 
> As far as I can tell, this all only ever happens at startup, and there
> isn't any mechanism that would attempt to reconnect to a wifi network after
> a disconnect. I've done some googling, and here's what I've learned:
> 
>    - I'm pretty sure that wpa_supplicant is not supposed to handle this.
>    - It looks like some people write scripts to handle this for themselves.
> See this SO answer <https://raspberrypi.stackexchange.com/a/5121> and
> this dweeber/WiFi_Check
> repo <https://github.com/dweeber/WiFi_Check>.
> 
> Am I correct that this is something I should fix by adding some sort of
> background/cron process to do something like the WiFi_Check script above?
> Or is this something buildroot does have baked in support for, and I just
> haven't found it yet?

Buildroot has nothing out of the box for this, short of 
NetworkManager/connman or the likes.

In your case, wpasupplicant should reconnect automatically if it is 
disconnected, but the busybox DHCP client, udhcpc  won't retry 
indefinitely by default. If you use a custom busybox configuration, you 
can modify CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS to make udhcpc go into 
background and retry indefinitely.

Also, note that you can copy the Debian ifupdown scripts into your image 
and then use the Debian's wpa-* options in /etc/network/interface. You 
will have to tweak them a bit because buildroot install wpasupplicant in 
/usr/sbin instead of /sbin.
_______________________________________________
buildroot mailing list
buildroot@lists.buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] Recommended way to auto-reconnect wifi?
  2021-09-22  8:19 ` Nicolas Cavallari
@ 2021-09-22 17:40   ` Peter Seiderer
  2021-09-27  9:49     ` Jeremy Fleischman
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Seiderer @ 2021-09-22 17:40 UTC (permalink / raw)
  To: Nicolas Cavallari; +Cc: buildroot, Jeremy Fleischman

Hello Jeremy, Nicolas,

On Wed, 22 Sep 2021 10:19:27 +0200, Nicolas Cavallari <nicolas.cavallari@green-communications.fr> wrote:

> On 22/09/2021 02:16, Jeremy Fleischman wrote:
> > I've been happily using buildroot for a growing number of Raspberry PIs at
> > home. However, I've noticed that whenever our wifi cuts out, they do not
> > reconnect when it comes back.
> >
> > I've got them configured using BusyBox init + mdev + ifupdown +
> > wpa_supplicant. I've skimmed through /etc/inittab, and I think I understand
> > how everything is wired together:
> >
> >    - /etc/init.d/S10mdev: mdev starts up, and asynchronously starts
> > discovering devices.
> >    - /etc/init.d/S40network: This runs /sbin/ifup -a. I think this runs
> > while mdev is still discovering devices, which is fine, because there's a
> > wait-delay configured in /etc/network/interfaces:
> >
> > # cat /etc/network/interfaces
> > auto lo
> > iface lo inet loopback
> >
> > auto wlan0
> > iface wlan0 inet dhcp
> >      hostname thermometer
> >      pre-up wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
> >      post-down killall -q wpa_supplicant
> >      *wait-delay 15*
> >
> > iface default inet dhcp
> >
> > As far as I can tell, this all only ever happens at startup, and there
> > isn't any mechanism that would attempt to reconnect to a wifi network after
> > a disconnect. I've done some googling, and here's what I've learned:
> >
> >    - I'm pretty sure that wpa_supplicant is not supposed to handle this.
> >    - It looks like some people write scripts to handle this for themselves.
> > See this SO answer <https://raspberrypi.stackexchange.com/a/5121> and
> > this dweeber/WiFi_Check
> > repo <https://github.com/dweeber/WiFi_Check>.
> >
> > Am I correct that this is something I should fix by adding some sort of
> > background/cron process to do something like the WiFi_Check script above?
> > Or is this something buildroot does have baked in support for, and I just
> > haven't found it yet?
>
> Buildroot has nothing out of the box for this, short of
> NetworkManager/connman or the likes.
>
> In your case, wpasupplicant should reconnect automatically if it is
> disconnected, but the busybox DHCP client, udhcpc  won't retry
> indefinitely by default. If you use a custom busybox configuration, you
> can modify CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS to make udhcpc go into
> background and retry indefinitely.

Alternatively use the following patch [1] to change the ifupdown-scripts...,
or do a complete change away from wpasupplicant and use iwd (see [2])
providing AutoConnect and DHCP...

Regards,
Peter

[1] https://patchwork.ozlabs.org/project/buildroot/patch/20210216202022.27264-1-ps.report@gmx.net/
[2] https://iwd.wiki.kernel.org/start


>
> Also, note that you can copy the Debian ifupdown scripts into your image
> and then use the Debian's wpa-* options in /etc/network/interface. You
> will have to tweak them a bit because buildroot install wpasupplicant in
> /usr/sbin instead of /sbin.
> _______________________________________________
> buildroot mailing list
> buildroot@lists.buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
buildroot@lists.buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] Recommended way to auto-reconnect wifi?
  2021-09-22 17:40   ` Peter Seiderer
@ 2021-09-27  9:49     ` Jeremy Fleischman
  0 siblings, 0 replies; 4+ messages in thread
From: Jeremy Fleischman @ 2021-09-27  9:49 UTC (permalink / raw)
  To: Peter Seiderer; +Cc: buildroot


[-- Attachment #1.1: Type: text/plain, Size: 3603 bytes --]

Thanks! I've gone ahead with Nicolas's suggestion to create a
custom busybox configuration with CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS
tweaked to include the -b option.

On Wed, Sep 22, 2021 at 10:40 AM Peter Seiderer <ps.report@gmx.net> wrote:

> Hello Jeremy, Nicolas,
>
> On Wed, 22 Sep 2021 10:19:27 +0200, Nicolas Cavallari <
> nicolas.cavallari@green-communications.fr> wrote:
>
> > On 22/09/2021 02:16, Jeremy Fleischman wrote:
> > > I've been happily using buildroot for a growing number of Raspberry
> PIs at
> > > home. However, I've noticed that whenever our wifi cuts out, they do
> not
> > > reconnect when it comes back.
> > >
> > > I've got them configured using BusyBox init + mdev + ifupdown +
> > > wpa_supplicant. I've skimmed through /etc/inittab, and I think I
> understand
> > > how everything is wired together:
> > >
> > >    - /etc/init.d/S10mdev: mdev starts up, and asynchronously starts
> > > discovering devices.
> > >    - /etc/init.d/S40network: This runs /sbin/ifup -a. I think this runs
> > > while mdev is still discovering devices, which is fine, because
> there's a
> > > wait-delay configured in /etc/network/interfaces:
> > >
> > > # cat /etc/network/interfaces
> > > auto lo
> > > iface lo inet loopback
> > >
> > > auto wlan0
> > > iface wlan0 inet dhcp
> > >      hostname thermometer
> > >      pre-up wpa_supplicant -D nl80211 -i wlan0 -c
> /etc/wpa_supplicant.conf -B
> > >      post-down killall -q wpa_supplicant
> > >      *wait-delay 15*
> > >
> > > iface default inet dhcp
> > >
> > > As far as I can tell, this all only ever happens at startup, and there
> > > isn't any mechanism that would attempt to reconnect to a wifi network
> after
> > > a disconnect. I've done some googling, and here's what I've learned:
> > >
> > >    - I'm pretty sure that wpa_supplicant is not supposed to handle
> this.
> > >    - It looks like some people write scripts to handle this for
> themselves.
> > > See this SO answer <https://raspberrypi.stackexchange.com/a/5121> and
> > > this dweeber/WiFi_Check
> > > repo <https://github.com/dweeber/WiFi_Check>.
> > >
> > > Am I correct that this is something I should fix by adding some sort of
> > > background/cron process to do something like the WiFi_Check script
> above?
> > > Or is this something buildroot does have baked in support for, and I
> just
> > > haven't found it yet?
> >
> > Buildroot has nothing out of the box for this, short of
> > NetworkManager/connman or the likes.
> >
> > In your case, wpasupplicant should reconnect automatically if it is
> > disconnected, but the busybox DHCP client, udhcpc  won't retry
> > indefinitely by default. If you use a custom busybox configuration, you
> > can modify CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS to make udhcpc go into
> > background and retry indefinitely.
>
> Alternatively use the following patch [1] to change the
> ifupdown-scripts...,
> or do a complete change away from wpasupplicant and use iwd (see [2])
> providing AutoConnect and DHCP...
>
> Regards,
> Peter
>
> [1]
> https://patchwork.ozlabs.org/project/buildroot/patch/20210216202022.27264-1-ps.report@gmx.net/
> [2] https://iwd.wiki.kernel.org/start
>
>
> >
> > Also, note that you can copy the Debian ifupdown scripts into your image
> > and then use the Debian's wpa-* options in /etc/network/interface. You
> > will have to tweak them a bit because buildroot install wpasupplicant in
> > /usr/sbin instead of /sbin.
> > _______________________________________________
> > buildroot mailing list
> > buildroot@lists.buildroot.org
> > https://lists.buildroot.org/mailman/listinfo/buildroot
>
>

[-- Attachment #1.2: Type: text/html, Size: 5143 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2021-09-27  9:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22  0:16 [Buildroot] Recommended way to auto-reconnect wifi? Jeremy Fleischman
2021-09-22  8:19 ` Nicolas Cavallari
2021-09-22 17:40   ` Peter Seiderer
2021-09-27  9:49     ` Jeremy Fleischman

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.