All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
       [not found] <mailman.2285.1655818273.17960.buildroot@buildroot.org>
@ 2022-06-25  5:02 ` Andreas Ziegler
  2022-06-28  7:56   ` Angelo Compagnucci
  2022-06-25  5:32 ` [Buildroot] [PATCH 1/4] system: adding options for configuring wifi Andreas Ziegler
  1 sibling, 1 reply; 11+ messages in thread
From: Andreas Ziegler @ 2022-06-25  5:02 UTC (permalink / raw)
  To: Angelo Compagnucci; +Cc: Buildroot

Hi Angelo,

On 2022-06-21 13:31, Angelo Compagnucci <angelo@amarulasolutions.com> 
wrote:

>> 
>> 
>> On 20/06/2022 23:40, Angelo Compagnucci wrote:
>> > 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/modules file.
>> 
>>   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.
> 
> 
>>   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.
> 
> 
>>   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
> 
> 
>> 
>> 
>> >
>> > Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
>> > ---
>> >   package/busybox/S02modules | 56 ++++++++++++++++++++++++++++++++++++++
>> >   package/busybox/busybox.mk |  2 ++
>> >   2 files changed, 58 insertions(+)
>> >   create mode 100644 package/busybox/S02modules
>> >
>> > diff --git a/package/busybox/S02modules b/package/busybox/S02modules

S02 is a bit early, [mu]dev use S10.

>> > new file mode 100644
>> > index 0000000000..f25712e1ca
>> > --- /dev/null
>> > +++ b/package/busybox/S02modules
>> > @@ -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
>> > diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
>> > index 3e49de0a84..40490e866a 100644
>> > --- a/package/busybox/busybox.mk
>> > +++ b/package/busybox/busybox.mk
>> > @@ -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;

Since this is intended for systems without dynamic device handling, you 
might use an optional script, similar to BUSYBOX_INSTALL_*_SCRIPT:

# Copy S22modules to /etc/init.d if no dynamic device handling is used
ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
define BUSYBOX_INSTALL_MODULES_SCRIPT
	$(INSTALL) -m 0755 -D package/busybox/S22modules \
		$(TARGET_DIR)/etc/init.d/S22modules;
endef # BUSYBOX_INSTALL_MODULES_SCRIPT

Probably a default /etc/modules could also be installed.

Kind regards,
Andreas

>> 
>>   This is a sysvinit script, so it should be installed in
>> BUSYBOX_INSTALL_INIT_SYSV.
>> 
>> 
>> 
>>   Regards,
>>   Arnout
>> 
>> >   endef
>> >
>> >   # Install the sysvinit scripts, for the moment, but not those that
>> already
>> 
> 
> 
> --
> 
> Angelo Compagnucci
> 
> Software Engineer
> 
> angelo@amarulasolutions.com
> __________________________________
> Amarula Solutions SRL
> 
> Via le Canevare 30, 31100 Treviso, Veneto, IT
> 
> T. +39 (0)42 243 5310
> info@amarulasolutions.com
> 
> www.amarulasolutions.com
> [`as] https://www.amarulasolutions.com|
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/4] system: adding options for configuring wifi
       [not found] <mailman.2285.1655818273.17960.buildroot@buildroot.org>
  2022-06-25  5:02 ` [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot Andreas Ziegler
@ 2022-06-25  5:32 ` Andreas Ziegler
  2022-06-28  7:49   ` Angelo Compagnucci
  1 sibling, 1 reply; 11+ messages in thread
From: Andreas Ziegler @ 2022-06-25  5:32 UTC (permalink / raw)
  To: Angelo Compagnucci; +Cc: Buildroot

Hi Angelo,

On 2022-06-21 13:31, Angelo Compagnucci <angelo@amarulasolutions.com> 
wrote:
> 
> These options can be used by packages to configure a wifi card
> to connect at boot.
> 
> Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> ---
>  system/Config.in | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/system/Config.in b/system/Config.in
> index 888c24ce81..9a5bdb2932 100644
> --- a/system/Config.in
> +++ b/system/Config.in
> @@ -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
> +

Just nagging, but this is how security breaches get born. If I want to 
do something like this, I use a private overlay outside the region under 
backup or version control ...

Kind regards,
Andreas

>  endif # BR2_ROOTFS_SKELETON_DEFAULT
> 
>  config BR2_SYSTEM_DEFAULT_PATH
> --
> 2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/4] system: adding options for configuring wifi
  2022-06-25  5:32 ` [Buildroot] [PATCH 1/4] system: adding options for configuring wifi Andreas Ziegler
@ 2022-06-28  7:49   ` Angelo Compagnucci
  0 siblings, 0 replies; 11+ messages in thread
From: Angelo Compagnucci @ 2022-06-28  7:49 UTC (permalink / raw)
  To: Andreas Ziegler; +Cc: Buildroot


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

On Sat, Jun 25, 2022 at 7:32 AM Andreas Ziegler <br015@umbiko.net> wrote:

> Hi Angelo,
>
> On 2022-06-21 13:31, Angelo Compagnucci <angelo@amarulasolutions.com>
> wrote:
> >
> > These options can be used by packages to configure a wifi card
> > to connect at boot.
> >
> > Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> > ---
> >  system/Config.in | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> >
> > diff --git a/system/Config.in b/system/Config.in
> > index 888c24ce81..9a5bdb2932 100644
> > --- a/system/Config.in
> > +++ b/system/Config.in
> > @@ -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
> > +
>
> Just nagging, but this is how security breaches get born. If I want to
> do something like this, I use a private overlay outside the region under
> backup or version control ...
>

I wouldn't be so worried about security since a user can have
BR2_TARGET_GENERIC_ROOT_PASSWD in his .config

Anyway, you end up having the wifi password stored somewhere in the overlay
anyway, so I can't see a problem here.

Or you can use an empty password to store in the .config on the version
control, and have a simple sed to replace with the correct credentials just
before the developer makes a build. In any case, having those options makes
way easier to configure a wifi than guessing the correct overlay to setup.


> Kind regards,
> Andreas
>
> >  endif # BR2_ROOTFS_SKELETON_DEFAULT
> >
> >  config BR2_SYSTEM_DEFAULT_PATH
> > --
> > 2.25.1
>


-- 

Angelo Compagnucci

Software Engineer

angelo@amarulasolutions.com
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
info@amarulasolutions.com

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

[-- Attachment #1.2: Type: text/html, Size: 7235 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] 11+ messages in thread

* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-25  5:02 ` [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot Andreas Ziegler
@ 2022-06-28  7:56   ` Angelo Compagnucci
  2022-06-28  8:17     ` Nicolas Cavallari
  2022-06-28  9:03     ` Andreas Ziegler
  0 siblings, 2 replies; 11+ messages in thread
From: Angelo Compagnucci @ 2022-06-28  7:56 UTC (permalink / raw)
  To: Andreas Ziegler; +Cc: Buildroot


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

On Sat, Jun 25, 2022 at 7:02 AM Andreas Ziegler <br015@umbiko.net> wrote:

> Hi Angelo,
>
> On 2022-06-21 13:31, Angelo Compagnucci <angelo@amarulasolutions.com>
> wrote:
>
> >>
> >>
> >> On 20/06/2022 23:40, Angelo Compagnucci wrote:
> >> > 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/modules file.
> >>
> >>   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.
> >
> >
> >>   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.
> >
> >
> >>   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
> >
> >
> >>
> >>
> >> >
> >> > Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> >> > ---
> >> >   package/busybox/S02modules | 56
> ++++++++++++++++++++++++++++++++++++++
> >> >   package/busybox/busybox.mk |  2 ++
> >> >   2 files changed, 58 insertions(+)
> >> >   create mode 100644 package/busybox/S02modules
> >> >
> >> > diff --git a/package/busybox/S02modules b/package/busybox/S02modules
>
> S02 is a bit early, [mu]dev use S10.
>

Can you point me to these  [mu]dev scripts?


> >> > new file mode 100644
> >> > index 0000000000..f25712e1ca
> >> > --- /dev/null
> >> > +++ b/package/busybox/S02modules
> >> > @@ -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
> >> > diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> >> > index 3e49de0a84..40490e866a 100644
> >> > --- a/package/busybox/busybox.mk
> >> > +++ b/package/busybox/busybox.mk
> >> > @@ -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;
>
> Since this is intended for systems without dynamic device handling, you
> might use an optional script, similar to BUSYBOX_INSTALL_*_SCRIPT:
>
> # Copy S22modules to /etc/init.d if no dynamic device handling is used
> ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
> define BUSYBOX_INSTALL_MODULES_SCRIPT
>         $(INSTALL) -m 0755 -D package/busybox/S22modules \
>                 $(TARGET_DIR)/etc/init.d/S22modules;
> endef # BUSYBOX_INSTALL_MODULES_SCRIPT
>
> Probably a default /etc/modules could also be installed.
>

Yes, but it is not the only usecase here. A usecase could be a userspace
software that needs a special kernel module to be loaded on boot or a
hardware which cannot be hotplugged.
My usecase was for a wifi card connected via sdio running only with an out
of tree kernel module. The wifi card is soldered and doesn't have a CS to
trigger an hotplug event and the only sensible way I found to load the
module at boot was to have a proper way to load modules at boot.
I'm not aware normal distros does so much tinkering about loading a kernel
module at boot: /etc/modules or the newly /etc/modules-load.d/ for systemd
are widely adopted and are usually working out of the box.


>
> Kind regards,
> Andreas
>
> >>
> >>   This is a sysvinit script, so it should be installed in
> >> BUSYBOX_INSTALL_INIT_SYSV.
> >>
> >>
> >>
> >>   Regards,
> >>   Arnout
> >>
> >> >   endef
> >> >
> >> >   # Install the sysvinit scripts, for the moment, but not those that
> >> already
> >>
> >
> >
> > --
> >
> > Angelo Compagnucci
> >
> > Software Engineer
> >
> > angelo@amarulasolutions.com
> > __________________________________
> > Amarula Solutions SRL
> >
> > Via le Canevare 30, 31100 Treviso, Veneto, IT
> >
> > T. +39 (0)42 243 5310
> > info@amarulasolutions.com
> >
> > www.amarulasolutions.com
> > [`as] https://www.amarulasolutions.com|
>


-- 

Angelo Compagnucci

Software Engineer

angelo@amarulasolutions.com
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
info@amarulasolutions.com

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

[-- Attachment #1.2: Type: text/html, Size: 13261 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] 11+ messages in thread

* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-28  7:56   ` Angelo Compagnucci
@ 2022-06-28  8:17     ` Nicolas Cavallari
  2022-06-28  8:41       ` Angelo Compagnucci
  2022-06-28  9:03     ` Andreas Ziegler
  1 sibling, 1 reply; 11+ messages in thread
From: Nicolas Cavallari @ 2022-06-28  8:17 UTC (permalink / raw)
  To: Angelo Compagnucci, Andreas Ziegler; +Cc: Buildroot

On 28/06/2022 09:56, Angelo Compagnucci wrote:
>      >> > diff --git a/package/busybox/S02modules
>     b/package/busybox/S02modules
> 
>     S02 is a bit early, [mu]dev use S10.
> 
> 
> Can you point me to these  [mu]dev scripts?

package/eudev/S10udev and package/busybox/S10mdev
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-28  8:17     ` Nicolas Cavallari
@ 2022-06-28  8:41       ` Angelo Compagnucci
  0 siblings, 0 replies; 11+ messages in thread
From: Angelo Compagnucci @ 2022-06-28  8:41 UTC (permalink / raw)
  To: Nicolas Cavallari; +Cc: Andreas Ziegler, Buildroot, Angelo Compagnucci

Il giorno mar 28 giu 2022 alle ore 10:23 Nicolas Cavallari
<nicolas.cavallari@green-communications.fr> ha scritto:
>
> On 28/06/2022 09:56, Angelo Compagnucci wrote:
> >      >> > diff --git a/package/busybox/S02modules
> >     b/package/busybox/S02modules
> >
> >     S02 is a bit early, [mu]dev use S10.
> >
> >
> > Can you point me to these  [mu]dev scripts?
>
> package/eudev/S10udev and package/busybox/S10mdev

Thanks! So basically the idea is to move this service after the
[mu]dev ones, S11modules should be ok, will do.

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



-- 
Profile: http://it.linkedin.com/in/compagnucciangelo
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-28  7:56   ` Angelo Compagnucci
  2022-06-28  8:17     ` Nicolas Cavallari
@ 2022-06-28  9:03     ` Andreas Ziegler
  2022-06-28  9:11       ` Angelo Compagnucci
  1 sibling, 1 reply; 11+ messages in thread
From: Andreas Ziegler @ 2022-06-28  9:03 UTC (permalink / raw)
  To: Angelo Compagnucci; +Cc: Buildroot

Hi Angelo,

On 2022-06-28 07:56, Angelo Compagnucci wrote:
> On Sat, Jun 25, 2022 at 7:02 AM Andreas Ziegler <br015@umbiko.net>
> wrote:
> 
>> Hi Angelo,
>> 
>> On 2022-06-21 13:31, Angelo Compagnucci
>> <angelo@amarulasolutions.com>
>> wrote:
>> 
>>>> 
>>>> 
>>>> On 20/06/2022 23:40, Angelo Compagnucci wrote:
>>>>> 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/modules file.
>>>> 
>>>> 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.
>>> 
>>> 
>>>> 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.
>>> 
>>> 
>>>> 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
>>> 
>>> 
>>>> 
>>>> 
>>>>> 
>>>>> Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
>>>>> ---
>>>>>   package/busybox/S02modules | 56
>> ++++++++++++++++++++++++++++++++++++++
>>>>>   package/busybox/busybox.mk [1] |  2 ++
>>>>>   2 files changed, 58 insertions(+)
>>>>>   create mode 100644 package/busybox/S02modules
>>>>> 
>>>>> diff --git a/package/busybox/S02modules
>> b/package/busybox/S02modules
>> 
>> S02 is a bit early, [mu]dev use S10.
> 
> Can you point me to these  [mu]dev scripts?
> 
>>>>> new file mode 100644
>>>>> index 0000000000..f25712e1ca
>>>>> --- /dev/null
>>>>> +++ b/package/busybox/S02modules
>>>>> @@ -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
>>>>> diff --git a/package/busybox/busybox.mk [1]
>> b/package/busybox/busybox.mk [1]
>>>>> index 3e49de0a84..40490e866a 100644
>>>>> --- a/package/busybox/busybox.mk [1]
>>>>> +++ b/package/busybox/busybox.mk [1]
>>>>> @@ -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;
>> 
>> Since this is intended for systems without dynamic device handling,
>> you
>> might use an optional script, similar to BUSYBOX_INSTALL_*_SCRIPT:
>> 
>> # Copy S22modules to /etc/init.d if no dynamic device handling is
>> used
>> ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
>> define BUSYBOX_INSTALL_MODULES_SCRIPT
>> $(INSTALL) -m 0755 -D package/busybox/S22modules \
>> $(TARGET_DIR)/etc/init.d/S22modules;
>> endef # BUSYBOX_INSTALL_MODULES_SCRIPT
>> 
>> Probably a default /etc/modules could also be installed.
> 
> Yes, but it is not the only usecase here. A usecase could be a
> userspace software that needs a special kernel module to be loaded on
> boot or a hardware which cannot be hotplugged.

Then a Config.in item to select this feature would be appreciated, since 
most configurations will not need it.

> My usecase was for a wifi card connected via sdio running only with an
> out of tree kernel module. The wifi card is soldered and doesn't have
> a CS to trigger an hotplug event and the only sensible way I found to
> load the module at boot was to have a proper way to load modules at
> boot.

I used something similar initially, until switching to udev.

> I'm not aware normal distros does so much tinkering about loading a
> kernel module at boot: /etc/modules or the newly /etc/modules-load.d/
> for systemd are widely adopted and are usually working out of the box.
> 

Kind regards,
Andreas

>> Kind regards,
>> Andreas
>> 
>>>> 
>>>> This is a sysvinit script, so it should be installed in
>>>> BUSYBOX_INSTALL_INIT_SYSV.
>>>> 
>>>> 
>>>> 
>>>> Regards,
>>>> Arnout
>>>> 
>>>>>   endef
>>>>> 
>>>>>   # Install the sysvinit scripts, for the moment, but not those
>> that
>>>> already
>>>> 
>>> 
>>> 
>>> --
>>> 
>>> Angelo Compagnucci
>>> 
>>> Software Engineer
>>> 
>>> angelo@amarulasolutions.com
>>> __________________________________
>>> Amarula Solutions SRL
>>> 
>>> Via le Canevare 30, 31100 Treviso, Veneto, IT
>>> 
>>> T. +39 (0)42 243 5310
>>> info@amarulasolutions.com
>>> 
>>> www.amarulasolutions.com [2]
>>> [`as] https://www.amarulasolutions.com|
> 
> --
> 
> Angelo Compagnucci
> 
> Software Engineer
> 
> angelo@amarulasolutions.com
> __________________________________
> Amarula Solutions SRL
> 
> Via le Canevare 30, 31100 Treviso, Veneto, IT
> 
> T. +39 (0)42 243 5310
> info@amarulasolutions.com
> 
> www.amarulasolutions.com [3]
> 
> [`as] https://www.amarulasolutions.com|
> 
> Links:
> ------
> [1] http://busybox.mk
> [2] http://www.amarulasolutions.com
> [3] http://www.amarulasolutions.com/
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-28  9:03     ` Andreas Ziegler
@ 2022-06-28  9:11       ` Angelo Compagnucci
  0 siblings, 0 replies; 11+ messages in thread
From: Angelo Compagnucci @ 2022-06-28  9:11 UTC (permalink / raw)
  To: Andreas Ziegler; +Cc: Buildroot


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

On Tue, Jun 28, 2022 at 11:03 AM Andreas Ziegler <br015@umbiko.net> wrote:

> Hi Angelo,
>
> On 2022-06-28 07:56, Angelo Compagnucci wrote:
> > On Sat, Jun 25, 2022 at 7:02 AM Andreas Ziegler <br015@umbiko.net>
> > wrote:
> >
> >> Hi Angelo,
> >>
> >> On 2022-06-21 13:31, Angelo Compagnucci
> >> <angelo@amarulasolutions.com>
> >> wrote:
> >>
> >>>>
> >>>>
> >>>> On 20/06/2022 23:40, Angelo Compagnucci wrote:
> >>>>> 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/modules file.
> >>>>
> >>>> 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.
> >>>
> >>>
> >>>> 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.
> >>>
> >>>
> >>>> 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
> >>>
> >>>
> >>>>
> >>>>
> >>>>>
> >>>>> Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> >>>>> ---
> >>>>>   package/busybox/S02modules | 56
> >> ++++++++++++++++++++++++++++++++++++++
> >>>>>   package/busybox/busybox.mk [1] |  2 ++
> >>>>>   2 files changed, 58 insertions(+)
> >>>>>   create mode 100644 package/busybox/S02modules
> >>>>>
> >>>>> diff --git a/package/busybox/S02modules
> >> b/package/busybox/S02modules
> >>
> >> S02 is a bit early, [mu]dev use S10.
> >
> > Can you point me to these  [mu]dev scripts?
> >
> >>>>> new file mode 100644
> >>>>> index 0000000000..f25712e1ca
> >>>>> --- /dev/null
> >>>>> +++ b/package/busybox/S02modules
> >>>>> @@ -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
> >>>>> diff --git a/package/busybox/busybox.mk [1]
> >> b/package/busybox/busybox.mk [1]
> >>>>> index 3e49de0a84..40490e866a 100644
> >>>>> --- a/package/busybox/busybox.mk [1]
> >>>>> +++ b/package/busybox/busybox.mk [1]
> >>>>> @@ -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;
> >>
> >> Since this is intended for systems without dynamic device handling,
> >> you
> >> might use an optional script, similar to BUSYBOX_INSTALL_*_SCRIPT:
> >>
> >> # Copy S22modules to /etc/init.d if no dynamic device handling is
> >> used
> >> ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
> >> define BUSYBOX_INSTALL_MODULES_SCRIPT
> >> $(INSTALL) -m 0755 -D package/busybox/S22modules \
> >> $(TARGET_DIR)/etc/init.d/S22modules;
> >> endef # BUSYBOX_INSTALL_MODULES_SCRIPT
> >>
> >> Probably a default /etc/modules could also be installed.
> >
> > Yes, but it is not the only usecase here. A usecase could be a
> > userspace software that needs a special kernel module to be loaded on
> > boot or a hardware which cannot be hotplugged.
>
> Then a Config.in item to select this feature would be appreciated, since
> most configurations will not need it.
>

Not sure if it will be happily accepted ;)
The last word is on the BR maintainers.
Anyway, in systemd we have the service always installed and available, it
prints anything to the console if no module should be loaded.
I can move the check for the modules file at the very beginning of the
script, so it's like it has never been executed.

> My usecase was for a wifi card connected via sdio running only with an
> > out of tree kernel module. The wifi card is soldered and doesn't have
> > a CS to trigger an hotplug event and the only sensible way I found to
> > load the module at boot was to have a proper way to load modules at
> > boot.
>
> I used something similar initially, until switching to udev.
>

Sure I can, but this patch is exactly to cover the cases where a developer
cannot/won't switch to something like that.


>
> > I'm not aware normal distros does so much tinkering about loading a
> > kernel module at boot: /etc/modules or the newly /etc/modules-load.d/
> > for systemd are widely adopted and are usually working out of the box.
> >
>
> Kind regards,
> Andreas
>
> >> Kind regards,
> >> Andreas
> >>
> >>>>
> >>>> This is a sysvinit script, so it should be installed in
> >>>> BUSYBOX_INSTALL_INIT_SYSV.
> >>>>
> >>>>
> >>>>
> >>>> Regards,
> >>>> Arnout
> >>>>
> >>>>>   endef
> >>>>>
> >>>>>   # Install the sysvinit scripts, for the moment, but not those
> >> that
> >>>> already
> >>>>
> >>>
> >>>
> >>> --
> >>>
> >>> Angelo Compagnucci
> >>>
> >>> Software Engineer
> >>>
> >>> angelo@amarulasolutions.com
> >>> __________________________________
> >>> Amarula Solutions SRL
> >>>
> >>> Via le Canevare 30, 31100 Treviso, Veneto, IT
> >>>
> >>> T. +39 (0)42 243 5310
> >>> info@amarulasolutions.com
> >>>
> >>> www.amarulasolutions.com [2]
> >>> [`as] https://www.amarulasolutions.com|
> >
> > --
> >
> > Angelo Compagnucci
> >
> > Software Engineer
> >
> > angelo@amarulasolutions.com
> > __________________________________
> > Amarula Solutions SRL
> >
> > Via le Canevare 30, 31100 Treviso, Veneto, IT
> >
> > T. +39 (0)42 243 5310
> > info@amarulasolutions.com
> >
> > www.amarulasolutions.com [3]
> >
> > [`as] https://www.amarulasolutions.com|
> >
> > Links:
> > ------
> > [1] http://busybox.mk
> > [2] http://www.amarulasolutions.com
> > [3] http://www.amarulasolutions.com/
>


-- 

Angelo Compagnucci

Software Engineer

angelo@amarulasolutions.com
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
info@amarulasolutions.com

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

[-- Attachment #1.2: Type: text/html, Size: 17057 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] 11+ messages in thread

* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-21  7:49   ` Arnout Vandecappelle
@ 2022-06-21  9:20     ` Angelo Compagnucci
  0 siblings, 0 replies; 11+ messages in thread
From: Angelo Compagnucci @ 2022-06-21  9:20 UTC (permalink / raw)
  To: Arnout Vandecappelle; +Cc: buildroot


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

On Tue, Jun 21, 2022 at 9:49 AM Arnout Vandecappelle <arnout@mind.be> wrote:

>
>
> On 20/06/2022 23:40, Angelo Compagnucci wrote:
> > 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/modules file.
>
>   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.


>   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.


>   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


>
>
> >
> > Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> > ---
> >   package/busybox/S02modules | 56 ++++++++++++++++++++++++++++++++++++++
> >   package/busybox/busybox.mk |  2 ++
> >   2 files changed, 58 insertions(+)
> >   create mode 100644 package/busybox/S02modules
> >
> > diff --git a/package/busybox/S02modules b/package/busybox/S02modules
> > new file mode 100644
> > index 0000000000..f25712e1ca
> > --- /dev/null
> > +++ b/package/busybox/S02modules
> > @@ -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
> > diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> > index 3e49de0a84..40490e866a 100644
> > --- a/package/busybox/busybox.mk
> > +++ b/package/busybox/busybox.mk
> > @@ -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
>
> >   endef
> >
> >   # Install the sysvinit scripts, for the moment, but not those that
> already
>


-- 

Angelo Compagnucci

Software Engineer

angelo@amarulasolutions.com
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
info@amarulasolutions.com

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

[-- Attachment #1.2: Type: text/html, Size: 9800 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] 11+ messages in thread

* Re: [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-20 21:40 ` [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot Angelo Compagnucci
@ 2022-06-21  7:49   ` Arnout Vandecappelle
  2022-06-21  9:20     ` Angelo Compagnucci
  0 siblings, 1 reply; 11+ messages in thread
From: Arnout Vandecappelle @ 2022-06-21  7:49 UTC (permalink / raw)
  To: Angelo Compagnucci, buildroot



On 20/06/2022 23:40, Angelo Compagnucci wrote:
> 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/modules file.

  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).


> 
> Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> ---
>   package/busybox/S02modules | 56 ++++++++++++++++++++++++++++++++++++++
>   package/busybox/busybox.mk |  2 ++
>   2 files changed, 58 insertions(+)
>   create mode 100644 package/busybox/S02modules
> 
> diff --git a/package/busybox/S02modules b/package/busybox/S02modules
> new file mode 100644
> index 0000000000..f25712e1ca
> --- /dev/null
> +++ b/package/busybox/S02modules
> @@ -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
> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> index 3e49de0a84..40490e866a 100644
> --- a/package/busybox/busybox.mk
> +++ b/package/busybox/busybox.mk
> @@ -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

>   endef
>   
>   # Install the sysvinit scripts, for the moment, but not those that already
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot
  2022-06-20 21:40 [Buildroot] [PATCH 0/4] Configure default wifi through kconfig Angelo Compagnucci
@ 2022-06-20 21:40 ` Angelo Compagnucci
  2022-06-21  7:49   ` Arnout Vandecappelle
  0 siblings, 1 reply; 11+ messages in thread
From: Angelo Compagnucci @ 2022-06-20 21:40 UTC (permalink / raw)
  To: buildroot; +Cc: 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/modules file.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
---
 package/busybox/S02modules | 56 ++++++++++++++++++++++++++++++++++++++
 package/busybox/busybox.mk |  2 ++
 2 files changed, 58 insertions(+)
 create mode 100644 package/busybox/S02modules

diff --git a/package/busybox/S02modules b/package/busybox/S02modules
new file mode 100644
index 0000000000..f25712e1ca
--- /dev/null
+++ b/package/busybox/S02modules
@@ -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
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index 3e49de0a84..40490e866a 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -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
-- 
2.25.1

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

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

end of thread, other threads:[~2022-06-28  9:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.2285.1655818273.17960.buildroot@buildroot.org>
2022-06-25  5:02 ` [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot Andreas Ziegler
2022-06-28  7:56   ` Angelo Compagnucci
2022-06-28  8:17     ` Nicolas Cavallari
2022-06-28  8:41       ` Angelo Compagnucci
2022-06-28  9:03     ` Andreas Ziegler
2022-06-28  9:11       ` Angelo Compagnucci
2022-06-25  5:32 ` [Buildroot] [PATCH 1/4] system: adding options for configuring wifi Andreas Ziegler
2022-06-28  7:49   ` Angelo Compagnucci
2022-06-20 21:40 [Buildroot] [PATCH 0/4] Configure default wifi through kconfig Angelo Compagnucci
2022-06-20 21:40 ` [Buildroot] [PATCH 4/4] package/busybox: add service to load kernel modules at boot Angelo Compagnucci
2022-06-21  7:49   ` Arnout Vandecappelle
2022-06-21  9:20     ` Angelo Compagnucci

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.