Configure default wifi through kconfig
cover Configure default wifi through kconfig
This series was born while adding support for a board and feeling the necessity to have the networking options available in .config. I understand that something like that could be done by adding an overlay, but it requires a lot of boilerplate only to be able to connect to a wifi network.
Angelo Compagnucci (4):
system: adding options for configuring wifi package/wpa_supplicant: configure wifi when enabled package/ifupdown-scripts: add wifi configuration when enabled package/busybox: add service to load kernel modules at boot
package/busybox/S02modules | 56 ++++++++++++++++++++ package/busybox/busybox.mk | 2 + package/ifupdown-scripts/ifupdown-scripts.mk | 2 + package/wpa_supplicant/wpa_supplicant.mk | 14 +++++ system/Config.in | 15 ++++++ 5 files changed, 89 insertions(+) create mode 100644 package/busybox/S02modules
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 1/4 system: adding options for configuring wifi
These options can be used by packages to configure a wifi card to connect at boot.
--- system/Config.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
system/Config.in +15 -0
@@ -418,6 +418,21 @@ comment "automatic network configuration via DHCP needs ifupdown or busybox or n depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN || \ BR2_PACKAGE_SYSTEMD_NETWORKD || BR2_PACKAGE_NETIFRC) +config BR2_SYSTEM_CONNECT_WIFI + bool "Connect to a default wifi access point" + default n + depends on BR2_PACKAGE_WPA_SUPPLICANT + +config BR2_SYSTEM_CONNECT_WIFI_SSID + string "Access point SSID" + default "" + depends on BR2_SYSTEM_CONNECT_WIFI + +config BR2_SYSTEM_CONNECT_WIFI_PASSWORD + string "Access point password" + default "" + depends on BR2_SYSTEM_CONNECT_WIFI + endif # BR2_ROOTFS_SKELETON_DEFAULT config BR2_SYSTEM_DEFAULT_PATH
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/4 package/wpa_supplicant: configure wifi when enabled
In reply to Angelo CompagnucciConfigure a default basic wifi setup able to automatically connect to the selected access point.
--- package/wpa_supplicant/wpa_supplicant.mk | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
package/wpa_supplicant/wpa_supplicant.mk +14 -0
@@ -264,6 +264,19 @@ define WPA_SUPPLICANT_INSTALL_IFUP_SCRIPTS endef endif +ifeq ($(BR2_SYSTEM_CONNECT_WIFI),y) +define WPA_SUPPLICANT_ENABLE_WIFI + $(SED) '/network={/,/}/d' $(TARGET_DIR)/etc/wpa_supplicant.conf; \ + ( echo "network={"; \ + echo " scan_ssid=1"; \ + echo " key_mgmt=WPA-PSK"; \ + echo " ssid=\"$(BR2_SYSTEM_CONNECT_WIFI_SSID)\""; \ + echo " psk=\"$(BR2_SYSTEM_CONNECT_WIFI_PASSWORD)\""; \ + echo "}"; \ + ) >> $(TARGET_DIR)/etc/wpa_supplicant.conf +endef +endif + define WPA_SUPPLICANT_INSTALL_TARGET_CMDS $(INSTALL) -m 0755 -D $(@D)/$(WPA_SUPPLICANT_SUBDIR)/wpa_supplicant \ $(TARGET_DIR)/usr/sbin/wpa_supplicant
@@ -275,6 +288,7 @@ define WPA_SUPPLICANT_INSTALL_TARGET_CMDS $(WPA_SUPPLICANT_INSTALL_WPA_CLIENT_SO) $(WPA_SUPPLICANT_INSTALL_IFUP_SCRIPTS) $(WPA_SUPPLICANT_ENABLE_CTRL_IFACE) + $(WPA_SUPPLICANT_ENABLE_WIFI) endef define WPA_SUPPLICANT_INSTALL_INIT_SYSTEMD
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/4 package/ifupdown-scripts: add wifi configuration when enabled
In reply to Angelo CompagnucciAdd a proper wpa-conf line to the interfaces files to let the system bringup the wifi interface and the related wpa supplicant.
--- package/ifupdown-scripts/ifupdown-scripts.mk | 2 ++ 1 file changed, 2 insertions(+)
package/ifupdown-scripts/ifupdown-scripts.mk +2 -0
@@ -28,6 +28,8 @@ define IFUPDOWN_SCRIPTS_DHCP echo " pre-up /etc/network/nfs_check"; \ echo " wait-delay 15"; \ echo " hostname \$$(hostname)"; \ + test -n "$(BR2_SYSTEM_CONNECT_WIFI)" && \ + echo " wpa-conf /etc/wpa_supplicant.conf"; \ ) >> $(TARGET_DIR)/etc/network/interfaces endef define IFUPDOWN_SCRIPTS_DHCP_OPENRC
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 4/4 package/busybox: add service to load kernel modules at boot
In reply to Angelo CompagnucciIn cases where no hotplug is available (by choice or by the lack of a proper hotplug method for a device), this service can be used to load kernel module drivers by reading the /etc/modules file.
--- package/busybox/S02modules | 56 ++++++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 2 ++ 2 files changed, 58 insertions(+) create mode 100644 package/busybox/S02modules
package/busybox/S02modules new file +56 -0
@@ -0,0 +1,56 @@ +#!/bin/sh + +MODULES="modules" + +load_unload() { + [ ! -f /etc/${MODULES} ] && echo ' OK' && exit 0 + + while read module args; do + + case "$module" in + ""|"#"*) continue ;; + esac + + if [ "$1" = "load" ]; then + modprobe -q ${module} ${args} >/dev/null && \ + printf ' %s success,' "$module" || + printf ' %s failed,' "$module" + else + rmmod ${module} >/dev/null + fi + + done < /etc/${MODULES} +} + +start() { + printf 'Starting %s:' "$MODULES" + + load_unload load + + echo ' OK' +} + +stop() { + printf 'Stopping %s: ' "$MODULES" + + load_unload unload + + echo 'OK' +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac
package/busybox/busybox.mk +2 -0
@@ -382,6 +382,8 @@ define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_INSTALL_UDHCPC_SCRIPT) $(BUSYBOX_INSTALL_ZCIP_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) + $(INSTALL) -m 0755 -D package/busybox/S02modules \ + $(TARGET_DIR)/etc/init.d/S02modules; endef # Install the sysvinit scripts, for the moment, but not those that already
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
Quoted 3 lines · Angelo Compagnucci
In cases where no hotplug is available (by choice or by the lack of a proper hotplug method for a device), this service can be used to load kernel module drivers by reading the
/etc/modulesfile.
Do you have a concrete example of something that needs this? It's kind of a
hack for e.g. a device connected to a serial port that isn't described in DT (e.g. on an x86 platform), right?
I'm not altogether sure if it is worth making an init script for that.
Also, this would belong to the initscripts package because it would also be
needed if busybox isn't used at all (it would of course require kmod).
Quoted 75 lines
Signed-off-by Angelo Compagnucci <[email protected]>--- package/busybox/S02modules | 56 ++++++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 2 ++ 2 files changed, 58 insertions(+)create mode 100644 package/busybox/S02modules
package/busybox/S02modules new file +56
-0@@ -0,0 +1,56 @@ +#!/bin/sh + +MODULES="modules" + +load_unload() { + [ ! -f /etc/${MODULES} ] && echo ' OK' && exit 0 + + while read module args; do + + case "$module" in + ""|"#"*) continue ;; + esac + + if [ "$1" = "load" ]; then + modprobe -q ${module} ${args} >/dev/null && \ + printf ' %s success,' "$module" || + printf ' %s failed,' "$module" + else + rmmod ${module} >/dev/null + fi + + done < /etc/${MODULES} +} + +start() { + printf 'Starting %s:' "$MODULES" + + load_unload load + + echo ' OK' +} + +stop() { + printf 'Stopping %s: ' "$MODULES" + + load_unload unload + + echo 'OK' +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esacpackage/busybox/busybox.mk +0
-0
package/busybox/busybox.mk define BUSYBOX_INSTALL_TARGET_CMDS · line 386
Quoted 5 lines
package/busybox/busybox.mk +2
-0@@ -382,6 +382,8 @@ define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_INSTALL_UDHCPC_SCRIPT) $(BUSYBOX_INSTALL_ZCIP_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) + $(INSTALL) -m 0755 -D package/busybox/S02modules \ + $(TARGET_DIR)/etc/init.d/S02modules;
This is a sysvinit script, so it should be installed in BUSYBOX_INSTALL_INIT_SYSV.
Regards,
Arnout
package/busybox/busybox.mk define BUSYBOX_INSTALL_TARGET_CMDS · line 389
Quoted 3 lines
package/busybox/busybox.mk +0
-0endef # Install the sysvinit scripts, for the moment, but not those that already
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
Quoted 7 lines · Arnout Vandecappelle
Quoted 3 lines · Angelo Compagnucci
In cases where no hotplug is available (by choice or by the lack of a proper hotplug method for a device), this service can be used to load kernel module drivers by reading the
/etc/modulesfile.
Quoted 6 lines
Do you have a concrete example of something that needs this? It's kind
of a
hack for e.g. a device connected to a serial port that isn't described in DT
(e.g. on an x86 platform), right?
Wifi card connected on SDIO with an out of tree kernel module.
Quoted 2 lines
I'm not altogether sure if it is worth making an init script for that.
Most distros out there have the /etc/modules loaded at boot time.
Quoted 4 lines
Also, this would belong to the initscripts package because it would also
be
needed if busybox isn't used at all (it would of course require kmod).
Right, I'll fix it
Quoted 96 lines
Quoted 77 lines
Signed-off-by Angelo Compagnucci <[email protected]>--- package/busybox/S02modules | 56 ++++++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 2 ++ 2 files changed, 58 insertions(+)create mode 100644 package/busybox/S02modules
package/busybox/S02modules new file +56
-0@@ -0,0 +1,56 @@ +#!/bin/sh + +MODULES="modules" + +load_unload() { + [ ! -f /etc/${MODULES} ] && echo ' OK' && exit 0 + + while read module args; do + + case "$module" in + ""|"#"*) continue ;; + esac + + if [ "$1" = "load" ]; then + modprobe -q ${module} ${args} >/dev/null && \ + printf ' %s success,' "$module" || + printf ' %s failed,' "$module" + else + rmmod ${module} >/dev/null + fi + + done < /etc/${MODULES} +} + +start() { + printf 'Starting %s:' "$MODULES" + + load_unload load + + echo ' OK' +} + +stop() { + printf 'Stopping %s: ' "$MODULES" + + load_unload unload + + echo 'OK' +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esacpackage/busybox/busybox.mk +0
-0package/busybox/busybox.mk define BUSYBOX_INSTALL_TARGET_CMDS · line 386
Quoted 5 lines
package/busybox/busybox.mk +2
-0@@ -382,6 +382,8 @@ define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_INSTALL_UDHCPC_SCRIPT) $(BUSYBOX_INSTALL_ZCIP_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) + $(INSTALL) -m 0755 -D package/busybox/S02modules \ + $(TARGET_DIR)/etc/init.d/S02modules;This is a sysvinit script, so it should be installed in
BUSYBOX_INSTALL_INIT_SYSV.Regards,
Arnoutpackage/busybox/busybox.mk define BUSYBOX_INSTALL_TARGET_CMDS · line 389
Quoted 3 lines
package/busybox/busybox.mk +0
-0endef # Install the sysvinit scripts, for the moment, but not those thatalready
Signature · 15 lines
Angelo Compagnucci Software Engineer [email protected] __________________________________ Amarula Solutions SRL Via le Canevare 30, 31100 Treviso, Veneto, IT T. +39 (0)42 243 5310 [email protected] www.amarulasolutions.com [`as] https://www.amarulasolutions.com|
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot