[Buildroot] [PATCH 1/3] Create menu entry to select device creation method
Yann E. MORIN
yann.morin.1998 at anciens.enib.fr
Sat Apr 2 17:21:50 UTC 2011
On Saturday 02 April 2011 18:53:32 Thomas Petazzoni wrote:
> From: Yegor Yefremov <yegor_sub1 at visionsystems.de>
>
> Four methods for the creation of device files in /dev are now
> proposed:
>
> - static method uses device table as before
> - devtmpfs method enables this feature in kernel
> - mdev method adds mdev starting script to the file system
> and selects mdev itself for installation
> - udev method selects udev for installation
>
> All dynamic methods are based on devtmpfs, so one doesn't need to care
> about /dev folder.
>
> Signed-off-by: Yegor Yefremov <yegorslists at googlemail.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
> ---
> fs/Config.in | 33 +++++++++++++++++++++++++++------
> linux/linux.mk | 7 +++++++
> package/busybox/S10mdev | 22 ++++++++++++++++++++++
> package/busybox/busybox.mk | 15 +++++++++++++++
> 4 files changed, 71 insertions(+), 6 deletions(-)
> create mode 100644 package/busybox/S10mdev
>
> diff --git a/fs/Config.in b/fs/Config.in
> index 188e815..9ac3acc 100644
> --- a/fs/Config.in
> +++ b/fs/Config.in
> @@ -15,13 +15,34 @@ config BR2_ROOTFS_POST_BUILD_SCRIPT
> only argument. Make sure the exit code of that script is 0,
> otherwise make will stop after calling it.
>
> +choice
> + prompt "/dev management"
> + default BR2_ROOTFS_DEVICE_CREATION_STATIC
> +
> +config BR2_ROOTFS_DEVICE_CREATION_STATIC
> + bool "Static using device table"
> +
> +config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS
> + bool "Dynamic using devtmpfs only"
> +
> +config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV
> + bool "Dynamic using mdev"
> + select BR2_PACKAGE_BUSYBOX
> +
> +config BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV
> + bool "Dynamic using udev"
> + select BR2_PACKAGE_UDEV
> +
> +endchoice
> +
> config BR2_ROOTFS_DEVICE_TABLE
> - string "Path to the device table"
> - default "target/generic/device_table.txt"
> - help
> - Specify the location of a device table, that will be passed
> - to the makedevs utility to create all the special device
> - files in the target filesystem.
> + string "Path to the device table"
> + depends on BR2_ROOTFS_DEVICE_CREATION_STATIC
> + default "target/generic/device_table.txt"
> + help
> + Specify the location of a device table, that will be passed
> + to the makedevs utility to create all the special device
> + files in the target filesystem.
>
> choice
> prompt "Root FS skeleton"
> diff --git a/linux/linux.mk b/linux/linux.mk
> index 9076fb9..873a9e0 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -130,6 +130,13 @@ ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
> $(call KCONFIG_DISABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_NONE,$(@D)/.config)
> $(call KCONFIG_ENABLE_OPT,CONFIG_INITRAMFS_COMPRESSION_GZIP,$(@D)/.config)
> endif
> +ifneq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
^^^^^^
> + $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS,$(@D)/.config)
> + $(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS_MOUNT,$(@D)/.config)
> +endif
This should be BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS, no?
> +ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)
> + $(call KCONFIG_SET_OPT,CONFIG_UEVENT_HELPER_PATH,\"/sbin/mdev\",$(@D)/.config)
> +endif
As I suggest below, I'd move that into the startup script.
> $(TARGET_MAKE_ENV) $(MAKE) $(LINUX26_MAKE_FLAGS) -C $(@D) oldconfig
> $(Q)touch $@
>
> diff --git a/package/busybox/S10mdev b/package/busybox/S10mdev
> new file mode 100644
> index 0000000..472810b
> --- /dev/null
> +++ b/package/busybox/S10mdev
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +#
> +# Start mdev....
> +#
> +
> +case "$1" in
> + start)
> + echo "Starting mdev..."
> + /sbin/mdev -s
From busybox/docs/mdev.txt:
Here's a typical code snippet from the init script:
[0] mount -t proc proc /proc
[1] mount -t sysfs sysfs /sys
[2] echo /sbin/mdev > /proc/sys/kernel/hotplug
[3] mdev -s
I see that [2] is done in the kernel's .config. I find it non-obvious,
and I would move that to the script above. It makes it easier to
follow.
Also, I did not see where /dev is mounted (as a tmpfs). If / is a RO file
system, then you can't use dynamic nodes, or you need a RW file system on
/dev.
> + ;;
> + stop)
For completeness:
echo "/bin/true" > /proc/sys/kernel/hotplug
killall mdev
sleep 2 # Leave it some time to proerly quit (adjust delay)
killall -9 mdev
> + ;;
> + restart|reload)
stop + start, maybe?
> + ;;
> + *)
> + echo $"Usage: $0 {start|stop|restart}"
> + exit 1
> +esac
> +
> +exit $?
> +
> +
> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> index ffd6667..711d11b 100644
> --- a/package/busybox/busybox.mk
> +++ b/package/busybox/busybox.mk
> @@ -28,6 +28,19 @@ ifndef BUSYBOX_CONFIG_FILE
> BUSYBOX_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG))
> endif
>
> +# If mdev will be used for device creation enable it and copy S10mdev to /etc/init.d
> +ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)
> +define BUSYBOX_INSTALL_MDEV_SCRIPT
> + install -m 0755 package/busybox/S10mdev $(TARGET_DIR)/etc/init.d
> +endef
> +define BUSYBOX_SET_MDEV
> + $(call KCONFIG_ENABLE_OPT,CONFIG_MDEV,$(BUSYBOX_BUILD_CONFIG))
> + $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_CONF,$(BUSYBOX_BUILD_CONFIG))
> + $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_EXEC,$(BUSYBOX_BUILD_CONFIG))
> + $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_LOAD_FIRMWARE,$(BUSYBOX_BUILD_CONFIG))
> +endef
> +endif
> +
> # If we have external syslogd, force busybox to use it
> ifeq ($(BR2_PACKAGE_SYSKLOGD),y)
> define BUSYBOX_SET_SYSKLOGD
> @@ -122,6 +135,7 @@ define BUSYBOX_CONFIGURE_CMDS
> $(BUSYBOX_SET_IPV6)
> $(BUSYBOX_SET_RPC)
> $(BUSYBOX_PREFER_STATIC)
> + $(BUSYBOX_SET_MDEV)
> $(BUSYBOX_NETKITBASE)
> $(BUSYBOX_NETKITTELNET)
> @yes "" | $(MAKE) ARCH=$(KERNEL_ARCH) CROSS_COMPILE="$(TARGET_CROSS)" \
> @@ -138,6 +152,7 @@ define BUSYBOX_INSTALL_TARGET_CMDS
> $(INSTALL) -m 0755 -D package/busybox/udhcpc.script \
> $(TARGET_DIR)/usr/share/udhcpc/default.script; \
> fi
> + $(BUSYBOX_INSTALL_MDEV_SCRIPT)
> endef
>
> define BUSYBOX_UNINSTALL_TARGET_CMDS
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
More information about the buildroot
mailing list