Skip to contentSkip to conversation

Enable a buildroot-based petitboot bootloader

PATCH Superseded Jeremy Kerr 4 participants 17 messages Mar 12, 2014 – Mar 29, 2014

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Enable a buildroot-based petitboot bootloader

Hi all,

The following series allows us to build a petitboot-based bootloader using buildroot.

Petitboot is a kexec-based bootloader; by plumbing together a few linux utilities, we can implement a bootloader in userspace, using standard Linux drivers for hardware support. There's a bit of background of petitboot in my recent linux.conf.au talk:

http://mirror.linux.org.au/linux.conf.au/2014/Thursday/89-Petitboot_doing_interesting_things_in_your_bootloader_-_Jeremy_Kerr.mp4

And the project homepage:

https://www.kernel.org/pub/linux/kernel/people/geoff/petitboot/petitboot.html

My primary target here is powerpc machines (and this series adds a defconfig to do a powerpc petitboot build), but I've also been able to get most of petitboot working when built as an EFI stub on x86 machines (we still need some platform-specific bits in petitboot for proper configuration persistence).

While most of this series is fairly straightforward, there are a few items that might need a little more attention:

- At the moment, I'm using my local repo for petitboot sources; it may be better to wait until everything is merged upstream. Upstream is still active, and I don't think this should take long.

- We add wide-char support for ncurses; this seems to be working okay, but could do with a little review.

- I still need a couple of tweaks to the target system (/etc/locale and /etc/inittab). At the moment, I'm carrying a change that introduces an overlay for these two files, but that's not suitable for upstream use:

     http://git.ozlabs.org/?p=buildroot;a=commitdiff;h=d50bd74b

Is there any way I can provide updates to these files? The changes aren't board-specific; they're due to petitboot expecting to own the default consoles for UIs. Or is there a better way to do this?

This series is also available in my git tree, at:

git://git.ozlabs.org/~jk/buildroot/

- in the petitboot branch. Note that that branch includes the overlay too, which isn't intended for upstream.

Also, I'd like to give a big thanks to the buildroot developers; being able to re-roll an entire system with one command has made petitboot development *significantly* easier. Also, thanks to Thomas for the nudge to send these changes upstream!

Please let me know if you have questions/comments/etc.

Changes since v1, based on feedback:

- drobbear: we only want a config option to disable the server, instead of both client and server

- ncurses: use NCURSES_LIBS-y

- busybox: fix HOOK_DIR glob expansion

- powerpc-utils, kexec-lite, petitboot: update upstream versions

- petitboot: add dependencies

- all: unified headers, now using full git SHAs

- dtc: Added patch to update to 1.4.0

Cheers,

Jeremy

---
Jeremy Kerr (10):
package/busybox: Add facility for DHCP hooks package/dropbear: Add separate configuration option for dropbear server package/ncurses: Remove duplicated library install code package/ncurses: Allow building wide char support package/dtc: Update to v1.4.0
package/powerpc-utils: Add powerpc hardware utilities package/kexec-lite: Add a package for the kexec-lite tools package/petitboot: Add petitboot, the userspace bootloader package/iprutils: Add IBM Power RAID utilities
Add powerpc petitboot defconfig

#1 lore raw

PATCH v2 1/10 package/busybox: Add facility for DHCP hooks

The (u)dhcpc hook installed by the busybox package configures the network and exits. If we want to do anything further with a DHCP lease, we'd have to replace the script entirely.

This change introduces a .d directory for hooks (based on the script filename), which are executed after the interface configuration. This allows packages to drop a script file in the .d directory to perform actions on DHCP events.

We'll use this in a later change to notify petitboot of DHCP boot information.

---
 package/busybox/busybox.mk    |    2 ++
 package/busybox/udhcpc.script |    6 ++++++
 2 files changed, 8 insertions(+)
package/busybox/busybox.mk +2 -0
index 793ffb9..0a094e1 100644
@@ -206,6 +206,8 @@ define BUSYBOX_INSTALL_TARGET_CMDS
 	if [ ! -f $(TARGET_DIR)/usr/share/udhcpc/default.script ]; then \
 		$(INSTALL) -m 0755 -D package/busybox/udhcpc.script \
 			$(TARGET_DIR)/usr/share/udhcpc/default.script; \
+		$(INSTALL) -m 755 -d \
+			$(TARGET_DIR)/usr/share/udhcpc/default.script.d; \
 	fi
 	$(BUSYBOX_INSTALL_MDEV_SCRIPT)
 	$(BUSYBOX_INSTALL_MDEV_CONF)
package/busybox/udhcpc.script +6 -0
index e23d1f1..50c52e6 100755
@@ -64,4 +64,10 @@ case "$1" in
 		;;
 esac
 
+HOOK_DIR="$0.d"
+for hook in "${HOOK_DIR}/"*; do
+    [ -f "${hook}" -a -x "${hook}" ] || continue
+    "${hook}" "${@}"
+done
+
 exit 0
#2 lore raw

PATCH v2 2/10 package/dropbear: Add separate configuration option for dropbear server

In reply to Jeremy Kerr

Currently, the dropbear package installs both client and server components. This means that when we only want the client binaries, we also get the server, which is run from init.

Even though it's a multi-call binary (the client and server exist in the same executable), we can define which parts are compiled-in. We'd also like to selectively install the links and init scripts.

This change introduces a separate configuration for the dropbear server.

---
 package/dropbear/Config.in   |    6 ++++++
 package/dropbear/dropbear.mk |   11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
package/dropbear/Config.in +6 -0
index 68c3b71..9ff5f47 100644
@@ -8,6 +8,12 @@ config BR2_PACKAGE_DROPBEAR
 
 if BR2_PACKAGE_DROPBEAR
 
+config BR2_PACKAGE_DROPBEAR_SERVER
+	bool "dropbear ssh server"
+	default y
+	help
+	  Enable the dropbear ssh server, run from init
+
 config BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS
 	bool "disable reverse DNS lookups"
 	help
package/dropbear/dropbear.mk +9 -2
index 2ac6211..b393c8a 100644
@@ -8,8 +8,9 @@ DROPBEAR_VERSION = 2014.63
 DROPBEAR_SITE = http://matt.ucc.asn.au/dropbear/releases
 DROPBEAR_SOURCE = dropbear-$(DROPBEAR_VERSION).tar.bz2
 DROPBEAR_TARGET_BINS = dbclient dropbearkey dropbearconvert scp ssh
+DROPBEAR_MAKE_PROGRAMS = $(filter-out ssh, $(DROPBEAR_TARGET_BINS))
 DROPBEAR_MAKE =	$(MAKE) MULTI=1 SCPPROGRESS=1 \
-		PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"
+		PROGRAMS="$(DROPBEAR_MAKE_PROGRAMS)"
 
 DROPBEAR_LICENSE = MIT, BSD-2c-like, BSD-2c
 DROPBEAR_LICENSE_FILES = LICENSE
@@ -18,6 +19,10 @@ ifeq ($(BR2_PREFER_STATIC_LIB),y)
 DROPBEAR_MAKE += STATIC=1
 endif
 
+ifeq ($(BR2_PACKAGE_DROPBEAR_SERVER),y)
+DROPBEAR_TARGET_BINS += dropbear
+endif
+
 define DROPBEAR_FIX_XAUTH
 	$(SED) 's,^#define XAUTH_COMMAND.*/xauth,#define XAUTH_COMMAND "/usr/bin/xauth,g' $(@D)/options.h
 endef
@@ -43,6 +48,7 @@ define DROPBEAR_DISABLE_STANDALONE
 	$(SED) 's:\(#define NON_INETD_MODE\):/*\1 */:' $(@D)/options.h
 endef
 
+ifeq ($(BR2_PACKAGE_DROPBEAR_SERVER),y)
 define DROPBEAR_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/dropbear/dropbear.service \
 		$(TARGET_DIR)/etc/systemd/system/dropbear.service
@@ -59,6 +65,7 @@ endef
 else
 DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_DISABLE_STANDALONE
 endif
+endif
 
 ifeq ($(BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS),)
 DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_ENABLE_REVERSE_DNS
@@ -82,7 +89,7 @@ endif
 
 define DROPBEAR_INSTALL_TARGET_CMDS
 	$(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear
-	for f in $(DROPBEAR_TARGET_BINS); do \
+	for f in $(filter-out dropbear,$(DROPBEAR_TARGET_BINS)); do \
 		ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/$$f ; \
 	done
 endef
#3 lore raw

PATCH v2 3/10 package/ncurses: Remove duplicated library install code

In reply to Jeremy Kerr

Currently, the ncurses package conditionally defines macros to install the panel, form and menu libraries. This means we duplicate the install step for each library type.

Rather than defining a set of macros, this change introduces a variable for the set of installed libraries, $(NCURSES_LIBS-y). We use this in a single macro to perform the library installation in one place.

Based on a change suggested by Thomas Petazzoni
<[email protected]>.

---
 package/ncurses/ncurses.mk |   33 ++++++++++-----------------------
 1 file changed, 10 insertions(+), 23 deletions(-)
package/ncurses/ncurses.mk +10 -23
index e180a95..c2e1c3f 100644
@@ -36,6 +36,11 @@ ifeq ($(BR2_PACKAGE_BUSYBOX),y)
 	NCURSES_DEPENDENCIES += busybox
 endif
 
+NCURSES_LIBS-y = libncurses
+NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_MENU) += libmenu
+NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_PANEL) += libpanel
+NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_FORM) += libform
+
 ifneq ($(BR2_ENABLE_DEBUG),y)
 NCURSES_CONF_OPT += --without-debug
 endif
@@ -45,27 +50,13 @@ define NCURSES_BUILD_CMDS
 endef
 
 ifneq ($(BR2_PREFER_STATIC_LIB),y)
-
-ifeq ($(BR2_PACKAGE_NCURSES_TARGET_PANEL),y)
-define NCURSES_INSTALL_TARGET_PANEL
-	cp -dpf $(NCURSES_DIR)/lib/libpanel.so* $(TARGET_DIR)/usr/lib/
-endef
-endif
-
-ifeq ($(BR2_PACKAGE_NCURSES_TARGET_FORM),y)
-define NCURSES_INSTALL_TARGET_FORM
-	cp -dpf $(NCURSES_DIR)/lib/libform.so* $(TARGET_DIR)/usr/lib/
-endef
-endif
-
-ifeq ($(BR2_PACKAGE_NCURSES_TARGET_MENU),y)
-define NCURSES_INSTALL_TARGET_MENU
-	cp -dpf $(NCURSES_DIR)/lib/libmenu.so* $(TARGET_DIR)/usr/lib/
+define NCURSES_INSTALL_TARGET_LIBS
+	for lib in $(NCURSES_LIBS-y); do \
+		cp -dpf $(NCURSES_DIR)/lib/$${lib}.so* $(TARGET_DIR)/usr/lib/; \
+	done
 endef
 endif
 
-endif
-
 ifeq ($(BR2_PACKAGE_NCURSES_TARGET_PROGS),y)
 define NCURSES_INSTALL_TARGET_PROGS
 	for x in $(NCURSES_PROGS); do \
@@ -78,11 +69,7 @@ endif
 
 define NCURSES_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/usr/lib
-	$(if $(BR2_PREFER_STATIC_LIB),,cp -dpf $(NCURSES_DIR)/lib/libncurses.so* $(TARGET_DIR)/usr/lib/)
-	$(NCURSES_INSTALL_TARGET_PANEL)
-	$(NCURSES_INSTALL_TARGET_FORM)
-	$(NCURSES_INSTALL_TARGET_MENU)
-	$(NCURSES_INSTALL_TARGET_PROGS)
+	$(NCURSES_INSTALL_TARGET_LIBS)
 	ln -snf /usr/share/terminfo $(TARGET_DIR)/usr/lib/terminfo
 	mkdir -p $(TARGET_DIR)/usr/share/terminfo/x
 	cp -dpf $(STAGING_DIR)/usr/share/terminfo/x/xterm $(TARGET_DIR)/usr/share/terminfo/x
#4 lore raw

PATCH v2 3/10 package/ncurses: Remove duplicated library install code

Hi all,

package/ncurses/ncurses.mk endif · line 72

Quoted 6 lines
package/ncurses/ncurses.mk +1 -5
-	$(if $(BR2_PREFER_STATIC_LIB),,cp -dpf $(NCURSES_DIR)/lib/libncurses.so* $(TARGET_DIR)/usr/lib/)
-	$(NCURSES_INSTALL_TARGET_PANEL)
-	$(NCURSES_INSTALL_TARGET_FORM)
-	$(NCURSES_INSTALL_TARGET_MENU)
-	$(NCURSES_INSTALL_TARGET_PROGS)
+	$(NCURSES_INSTALL_TARGET_LIBS)

Hmm, looks like I went overboard with deleting lines here; we still need NCURSES_INSTALL_TARGET_PROGS.

Updated patch coming.

Jeremy

#5 lore raw

PATCH 1/1 package/ncurses: Remove duplicated library install code

In reply to Jeremy Kerr

Currently, the ncurses package conditionally defines macros to install the panel, form and menu libraries. This means we duplicate the install step for each library type.

Rather than defining a set of macros, this change introduces a variable for the set of installed libraries, $(NCURSES_LIBS-y). We use this in a single macro to perform the library installation in one place.

Based on a change suggested by Thomas Petazzoni
<[email protected]>.

---
v2.1: Fix NCURSES_INSTALL_TARGET_PROGS deletion

---
 package/ncurses/ncurses.mk |   32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)
package/ncurses/ncurses.mk +10 -22
index e180a95..9805113 100644
@@ -36,6 +36,11 @@ ifeq ($(BR2_PACKAGE_BUSYBOX),y)
 	NCURSES_DEPENDENCIES += busybox
 endif
 
+NCURSES_LIBS-y = libncurses
+NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_MENU) += libmenu
+NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_PANEL) += libpanel
+NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_FORM) += libform
+
 ifneq ($(BR2_ENABLE_DEBUG),y)
 NCURSES_CONF_OPT += --without-debug
 endif
@@ -45,27 +50,13 @@ define NCURSES_BUILD_CMDS
 endef
 
 ifneq ($(BR2_PREFER_STATIC_LIB),y)
-
-ifeq ($(BR2_PACKAGE_NCURSES_TARGET_PANEL),y)
-define NCURSES_INSTALL_TARGET_PANEL
-	cp -dpf $(NCURSES_DIR)/lib/libpanel.so* $(TARGET_DIR)/usr/lib/
-endef
-endif
-
-ifeq ($(BR2_PACKAGE_NCURSES_TARGET_FORM),y)
-define NCURSES_INSTALL_TARGET_FORM
-	cp -dpf $(NCURSES_DIR)/lib/libform.so* $(TARGET_DIR)/usr/lib/
-endef
-endif
-
-ifeq ($(BR2_PACKAGE_NCURSES_TARGET_MENU),y)
-define NCURSES_INSTALL_TARGET_MENU
-	cp -dpf $(NCURSES_DIR)/lib/libmenu.so* $(TARGET_DIR)/usr/lib/
+define NCURSES_INSTALL_TARGET_LIBS
+	for lib in $(NCURSES_LIBS-y); do \
+		cp -dpf $(NCURSES_DIR)/lib/$${lib}.so* $(TARGET_DIR)/usr/lib/; \
+	done
 endef
 endif
 
-endif
-
 ifeq ($(BR2_PACKAGE_NCURSES_TARGET_PROGS),y)
 define NCURSES_INSTALL_TARGET_PROGS
 	for x in $(NCURSES_PROGS); do \
@@ -78,10 +69,7 @@ endif
 
 define NCURSES_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/usr/lib
-	$(if $(BR2_PREFER_STATIC_LIB),,cp -dpf $(NCURSES_DIR)/lib/libncurses.so* $(TARGET_DIR)/usr/lib/)
-	$(NCURSES_INSTALL_TARGET_PANEL)
-	$(NCURSES_INSTALL_TARGET_FORM)
-	$(NCURSES_INSTALL_TARGET_MENU)
+	$(NCURSES_INSTALL_TARGET_LIBS)
 	$(NCURSES_INSTALL_TARGET_PROGS)
 	ln -snf /usr/share/terminfo $(TARGET_DIR)/usr/lib/terminfo
 	mkdir -p $(TARGET_DIR)/usr/share/terminfo/x
#6 lore raw

PATCH 1/1 package/ncurses: Remove duplicated library install code

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Jeremy" == Jeremy Kerr <[email protected]> writes:

Currently, the ncurses package conditionally defines macros to install the panel, form and menu libraries. This means we duplicate the install step for each library type.

Rather than defining a set of macros, this change introduces a variable for the set of installed libraries, $(NCURSES_LIBS-y). We use this in a single macro to perform the library installation in one place.

Quoted 7 lines

Based on a change suggested by Thomas Petazzoni
<[email protected]>.

---
v2.1: Fix NCURSES_INSTALL_TARGET_PROGS deletion

Committed, thanks.

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

PATCH v2 4/10 package/ncurses: Allow building wide char support

In reply to Jeremy Kerr

Allow ncurses to be configured with wide char support; this causes the libraries to be built with the 'w' suffix (eg libncursesw.so, libmenuw.so, etc), so we need to create a few symlinks.

---
 package/ncurses/Config.in  |    6 ++++++
 package/ncurses/ncurses.mk |   24 ++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
package/ncurses/Config.in +6 -0
index e8ab710..b90ec9e 100644
@@ -10,6 +10,12 @@ config BR2_PACKAGE_NCURSES
 
 if BR2_PACKAGE_NCURSES
 
+config BR2_PACKAGE_NCURSES_WCHAR
+	bool "enable wide char support"
+	depends on BR2_USE_WCHAR
+	help
+	  Enable wide char & UTF-8 support in ncurses libraries
+
 config BR2_PACKAGE_NCURSES_TARGET_PANEL
 	bool "ncurses libpanel in target"
 	help
package/ncurses/ncurses.mk +22 -2
index c2e1c3f..445f259 100644
@@ -12,7 +12,7 @@ HOST_NCURSES_DEPENDENCIES =
 NCURSES_PROGS = clear infocmp tabs tic toe tput tset
 NCURSES_LICENSE = MIT with advertising clause
 NCURSES_LICENSE_FILES = README
-NCURSES_CONFIG_SCRIPTS = ncurses5-config
+NCURSES_CONFIG_SCRIPTS = ncurses$(NCURSES_LIB_SUFFIX)5-config
 
 NCURSES_CONF_OPT = \
 	$(if $(BR2_PREFER_STATIC_LIB),--without-shared,--with-shared) \
@@ -36,6 +36,24 @@ ifeq ($(BR2_PACKAGE_BUSYBOX),y)
 	NCURSES_DEPENDENCIES += busybox
 endif
 
+ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y)
+NCURSES_CONF_OPT += --enable-widec
+NCURSES_LIB_SUFFIX = w
+
+define NCURSES_LINK_LIBS
+	for lib in $(NCURSES_LIBS-y); do \
+		ln -sf $${lib}$(NCURSES_LIB_SUFFIX).so \
+			$(1)/usr/lib/$${lib}.so; \
+	done
+endef
+
+NCURSES_LINK_TARGET_LIBS =  $(call NCURSES_LINK_LIBS, $(TARGET_DIR))
+NCURSES_LINK_STAGING_LIBS =  $(call NCURSES_LINK_LIBS, $(STAGING_DIR))
+
+NCURSES_POST_INSTALL_STAGING_HOOKS += NCURSES_LINK_STAGING_LIBS
+
+endif
+
 NCURSES_LIBS-y = libncurses
 NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_MENU) += libmenu
 NCURSES_LIBS-$(BR2_PACKAGE_NCURSES_TARGET_PANEL) += libpanel
@@ -52,7 +70,8 @@ endef
 ifneq ($(BR2_PREFER_STATIC_LIB),y)
 define NCURSES_INSTALL_TARGET_LIBS
 	for lib in $(NCURSES_LIBS-y); do \
-		cp -dpf $(NCURSES_DIR)/lib/$${lib}.so* $(TARGET_DIR)/usr/lib/; \
+		cp -dpf $(NCURSES_DIR)/lib/$${lib}$(NCURSES_LIB_SUFFIX).so* \
+			$(TARGET_DIR)/usr/lib/; \
 	done
 endef
 endif
@@ -70,6 +89,7 @@ endif
 define NCURSES_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/usr/lib
 	$(NCURSES_INSTALL_TARGET_LIBS)
+	$(NCURSES_LINK_TARGET_LIBS)
 	ln -snf /usr/share/terminfo $(TARGET_DIR)/usr/lib/terminfo
 	mkdir -p $(TARGET_DIR)/usr/share/terminfo/x
 	cp -dpf $(STAGING_DIR)/usr/share/terminfo/x/xterm $(TARGET_DIR)/usr/share/terminfo/x
#8 lore raw

PATCH v2 5/10 package/dtc: Update to v1.4.0

In reply to Jeremy Kerr

Currently, we're using an untagged commit of dtc. Since inclusion in buildroot, version 1.4.0 has been released, which includes new endian-annotated type defintions.

We want to use these type definitions in kexec-lite, so update to the new release.

---
 package/dtc/dtc.mk |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/dtc/dtc.mk +1 -1
index a230e60..a6898f2 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-DTC_VERSION         = e4b497f367a3b2ae99cc52089a14a221b13a76ef
+DTC_VERSION         = v1.4.0
 DTC_SITE            = git://git.jdl.com/software/dtc.git
 DTC_LICENSE         = GPLv2+/BSD-2c
 DTC_LICENSE_FILES   = README.license GPL
#9 lore raw

PATCH v2 5/10 package/dtc: Update to v1.4.0

Dear Jeremy Kerr,

Quoted 8 lines · Jeremy Kerr

Currently, we're using an untagged commit of dtc. Since inclusion in buildroot, version 1.4.0 has been released, which includes new endian-annotated type defintions.

We want to use these type definitions in kexec-lite, so update to the new release.

Applied, thanks.

Thomas

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

PATCH v2 6/10 package/powerpc-utils: Add powerpc hardware utilities

In reply to Jeremy Kerr

This change adds a package definition for the powerpc-utils project, containing a set of powerpc-specific hardware management utilities.

We're using a git tag from upstream, which contains a few build-system fixes.

---
 package/Config.in                                                               |    1 
 package/powerpc-utils/Config.in                                                 |    5 
 package/powerpc-utils/powerpc-utils-01-add-subdir-objects-automake-option.patch |   71 ++++++++++
 package/powerpc-utils/powerpc-utils.mk                                          |   16 ++
 4 files changed, 93 insertions(+)
package/Config.in +1 -0
index 70e5a7f..5fe0594 100644
@@ -1062,6 +1062,7 @@ source "package/monit/Config.in"
 source "package/ncdu/Config.in"
 source "package/numactl/Config.in"
 source "package/nut/Config.in"
+source "package/powerpc-utils/Config.in"
 source "package/polkit/Config.in"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 source "package/procps/Config.in"
package/powerpc-utils/Config.in new file +5 -0
new file mode 100644
index 0000000..c919094
@@ -0,0 +1,5 @@
+config BR2_PACKAGE_POWERPC_UTILS
+	bool "powerpc-utils"
+	select BR2_PACKAGE_ZLIB
+	help
+	  System utilities for powerpc machines
package/powerpc-utils/powerpc-utils-01-add-subdir-objects-automake-option.patch new file +71 -0

71 lines not on this page · raw message

package/powerpc-utils/powerpc-utils.mk new file +16 -0
new file mode 100644
index 0000000..6f8448c
@@ -0,0 +1,16 @@
+################################################################################
+#
+# powerpc-utils
+#
+################################################################################
+
+POWERPC_UTILS_VERSION = 64fe85e9473d05607dd8deda5023c7dd426216a5
+POWERPC_UTILS_SITE = git://git.code.sf.net/p/powerpc-utils/powerpc-utils
+POWERPC_UTILS_AUTORECONF = YES
+POWERPC_UTILS_DEPENDENCIES = zlib
+POWERPC_UTILS_LICENSE = Common Public License Version 1.0
+POWERPC_UTILS_LICENSE_FILES = COPYRIGHT
+
+POWERPC_UTILS_CONF_OPT = --without-librtas
+
+$(eval $(autotools-package))
#11 lore raw

PATCH v2 7/10 package/kexec-lite: Add a package for the kexec-lite tools

In reply to Jeremy Kerr

Kexec-lite is a tiny impementation of kexec for devicetree-based platforms.

---
 package/Config.in                                    |    1 
 package/kexec-lite/Config.in                         |   12 +++
 package/kexec-lite/kexec-lite-01-clean-restart.patch |   34 +++++++++++
 package/kexec-lite/kexec-lite.mk                     |   22 +++++++
 4 files changed, 69 insertions(+)
package/Config.in +1 -0
index 5fe0594..e8662e0 100644
@@ -53,6 +53,7 @@ source "package/fio/Config.in"
 source "package/gdb/Config.in"
 source "package/iozone/Config.in"
 source "package/kexec/Config.in"
+source "package/kexec-lite/Config.in"
 source "package/ktap/Config.in"
 source "package/latencytop/Config.in"
 source "package/lmbench/Config.in"
package/kexec-lite/Config.in new file +12 -0
new file mode 100644
index 0000000..daf7eb9
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_KEXEC_LITE
+	bool "kexec-lite"
+	depends on BR2_powerpc
+	select BR2_PACKAGE_LIBELF
+	select BR2_PACKAGE_DTC
+	select BR2_PACKAGE_DTC_PROGRAMS
+	help
+	  Kexec is a user space utiltity for loading another kernel
+	  and asking the currently running kernel to do something with it.
+
+	  This package is a tiny implementation of the kexec userspace
+	  components, for devicetree-based platforms.
package/kexec-lite/kexec-lite-01-clean-restart.patch new file +34 -0
new file mode 100644
index 0000000..faaa93a
@@ -0,0 +1,34 @@
+From 0a654c20e1b9324c57ba4116b52fb6ab33847e1d Mon Sep 17 00:00:00 2001
+From: Jeremy Kerr <[email protected]>
+Date: Thu, 8 Aug 2013 17:16:31 +0800
+Subject: [PATCH] kexec: Implement clean restart for busybox init
+
+Signed-off-by: Jeremy Kerr <[email protected]>
+---
+ kexec.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/kexec.c b/kexec.c
+index 2edb7df..b2a0c42 100644
+--- a/kexec.c
++++ b/kexec.c
+@@ -27,6 +27,7 @@
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <syscall.h>
++#include <signal.h>
+ #include <libfdt.h>
+ #include <getopt.h>
+ #include <sys/types.h>
+@@ -818,7 +819,7 @@ int main(int argc, char *argv[])
+ 			sync();
+ 			exec_kexec();
+ 		} else {
+-			execlp("shutdown", "shutdown", "-r", "now", NULL);
++			kill(1, SIGQUIT);
+ 		}
+ 
+ 		return -1;
+-- 
+1.7.10.4
+
package/kexec-lite/kexec-lite.mk new file +22 -0
new file mode 100644
index 0000000..aa09abc
@@ -0,0 +1,22 @@
+################################################################################
+#
+# kexec-lite
+#
+################################################################################
+
+KEXEC_LITE_VERSION = 0e30677d8232595c135772e1121b7be98c118e13
+KEXEC_LITE_SITE = $(call github,antonblanchard,kexec-lite,$(KEXEC_LITE_VERSION))
+KEXEC_LITE_LICENSE = GPL
+KEXEC_LITE_DEPENDENCIES = libelf dtc
+
+define KEXEC_LITE_BUILD_CMDS
+	$(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" \
+		    CFLAGS="$(TARGET_CFLAGS)" \
+		    -C $(@D) all
+endef
+
+define KEXEC_LITE_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 755 $(@D)/kexec $(TARGET_DIR)/usr/sbin/
+endef
+
+$(eval $(generic-package))
#12 lore raw

PATCH v2 8/10 package/petitboot: Add petitboot, the userspace bootloader

In reply to Jeremy Kerr

This change adds the petitboot package, a bootloader that exists in userspace, and uses the kexec facility to boot into a new kernel.

We add a little extra infrastructure to get things integrated into a buildroot environment:

- scripts to make kexec work with busybox init, for a clean shutdown

- udev rules to get removable event notifications, and start the petitboot UI processes

- startup scripts for the device-discovery process

---
 package/Config.in                            |    1 
 package/petitboot/Config.in                  |   13 +++
 package/petitboot/S14silence-console         |    9 ++
 package/petitboot/S15pb-discover             |   23 ++++++
 package/petitboot/kexec-restart              |    8 ++
 package/petitboot/petitboot-console-ui.rules |    5 +
 package/petitboot/petitboot.mk               |   64 +++++++++++++++++++
 package/petitboot/removable-event-poll.rules |    4 +
 8 files changed, 127 insertions(+)
package/Config.in +1 -0
index e8662e0..d98688c 100644
@@ -1063,6 +1063,7 @@ source "package/monit/Config.in"
 source "package/ncdu/Config.in"
 source "package/numactl/Config.in"
 source "package/nut/Config.in"
+source "package/petitboot/Config.in"
 source "package/powerpc-utils/Config.in"
 source "package/polkit/Config.in"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
package/petitboot/Config.in new file +13 -0
new file mode 100644
index 0000000..f5ffe8e
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_PETITBOOT
+	bool "petitboot"
+	depends on BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV
+	select BR2_PACKAGE_UDEV
+	select BR2_PACKAGE_NCURSES
+	# run-time dependency only
+	select BR2_PACKAGE_KEXEC_LITE if !BR2_PACKAGE_KEXEC
+	# run-time dependency only
+	select BR2_PACKAGE_POWERPC_UTILS if BR2_powerpc
+	help
+	  Petitboot is a small kexec-based bootloader
+
+	  http://www.kernel.org/pub/linux/kernel/people/geoff/petitboot/petitboot.html
package/petitboot/S14silence-console new file +9 -0
new file mode 100755
index 0000000..6570200
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+case "$1" in
+    start)
+        echo 0 0 7 0 > /proc/sys/kernel/printk
+        ;;
+esac
+
+exit 0
package/petitboot/S15pb-discover new file +23 -0
new file mode 100755
index 0000000..ebdf944
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+LOGFILE=/var/log/petitboot/pb-discover.log
+PIDFILE=/var/run/petitboot.pid
+
+case "$1" in
+    start)
+        ulimit -c unlimited
+        mkdir -p $(dirname $LOGFILE)
+        PATH=/usr/bin:/usr/sbin:/bin:/sbin pb-discover -l $LOGFILE &
+        echo $! > $PIDFILE
+        ;;
+    stop)
+        pid=$(cat $PIDFILE)
+        [ -n "$pid" ] && kill -TERM $pid
+        ;;
+    *)
+        echo "Usage: $0 {start|stop}"
+        exit 1
+        ;;
+esac
+
+exit 0
package/petitboot/kexec-restart new file +8 -0
new file mode 100755
index 0000000..0175e76
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+/usr/sbin/kexec -f -e
+
+while :
+do
+    sleep 1
+done
package/petitboot/petitboot-console-ui.rules new file +5 -0
new file mode 100644
index 0000000..7464856
@@ -0,0 +1,5 @@
+
+# spawn a petitboot UI on common user-visible interface devices
+SUBSYSTEM=="tty", KERNEL=="hvc*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name vt100"
+SUBSYSTEM=="tty", KERNEL=="tty0", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name vt100"
+SUBSYSTEM=="tty", KERNEL=="ttyS*", RUN+="/usr/libexec/petitboot/pb-console --getty --detach -- -n -i 0 $name vt100"
package/petitboot/petitboot.mk new file +64 -0

64 lines not on this page · raw message

package/petitboot/removable-event-poll.rules new file +4 -0
new file mode 100644
index 0000000..b736aef
@@ -0,0 +1,4 @@
+
+# petitboot needs notification for media change events on removable devices,
+# which we only get if we've set the poll_msecs sysfs attribute.
+ACTION!="remove", ATTR{removable}=="1", ATTR{events_poll_msecs}="2000"
#13 lore raw

PATCH v2 8/10 package/petitboot: Add petitboot, the userspace bootloader

Jeremy, All,

On 2014-03-12 11:45 +0800, Jeremy Kerr spake thusly:

Quoted 2 lines

This change adds the petitboot package, a bootloader that exists in userspace, and uses the kexec facility to boot into a new kernel.

[--SNIP--]

package/petitboot/Config.in line 4

Quoted 10 lines
package/petitboot/Config.in new file +4 -0
new file mode 100644
index 0000000..f5ffe8e
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_PETITBOOT
+	bool "petitboot"
+	depends on BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV
+	select BR2_PACKAGE_UDEV

Package udev no longer exists. udev is now a virtual package that is provided by eother systemd of eudev. So you can not 'select' BR2_PACKAGE_UDEV.

You should instead use:
depends on BR2_PACKAGE_HAS_UDEV

[--SNIP--]

package/petitboot/petitboot.mk line 5

Quoted 11 lines
package/petitboot/petitboot.mk new file +5 -0
new file mode 100644
index 0000000..8370fa2
@@ -0,0 +1,64 @@
+################################################################################
+#
+# petitboot
+#
+################################################################################

[--SNIP--]

package/petitboot/petitboot.mk line 36

Quoted 5 lines
package/petitboot/petitboot.mk new file +5 -0
+define PETITBOOT_PRE_CONFIGURE_BOOTSTRAP
+	(cd $(@D) && ./bootstrap $(PETITBOOT_BOOTSTRAP_VERSION))
+endef
+
+PETITBOOT_PRE_CONFIGURE_HOOKS += PETITBOOT_PRE_CONFIGURE_BOOTSTRAP

I find it too bad that an autotools package can not be autoreconf'ed.

I've looked a bit at what this bootstrap does, and all it really is used for is to shoehorn the veersion in configure.ac.

Since you seem to be involved in petitboot, here's a suggestion to do it otherwise:

- move the version stuff out of ./bootstrap, into its own script, eg. ./version.sh

- change configure.ac to use AC_INIT as thus:

AC_INIT([petitboot],
[m4_esyscmd_s([./version.sh])],
[Geoff Levand <[email protected]>])

Then the package will be entirely autoreconf-igurable. ;-)

I haven't looked further in the patch, just pointing out a few things I spotted on a cursory look.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#14 lore raw

PATCH v2 9/10 package/iprutils: Add IBM Power RAID utilities

In reply to Jeremy Kerr
---
 package/Config.in                                   |    1 
 package/iprutils/Config.in                          |   10 ++++
 package/iprutils/iprutils-01-dont-use-gettext.patch |   30 ++++++++++++
 package/iprutils/iprutils.mk                        |   26 ++++++++++
 4 files changed, 67 insertions(+)
package/Config.in +1 -0
index d98688c..d62731d 100644
@@ -1056,6 +1056,7 @@ endif
 source "package/cpuload/Config.in"
 source "package/dsp-tools/Config.in"
 source "package/htop/Config.in"
+source "package/iprutils/Config.in"
 source "package/keyutils/Config.in"
 source "package/kmod/Config.in"
 source "package/lxc/Config.in"
package/iprutils/Config.in new file +10 -0
new file mode 100644
index 0000000..d72688f
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_IPRUTILS
+	bool "iprutils"
+	select BR2_PACKAGE_NCURSES
+	select BR2_PACKAGE_NCURSES_TARGET_PANEL
+	select BR2_PACKAGE_NCURSES_TARGET_FORM
+	select BR2_PACKAGE_NCURSES_TARGET_MENU
+	select BR2_PACKAGE_LIBSYSFS
+	select BR2_PACKAGE_PCIUTILS
+	help
+	  System utilities for IBM Power RAID devices
package/iprutils/iprutils-01-dont-use-gettext.patch new file +30 -0
new file mode 100644
index 0000000..8d3d5dd
@@ -0,0 +1,30 @@
+From 0aa3952890e14f5447147ae4d0d37c515e4fefea Mon Sep 17 00:00:00 2001
+From: Jeremy Kerr <[email protected]>
+Date: Fri, 26 Jul 2013 13:07:22 +0800
+Subject: [PATCH] iprconfig: Don't use gettext
+
+... since we don't have any translations.
+
+Signed-off-by: Jeremy Kerr <[email protected]>
+---
+ iprconfig.h |    4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/iprconfig.h b/iprconfig.h
+index 867b5ac..a9cdf5e 100644
+--- a/iprconfig.h
++++ b/iprconfig.h
+@@ -11,9 +11,7 @@
+  *
+  **/
+ 
+-#include <libintl.h>
+-
+-#define _(string) gettext(string)
++#define _(string) (string)
+ #define __(string) (string)
+ #define EXIT_FLAG		0x8000	/* stops at given screen on exit call */
+ #define CANCEL_FLAG		0x4000	/* stops at given screen on quit call */
+-- 
+1.7.10.4
+
package/iprutils/iprutils.mk new file +26 -0
new file mode 100644
index 0000000..15de9af
@@ -0,0 +1,26 @@
+################################################################################
+#
+# iprutils
+#
+################################################################################
+
+IPRUTILS_VERSION = 2.3.15
+IPRUTILS_SITE = http://downloads.sourceforge.net/project/iprdd/iprutils%20for%202.6%20kernels/$(IPRUTILS_VERSION)
+IPRUTILS_SOURCE = iprutils-$(IPRUTILS_VERSION)-src.tgz
+IPRUTILS_DEPENDENCIES = ncurses libsysfs pciutils
+IPRUTILS_LICENSE = Common Public License Version 1.0
+IPRUTILS_LICENSE_FILES = LICENSE
+
+define IPRUTILS_BUILD_CMDS
+	$(MAKE) CC=$(TARGET_CC) LD=$(TARGET_LD) -C $(@D) all
+endef
+
+define IPRUTILS_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/iprconfig $(TARGET_DIR)/sbin/iprconfig
+	$(INSTALL) -D -m 0755 $(@D)/iprupdate $(TARGET_DIR)/sbin/iprupdate
+	$(INSTALL) -D -m 0755 $(@D)/iprdump $(TARGET_DIR)/sbin/iprdump
+	$(INSTALL) -D -m 0755 $(@D)/iprinit $(TARGET_DIR)/sbin/iprinit
+	$(INSTALL) -D -m 0755 $(@D)/iprdbg $(TARGET_DIR)/sbin/iprdbg
+endef
+
+$(eval $(generic-package))
#15 lore raw

PATCH v2 9/10 package/iprutils: Add IBM Power RAID utilities

Dear Jeremy Kerr,

I've applied your patch, with a few corrections (see below).

Quoted 6 lines · Jeremy Kerr
package/iprutils/Config.in new file +0 -0
new file mode 100644
index 0000000..d72688f

package/iprutils/Config.in line 10

Quoted 10 lines
package/iprutils/Config.in new file +10 -0
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_IPRUTILS
+	bool "iprutils"
+	select BR2_PACKAGE_NCURSES
+	select BR2_PACKAGE_NCURSES_TARGET_PANEL
+	select BR2_PACKAGE_NCURSES_TARGET_FORM
+	select BR2_PACKAGE_NCURSES_TARGET_MENU
+	select BR2_PACKAGE_LIBSYSFS
+	select BR2_PACKAGE_PCIUTILS
+	help
+	  System utilities for IBM Power RAID devices

Here I've added the URL of the upstream project on SourceForge.

Quoted 12 lines
package/iprutils/iprutils.mk new file +6 -0
new file mode 100644
index 0000000..15de9af
@@ -0,0 +1,26 @@
+################################################################################
+#
+# iprutils
+#
+################################################################################
+

package/iprutils/iprutils.mk line 16

Quoted 10 lines
package/iprutils/iprutils.mk new file +10 -0
+IPRUTILS_VERSION = 2.3.15
+IPRUTILS_SITE = http://downloads.sourceforge.net/project/iprdd/iprutils%20for%202.6%20kernels/$(IPRUTILS_VERSION)
+IPRUTILS_SOURCE = iprutils-$(IPRUTILS_VERSION)-src.tgz
+IPRUTILS_DEPENDENCIES = ncurses libsysfs pciutils
+IPRUTILS_LICENSE = Common Public License Version 1.0
+IPRUTILS_LICENSE_FILES = LICENSE
+
+define IPRUTILS_BUILD_CMDS
+	$(MAKE) CC=$(TARGET_CC) LD=$(TARGET_LD) -C $(@D) all
+endef

Here instead of CC=$(TARGET_CC) and LD=$(TARGET_LD), I've used $(TARGET_CONFIGURE_OPTS), which also ensures CFLAGS and al. are passed. This required adding another patch to the package so that our CFLAGS can be passed from the environment and can be added with the package-specific CFLAGS.

package/iprutils/iprutils.mk line 24

Quoted 7 lines
package/iprutils/iprutils.mk new file +7 -0
+define IPRUTILS_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/iprconfig $(TARGET_DIR)/sbin/iprconfig
+	$(INSTALL) -D -m 0755 $(@D)/iprupdate $(TARGET_DIR)/sbin/iprupdate
+	$(INSTALL) -D -m 0755 $(@D)/iprdump $(TARGET_DIR)/sbin/iprdump
+	$(INSTALL) -D -m 0755 $(@D)/iprinit $(TARGET_DIR)/sbin/iprinit
+	$(INSTALL) -D -m 0755 $(@D)/iprdbg $(TARGET_DIR)/sbin/iprdbg
+endef

And I've replaced that my using the "make install" target of the package Makefile, which was doing the same thing. "make install" is also installing manpages, which is probably why you didn't use it, but Buildroot anyway automatically removes documentation from the target, such as manpages. Therefore, we prefer to use the package "make install", which is more likely to continue to work in the future.

Thanks!

Thomas

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

PATCH v2 10/10 Add powerpc petitboot defconfig

In reply to Jeremy Kerr

A simple defconfig for building a petitboot-based bootloader for powerpc machines.

---
 configs/powerpc_petitboot_defconfig |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
configs/powerpc_petitboot_defconfig new file +22 -0
new file mode 100644
index 0000000..eb4a56a
@@ -0,0 +1,22 @@
+BR2_powerpc=y
+BR2_TOOLCHAIN_BUILDROOT_LARGEFILE=y
+BR2_TOOLCHAIN_BUILDROOT_LOCALE=y
+BR2_GENERATE_LOCALE="en_US.utf8"
+BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_UDEV=y
+BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
+BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+BR2_PACKAGE_KEXEC_LITE=y
+BR2_PACKAGE_LINUX_FIRMWARE=y
+BR2_PACKAGE_LINUX_FIRMWARE_BNX2X=y
+BR2_PACKAGE_LINUX_FIRMWARE_CXGB4=y
+BR2_PACKAGE_NCURSES_WCHAR=y
+BR2_PACKAGE_NCURSES_TARGET_FORM=y
+BR2_PACKAGE_NCURSES_TARGET_MENU=y
+BR2_PACKAGE_DROPBEAR=y
+# BR2_PACKAGE_DROPBEAR_SERVER is not set
+BR2_PACKAGE_ETHTOOL=y
+BR2_PACKAGE_NETCAT=y
+BR2_PACKAGE_RSYNC=y
+BR2_PACKAGE_PETITBOOT=y
+BR2_TARGET_ROOTFS_CPIO=y
+BR2_TARGET_ROOTFS_CPIO_GZIP=y