Skip to contentSkip to conversation

mdev-only /dev management (without devtmpfs)

RFC New Luca Ceresoli 4 participants 49 messages Sep 8, 2015 – Oct 1, 2015

lore
Share & tools
lore
#0 lore raw

cover mdev-only /dev management (without devtmpfs)

Hi,

this patchset adds a new /dev management mechanism, using mdev for dynamic device creation but without relying on devtmpfs.

The main motivation is the need of dynamic /dev management and/or firmware loading assisted by mdev on targets that are bound to kernels < 2.6.32, and thus cannot use devtmpfs.

The topic has been discussed back in July when I proposed a totally unacceptable implementation. In the discussion that followed I made a proposal [0], whose general principle was positively received by Thomas.

The proposal is to augment the /dev management choice this way:
( ) Static using device table
( ) Static using device table + mdev <- New option
(X) Dynamic using devtmpfs only
( ) Dynamic using {devtmpfs +} mdev {} = new wording only
( ) Dynamic using {devtmpfs +} eudev {} = new wording only

Of course we still have a static table to make the system boot until mdev is activated.

In order to activate mdev I first tried to hook in S10mdev to make a boot process that is similar to the current "devtmpfs + mdev" case. But that didn't work well, because when S10mdev runs /dev/shm and /dev/pts are already mounted. This raises issues explained in detail in the commit log for patch 3.

Instead the approached that worked best is to activate mdev as early as possible, i.e. in inittab. This makes the system boot (of course) like the static case for the few very initial moments of userspace life: launching init and mounting /proc and /sys; yes, we now mount /sys in inittab, it's needed by mdev. Then mdev is enabled, and things look very much like any other dynamic method since then.

In the end I think the modifications to implement this feature are relatively few, and it all works well. I tested it with 10 qemu configs, testing every /dev management method with both busybox and sysvinit init. Patch 6 shows my ugly testing scripts.

So it is quite stable. It is called an RFC because the change touches a few important lines and because this addition was not considered a good idea by Peter, according to Thomas' memory [1].

I even wondered whether this new kind of /dev management should replace the "devtmpfs + mdev" at some point, since it does not seem to provide any drawback. Unless I'm missing something, which is definitely possible...

There is one rough edge that I'd like to have comments about: variable naming. The new method implemented by this patchset is dynamic and uses mdev, so it should ba named BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV and described in kconfig as "dynamic using mdev". But hey, that name and description are already used for the current "devtmpfs + mdev" method! So we might want to rename all variables to encompass the new use case in a clean way. Thid would also imply lagacy management etc.

For the time being I didn't enter the jungle of variable naming and just expanded the description for the current mdev and eudev cases to clarify they also use devtmpfs. This is done in patch 2. Then I called the newly introduced method BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY and described it "Dynamic using mdev only", to make sure it is well distinguishable@least during teh oatch review process. If the overall work is considered good, I'll take care of the renaming in a future patchset.

Here are a few figures about the storage space needed for the various configurations. All are compared to the "devtmpfs + mdev" reference method. Not a big surprise, the differences are all quite negligible, being all below 1%.

devtmpfs+mdev: zImage 2.1 MB, rootfs.ext2 6.8 MB
-------------------------------------------------------
devtmpfs-only delta: zImage equal, rootfs.ext2 -9 kB
mdev-only delta: zImage -1.6 kB, rootfs.ext2 equal
static delta: zImage -1.6 kB, rootfs.ext2 +28 kB

Luca

[0] http://lists.busybox.net/pipermail/buildroot/2015-July/133695.html
[1] http://lists.busybox.net/pipermail/buildroot/2015-July/133701.html

Luca Ceresoli (6):
Move mounting /sys from fstab to inittab
system: clarify /dev management using devtmpfs + {mdev,eudev}
system: add mdev-only /dev management (without devtmpfs)
system: strip the initial /dev for mdev-only /dev management docs/manual: document "Dynamic using mdev only" /dev management **** DO NOT COMMIT THIS **** ugly stuff to test mdev-only /dev
management

 .gitignore                             |  1 +
 configs/test_bb_dyn_devtmpfs_defconfig | 12 ++++++++++++
 configs/test_bb_dyn_eudev_defconfig    | 13 +++++++++++++
 configs/test_bb_dyn_mdev_defconfig     | 13 +++++++++++++
 configs/test_bb_mdev_only_defconfig    | 13 +++++++++++++
 configs/test_bb_static_defconfig       | 13 +++++++++++++
 configs/test_sv_dyn_devtmpfs_defconfig | 13 +++++++++++++
 configs/test_sv_dyn_eudev_defconfig    | 14 ++++++++++++++
 configs/test_sv_dyn_mdev_defconfig     | 14 ++++++++++++++
 configs/test_sv_mdev_only_defconfig    | 14 ++++++++++++++
 configs/test_sv_static_defconfig       | 14 ++++++++++++++
 docs/manual/configure.txt              | 18 +++++++++++++++---
 linux/linux.mk                         |  2 +-
 package/busybox/activate-mdev          |  5 +++++
 package/busybox/busybox.mk             |  7 +++++++
 package/busybox/inittab                |  2 ++
 package/skeleton/skeleton.mk           | 15 +++++++++++++++
 package/sysvinit/inittab               | 14 ++++++++------
 run                                    | 12 ++++++++++++
 system/Config.in                       | 11 ++++++++---
 system/device_table_dev_mdev_only.txt  | 10 ++++++++++
 system/skeleton/etc/fstab              |  1 -
 test-all                               | 34 ++++++++++++++++++++++++++++++++++
 23 files changed, 251 insertions(+), 14 deletions(-)
 create mode 100644 configs/test_bb_dyn_devtmpfs_defconfig
 create mode 100644 configs/test_bb_dyn_eudev_defconfig
 create mode 100644 configs/test_bb_dyn_mdev_defconfig
 create mode 100644 configs/test_bb_mdev_only_defconfig
 create mode 100644 configs/test_bb_static_defconfig
 create mode 100644 configs/test_sv_dyn_devtmpfs_defconfig
 create mode 100644 configs/test_sv_dyn_eudev_defconfig
 create mode 100644 configs/test_sv_dyn_mdev_defconfig
 create mode 100644 configs/test_sv_mdev_only_defconfig
 create mode 100644 configs/test_sv_static_defconfig
 create mode 100755 package/busybox/activate-mdev
 create mode 100755 run
 create mode 100644 system/device_table_dev_mdev_only.txt
 create mode 100755 test-all
Signature · 1 line
1.9.1
#1 lore raw

RFC 1/6 Move mounting /sys from fstab to inittab

We are going to launch mdev from inittab, to have dynamic /dev without devtmpfs. However, mdev needs /sys to detect devices.

So, mount /sys before the place where mdev will be activated.

---
 package/busybox/inittab   |  1 +
 package/sysvinit/inittab  | 13 +++++++------
 system/skeleton/etc/fstab |  1 -
 3 files changed, 8 insertions(+), 7 deletions(-)
package/busybox/inittab +1 -0
index b1892c1..6703fc5 100644
@@ -15,6 +15,7 @@
 
 # Startup the system
 null::sysinit:/bin/mount -t proc proc /proc
+null::sysinit:/bin/mount -t sysfs sysfs /sys
 null::sysinit:/bin/mount -o remount,rw /
 null::sysinit:/bin/mkdir -p /dev/pts
 null::sysinit:/bin/mkdir -p /dev/shm
package/sysvinit/inittab +7 -6
index fc0c9b5..6ebf6fa 100644
@@ -5,12 +5,13 @@
 id:3:initdefault:
 
 si0::sysinit:/bin/mount -t proc proc /proc
-si1::sysinit:/bin/mount -o remount,rw /
-si2::sysinit:/bin/mkdir -p /dev/pts
-si3::sysinit:/bin/mkdir -p /dev/shm
-si4::sysinit:/bin/mount -a
-si5::sysinit:/bin/hostname -F /etc/hostname
-si6::sysinit:/etc/init.d/rcS
+si1::sysinit:/bin/mount -t sysfs sysfs /sys
+si2::sysinit:/bin/mount -o remount,rw /
+si3::sysinit:/bin/mkdir -p /dev/pts
+si4::sysinit:/bin/mkdir -p /dev/shm
+si5::sysinit:/bin/mount -a
+si6::sysinit:/bin/hostname -F /etc/hostname
+si7::sysinit:/etc/init.d/rcS
 
 # S0:1:respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
 
system/skeleton/etc/fstab +0 -1
index 2b418a0..489f256 100644
@@ -5,4 +5,3 @@ devpts		/dev/pts	devpts	defaults,gid=5,mode=620	0	0
 tmpfs		/dev/shm	tmpfs	mode=0777	0	0
 tmpfs		/tmp		tmpfs	mode=1777	0	0
 tmpfs		/run		tmpfs	mode=0755,nosuid,nodev	0	0
-sysfs		/sys		sysfs	defaults	0	0
Signature · 1 line
1.9.1
#2 lore raw

RFC 1/6 Move mounting /sys from fstab to inittab

Quoted 6 lines · Luca Ceresoli

We are going to launch mdev from inittab, to have dynamic /dev without devtmpfs. However, mdev needs /sys to detect devices.

So, mount /sys before the place where mdev will be activated.

Not tested, but I trust patch 6/6 :-)

Regards,
Arnout

Quoted 52 lines
---
 package/busybox/inittab   |  1 +
 package/sysvinit/inittab  | 13 +++++++------
 system/skeleton/etc/fstab |  1 -
 3 files changed, 8 insertions(+), 7 deletions(-)
package/busybox/inittab +1 -0
index b1892c1..6703fc5 100644
@@ -15,6 +15,7 @@
 
 # Startup the system
 null::sysinit:/bin/mount -t proc proc /proc
+null::sysinit:/bin/mount -t sysfs sysfs /sys
 null::sysinit:/bin/mount -o remount,rw /
 null::sysinit:/bin/mkdir -p /dev/pts
 null::sysinit:/bin/mkdir -p /dev/shm
package/sysvinit/inittab +7 -6
index fc0c9b5..6ebf6fa 100644
@@ -5,12 +5,13 @@
 id:3:initdefault:
 
 si0::sysinit:/bin/mount -t proc proc /proc
-si1::sysinit:/bin/mount -o remount,rw /
-si2::sysinit:/bin/mkdir -p /dev/pts
-si3::sysinit:/bin/mkdir -p /dev/shm
-si4::sysinit:/bin/mount -a
-si5::sysinit:/bin/hostname -F /etc/hostname
-si6::sysinit:/etc/init.d/rcS
+si1::sysinit:/bin/mount -t sysfs sysfs /sys
+si2::sysinit:/bin/mount -o remount,rw /
+si3::sysinit:/bin/mkdir -p /dev/pts
+si4::sysinit:/bin/mkdir -p /dev/shm
+si5::sysinit:/bin/mount -a
+si6::sysinit:/bin/hostname -F /etc/hostname
+si7::sysinit:/etc/init.d/rcS
 
 # S0:1:respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
 
system/skeleton/etc/fstab +0 -1
index 2b418a0..489f256 100644
@@ -5,4 +5,3 @@ devpts		/dev/pts	devpts	defaults,gid=5,mode=620	0	0
 tmpfs		/dev/shm	tmpfs	mode=0777	0	0
 tmpfs		/tmp		tmpfs	mode=1777	0	0
 tmpfs		/run		tmpfs	mode=0755,nosuid,nodev	0	0
-sysfs		/sys		sysfs	defaults	0	0
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

RFC 2/6 system: clarify /dev management using devtmpfs + {mdev, eudev}

In reply to Luca Ceresoli

We're going to introduce /dev management with mdev only (no devtmpfs), which will be called "Dynamic using mdev only".

In preparation to that addition, clarify the current /dev managements systems which use devtmpfs with an additional tool. Otherwise "Dynamic using mdev" and "Dynamic using mdev only" wight look quite undistinguishable to mortals...

---
 docs/manual/configure.txt | 7 ++++---
 system/Config.in          | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)
docs/manual/configure.txt +4 -3
index dd34eef..997be2b 100644
@@ -295,7 +295,7 @@ different solutions to handle the +/dev+ directory :
    responsibility to enable those two options (if you fail to do so,
    your Buildroot system will not boot).
 
- * The third solution is *Dynamic using mdev*. This method also relies
+ * The third solution is *Dynamic using devtmpfs + mdev*. This method also relies
    on the _devtmpfs_ virtual filesystem detailed above (so the
    requirement to have +CONFIG_DEVTMPFS+ and +CONFIG_DEVTMPFS_MOUNT+
    enabled in the kernel configuration still apply), but adds the
@@ -314,7 +314,7 @@ different solutions to handle the +/dev+ directory :
    about +mdev+ and the syntax of its configuration file, see
    http://git.busybox.net/busybox/tree/docs/mdev.txt.
 
- * The fourth solution is *Dynamic using eudev*. This method also
+ * The fourth solution is *Dynamic using devtmpfs + eudev*. This method also
    relies on the _devtmpfs_ virtual filesystem detailed above, but
    adds the +eudev+ userspace daemon on top of it. +eudev+ is a daemon
    that runs in the background, and gets called by the kernel when a
@@ -327,7 +327,8 @@ different solutions to handle the +/dev+ directory :
 The Buildroot developers recommendation is to start with the *Dynamic
 using devtmpfs only* solution, until you have the need for userspace
 to be notified when devices are added/removed, or if firmwares are
-needed, in which case *Dynamic using mdev* is usually a good solution.
+needed, in which case *Dynamic using devtmpfs + mdev* is usually a
+good solution.
 
 Note that if +systemd+ is chosen as init system, /dev management will
 be performed by the +udev+ program provided by +systemd+.
system/Config.in +2 -2
index fad829d..5bf5048 100644
@@ -110,11 +110,11 @@ config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS
 	bool "Dynamic using devtmpfs only"
 
 config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV
-	bool "Dynamic using mdev"
+	bool "Dynamic using devtmpfs + mdev"
 	select BR2_PACKAGE_BUSYBOX
 
 config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV
-	bool "Dynamic using eudev"
+	bool "Dynamic using devtmpfs + eudev"
 	depends on BR2_USE_WCHAR
 	depends on !BR2_STATIC_LIBS
 	depends on BR2_USE_MMU # eudev
Signature · 1 line
1.9.1
#4 lore raw

RFC 2/6 system: clarify /dev management using devtmpfs + {mdev, eudev}

Quoted 7 lines · Luca Ceresoli

We're going to introduce /dev management with mdev only (no devtmpfs), which will be called "Dynamic using mdev only".

In preparation to that addition, clarify the current /dev managements systems which use devtmpfs with an additional tool. Otherwise "Dynamic using mdev" and "Dynamic using mdev only" wight look quite undistinguishable to mortals...

I would squash the change to the manual with patch 5/6 and squash the changes
to the Config.in prompts into patch 3/6, since these changes are related.

But the updated text looks good to me, so:

Oh, perhaps you could add a brief help text to the choice options? You can more
or less copy and paste the text from the manual. If you do add help text, do it as a separate patch at the end of the series so it doesn't have to be updated again after the introduction of mdev-only.

Regards,
Arnout

Quoted 58 lines
---
 docs/manual/configure.txt | 7 ++++---
 system/Config.in          | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)
docs/manual/configure.txt +4 -3
index dd34eef..997be2b 100644
@@ -295,7 +295,7 @@ different solutions to handle the +/dev+ directory :
    responsibility to enable those two options (if you fail to do so,
    your Buildroot system will not boot).
 
- * The third solution is *Dynamic using mdev*. This method also relies
+ * The third solution is *Dynamic using devtmpfs + mdev*. This method also relies
    on the _devtmpfs_ virtual filesystem detailed above (so the
    requirement to have +CONFIG_DEVTMPFS+ and +CONFIG_DEVTMPFS_MOUNT+
    enabled in the kernel configuration still apply), but adds the
@@ -314,7 +314,7 @@ different solutions to handle the +/dev+ directory :
    about +mdev+ and the syntax of its configuration file, see
    http://git.busybox.net/busybox/tree/docs/mdev.txt.
 
- * The fourth solution is *Dynamic using eudev*. This method also
+ * The fourth solution is *Dynamic using devtmpfs + eudev*. This method also
    relies on the _devtmpfs_ virtual filesystem detailed above, but
    adds the +eudev+ userspace daemon on top of it. +eudev+ is a daemon
    that runs in the background, and gets called by the kernel when a
@@ -327,7 +327,8 @@ different solutions to handle the +/dev+ directory :
 The Buildroot developers recommendation is to start with the *Dynamic
 using devtmpfs only* solution, until you have the need for userspace
 to be notified when devices are added/removed, or if firmwares are
-needed, in which case *Dynamic using mdev* is usually a good solution.
+needed, in which case *Dynamic using devtmpfs + mdev* is usually a
+good solution.
 
 Note that if +systemd+ is chosen as init system, /dev management will
 be performed by the +udev+ program provided by +systemd+.
system/Config.in +2 -2
index fad829d..5bf5048 100644
@@ -110,11 +110,11 @@ config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS
 	bool "Dynamic using devtmpfs only"
 
 config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV
-	bool "Dynamic using mdev"
+	bool "Dynamic using devtmpfs + mdev"
 	select BR2_PACKAGE_BUSYBOX
 
 config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV
-	bool "Dynamic using eudev"
+	bool "Dynamic using devtmpfs + eudev"
 	depends on BR2_USE_WCHAR
 	depends on !BR2_STATIC_LIBS
 	depends on BR2_USE_MMU # eudev
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#5 lore raw

RFC 2/6 system: clarify /dev management using devtmpfs + {mdev, eudev}

Dear Arnout,

thanks for you review.

Quoted 11 lines · Arnout Vandecappelle
Quoted 7 lines · Luca Ceresoli

We're going to introduce /dev management with mdev only (no devtmpfs), which will be called "Dynamic using mdev only".

In preparation to that addition, clarify the current /dev managements systems which use devtmpfs with an additional tool. Otherwise "Dynamic using mdev" and "Dynamic using mdev only" wight look quite undistinguishable to mortals...

I would squash the change to the manual with patch 5/6 and squash the changes
to the Config.in prompts into patch 3/6, since these changes are related.

Well, to be picky about bisectability, the changes in this patch should stay together. Otherwise at some commit we'd have "Dynamic using devtmpfs + mdev" in kconfig but "Dynamic using mdev" in the docs.

Quoted 9 lines

But the updated text looks good to me, so:

Oh, perhaps you could add a brief help text to the choice options? You can more
or less copy and paste the text from the manual. If you do add help text, do it as a separate patch at the end of the series so it doesn't have to be updated again after the introduction of mdev-only.

Good idea, I'll do it in the next iteration.

Signature · 1 line
Luca
#6 lore raw

RFC 2/6 system: clarify /dev management using devtmpfs + {mdev, eudev}

Quoted 14 lines · Luca Ceresoli

Dear Arnout,

thanks for you review.

Quoted 9 lines · Arnout Vandecappelle
Quoted 7 lines · Luca Ceresoli

We're going to introduce /dev management with mdev only (no devtmpfs), which will be called "Dynamic using mdev only".

In preparation to that addition, clarify the current /dev managements systems which use devtmpfs with an additional tool. Otherwise "Dynamic using mdev" and "Dynamic using mdev only" wight look quite undistinguishable to mortals...

Quoted 6 lines
Quoted 2 lines

I would squash the change to the manual with patch 5/6 and squash the changes
to the Config.in prompts into patch 3/6, since these changes are related.

Well, to be picky about bisectability, the changes in this patch should stay together. Otherwise at some commit we'd have "Dynamic using devtmpfs + mdev" in kconfig but "Dynamic using mdev" in the docs.

OK, so then keep this patch and include my Reviewed-by.

Regards,
Arnout

[snip]

Signature · 6 lines
Arnout Vandecappelle      arnout dot vandecappelle at essensium dot com
Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile)
Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#7 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Luca Ceresoli

There are a few reasons for an embedded Linux system not to use devtmpfs, but still want to have dynamic /dev management. The most notable is to use a kernel < 2.6.32, which have no devtmpfs support.

For such corner cases, we introduce the ability to use busybox mdev for /dev management even without devtmpfs.

First, we need the BR2_ROOTFS_STATIC_DEVICE_TABLE just like the static /dev management, in order to have the very basic devices such as /dev/null and /dev/console until mdev is enabled.

Then we mount a tmpfs on /dev and enable mdev using the incantations:

/bin/mount -t tmpfs mdev /dev
echo /sbin/mdev >/proc/sys/kernel/hotplug
/sbin/mdev -s

But doing this in S10mdev, which already does something similar, would be a bit complex because when S10mdev runs /dev/shm and /dev/pts are already mounted. We might unmount, recreate and mount them again, but devices in them might be already in use. Or we could leave the "old" alone, and mount them again in the newly created /dev. Both solutions are dirty and potentially problematic.

Instead we hook in inittab (both busybox and sysvinit) and do the same incantations there, right after mounting /sys (needed for mdev) but before any other actions on /dev, such as creating and mounting /dev/shm and /dev/pts. We also skip installing S10mdev: it would do the same things twice. In order to keep the inittab files concise and maintainable, this taks is delegated to a helper script, /sbin/activate-mdev.

---
 linux/linux.mk                |  2 +-
 package/busybox/activate-mdev |  5 +++++
 package/busybox/busybox.mk    |  7 +++++++
 package/busybox/inittab       |  1 +
 package/skeleton/skeleton.mk  | 15 +++++++++++++++
 package/sysvinit/inittab      | 13 +++++++------
 system/Config.in              |  6 +++++-
 7 files changed, 41 insertions(+), 8 deletions(-)
 create mode 100755 package/busybox/activate-mdev
linux/linux.mk +1 -1
index bbcc54b..bbac1e6 100644
@@ -190,7 +190,7 @@ define LINUX_KCONFIG_FIXUP_CMDS
 		$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio",$(@D)/.config)
 		$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0,$(@D)/.config)
 		$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0,$(@D)/.config))
-	$(if $(BR2_ROOTFS_DEVICE_CREATION_STATIC),,
+	$(if $(BR2_ROOTFS_DEVICE_CREATION_STATIC)$(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY),,
 		$(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config)
 		$(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config))
 	$(if $(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV),
package/busybox/activate-mdev new file +5 -0
new file mode 100755
index 0000000..db2a53d
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+/bin/mount -t tmpfs mdev /dev
+echo /sbin/mdev >/proc/sys/kernel/hotplug
+/sbin/mdev -s
package/busybox/busybox.mk +7 -0
index 6e302f4..f95ff52 100644
@@ -55,11 +55,18 @@ define BUSYBOX_PERMISSIONS
 endef
 
 # If mdev will be used for device creation enable it and copy S10mdev to /etc/init.d
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV)$(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY),y)
 ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)
 define BUSYBOX_INSTALL_MDEV_SCRIPT
 	$(INSTALL) -D -m 0755 package/busybox/S10mdev \
 		$(TARGET_DIR)/etc/init.d/S10mdev
 endef
+else
+define BUSYBOX_INSTALL_MDEV_SCRIPT
+	$(INSTALL) -D -m 0755 package/busybox/activate-mdev \
+		$(TARGET_DIR)/sbin/activate-mdev
+endef
+endif
 define BUSYBOX_INSTALL_MDEV_CONF
 	$(INSTALL) -D -m 0644 package/busybox/mdev.conf \
 		$(TARGET_DIR)/etc/mdev.conf
package/busybox/inittab +1 -0
index 6703fc5..eaba42f 100644
@@ -16,6 +16,7 @@
 # Startup the system
 null::sysinit:/bin/mount -t proc proc /proc
 null::sysinit:/bin/mount -t sysfs sysfs /sys
+#null::sysinit:/sbin/activate-mdev
 null::sysinit:/bin/mount -o remount,rw /
 null::sysinit:/bin/mkdir -p /dev/pts
 null::sysinit:/bin/mkdir -p /dev/shm
package/skeleton/skeleton.mk +15 -0
index 48e7085..975e2a5 100644
@@ -141,6 +141,7 @@ TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_GETTY
 endif
 
 ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y)
+
 ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
 # Find commented line, if any, and remove leading '#'s
 define SKELETON_SYSTEM_REMOUNT_RW
@@ -153,6 +154,20 @@ define SKELETON_SYSTEM_REMOUNT_RW
 endef
 endif
 TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_REMOUNT_RW
+
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY),y)
+# Find commented line, if any, and remove leading '#'s
+define SKELETON_SYSTEM_EARLY_MDEV
+	$(SED) '/^#.*sbin\/activate-mdev$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
+endef
+else
+# Find uncommented line, if any, and add a leading '#'
+define SKELETON_SYSTEM_EARLY_MDEV
+	$(SED) '/^[^#].*sbin\/activate-mdev$$/s~^~#~' $(TARGET_DIR)/etc/inittab
+endef
+endif
+TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_EARLY_MDEV
+
 endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
package/sysvinit/inittab +7 -6
index 6ebf6fa..5abca7f 100644
@@ -6,12 +6,13 @@ id:3:initdefault:
 
 si0::sysinit:/bin/mount -t proc proc /proc
 si1::sysinit:/bin/mount -t sysfs sysfs /sys
-si2::sysinit:/bin/mount -o remount,rw /
-si3::sysinit:/bin/mkdir -p /dev/pts
-si4::sysinit:/bin/mkdir -p /dev/shm
-si5::sysinit:/bin/mount -a
-si6::sysinit:/bin/hostname -F /etc/hostname
-si7::sysinit:/etc/init.d/rcS
+si2::sysinit:/sbin/activate-mdev
+si3::sysinit:/bin/mount -o remount,rw /
+si4::sysinit:/bin/mkdir -p /dev/pts
+si5::sysinit:/bin/mkdir -p /dev/shm
+si6::sysinit:/bin/mount -a
+si7::sysinit:/bin/hostname -F /etc/hostname
+si8::sysinit:/etc/init.d/rcS
 
 # S0:1:respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
 
system/Config.in +5 -1
index 5bf5048..a10de1e 100644
@@ -106,6 +106,10 @@ choice
 config BR2_ROOTFS_DEVICE_CREATION_STATIC
 	bool "Static using device table"
 
+config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY
+	bool "Dynamic using mdev only"
+	select BR2_PACKAGE_BUSYBOX
+
 config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS
 	bool "Dynamic using devtmpfs only"
 
@@ -144,7 +148,7 @@ config BR2_ROOTFS_DEVICE_TABLE
 config BR2_ROOTFS_STATIC_DEVICE_TABLE
 	string "Path to the device tables"
 	default "system/device_table_dev.txt"
-	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC
+	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC || BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY
 	help
 	  Specify a space-separated list of device table locations,
 	  that will be passed to the makedevs utility to create all
Signature · 1 line
1.9.1
#8 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

package/busybox/inittab line 19

Quoted 6 lines · Luca Ceresoli

+++ b/package/busybox/inittab

package/busybox/inittab +1 -0
@@ -16,6 +16,7 @@
 # Startup the system
 null::sysinit:/bin/mount -t proc proc /proc
 null::sysinit:/bin/mount -t sysfs sysfs /sys
+#null::sysinit:/sbin/activate-mdev

Excuse my stupidity, but wouldn't it be enough to add the following here:

null::sysinit:/bin/mount -t tmpfs mdev /dev

and keep on using S10mdev? That is less invasive, and it should work since it's more or less the same as what is done in the cpio/initramfs case.

Regards,
Arnout

Quoted 4 lines
package/busybox/inittab +0 -0
 null::sysinit:/bin/mount -o remount,rw /
 null::sysinit:/bin/mkdir -p /dev/pts
 null::sysinit:/bin/mkdir -p /dev/shm
package/skeleton/skeleton.mk +0 -0
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#9 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Arnout,

Quoted 10 lines · Arnout Vandecappelle

package/busybox/inittab line 19

Quoted 6 lines · Luca Ceresoli

+++ b/package/busybox/inittab

package/busybox/inittab +1 -0
@@ -16,6 +16,7 @@
  # Startup the system
  null::sysinit:/bin/mount -t proc proc /proc
  null::sysinit:/bin/mount -t sysfs sysfs /sys
+#null::sysinit:/sbin/activate-mdev

Excuse my stupidity, but wouldn't it be enough to add the following here:

Quoted 4 lines

null::sysinit:/bin/mount -t tmpfs mdev /dev

and keep on using S10mdev? That is less invasive, and it should work since it's more or less the same as what is done in the cpio/initramfs case.

Good idea, with a couple caveats.

The first problem is we'd have an empty /dev since the mount until the execution of S10mdev. This prevents busybox init from executing all lines in inittab after the mount, since they would try to open /dev/null. Symptom: "can't open /dev/null: No such file or directory". The fix should be simply:

-null::sysinit:/bin/mkdir -p /dev/pts
-null::sysinit:/bin/mkdir -p /dev/shm
-null::sysinit:/bin/mount -a
-null::sysinit:/bin/hostname -F /etc/hostname
+::sysinit:/bin/mkdir -p /dev/pts
+::sysinit:/bin/mkdir -p /dev/shm
+::sysinit:/bin/mount -a
+::sysinit:/bin/hostname -F /etc/hostname

Lines up to the /dev mount might be changed as well to have a more uniform style, but it's not strictly needed.

I'll check if sysvinit init has any issues.

But ehen, if any user has an S05something that uses /dev, it would break. In order to reduce the risk to nearly zero, we might move S10mdev to S00mdev, so it runs (most likely) as the first script.

This would slightly change the current behaviour for all cases, and start S01logging after mdev, not before. I tested it quickly and it looks like it works. Can you think of any problem with moving S10mdev to S00mdev?

Signature · 1 line
Luca
#10 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 8 lines · Luca Ceresoli

But ehen, if any user has an S05something that uses /dev, it would break. In order to reduce the risk to nearly zero, we might move S10mdev to S00mdev, so it runs (most likely) as the first script.

This would slightly change the current behaviour for all cases, and start S01logging after mdev, not before. I tested it quickly and it looks like it works. Can you think of any problem with moving S10mdev to S00mdev?

I'd prefer to have logging before mdev, so any fallout from mdev will appear in
the logs. So for me, S02mdev is fine.

In my mdev-using projects I usually have a custom mdev script (to do more
extensive coldplugging) and I also move it to S02.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle      arnout dot vandecappelle at essensium dot com
Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile)
Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#11 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Luca Ceresoli

Dear Luca Ceresoli,

Quoted 15 lines · Luca Ceresoli

The first problem is we'd have an empty /dev since the mount until the execution of S10mdev. This prevents busybox init from executing all lines in inittab after the mount, since they would try to open /dev/null. Symptom: "can't open /dev/null: No such file or directory". The fix should be simply:

(quoted diff) +4 -4
-null::sysinit:/bin/mkdir -p /dev/pts
-null::sysinit:/bin/mkdir -p /dev/shm
-null::sysinit:/bin/mount -a
-null::sysinit:/bin/hostname -F /etc/hostname
+::sysinit:/bin/mkdir -p /dev/pts
+::sysinit:/bin/mkdir -p /dev/shm
+::sysinit:/bin/mount -a
+::sysinit:/bin/hostname -F /etc/hostname
Quoted 2 lines

Lines up to the /dev mount might be changed as well to have a more uniform style, but it's not strictly needed.

It actually looks better to me to *not* redirect the output of those commands to /dev/null. I don't know why we are doing this, but it means that if any of those commands wants to display something, it is redirected to oblivion. Not good. So it looks better to continue using the stdout/stderr set up by the kernel for the init process.

BTW, does this means that in the minimal static device table, we only need /dev/console? That's the only device that is opened by the kernel directly, I believe /dev/null was only needed for those lines.

Quoted 8 lines

But ehen, if any user has an S05something that uses /dev, it would break. In order to reduce the risk to nearly zero, we might move S10mdev to S00mdev, so it runs (most likely) as the first script.

This would slightly change the current behaviour for all cases, and start S01logging after mdev, not before. I tested it quickly and it looks like it works. Can you think of any problem with moving S10mdev to S00mdev?

In principle, it seems better to me if the devices are all set up before starting anything else, so if it works, I'm all for S00mdev. The only question is whether mdev logs things to syslog, and if so what happens to those messages that are emitted before syslog is started.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#12 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Thomas,

Quoted 19 lines · Thomas Petazzoni

Dear Luca Ceresoli,

Quoted 15 lines · Luca Ceresoli

The first problem is we'd have an empty /dev since the mount until the execution of S10mdev. This prevents busybox init from executing all lines in inittab after the mount, since they would try to open /dev/null. Symptom: "can't open /dev/null: No such file or directory". The fix should be simply:

(quoted diff) +4 -4
-null::sysinit:/bin/mkdir -p /dev/pts
-null::sysinit:/bin/mkdir -p /dev/shm
-null::sysinit:/bin/mount -a
-null::sysinit:/bin/hostname -F /etc/hostname
+::sysinit:/bin/mkdir -p /dev/pts
+::sysinit:/bin/mkdir -p /dev/shm
+::sysinit:/bin/mount -a
+::sysinit:/bin/hostname -F /etc/hostname
Quoted 8 lines
Quoted 2 lines

Lines up to the /dev mount might be changed as well to have a more uniform style, but it's not strictly needed.

It actually looks better to me to *not* redirect the output of those commands to /dev/null. I don't know why we are doing this, but it means that if any of those commands wants to display something, it is redirected to oblivion. Not good. So it looks better to continue using the stdout/stderr set up by the kernel for the init process.

Aha! And removing the "null" prefix uncovered this error while booting a static /dev system:

mkdir: can't create directory '/dev/shm': Read-only file system

Which comes from the line

::sysinit:/bin/mkdir -p /dev/shm

Yeah, time to get rid of these "null" redirects, and fix the lack of /dev/shm in the static device table! Will do in v2.

Quoted 14 lines

BTW, does this means that in the minimal static device table, we only need /dev/console? That's the only device that is opened by the kernel directly, I believe /dev/null was only needed for those lines.

Quoted 8 lines

But ehen, if any user has an S05something that uses /dev, it would break. In order to reduce the risk to nearly zero, we might move S10mdev to S00mdev, so it runs (most likely) as the first script.

This would slightly change the current behaviour for all cases, and start S01logging after mdev, not before. I tested it quickly and it looks like it works. Can you think of any problem with moving S10mdev to S00mdev?

Quoted 4 lines

In principle, it seems better to me if the devices are all set up before starting anything else, so if it works, I'm all for S00mdev. The only question is whether mdev logs things to syslog, and if so what happens to those messages that are emitted before syslog is started.

At a quick code inspection it looks like mdev does not use syslog. I'll do some testing.

Signature · 1 line
Luca
#13 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 6 lines · Luca Ceresoli

Dear Thomas,

Quoted 3 lines · Thomas Petazzoni

Dear Luca Ceresoli,

On Wed, 9 Sep 2015 14:29:36 +0200, Luca Ceresoli wrote:

[snip]

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

This would slightly change the current behaviour for all cases, and start S01logging after mdev, not before. I tested it quickly and it looks like it works. Can you think of any problem with moving S10mdev to S00mdev?

Quoted 7 lines
Quoted 4 lines

In principle, it seems better to me if the devices are all set up before starting anything else, so if it works, I'm all for S00mdev. The only question is whether mdev logs things to syslog, and if so what happens to those messages that are emitted before syslog is started.

At a quick code inspection it looks like mdev does not use syslog. I'll do some testing.

mdev doesn't but any script it calls might.

Also, if a crash happens during mdev coldplugging, it's an advantage if the
kernel messages can be captured by syslog.

So I'd prefer to keep syslog before mdev.

FYI: systemd starts journald and udev in parallel (at least as far as I can
make out from the service files).

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#14 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Arnout,

Quoted 18 lines · Arnout Vandecappelle
Quoted 6 lines · Luca Ceresoli

Dear Thomas,

Quoted 3 lines · Thomas Petazzoni

Dear Luca Ceresoli,

On Wed, 9 Sep 2015 14:29:36 +0200, Luca Ceresoli wrote:

[snip]

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

This would slightly change the current behaviour for all cases, and start S01logging after mdev, not before. I tested it quickly and it looks like it works. Can you think of any problem with moving S10mdev to S00mdev?

In principle, it seems better to me if the devices are all set up before starting anything else, so if it works, I'm all for S00mdev. The only question is whether mdev logs things to syslog, and if so what happens to those messages that are emitted before syslog is started.

Quoted 4 lines
Quoted 2 lines

At a quick code inspection it looks like mdev does not use syslog. I'll do some testing.

mdev doesn't but any script it calls might.

Good point. S02mdev then (if the current implementation idea will survive at all, given the rest of the discussion).

Quoted 12 lines

Also, if a crash happens during mdev coldplugging, it's an advantage if the
kernel messages can be captured by syslog.

So I'd prefer to keep syslog before mdev.

FYI: systemd starts journald and udev in parallel (at least as far as I can
make out from the service files).

Regards,
Arnout

Signature · 1 line
Luca
#15 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Thomas Petazzoni
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 4 lines

In principle, it seems better to me if the devices are all set up before starting anything else, so if it works, I'm all for S00mdev. The only question is whether mdev logs things to syslog, and if so what happens to those messages that are emitted before syslog is started.

It doesn't:

git grep log mdev.c
mdev.c://usage: "If /dev/mdev.log file exists, debug log will be appended to it."
mdev.c:static void open_mdev_log(const char *seq, unsigned my_pid)

mdev.c: int logfd = open("mdev.log", O_WRONLY | O_APPEND);
mdev.c: if (logfd >= 0) {
mdev.c:         xmove_fd(logfd, STDERR_FILENO);
mdev.c:         open_mdev_log(seq, my_pid);

So only to stderr (and /dev/mdev.log if it exists).

Signature · 1 line
Bye, Peter Korsgaard
#16 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Peter Korsgaard,

Quoted 15 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 4 lines

In principle, it seems better to me if the devices are all set up before starting anything else, so if it works, I'm all for S00mdev. The only question is whether mdev logs things to syslog, and if so what happens to those messages that are emitted before syslog is started.

It doesn't:

git grep log mdev.c
mdev.c://usage: "If /dev/mdev.log file exists, debug log will be appended to it."
mdev.c:static void open_mdev_log(const char *seq, unsigned my_pid)

Quoted 6 lines
mdev.c: int logfd = open("mdev.log", O_WRONLY | O_APPEND);
mdev.c: if (logfd >= 0) {
mdev.c:         xmove_fd(logfd, STDERR_FILENO);
mdev.c:         open_mdev_log(seq, my_pid);

So only to stderr (and /dev/mdev.log if it exists).

Then we can safely start mdev before the syslog/klogd stuff, right?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#17 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 11 lines
Quoted 9 lines

git grep log mdev.c
mdev.c://usage: "If /dev/mdev.log file exists, debug log will be appended to it."
mdev.c:static void open_mdev_log(const char *seq, unsigned my_pid)

mdev.c: int logfd = open("mdev.log", O_WRONLY | O_APPEND);
mdev.c: if (logfd >= 0) {
mdev.c:         xmove_fd(logfd, STDERR_FILENO);
mdev.c:         open_mdev_log(seq, my_pid);

So only to stderr (and /dev/mdev.log if it exists).

Then we can safely start mdev before the syslog/klogd stuff, right?

Yes, but I still question the need for all of this work in the first place.

Is there any reason for NOT using devtmpfs if it is available? And if it isn't, is making Buildroot more complicated better than asking people to backport devtmpfs support and/or upgrade to a newer kernel? We certainly don't test such old kernel headers in the autobuilders.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#18 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Hello,

Quoted 4 lines · Peter Korsgaard
Quoted 1 line

Then we can safely start mdev before the syslog/klogd stuff, right?

Yes, but I still question the need for all of this work in the first place.

On my side, I don't. Some people are still forced to use 2.6.x kernels older than 2.6.32, and if Luca (who is a knowledgeable and skilled developer) has such a need, I'm sure it means there is a silent group of people stuck with prehistoric kernels that would benefit from this.

In addition, the changes that Luca is proposing are very self-contained, and often shared with the other /dev management solutions. So I don't see a lot of additional complexity in what Luca is proposing.

Quoted 1 line

Is there any reason for NOT using devtmpfs if it is available?

Well the point is precisely that it isn't.

Quoted 3 lines

And if it isn't, is making Buildroot more complicated better than asking people to backport devtmpfs support and/or upgrade to a newer kernel?

Luca is using a vendor-specific kernel in which the entire SoC support is not in mainline. So moving to a newer kernel is simply not an option (or an option with a several man-years effort, which for many companies is the same as "not an option").

I'm not sure how complicated it is to backport devtmpfs. However I would suspect that it isn't that easy.

Quoted 1 line

We certainly don't test such old kernel headers in the autobuilders.

Indeed, we don't. But we could ask Luca, as part of this patch series, to help us add such a toolchain in our autobuilders. So far, Luca has provided some patches that are perfectly documented, along with test cases and test scripts to validate the booting with all possible /dev management situations. To me, the perfectness of Luca's contribution is a good enough argument to merge this feature :-)

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#19 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 8 lines
Quoted 2 lines

Yes, but I still question the need for all of this work in the first place.

On my side, I don't. Some people are still forced to use 2.6.x kernels older than 2.6.32, and if Luca (who is a knowledgeable and skilled developer) has such a need, I'm sure it means there is a silent group of people stuck with prehistoric kernels that would benefit from this.

Sure, I get that. I just question the sensibility of combining a 6+ year old kernel with modern user space.

Quoted 4 lines

In addition, the changes that Luca is proposing are very self-contained, and often shared with the other /dev management solutions. So I don't see a lot of additional complexity in what Luca is proposing.

I do, it is yet another slightly different variant of the /dev handling to confuse new users and complicate the build logic.

I agree that it isn't a _LOT_ of complexity, but it isn't non trivial either.

Quoted 3 lines
Quoted 1 line

Is there any reason for NOT using devtmpfs if it is available?

Well the point is precisely that it isn't.

What I meant is actually if this option is only useful for the (few?) Buildroot users with <2.6.32 kernels that want mdev support, or also for others?

Quoted 4 lines

Luca is using a vendor-specific kernel in which the entire SoC support is not in mainline. So moving to a newer kernel is simply not an option (or an option with a several man-years effort, which for many companies is the same as "not an option").

I get that.

Quoted 2 lines

I'm not sure how complicated it is to backport devtmpfs. However I would suspect that it isn't that easy.

Take a look at 2b2af54a5bb6f7e80ccf78f20084b93c398c3a8b in the kernel. To me it looks quite self contained, so backporting it to something close to 2.6.32 doesn't look too bad.

Quoted 4 lines
Quoted 1 line

We certainly don't test such old kernel headers in the autobuilders.

Indeed, we don't. But we could ask Luca, as part of this patch series, to help us add such a toolchain in our autobuilders.

I'm not sure I'm really interested in seeing a bunch of patches adding 'depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_2_6_<old>' / comments to packages.

Quoted 5 lines

So far, Luca has provided some patches that are perfectly documented, along with test cases and test scripts to validate the booting with all possible /dev management situations. To me, the perfectness of Luca's contribution is a good enough argument to merge this feature :-)

I agree, the patches themselves are very nice work!

But I still need to be convinced that adding this other mdev variant is the best tradeoff between:

- Adding the patches

- Ask people to backport devtmpfs to their kernel

- Ask people to handle it in a post-build script

- Ask people to add a initramfs mounting a tmpfs on /dev + mknod before executing init

- Asking people to stick with user space of the same "maturity" ;) as their kernel

If there's other people interested in this feature, then it would be nice to hear from you.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#20 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Hello,

Quoted 8 lines · Peter Korsgaard
Quoted 5 lines

On my side, I don't. Some people are still forced to use 2.6.x kernels older than 2.6.32, and if Luca (who is a knowledgeable and skilled developer) has such a need, I'm sure it means there is a silent group of people stuck with prehistoric kernels that would benefit from this.

Sure, I get that. I just question the sensibility of combining a 6+ year old kernel with modern user space.

Well, it is quite understandable that Luca would like to use a recent and modern Buildroot for his project. But since Buildroot is a bundle of a build infrastructure *and* package recipes, you can't get a recent and modern Buildroot without getting a recent and modern user-space.

Quoted 7 lines
Quoted 4 lines

In addition, the changes that Luca is proposing are very self-contained, and often shared with the other /dev management solutions. So I don't see a lot of additional complexity in what Luca is proposing.

I do, it is yet another slightly different variant of the /dev handling to confuse new users and complicate the build logic.

Well, the /dev handling already has a number of different options, and the user must anyway understand a little bit how a Linux system is working to make a sensible choice between the different options. The default is sane, and will remain the same, so that clueless users continue to get the same experience/result.

I don't think a new variant of /dev management is that more complicated than the "OpenMP support", "stack smashing protection support" or "LTO support" options we have in the Toolchain menu.

Quoted 2 lines

I agree that it isn't a _LOT_ of complexity, but it isn't non trivial either.

If it "isn't non trivial", then it is trivial, right ? :-)

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Is there any reason for NOT using devtmpfs if it is available?

Well the point is precisely that it isn't.

What I meant is actually if this option is only useful for the (few?) Buildroot users with <2.6.32 kernels that want mdev support, or also for others?

Yes, it is probably only for people using kernels older than 2.6.32 who need mdev for automatic module loading, or firmware loading.

There might be more users of such a thing that there are users of some of our weird packages. Admitted, a package is just a package and doesn't add any complexity to the core. But the additional complexity brought by Luca's work is relatively small. And his work has in fact uncovered a few issues in our existing code (the fact that we redirect the output of all inittab commands to /dev/null, and that some of them are in fact failing without us noticing).

Quoted 6 lines
Quoted 2 lines

I'm not sure how complicated it is to backport devtmpfs. However I would suspect that it isn't that easy.

Take a look at 2b2af54a5bb6f7e80ccf78f20084b93c398c3a8b in the kernel. To me it looks quite self contained, so backporting it to something close to 2.6.32 doesn't look too bad.

Indeed. I wonder how many dependencies on other patches it has, though. Luca, can you give it a try and see if it would work for you?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

We certainly don't test such old kernel headers in the autobuilders.

Indeed, we don't. But we could ask Luca, as part of this patch series, to help us add such a toolchain in our autobuilders.

I'm not sure I'm really interested in seeing a bunch of patches adding 'depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_2_6_<old>' / comments to packages.

Right, this I understand. We could keep the current state of things:
dependencies are only for >= 3.x kernels. So if something builds with 2.6.38 but not 2.6.32, then we don't care, and we make it depend on >= 3.x. Though I agree some people using 2.6.35 might complain, as they can technically build that thing.

Quoted 9 lines

But I still need to be convinced that adding this other mdev variant is the best tradeoff between:

- Adding the patches

- Ask people to backport devtmpfs to their kernel

- Ask people to handle it in a post-build script

Quoted 8 lines

- Ask people to add a initramfs mounting a tmpfs on /dev + mknod before executing init

- Asking people to stick with user space of the same "maturity" ;) as their kernel

If there's other people interested in this feature, then it would be nice to hear from you.

I agree getting more feedback from other potential users would be good. However, I fear that many of the people who are stuck with old crappy kernels are also in companies that are not necessarily very open, and we may simply never hear from them.

So, as suggested above, Luca, can you try to backport devtmpfs? If that solves the problem, then it's probably a good enough solution.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#21 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 7 lines
Quoted 2 lines

Sure, I get that. I just question the sensibility of combining a 6+ year old kernel with modern user space.

Well, it is quite understandable that Luca would like to use a recent and modern Buildroot for his project. But since Buildroot is a bundle of a build infrastructure *and* package recipes, you can't get a recent and modern Buildroot without getting a recent and modern user-space.

Yes, and these new packages may or may not build/work with the old kernel (and presumably toolchain).

Quoted 8 lines
Quoted 2 lines

I do, it is yet another slightly different variant of the /dev handling to confuse new users and complicate the build logic.

Well, the /dev handling already has a number of different options, and the user must anyway understand a little bit how a Linux system is working to make a sensible choice between the different options. The default is sane, and will remain the same, so that clueless users continue to get the same experience/result.

Yes, but adding one more option that is only a slight variant of one of them doesn't help.

When would we remove this option again? When 2.6.32 comes 10 years old? 15?

Quoted 4 lines
Quoted 2 lines

I agree that it isn't a _LOT_ of complexity, but it isn't non trivial either.

If it "isn't non trivial", then it is trivial, right ? :-)

Argh, the 'non' shouldn't have been there ;)

Quoted 6 lines
Quoted 3 lines

What I meant is actually if this option is only useful for the (few?) Buildroot users with <2.6.32 kernels that want mdev support, or also for others?

Yes, it is probably only for people using kernels older than 2.6.32 who need mdev for automatic module loading, or firmware loading.

And we expect that to be a significant amount of people?

Quoted 7 lines

There might be more users of such a thing that there are users of some of our weird packages. Admitted, a package is just a package and doesn't add any complexity to the core. But the additional complexity brought by Luca's work is relatively small. And his work has in fact uncovered a few issues in our existing code (the fact that we redirect the output of all inittab commands to /dev/null, and that some of them are in fact failing without us noticing).

Packages indeed very rarely add complexity elsewhere. And yes, reviewing the finer inittab details is indeed good.

Quoted 6 lines
Quoted 3 lines

Take a look at 2b2af54a5bb6f7e80ccf78f20084b93c398c3a8b in the kernel. To me it looks quite self contained, so backporting it to something close to 2.6.32 doesn't look too bad.

Indeed. I wonder how many dependencies on other patches it has, though. Luca, can you give it a try and see if it would work for you?

From a quick look (depending on how old the kernel is) I think it is basically just device_get_nodename():

commit 6fcf53acccf85b4b0d0260e66c692a341760f464

Author: Kay Sievers <[email protected]>
Date:   Thu Apr 30 15:23:42 2009 +0200

Driver Core: add nodename callbacks

This adds the nodename callback for struct class, struct device_type and struct device, to allow drivers to send userspace hints on the device name and subdirectory that should be used for it.

Quoted 9 lines
Quoted 3 lines

I'm not sure I'm really interested in seeing a bunch of patches adding 'depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_2_6_<old>' / comments to packages.

Right, this I understand. We could keep the current state of things:
dependencies are only for >= 3.x kernels. So if something builds with 2.6.38 but not 2.6.32, then we don't care, and we make it depend on >= 3.x. Though I agree some people using 2.6.35 might complain, as they can technically build that thing.

So in other words, <3.x isn't really supported.

Quoted 7 lines
Quoted 7 lines

But I still need to be convinced that adding this other mdev variant is the best tradeoff between:

- Adding the patches

- Ask people to backport devtmpfs to their kernel

Quoted 7 lines
Quoted 7 lines

- Ask people to handle it in a post-build script

- Ask people to add a initramfs mounting a tmpfs on /dev + mknod before executing init

- Asking people to stick with user space of the same "maturity" ;) as their kernel

Or alternatively, extend the S10mdev logic to detect that it need to create a tmpfs on /dev (by looking for devtmpfs in /proc/filesystems or detecting that /dev is RO) and have all the fixup there. That way it atleast doesn't add any more complications to the rest of Buildroot / users.

Quoted 10 lines
Quoted 2 lines

If there's other people interested in this feature, then it would be nice to hear from you.

I agree getting more feedback from other potential users would be good. However, I fear that many of the people who are stuck with old crappy kernels are also in companies that are not necessarily very open, and we may simply never hear from them.

So, as suggested above, Luca, can you try to backport devtmpfs? If that solves the problem, then it's probably a good enough solution.

Or alternatively, one of the other options suggested above.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#22 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 5 lines · Peter Korsgaard

Or alternatively, extend the S10mdev logic to detect that it need to create a tmpfs on /dev (by looking for devtmpfs in /proc/filesystems or detecting that /dev is RO) and have all the fixup there. That way it atleast doesn't add any more complications to the rest of Buildroot / users.

That's a great idea, because it actually simplifies the buildroot code (no
longer needed to force devtmpfs in the kernel when mdev is selected).

To detect, it's as simple as:

if [ "$(cut -d ' ' -f 2,3 /proc/mounts | sed -n '/^\/dev /s///p')" != devtmpfs ]

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle      arnout dot vandecappelle at essensium dot com
Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile)
Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#23 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Hi,

Quoted 7 lines · Peter Korsgaard
Quoted 5 lines

Or alternatively, extend the S10mdev logic to detect that it need to create a tmpfs on /dev (by looking for devtmpfs in /proc/filesystems or detecting that /dev is RO) and have all the fixup there. That way it atleast doesn't add any more complications to the rest of Buildroot / users.

Quoted 6 lines

That's a great idea, because it actually simplifies the buildroot code (no
longer needed to force devtmpfs in the kernel when mdev is selected).

To detect, it's as simple as:

if [ "$(cut -d ' ' -f 2,3 /proc/mounts | sed -n '/^\/dev /s///p')" != devtmpfs ]

Or simply 'grep -q devtmpfs /proc/filesystems'. It doesn't check if /dev is really a devtmpfs, but as we force DEVTMPFS_MOUNT=y (and the cpio init wrapper) that is probably good enough.

For mdev, I think it makes more sense to check if /dev is writable, as that is the really what mdev requires (E.G. we could be in an initramfs on a <2.6.32 kernel or similar.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#24 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Peter,

Quoted 18 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Hi,

Quoted 7 lines · Peter Korsgaard
Quoted 5 lines

Or alternatively, extend the S10mdev logic to detect that it need to create a tmpfs on /dev (by looking for devtmpfs in /proc/filesystems or detecting that /dev is RO) and have all the fixup there. That way it atleast doesn't add any more complications to the rest of Buildroot / users.

Quoted 6 lines

That's a great idea, because it actually simplifies the buildroot code (no
longer needed to force devtmpfs in the kernel when mdev is selected).

To detect, it's as simple as:

if [ "$(cut -d ' ' -f 2,3 /proc/mounts | sed -n '/^\/dev /s///p')" != devtmpfs ]

Quoted 8 lines

Or simply 'grep -q devtmpfs /proc/filesystems'. It doesn't check if /dev is really a devtmpfs, but as we force DEVTMPFS_MOUNT=y (and the cpio init wrapper) that is probably good enough.

For mdev, I think it makes more sense to check if /dev is writable, as that is the really what mdev requires (E.G. we could be in an initramfs on a <2.6.32 kernel or similar.

Theoretically correct, but having a dynamic /dev management on flash storage seems a very bad idea.

In addition, i'm not sure I can write a good test to check whether it's writable. [ -w /dev] does not consider if the filesystem is mounted read-only. Checking if "/" has the "ro" option in /proc/mounts can be done. But I'm not sure there are other possible configuration that make /dev not writable for other reasons. SELinux maybe?

Mmh, overall I think the best idea is to base mdev either on devtmpfs or on a generic tmpfs. It's more or less what Arnout's test does, except it does not take into account the case where a tmpfs (but not devtmpfs) is already mounted. But this should happen only if a user tweaks inittab to do so.

Signature · 1 line
Luca
#25 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Arnout Vandecappelle

Dear Arnout Vandecappelle,

Quoted 9 lines · Arnout Vandecappelle
Quoted 5 lines · Peter Korsgaard

Or alternatively, extend the S10mdev logic to detect that it need to create a tmpfs on /dev (by looking for devtmpfs in /proc/filesystems or detecting that /dev is RO) and have all the fixup there. That way it atleast doesn't add any more complications to the rest of Buildroot / users.

Quoted 6 lines

That's a great idea, because it actually simplifies the buildroot code (no
longer needed to force devtmpfs in the kernel when mdev is selected).

To detect, it's as simple as:

if [ "$(cut -d ' ' -f 2,3 /proc/mounts | sed -n '/^\/dev /s///p')" != devtmpfs ]

But then, who creates /dev/console when devtmpfs is not available? We have it unconditionally?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#26 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 2 lines

But then, who creates /dev/console when devtmpfs is not available? We have it unconditionally?

I would say so, especially as we also "need" it for initramfs.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#27 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Peter Korsgaard

Dear Peter,

Quoted 12 lines · Peter Korsgaard
Quoted 12 lines
Quoted 12 lines

But I still need to be convinced that adding this other mdev variant is the best tradeoff between:

- Adding the patches

- Ask people to backport devtmpfs to their kernel

- Ask people to handle it in a post-build script

- Ask people to add a initramfs mounting a tmpfs on /dev + mknod before executing init

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

- Asking people to stick with user space of the same "maturity" ;) as their kernel

Or alternatively, extend the S10mdev logic to detect that it need to create a tmpfs on /dev (by looking for devtmpfs in /proc/filesystems or detecting that /dev is RO) and have all the fixup there. That way it atleast doesn't add any more complications to the rest of Buildroot / users.

Indeed another interesting option. I'll consider it, thanks.

Signature · 1 line
Luca
#28 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Peter Korsgaard

Dear Peter,

Peter Korsgaard wrote:
[...]

Quoted 16 lines
Quoted 6 lines
Quoted 3 lines

Take a look at 2b2af54a5bb6f7e80ccf78f20084b93c398c3a8b in the kernel. To me it looks quite self contained, so backporting it to something close to 2.6.32 doesn't look too bad.

Indeed. I wonder how many dependencies on other patches it has, though. Luca, can you give it a try and see if it would work for you?

From a quick look (depending on how old the kernel is) I think it is
basically just device_get_nodename():

commit 6fcf53acccf85b4b0d0260e66c692a341760f464

Author: Kay Sievers <[email protected]>
Date:   Thu Apr 30 15:23:42 2009 +0200

Driver Core: add nodename callbacks

Quoted 7 lines

This adds the nodename callback for struct class, struct device_type and struct device, to allow drivers to send userspace hints on the device name and subdirectory that should be used for it.

Wow, it works! Well, at least it boots, I haven't tested everything, but it was far simpler that I suspected. Thanks for the hint!

Signature · 1 line
Luca
#29 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Hi,

Quoted 10 lines
Quoted 7 lines

This adds the nodename callback for struct class, struct device_type and struct device, to allow drivers to send userspace hints on the device name and subdirectory that should be used for it.

Wow, it works! Well, at least it boots, I haven't tested everything, but it was far simpler that I suspected. Thanks for the hint!

Wee, that's good to hear!

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#30 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Peter Korsgaard

Dear Peter, Thomas,

Quoted 7 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

Yes, but I still question the need for all of this work in the first place.

Quoted 8 lines
Quoted 5 lines

On my side, I don't. Some people are still forced to use 2.6.x kernels older than 2.6.32, and if Luca (who is a knowledgeable and skilled developer) has such a need, I'm sure it means there is a silent group of people stuck with prehistoric kernels that would benefit from this.

Sure, I get that. I just question the sensibility of combining a 6+ year old kernel with modern user space.

I agree with you on the principle, but in the practice I have devices running very fine on 2.6.30 and some user space applications using C++11. Yes, I used a fairly recent toolchain (gcc 4.8 IIRC), which is of course a bad idea, I know... But in the practice it works. I had to spend a little time to check some packages that try to use kernel features not available in the running kernel. IIRC I only had issues with dhcpcd which tends to use recently-introduced syscalls. Other packaged run without problems.

Quoted 7 lines
Quoted 6 lines

In addition, the changes that Luca is proposing are very self-contained, and often shared with the other /dev management solutions. So I don't see a lot of additional complexity in what Luca is proposing.

Quoted 5 lines

I do, it is yet another slightly different variant of the /dev handling to confuse new users and complicate the build logic.

I agree that it isn't a _LOT_ of complexity, but it isn't non trivial either.

FWIW, it's even less complex in the v2 patchset that's half-brewed here.

Quoted 6 lines
Quoted 2 lines

I'm not sure how complicated it is to backport devtmpfs. However I would suspect that it isn't that easy.

Take a look at 2b2af54a5bb6f7e80ccf78f20084b93c398c3a8b in the kernel. To me it looks quite self contained, so backporting it to something close to 2.6.32 doesn't look too bad.

I think I had a look a couple of years ago when I did the first project on the same SoC. I think I had a look and found it non trival, but the product to create had no hotplugging capabilities and no firmware loading needs, so I just went for a static /dev.

Now I have a real goal, so I might try harder to look into backporting devtmpfs.

Quoted 7 lines
Quoted 5 lines

So far, Luca has provided some patches that are perfectly documented, along with test cases and test scripts to validate the booting with all possible /dev management situations. To me, the perfectness of Luca's contribution is a good enough argument to merge this feature :-)

I agree, the patches themselves are very nice work!

Thanks both! :)

Signature · 1 line
Luca
#31 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Hi,

Quoted 6 lines
Quoted 2 lines

Sure, I get that. I just question the sensibility of combining a 6+ year old kernel with modern user space.

I agree with you on the principle, but in the practice I have devices running very fine on 2.6.30 and some user space applications using C++11.

Ok, and are you actively doing system level development, or "just" adjusting a single application on a mature product? E.G. are you interested in getting the latest versions of all the libraries or rather freeze the entire system except for your application?

Quoted 2 lines

Yes, I used a fairly recent toolchain (gcc 4.8 IIRC), which is of course a bad idea, I know... But in the practice it works.

Then you presumably already had to backport kernel fixes to build with 4.8? E.G. I've worked on a system stuck on 2.6.37 where I had to backport this to get it to run with gcc 4.7+:

commit 8428e84d42179c2a00f5f6450866e70d802d1d05

Author: Catalin Marinas <[email protected]>
Date:   Mon Nov 7 18:05:53 2011 +0100

ARM: 7150/1: Allow kernel unaligned accesses on ARMv6+ processors

Recent gcc versions generate unaligned accesses by default on ARMv6 and later processors. This patch ensures that the SCTLR.A bit is always cleared on such processors to avoid kernel traping before alignment_init() is called.

Quoted 4 lines

I had to spend a little time to check some packages that try to use kernel features not available in the running kernel. IIRC I only had issues with dhcpcd which tends to use recently-introduced syscalls. Other packaged run without problems.

I've personally had issues with network-manager (and dhcpcd like you said) as well.

Quoted 4 lines
Quoted 2 lines

I agree that it isn't a _LOT_ of complexity, but it isn't non trivial either.

FWIW, it's even less complex in the v2 patchset that's half-brewed here.

True.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

I'm not sure how complicated it is to backport devtmpfs. However I would suspect that it isn't that easy.

Take a look at 2b2af54a5bb6f7e80ccf78f20084b93c398c3a8b in the kernel. To me it looks quite self contained, so backporting it to something close to 2.6.32 doesn't look too bad.

Quoted 7 lines

I think I had a look a couple of years ago when I did the first project on the same SoC. I think I had a look and found it non trival, but the product to create had no hotplugging capabilities and no firmware loading needs, so I just went for a static /dev.

Now I have a real goal, so I might try harder to look into backporting devtmpfs.

It seems doable to backport devtmpfs support to 2.6.30.

I just tried cherry-picking 6fcf53acccf85b4 + 2b2af54a5bb6f7e80ccf7 and I only get a trivial conflict about some header files getting added to init/main.c

To give it a quick test I tweaked our qemu_x86_defconfig to build 2.6.30
+ the two backports and booted it:

Welcome to Buildroot
buildroot login: root

# uname -a
Linux buildroot 2.6.30-00193-g9a8d49a #3 Wed Sep 16 09:27:23 CEST 2015 i686 GNU/Linux
# grep devtmpfs /proc/mounts 
devtmpfs /dev devtmpfs rw,size=63272k,nr_inodes=15818 0 0

(I did have to fix the kernel a bit to get it to build with sourcery codebench 2011.09, E.G. gcc 4.6.1 - But that was just s/-m elf_x86/-m32/)

Quoted 3 lines
Quoted 1 line

I agree, the patches themselves are very nice work!

Thanks both! :)

You're welcome.

Signature · 2 lines
Venlig hilsen,
Peter Korsgaard 
#32 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Peter,

Quoted 7 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

Sure, I get that. I just question the sensibility of combining a 6+ year old kernel with modern user space.

Quoted 8 lines
Quoted 3 lines

I agree with you on the principle, but in the practice I have devices running very fine on 2.6.30 and some user space applications using C++11.

Ok, and are you actively doing system level development, or "just" adjusting a single application on a mature product? E.G. are you interested in getting the latest versions of all the libraries or rather freeze the entire system except for your application?

I work both on new products and on mature products. But the latter receive consistent updates at times, which might add a lot more packages or change the dependencies.

In both cases I want a recent a fairly recent set of packages.

A few months ago I had to bump a library to a version that was not yet stable at that time, and thus not yet in Buildroot, because it implemented a method that we needed in an application.

Quoted 6 lines
Quoted 2 lines

Yes, I used a fairly recent toolchain (gcc 4.8 IIRC), which is of course a bad idea, I know... But in the practice it works.

Then you presumably already had to backport kernel fixes to build with 4.8? E.G. I've worked on a system stuck on 2.6.37 where I had to backport this to get it to run with gcc 4.7+:

Nope. Maybe because I'm currently working mostly on ARM9 machines, and ARM9 is definitely "mature".

However I had to forced an "old" Sourcery toolchain (2013.05) for an ARM9 project because I was getting mysterious runtime errors with 2014.05, the latest available in BR at that time.

Quoted 26 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

I'm not sure how complicated it is to backport devtmpfs. However I would suspect that it isn't that easy.

Take a look at 2b2af54a5bb6f7e80ccf78f20084b93c398c3a8b in the kernel. To me it looks quite self contained, so backporting it to something close to 2.6.32 doesn't look too bad.

Quoted 7 lines

I think I had a look a couple of years ago when I did the first project on the same SoC. I think I had a look and found it non trival, but the product to create had no hotplugging capabilities and no firmware loading needs, so I just went for a static /dev.

Now I have a real goal, so I might try harder to look into backporting devtmpfs.

It seems doable to backport devtmpfs support to 2.6.30.

I just tried cherry-picking 6fcf53acccf85b4 + 2b2af54a5bb6f7e80ccf7 and I only get a trivial conflict about some header files getting added to init/main.c

To give it a quick test I tweaked our qemu_x86_defconfig to build 2.6.30
+ the two backports and booted it:

Welcome to Buildroot
buildroot login: root

Quoted 7 lines
# uname -a
Linux buildroot 2.6.30-00193-g9a8d49a #3 Wed Sep 16 09:27:23 CEST 2015 i686 GNU/Linux
# grep devtmpfs /proc/mounts
devtmpfs /dev devtmpfs rw,size=63272k,nr_inodes=15818 0 0

(I did have to fix the kernel a bit to get it to build with sourcery codebench 2011.09, E.G. gcc 4.6.1 - But that was just s/-m elf_x86/-m32/)

Interesting. I'll have a look... sometime.

Signature · 1 line
Luca
#33 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Luca Ceresoli
Quoted 3 lines · Luca Ceresoli

First, we need the BR2_ROOTFS_STATIC_DEVICE_TABLE just like the static /dev management, in order to have the very basic devices such as /dev/null and /dev/console until mdev is enabled.

Actually, I don't think this is a good idea: we're asking the user to configure
a static device table which is not going to be used anyway.

I think it's better to move /dev/null and /dev/console to device_table.txt -
i.e., include them in every rootfs. It just increases the size with a few hundred bytes, it doesn't hurt because devtmpfs is normally automounted over it right away, and it is better for the cpio/initramfs case because you won't get the 'Unable to open initial console' message anymore (I think). Plus, the redirects can be removed from fs/cpio/init since they'll be automatic.

What do the other developers think?

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#34 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Arnout, Luca,

Quoted 8 lines · Arnout Vandecappelle
Quoted 3 lines · Luca Ceresoli

First, we need the BR2_ROOTFS_STATIC_DEVICE_TABLE just like the static /dev management, in order to have the very basic devices such as /dev/null and /dev/console until mdev is enabled.

Actually, I don't think this is a good idea: we're asking the user to configure
a static device table which is not going to be used anyway.

Quoted 8 lines

I think it's better to move /dev/null and /dev/console to device_table.txt -
i.e., include them in every rootfs. It just increases the size with a few hundred bytes, it doesn't hurt because devtmpfs is normally automounted over it right away, and it is better for the cpio/initramfs case because you won't get the 'Unable to open initial console' message anymore (I think). Plus, the redirects can be removed from fs/cpio/init since they'll be automatic.

What do the other developers think?

I would prefer to keep /dev/null and /dev/console in a special device table, used only for the mdev without devtmpfs case, but not make it configurable.

So, I would actually not make the option BR2_ROOTFS_STATIC_DEVICE_TABLE visible for the BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY case, and instead force using a minimal, hard-coded, device table in this case. There is no reason whatsoever to have anything else but /dev/null and /dev/zero in the mdev without devtmpfs case.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#35 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Luca Ceresoli

Luca,

Quoted 10 lines · Luca Ceresoli

There are a few reasons for an embedded Linux system not to use devtmpfs, but still want to have dynamic /dev management. The most notable is to use a kernel < 2.6.32, which have no devtmpfs support.

For such corner cases, we introduce the ability to use busybox mdev for /dev management even without devtmpfs.

First, we need the BR2_ROOTFS_STATIC_DEVICE_TABLE just like the static /dev management, in order to have the very basic devices such as /dev/null and /dev/console until mdev is enabled.

As said in another e-mail, this is not really true: we just need a very simple, two devices long, hard-coded device table. There is no need to allow the user to customize it. It would in fact be potentially misleading because the user who would add more devices in this static device table would not see them on the target: they would be "overridden" by the tmpfs mounted in /dev.

Quoted 7 lines

But doing this in S10mdev, which already does something similar, would be a bit complex because when S10mdev runs /dev/shm and /dev/pts are already mounted. We might unmount, recreate and mount them again, but devices in them might be already in use. Or we could leave the "old" alone, and mount them again in the newly created /dev. Both solutions are dirty and potentially problematic.

Quoted 6 lines

Instead we hook in inittab (both busybox and sysvinit) and do the same incantations there, right after mounting /sys (needed for mdev) but before any other actions on /dev, such as creating and mounting /dev/shm and /dev/pts. We also skip installing S10mdev: it would do the same things twice. In order to keep the inittab files concise and maintainable, this taks is delegated to a helper script, /sbin/activate-mdev.

taks -> task

One thing I dislike a bit is that there is quite a bit overlap between S10mdev and activate-mdev. As Arnout suggested, can you just mount a tmpfs in /dev in the inittab in the "mdev without devtmpfs" case, and then keep the normal S10mdev script?

Quoted 10 lines
package/busybox/busybox.mk +1 -0
index 6e302f4..f95ff52 100644
@@ -55,11 +55,18 @@ define BUSYBOX_PERMISSIONS
 endef
 
 # If mdev will be used for device creation enable it and copy S10mdev to /etc/init.d
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV)$(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY),y)
 ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)

package/busybox/busybox.mk define BUSYBOX_PERMISSIONS · line 69

Quoted 10 lines
package/busybox/busybox.mk +6 -0
 define BUSYBOX_INSTALL_MDEV_SCRIPT
 	$(INSTALL) -D -m 0755 package/busybox/S10mdev \
 		$(TARGET_DIR)/etc/init.d/S10mdev
 endef
+else
+define BUSYBOX_INSTALL_MDEV_SCRIPT
+	$(INSTALL) -D -m 0755 package/busybox/activate-mdev \
+		$(TARGET_DIR)/sbin/activate-mdev
+endef
+endif

Any reason to enclose the internal condition inside a bigger condition?

(Of course, this becomes moot if we can use S10mdev in both cases)

package/skeleton/skeleton.mk TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_GETTY · line 144

Quoted 9 lines
package/skeleton/skeleton.mk +1 -0
index 48e7085..975e2a5 100644
@@ -141,6 +141,7 @@ TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_GETTY
 endif
 
 ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y)
+

Not really related to the change.

Quoted 64 lines
package/skeleton/skeleton.mk +14 -0
 ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
 # Find commented line, if any, and remove leading '#'s
 define SKELETON_SYSTEM_REMOUNT_RW
@@ -153,6 +154,20 @@ define SKELETON_SYSTEM_REMOUNT_RW
 endef
 endif
 TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_REMOUNT_RW
+
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY),y)
+# Find commented line, if any, and remove leading '#'s
+define SKELETON_SYSTEM_EARLY_MDEV
+	$(SED) '/^#.*sbin\/activate-mdev$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
+endef
+else
+# Find uncommented line, if any, and add a leading '#'
+define SKELETON_SYSTEM_EARLY_MDEV
+	$(SED) '/^[^#].*sbin\/activate-mdev$$/s~^~#~' $(TARGET_DIR)/etc/inittab
+endef
+endif
+TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_EARLY_MDEV
+
 endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
package/sysvinit/inittab +7 -6
index 6ebf6fa..5abca7f 100644
@@ -6,12 +6,13 @@ id:3:initdefault:
 
 si0::sysinit:/bin/mount -t proc proc /proc
 si1::sysinit:/bin/mount -t sysfs sysfs /sys
-si2::sysinit:/bin/mount -o remount,rw /
-si3::sysinit:/bin/mkdir -p /dev/pts
-si4::sysinit:/bin/mkdir -p /dev/shm
-si5::sysinit:/bin/mount -a
-si6::sysinit:/bin/hostname -F /etc/hostname
-si7::sysinit:/etc/init.d/rcS
+si2::sysinit:/sbin/activate-mdev
+si3::sysinit:/bin/mount -o remount,rw /
+si4::sysinit:/bin/mkdir -p /dev/pts
+si5::sysinit:/bin/mkdir -p /dev/shm
+si6::sysinit:/bin/mount -a
+si7::sysinit:/bin/hostname -F /etc/hostname
+si8::sysinit:/etc/init.d/rcS
 
 # S0:1:respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
 
system/Config.in +4 -0
index 5bf5048..a10de1e 100644
@@ -106,6 +106,10 @@ choice
 config BR2_ROOTFS_DEVICE_CREATION_STATIC
 	bool "Static using device table"
 
+config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY
+	bool "Dynamic using mdev only"
+	select BR2_PACKAGE_BUSYBOX
+
 config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS
 	bool "Dynamic using devtmpfs only"
 

system/Config.in config BR2_ROOTFS_DEVICE_TABLE · line 151

Quoted 5 lines
system/Config.in +1 -1
@@ -144,7 +148,7 @@ config BR2_ROOTFS_DEVICE_TABLE
 config BR2_ROOTFS_STATIC_DEVICE_TABLE
 	string "Path to the device tables"
 	default "system/device_table_dev.txt"
-	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC
+	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC || BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY

As suggested above, we probably don't want to show this option in the BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY case.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#36 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 14 lines · Thomas Petazzoni

Luca,

Quoted 10 lines · Luca Ceresoli

There are a few reasons for an embedded Linux system not to use devtmpfs, but still want to have dynamic /dev management. The most notable is to use a kernel < 2.6.32, which have no devtmpfs support.

For such corner cases, we introduce the ability to use busybox mdev for /dev management even without devtmpfs.

First, we need the BR2_ROOTFS_STATIC_DEVICE_TABLE just like the static /dev management, in order to have the very basic devices such as /dev/null and /dev/console until mdev is enabled.

Quoted 6 lines

As said in another e-mail, this is not really true: we just need a very simple, two devices long, hard-coded device table. There is no need to allow the user to customize it. It would in fact be potentially misleading because the user who would add more devices in this static device table would not see them on the target: they would be "overridden" by the tmpfs mounted in /dev.

Right! So:

define BUSYBOX_DEVICES

	/dev/console c 666 0 0 5 1 - - -
	/dev/null c 666 0 0 1 3 0 0 -

endef

Regards,
Arnout

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#37 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Arnout,

Quoted 22 lines · Arnout Vandecappelle
Quoted 14 lines · Thomas Petazzoni

Luca,

Quoted 10 lines · Luca Ceresoli

There are a few reasons for an embedded Linux system not to use devtmpfs, but still want to have dynamic /dev management. The most notable is to use a kernel < 2.6.32, which have no devtmpfs support.

For such corner cases, we introduce the ability to use busybox mdev for /dev management even without devtmpfs.

First, we need the BR2_ROOTFS_STATIC_DEVICE_TABLE just like the static /dev management, in order to have the very basic devices such as /dev/null and /dev/console until mdev is enabled.

Quoted 6 lines

As said in another e-mail, this is not really true: we just need a very simple, two devices long, hard-coded device table. There is no need to allow the user to customize it. It would in fact be potentially misleading because the user who would add more devices in this static device table would not see them on the target: they would be "overridden" by the tmpfs mounted in /dev.

Quoted 6 lines

Right! So:

define BUSYBOX_DEVICES

	/dev/console c 666 0 0 5 1 - - -
	/dev/null c 666 0 0 1 3 0 0 -

endef

Good idea, this saves creating a new device table.

Signature · 1 line
Luca
#38 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

In reply to Thomas Petazzoni

Dear Thomas,

Quoted 14 lines · Thomas Petazzoni

Luca,

Quoted 10 lines · Luca Ceresoli

There are a few reasons for an embedded Linux system not to use devtmpfs, but still want to have dynamic /dev management. The most notable is to use a kernel < 2.6.32, which have no devtmpfs support.

For such corner cases, we introduce the ability to use busybox mdev for /dev management even without devtmpfs.

First, we need the BR2_ROOTFS_STATIC_DEVICE_TABLE just like the static /dev management, in order to have the very basic devices such as /dev/null and /dev/console until mdev is enabled.

Quoted 6 lines

As said in another e-mail, this is not really true: we just need a very simple, two devices long, hard-coded device table. There is no need to allow the user to customize it. It would in fact be potentially misleading because the user who would add more devices in this static device table would not see them on the target: they would be "overridden" by the tmpfs mounted in /dev.

Yup, I did that in patch 4.

But now I removed that patch, and replaced with a different implementation based on Arnout's suggestion of using BUSYBOX_DEVICES.

Quoted 8 lines
Quoted 8 lines

But doing this in S10mdev, which already does something similar, would be a bit complex because when S10mdev runs /dev/shm and /dev/pts are already mounted. We might unmount, recreate and mount them again, but devices in them might be already in use. Or we could leave the "old" alone, and mount them again in the newly created /dev. Both solutions are dirty and potentially problematic.

Quoted 8 lines
Quoted 6 lines

Instead we hook in inittab (both busybox and sysvinit) and do the same incantations there, right after mounting /sys (needed for mdev) but before any other actions on /dev, such as creating and mounting /dev/shm and /dev/pts. We also skip installing S10mdev: it would do the same things twice. In order to keep the inittab files concise and maintainable, this taks is delegated to a helper script, /sbin/activate-mdev.

taks -> task

Sure.

Quoted 5 lines

One thing I dislike a bit is that there is quite a bit overlap between S10mdev and activate-mdev. As Arnout suggested, can you just mount a tmpfs in /dev in the inittab in the "mdev without devtmpfs" case, and then keep the normal S10mdev script?

v2 will do things this way.

Quoted 24 lines
Quoted 11 lines
package/busybox/busybox.mk +1 -0
index 6e302f4..f95ff52 100644
@@ -55,11 +55,18 @@ define BUSYBOX_PERMISSIONS
  endef
 
  # If mdev will be used for device creation enable it and copy S10mdev to /etc/init.d
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV)$(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY),y)
  ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)

package/busybox/busybox.mk define BUSYBOX_PERMISSIONS · line 69

Quoted 10 lines
package/busybox/busybox.mk +6 -0
  define BUSYBOX_INSTALL_MDEV_SCRIPT
  	$(INSTALL) -D -m 0755 package/busybox/S10mdev \
  		$(TARGET_DIR)/etc/init.d/S10mdev
  endef
+else
+define BUSYBOX_INSTALL_MDEV_SCRIPT
+	$(INSTALL) -D -m 0755 package/busybox/activate-mdev \
+		$(TARGET_DIR)/sbin/activate-mdev
+endef
+endif

Any reason to enclose the internal condition inside a bigger condition?

Quoted 1 line

(Of course, this becomes moot if we can use S10mdev in both cases)

Indeed, I removed entirely that script in the next iteration.

Quoted 8 lines
Quoted 8 lines
package/skeleton/skeleton.mk +0 -0
index 48e7085..975e2a5 100644
@@ -141,6 +141,7 @@ TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_GETTY
  endif
 
Quoted 4 lines

package/skeleton/skeleton.mk TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_GETTY · line 144

Quoted 2 lines
package/skeleton/skeleton.mk +1 -0
  ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y)
+

Not really related to the change.

I just wanted to highlight the two main blocks inside that ifeq:
[un]commenting read-write mount and [un]commenting the mdev line. The code there is lengthy and not very readable IMHO. But ok, removed that.

Quoted 15 lines
Quoted 15 lines
system/Config.in +4 -0
index 5bf5048..a10de1e 100644
@@ -106,6 +106,10 @@ choice
  config BR2_ROOTFS_DEVICE_CREATION_STATIC
  	bool "Static using device table"
 
+config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY
+	bool "Dynamic using mdev only"
+	select BR2_PACKAGE_BUSYBOX
+
  config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS
  	bool "Dynamic using devtmpfs only"
 
Quoted 9 lines

system/Config.in config BR2_ROOTFS_DEVICE_TABLE · line 151

Quoted 6 lines
system/Config.in +1 -1
@@ -144,7 +148,7 @@ config BR2_ROOTFS_DEVICE_TABLE
  config BR2_ROOTFS_STATIC_DEVICE_TABLE
  	string "Path to the device tables"
  	default "system/device_table_dev.txt"
-	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC
+	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC || BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY

As suggested above, we probably don't want to show this option in the BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY case.

That's not present in v2.

Signature · 1 line
Luca
#39 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Luca Ceresoli,

Quoted 2 lines · Luca Ceresoli

But now I removed that patch, and replaced with a different implementation based on Arnout's suggestion of using BUSYBOX_DEVICES.

I am not sure using BUSYBOX_DEVICES is fully correct. The reason why /dev/console is needed is *not* because of Busybox, but because of the kernel that is opening /dev/console before handing control over to the init application:

http://lxr.free-electrons.com/source/init/main.c#L1011

If you do BUSYBOX_DEVICES with just /dev/console, then you will also need a SYSVINIT_DEVICES with just /dev/console.

Though I admit my comment here is mainly nitpicking :)

Quoted 6 lines
Quoted 4 lines

One thing I dislike a bit is that there is quite a bit overlap between S10mdev and activate-mdev. As Arnout suggested, can you just mount a tmpfs in /dev in the inittab in the "mdev without devtmpfs" case, and then keep the normal S10mdev script?

v2 will do things this way.

Great!

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#40 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Quoted 12 lines · Thomas Petazzoni

Dear Luca Ceresoli,

Quoted 2 lines · Luca Ceresoli

But now I removed that patch, and replaced with a different implementation based on Arnout's suggestion of using BUSYBOX_DEVICES.

I am not sure using BUSYBOX_DEVICES is fully correct. The reason why /dev/console is needed is *not* because of Busybox, but because of the kernel that is opening /dev/console before handing control over to the init application:

Quoted 6 lines

http://lxr.free-electrons.com/source/init/main.c#L1011

If you do BUSYBOX_DEVICES with just /dev/console, then you will also need a SYSVINIT_DEVICES with just /dev/console.

Though I admit my comment here is mainly nitpicking :)

But of course you are right. This is part of the system/skeleton handling, and
now skeleton is a package, we can make it part of SKELETON_DEVICES.

Regards,
Arnout

Quoted 14 lines
Quoted 7 lines
Quoted 5 lines

One thing I dislike a bit is that there is quite a bit overlap between S10mdev and activate-mdev. As Arnout suggested, can you just mount a tmpfs in /dev in the inittab in the "mdev without devtmpfs" case, and then keep the normal S10mdev script?

v2 will do things this way.

Great!

Thanks!

Thomas

Signature · 6 lines
Arnout Vandecappelle      arnout dot vandecappelle at essensium dot com
Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile)
Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#41 lore raw

RFC 3/6 system: add mdev-only /dev management (without devtmpfs)

Dear Arnout, Thomas,

Quoted 17 lines · Arnout Vandecappelle
Quoted 14 lines · Thomas Petazzoni

Dear Luca Ceresoli,

Quoted 2 lines · Luca Ceresoli

But now I removed that patch, and replaced with a different implementation based on Arnout's suggestion of using BUSYBOX_DEVICES.

I am not sure using BUSYBOX_DEVICES is fully correct. The reason why /dev/console is needed is *not* because of Busybox, but because of the kernel that is opening /dev/console before handing control over to the init application:

   http://lxr.free-electrons.com/source/init/main.c#L1011
Quoted 7 lines
Quoted 4 lines

If you do BUSYBOX_DEVICES with just /dev/console, then you will also need a SYSVINIT_DEVICES with just /dev/console.

Though I admit my comment here is mainly nitpicking :)

But of course you are right. This is part of the system/skeleton handling, and
now skeleton is a package, we can make it part of SKELETON_DEVICES.

Aah, yes, indeed! Thanks both.

Signature · 1 line
Luca
#42 lore raw

RFC 4/6 system: strip the initial /dev for mdev-only /dev management

In reply to Luca Ceresoli

When using mdev-only /dev management a static device table is needed before mdev is activated. This is used only for a very short time and then replaced by the dymanic table managen by mdev, so it should be very minimalistic.

But the current default, system/device_table_dev.txt, contains way too many devices that are useless in this contex.

Replace it with a very minimal table.

---
 system/Config.in                      |  1 +
 system/device_table_dev_mdev_only.txt | 10 ++++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 system/device_table_dev_mdev_only.txt
system/Config.in +1 -0
index a10de1e..48558b1 100644
@@ -147,6 +147,7 @@ config BR2_ROOTFS_DEVICE_TABLE
 
 config BR2_ROOTFS_STATIC_DEVICE_TABLE
 	string "Path to the device tables"
+	default "system/device_table_dev_mdev_only.txt" if BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY
 	default "system/device_table_dev.txt"
 	depends on BR2_ROOTFS_DEVICE_CREATION_STATIC || BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY
 	help
system/device_table_dev_mdev_only.txt new file +10 -0
new file mode 100644
index 0000000..477aaea
@@ -0,0 +1,10 @@
+# See package/makedevs/README for details
+#
+# This device table is used only to create device files when a static
+# device configuration is used (entries in /dev are static).
+#
+# <name>	<type>	<mode>	<uid>	<gid>	<major>	<minor>	<start>	<inc>	<count>
+
+# Normal system devices
+/dev/null	c	666	0	0	1	3	0	0	-
+/dev/console	c	666	0	0	5	1	-	-	-
Signature · 1 line
1.9.1
#43 lore raw

RFC 5/6 docs/manual: document "Dynamic using mdev only" /dev management

In reply to Luca Ceresoli
---
 docs/manual/configure.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
docs/manual/configure.txt +11 -0
index 997be2b..ea78d96 100644
@@ -324,6 +324,17 @@ different solutions to handle the +/dev+ directory :
    daemon used in most desktop Linux distributions, which is now part
    of Systemd. For more details, see http://en.wikipedia.org/wiki/Udev.
 
+ * *Dynamic using mdev only* uses +mdev+ and allows to use all the
+   features of +mdev+, including dynamic device creation and firmware
+   handling, but does not use _devtmpfs_.
+   If you have to use a kernel older than 2.6.32 this is the only
+   option to have dynamic /dev management, although it can be used
+   with more recent versions of the kernel as well.
+   If you build your Linux kernel outside of Buildroot, you should
+   disable +CONFIG_DEVTMPFS+ and +CONFIG_DEVTMPFS_MOUNT+ in your kernel
+   configuration. When Buildroot is in charge of building the Linux
+   kernel, it disables them automatically.
+
 The Buildroot developers recommendation is to start with the *Dynamic
 using devtmpfs only* solution, until you have the need for userspace
 to be notified when devices are added/removed, or if firmwares are
Signature · 1 line
1.9.1
#44 lore raw

RFC 5/6 docs/manual: document "Dynamic using mdev only" /dev management

Hi Luca,

docs/manual/configure.txt different solutions to handle the +/dev+ directory : · line 326

Quoted 13 lines · Luca Ceresoli
---
 docs/manual/configure.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
docs/manual/configure.txt +0 -0
index 997be2b..ea78d96 100644
@@ -324,6 +324,17 @@ different solutions to handle the +/dev+ directory :
    daemon used in most desktop Linux distributions, which is now part
    of Systemd. For more details, see http://en.wikipedia.org/wiki/Udev.
 

For consistency with the way it's ordered in menuconfig, I'd move the new
bullet point to the second place in the list. That does mean you have to update all the second, third, fourth bullets but that's no biggy I guess.

docs/manual/configure.txt different solutions to handle the +/dev+ directory : · line 329

Quoted 3 lines
docs/manual/configure.txt +3 -0
+ * *Dynamic using mdev only* uses +mdev+ and allows to use all the
+   features of +mdev+, including dynamic device creation and firmware
+   handling, but does not use _devtmpfs_.

If you move it as the second bullet, the explanation about mdev should be moved
to here as well. So I propose the following rephrased bullet point (which includes a bunch of minor fixes to the text):

* The second solution is *Dynamic using mdev only*. +mdev+ is a helper program that is part of BusyBox. The kernel will call it every time a device is added or removed, and +mdev+ will create the appropriate device node in +/dev+. Thanks to the +/etc/mdev.conf+ configuration file, +mdev+ can be configured to, for example, set specific permissions or ownership on a device file, call a script or application whenever a device appears or disappears, etc. Basically, it allows _userspace_ to react on device addition and removal events. +mdev+ can for example be used to automatically load kernel modules when devices appear on the system. +mdev+ is also important if you have devices that require a firmware blob to be loaded: it will be responsible for pushing the firmware contents to the kernel. +mdev+ is a lightweight implementation (with fewer features) of +udev+. For more details about +mdev+ and the syntax of its configuration file, see
http://git.busybox.net/busybox/tree/docs/mdev.txt.
+
If you have to use a kernel older than 2.6.32, this is the only option to have dynamic +/dev+ management, although it can be used with more recent versions of the kernel as well. If you build your Linux kernel outside of Buildroot, you should disable +CONFIG_DEVTMPFS+ and +CONFIG_DEVTMPFS_MOUNT+ in your kernel configuration. When Buildroot is in charge of building the Linux kernel, it disables them automatically.

Clearly, if you take this proposal, also the devtmpfs+mdev option has to be
updated a little to avoid duplication.

Regards,
Arnout

Quoted 12 lines
docs/manual/configure.txt +8 -0
+   If you have to use a kernel older than 2.6.32 this is the only
+   option to have dynamic /dev management, although it can be used
+   with more recent versions of the kernel as well.
+   If you build your Linux kernel outside of Buildroot, you should
+   disable +CONFIG_DEVTMPFS+ and +CONFIG_DEVTMPFS_MOUNT+ in your kernel
+   configuration. When Buildroot is in charge of building the Linux
+   kernel, it disables them automatically.
+
 The Buildroot developers recommendation is to start with the *Dynamic
 using devtmpfs only* solution, until you have the need for userspace
 to be notified when devices are added/removed, or if firmwares are
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#45 lore raw

RFC 6/6 **** DO NOT COMMIT THIS **** ugly stuff to test mdev-only /dev management

In reply to Luca Ceresoli

2 init systems (busybox, sysvinit) x 5 /dev management = 10 defconfigs. All based on qemu_arm_versatile_defconfig + external toolchain + read-only rootfs (to test in the worst possible conditions).

To run-test one:
./run <your_output_dir> (default "output/")

To build- and run-test all:
./test-all build
./test-all run

Not-signed-off-by: anybody

---
 .gitignore                             |  1 +
 configs/test_bb_dyn_devtmpfs_defconfig | 12 ++++++++++++
 configs/test_bb_dyn_eudev_defconfig    | 13 +++++++++++++
 configs/test_bb_dyn_mdev_defconfig     | 13 +++++++++++++
 configs/test_bb_mdev_only_defconfig    | 13 +++++++++++++
 configs/test_bb_static_defconfig       | 13 +++++++++++++
 configs/test_sv_dyn_devtmpfs_defconfig | 13 +++++++++++++
 configs/test_sv_dyn_eudev_defconfig    | 14 ++++++++++++++
 configs/test_sv_dyn_mdev_defconfig     | 14 ++++++++++++++
 configs/test_sv_mdev_only_defconfig    | 14 ++++++++++++++
 configs/test_sv_static_defconfig       | 14 ++++++++++++++
 run                                    | 12 ++++++++++++
 test-all                               | 34 ++++++++++++++++++++++++++++++++++
 13 files changed, 180 insertions(+)
 create mode 100644 configs/test_bb_dyn_devtmpfs_defconfig
 create mode 100644 configs/test_bb_dyn_eudev_defconfig
 create mode 100644 configs/test_bb_dyn_mdev_defconfig
 create mode 100644 configs/test_bb_mdev_only_defconfig
 create mode 100644 configs/test_bb_static_defconfig
 create mode 100644 configs/test_sv_dyn_devtmpfs_defconfig
 create mode 100644 configs/test_sv_dyn_eudev_defconfig
 create mode 100644 configs/test_sv_dyn_mdev_defconfig
 create mode 100644 configs/test_sv_mdev_only_defconfig
 create mode 100644 configs/test_sv_static_defconfig
 create mode 100755 run
 create mode 100755 test-all
.gitignore +1 -0
index bb02d9f..9f335cc 100644
@@ -13,3 +13,4 @@
 *.rej
 *~
 *.pyc
+bld
configs/test_bb_dyn_devtmpfs_defconfig new file +12 -0
new file mode 100644
index 0000000..fdddb63
@@ -0,0 +1,12 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_bb_dyn_eudev_defconfig new file +13 -0
new file mode 100644
index 0000000..bb07e99
@@ -0,0 +1,13 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_bb_dyn_mdev_defconfig new file +13 -0
new file mode 100644
index 0000000..5f6a715
@@ -0,0 +1,13 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_bb_mdev_only_defconfig new file +13 -0
new file mode 100644
index 0000000..e2e7ec8
@@ -0,0 +1,13 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_bb_static_defconfig new file +13 -0
new file mode 100644
index 0000000..9e79fca
@@ -0,0 +1,13 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_ROOTFS_DEVICE_CREATION_STATIC=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_sv_dyn_devtmpfs_defconfig new file +13 -0
new file mode 100644
index 0000000..b0d758b
@@ -0,0 +1,13 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_INIT_SYSV=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_sv_dyn_eudev_defconfig new file +14 -0
new file mode 100644
index 0000000..a2142be
@@ -0,0 +1,14 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_INIT_SYSV=y
+BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_sv_dyn_mdev_defconfig new file +14 -0
new file mode 100644
index 0000000..02d6ca3
@@ -0,0 +1,14 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_INIT_SYSV=y
+BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_sv_mdev_only_defconfig new file +14 -0
new file mode 100644
index 0000000..7e7489f
@@ -0,0 +1,14 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_INIT_SYSV=y
+BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV_ONLY=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
configs/test_sv_static_defconfig new file +14 -0
new file mode 100644
index 0000000..2177aa0
@@ -0,0 +1,14 @@
+BR2_arm=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_INIT_SYSV=y
+BR2_ROOTFS_DEVICE_CREATION_STATIC=y
+BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.2"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arm-versatile/linux-4.2.config"
+BR2_LINUX_KERNEL_ZIMAGE=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
run new file +12 -0
new file mode 100755
index 0000000..56618a4
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+set -u
+
+OUTDIR=$([ -z "$1" ] && echo output || echo $1)
+
+qemu-system-arm -M versatilepb \
+    -kernel ${OUTDIR}/images/zImage \
+    -drive file=${OUTDIR}/images/rootfs.ext2,if=scsi \
+    -append "root=/dev/sda console=ttyAMA0,115200" \
+    -serial stdio -net nic,model=rtl8139 -net user
test-all new file +34 -0
new file mode 100755
index 0000000..21fdb2b
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+set -e
+set -u
+
+usage()
+{
+    echo "Usage: $0 {build|run}"
+}
+
+if [ -z "$1" ]; then
+    usage
+    exit 1
+fi
+
+for INIT in bb sv; do
+    for DEV in  static mdev_only dyn_devtmpfs dyn_eudev dyn_mdev; do
+	TARGET="${INIT}_${DEV}"
+	case "$1" in
+	    build)
+		make O=bld/${TARGET} test_${TARGET}_defconfig
+		make O=bld/${TARGET}
+		;;
+	    run)
+		echo "================= running ${TARGET} ==================="
+		./run bld/${TARGET}
+		echo "----------------- finished ${TARGET} -------------------"
+		;;
+	    *)
+		usage
+		exit 1
+	esac
+    done
+done
Signature · 1 line
1.9.1
#46 lore raw

cover mdev-only /dev management (without devtmpfs)

In reply to Luca Ceresoli
Quoted 7 lines · Luca Ceresoli

There is one rough edge that I'd like to have comments about: variable naming. The new method implemented by this patchset is dynamic and uses mdev, so it should ba named BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV and described in kconfig as "dynamic using mdev". But hey, that name and description are already used for the current "devtmpfs + mdev" method! So we might want to rename all variables to encompass the new use case in a clean way. Thid would also imply lagacy management etc.

Since we don't like legacy management :-) I'd propose to say that DYNAMIC
actually means DEVTMPFS. So the new option would be called BR2_ROOTFS_DEVICE_CREATION_MDEV: it's not devtmpfs, and there's no need for the explicit 'only' part.

What do you think?

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#47 lore raw

cover mdev-only /dev management (without devtmpfs)

Hello,

Quoted 9 lines · Arnout Vandecappelle
Quoted 7 lines · Luca Ceresoli

There is one rough edge that I'd like to have comments about: variable naming. The new method implemented by this patchset is dynamic and uses mdev, so it should ba named BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV and described in kconfig as "dynamic using mdev". But hey, that name and description are already used for the current "devtmpfs + mdev" method! So we might want to rename all variables to encompass the new use case in a clean way. Thid would also imply lagacy management etc.

Quoted 6 lines

Since we don't like legacy management :-) I'd propose to say that DYNAMIC
actually means DEVTMPFS. So the new option would be called BR2_ROOTFS_DEVICE_CREATION_MDEV: it's not devtmpfs, and there's no need for the explicit 'only' part.

What do you think?

I agree. I would prefer to not change the name of existing options.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#48 lore raw

cover mdev-only /dev management (without devtmpfs)

In reply to Luca Ceresoli
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Hi,
this patchset adds a new /dev management mechanism, using mdev for dynamic device creation but without relying on devtmpfs.

The main motivation is the need of dynamic /dev management and/or firmware loading assisted by mdev on targets that are bound to kernels < 2.6.32, and thus cannot use devtmpfs.

Is combining such old (<2009) kernel with modern userspace really a good idea?

git grep -l _AT_LEAST package/ | wc -l
48

But that is most likely not all of them, as none of the autobuilders use such ancient kernel headers.

How old is < 2.6.32? If you look@the commit adding devtmpfs to the kernel, it seems quite self contained and easy to backport:

git show --stat --oneline 2b2af54a5bb6f7e8
2b2af54 Driver Core: devtmpfs - kernel-maintained tmpfs-based /dev

 drivers/base/Kconfig     |  25 ++++
 drivers/base/Makefile    |   1 +
 drivers/base/base.h      |   6 +
 drivers/base/core.c      |   3 +
 drivers/base/devtmpfs.c  | 367 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/base/init.c      |   1 +
 include/linux/device.h   |  10 ++
 include/linux/shmem_fs.h |   3 +
 init/do_mounts.c         |   2 +-
 init/main.c              |   2 +
 mm/shmem.c               |   9 +-
 11 files changed, 422 insertions(+), 7 deletions(-)

Have you considered doing that instead?

Signature · 1 line
Bye, Peter Korsgaard