From 7fe6a59dfd76c9b6902b748b2db8d63d70ee8525 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sat, 26 Jun 2010 17:10:02 +0200 Subject: finetune kernel configuration, enable initramfs rootfs and enable reset button alix2d has a reset button, which might be used to startup a rescue system or anything you think about. add a small daemon from ipcop forum to implement this. See: http://www.ipcop-forum.de/forum/viewtopic.php?f=7&t=19183&hilit=alixswitch&start=30 finetune kernel configuration, enable MFGPT timers. Disable unsupported MTRR. Enable watchdog. Enable initramfs and initramfs+piggyback for alix targets. --- package/Config.in | 1 + package/alix-switch/Makefile | 35 ++++++++ package/alix-switch/files/alix-switch | 15 ++++ package/alix-switch/files/alix-switch.init | 27 ++++++ package/alix-switch/files/alix-switch.postinst | 3 + package/alix-switch/src/alix-switchd.c | 111 +++++++++++++++++++++++++ package/cfgfs/Makefile | 2 +- package/grub-bin/Makefile | 2 +- 8 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 package/alix-switch/Makefile create mode 100644 package/alix-switch/files/alix-switch create mode 100644 package/alix-switch/files/alix-switch.init create mode 100644 package/alix-switch/files/alix-switch.postinst create mode 100644 package/alix-switch/src/alix-switchd.c (limited to 'package') diff --git a/package/Config.in b/package/Config.in index 8922d7900..3c477c70e 100644 --- a/package/Config.in +++ b/package/Config.in @@ -16,6 +16,7 @@ config ADK_ENABLE_IPV6 exception proves the rule. ;) menu "Basesystem" +source "package/alix-switch/Config.in" source "package/adkinstall/Config.in" source "package/base-files/Config.in" source "package/base-files/Config.in.manual" diff --git a/package/alix-switch/Makefile b/package/alix-switch/Makefile new file mode 100644 index 000000000..442d2d3af --- /dev/null +++ b/package/alix-switch/Makefile @@ -0,0 +1,35 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +include ${TOPDIR}/rules.mk + +PKG_NAME:= alix-switch +PKG_VERSION:= 1.0 +PKG_RELEASE:= 1 +PKG_DESCR:= simple daemon listening on button events +PKG_SECTION:= base + +PKG_TARGET_DEPENDS:= alix + +NO_DISTFILES:= 1 + +include ${TOPDIR}/mk/package.mk + +$(eval $(call PKG_template,ALIX_SWITCH,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION})) + +PKGDFLT_ALIX_SWITCH= y + +CONFIG_STYLE:= manual +BUILD_STYLE:= manual +INSTALL_STYLE:= manual + +do-build: + ${TARGET_CC} -Wall ${TCPPFLAGS} ${TCFLAGS} \ + -o ${WRKBUILD}/alix-switchd ${WRKBUILD}/alix-switchd.c + +do-install: + ${INSTALL_DIR} ${IDIR_ALIX_SWITCH}/usr/sbin ${IDIR_ALIX_SWITCH}/etc + ${INSTALL_BIN} ${WRKBUILD}/alix-switchd ${IDIR_ALIX_SWITCH}/usr/sbin + ${INSTALL_BIN} ./files/alix-switch ${IDIR_ALIX_SWITCH}/etc + +include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/alix-switch/files/alix-switch b/package/alix-switch/files/alix-switch new file mode 100644 index 000000000..ad439a221 --- /dev/null +++ b/package/alix-switch/files/alix-switch @@ -0,0 +1,15 @@ +#!/bin/sh +# launched by alix-switchd in case of button event + +case "$1" in + on) + echo "alix-switch: on" + ;; + off) + echo "alix-switch: off" + ;; + *) + echo "Usage: $0 {on|off}" + ;; +esac +exit 0 diff --git a/package/alix-switch/files/alix-switch.init b/package/alix-switch/files/alix-switch.init new file mode 100644 index 000000000..c783a1be5 --- /dev/null +++ b/package/alix-switch/files/alix-switch.init @@ -0,0 +1,27 @@ +#!/bin/sh +#PKG alix-switch +#INIT 10 + +. /etc/rc.conf + +case $1 in +autostop) ;; +autostart) + test x"${alix_switch:-NO}" = x"NO" && exit 0 + exec sh $0 start + ;; +start) + alix-switchd -d + ;; +stop) + pkill alix-switchd + ;; +restart) + sh $0 stop + sh $0 start + ;; +*) + echo "usage: $0 (start|stop|restart)" + exit 1 +esac +exit $? diff --git a/package/alix-switch/files/alix-switch.postinst b/package/alix-switch/files/alix-switch.postinst new file mode 100644 index 000000000..6e0e60f12 --- /dev/null +++ b/package/alix-switch/files/alix-switch.postinst @@ -0,0 +1,3 @@ +#!/bin/sh +. $IPKG_INSTROOT/etc/functions.sh +add_rcconf alix_switchd alix_switchd NO diff --git a/package/alix-switch/src/alix-switchd.c b/package/alix-switch/src/alix-switchd.c new file mode 100644 index 000000000..d98748fa1 --- /dev/null +++ b/package/alix-switch/src/alix-switchd.c @@ -0,0 +1,111 @@ +/* +* alix-switchd.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SCRIPT "/etc/alix-switch" +#define GPIOBASE 0x6100 + +typedef void (*sighandler_t)(int); + +static sighandler_t handle_signal (int sig_nr, sighandler_t signalhandler) { + + struct sigaction neu_sig, alt_sig; + + neu_sig.sa_handler = signalhandler; + sigemptyset(&neu_sig.sa_mask); + neu_sig.sa_flags = SA_RESTART; + if (sigaction (sig_nr, &neu_sig, &alt_sig) < 0) + return SIG_ERR; + + return alt_sig.sa_handler; +} + +static void start_daemon (void) { + + int i; + pid_t pid; + + if (setsid() > 0) + exit(EXIT_FAILURE); + + handle_signal(SIGHUP, SIG_IGN); + + if ((pid = fork ()) != 0) + exit(EXIT_FAILURE); + + chdir("/"); + umask(0); + for (i = sysconf(_SC_OPEN_MAX); i > 0; i--) + close(i); +} + + +int main(int argc, char *argv[]) { + + int i; + unsigned long bPort = 0; + struct timespec sleep; + int bDaemon = 0, bSwitch = 0, bState = 0; + + for(i = 1; i < argc; i++) { + if (!strcasecmp(argv[i], "-d") || !strcasecmp(argv[i], "--daemon")) { + bDaemon = 1; + } else { + printf( "\nusage: %s [-d | --daemon]\n", argv[0]); + exit(EXIT_FAILURE); + } + } + + if (iopl(3)) { + fprintf( stderr, "Could not set I/O permissions to level 3\n"); + exit(EXIT_FAILURE); + } + + if (bDaemon) + start_daemon(); + + sleep.tv_sec = 0; + sleep.tv_nsec = 50000000; + + while(1) { + bPort = inl(GPIOBASE + 0xB0); + if ((bPort & 0x100) == 0) + bState = 1; + else + bState = 0; + + if (bState && !bSwitch) + system(SCRIPT " on"); + + bSwitch = bState; + nanosleep(&sleep, NULL); + } + + if (iopl(0)) { + fprintf(stderr, "Could not set I/O permissions to level 0"); + exit(EXIT_FAILURE); + } + + return EXIT_SUCCESS; +} diff --git a/package/cfgfs/Makefile b/package/cfgfs/Makefile index b7ca8a67c..96e297cfb 100644 --- a/package/cfgfs/Makefile +++ b/package/cfgfs/Makefile @@ -14,7 +14,7 @@ PKG_TARGET_DEPENDS:= alix wrap foxboard ag241 foxg20 routerboard WRKDIST= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION} NO_DISTFILES:= 1 -CFLINE_CFGFS:= select BUSYBOX_COMM\n\tselect BUSYBOX_MD5SUM\n\tselect BUSYBOX_XARGS\n\tselect BUSYBOX_FEATURE_SORT_BIG\n\tselect BUSYBOX_DIFF\n\tdepends on !ADK_TARGET_ROOTFS_NFSROOT +CFLINE_CFGFS:= select BUSYBOX_COMM\n\tselect BUSYBOX_MD5SUM\n\tselect BUSYBOX_XARGS\n\tselect BUSYBOX_FEATURE_SORT_BIG\n\tselect BUSYBOX_DIFF\n\tdepends on !ADK_TARGET_ROOTFS_NFSROOT && !ADK_TARGET_ROOTFS_INITRAMFS_PIGGYBACK && !ADK_TARGET_ROOTFS_INITRAMFS include ${TOPDIR}/mk/package.mk diff --git a/package/grub-bin/Makefile b/package/grub-bin/Makefile index df8a0d9d3..d4ec32554 100644 --- a/package/grub-bin/Makefile +++ b/package/grub-bin/Makefile @@ -14,7 +14,7 @@ PKG_SECTION:= base PKG_SITES:= http://openadk.org/distfiles/ PKG_TARGET_DEPENDS:= x86 x86_64 -CFLINE_GRUB_BIN:= select BUSYBOX_FEATURE_STAT_FORMAT +CFLINE_GRUB_BIN:= select BUSYBOX_FEATURE_STAT_FORMAT\n\tdepends on !ADK_TARGET_ROOTFS_INITRAMFS_PIGGYBACK && !ADK_TARGET_ROOTFS_INITRAMFS include ${TOPDIR}/mk/package.mk -- cgit v1.2.3 From 0e1f2bc120434cae43ba460fdc0519c0a1301b42 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sat, 26 Jun 2010 21:27:19 +0200 Subject: update to latest grub (binary package) --- package/grub-bin/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'package') diff --git a/package/grub-bin/Makefile b/package/grub-bin/Makefile index b74263b58..c1d412b32 100644 --- a/package/grub-bin/Makefile +++ b/package/grub-bin/Makefile @@ -4,11 +4,11 @@ include ${TOPDIR}/rules.mk # compiled with i486 toolchain, statically linked with uClibc -# cross-compile on amd64 does not work, so provide a binary package +# cross-compiling is difficult, so provide a binary package PKG_NAME:= grub-bin -PKG_VERSION:= 1.97.1 +PKG_VERSION:= 1.98 PKG_RELEASE:= 1 -PKG_MD5SUM:= 24961a39e63d8ec16d765aad3a301cda +PKG_MD5SUM:= 958f9fd415a0bd52fe115176afbf19d9 PKG_DESCR:= GRUB2 bootloader (binary package) PKG_SECTION:= base PKG_SITES:= http://openadk.org/distfiles/ -- cgit v1.2.3