add ap51-flash
authorNicolas Thill <nico@openwrt.org>
Thu, 28 Jan 2010 16:16:55 +0000 (16:16 +0000)
committerNicolas Thill <nico@openwrt.org>
Thu, 28 Jan 2010 16:16:55 +0000 (16:16 +0000)
SVN-Revision: 19360

utils/ap51-flash/Makefile [new file with mode: 0644]
utils/ap51-flash/files/ap51-flash.conf [new file with mode: 0644]
utils/ap51-flash/files/ap51-flash.init [new file with mode: 0644]
utils/ap51-flash/patches/001-flags.patch [new file with mode: 0644]

diff --git a/utils/ap51-flash/Makefile b/utils/ap51-flash/Makefile
new file mode 100644 (file)
index 0000000..d08bfdc
--- /dev/null
@@ -0,0 +1,41 @@
+# 
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ap51-flash
+PKG_REV:=195
+PKG_VERSION:=r$(PKG_REV)
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=svn
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE_SUBDIR:=ap51-flash-$(PKG_VERSION)
+PKG_SOURCE_URL:=http://dev.open-mesh.com/downloads/svn/ap51-flash/trunk
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/ap51-flash
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=A tool for flashing (nearly) all ap51/ap61 based routers
+  URL:=http://dev.open-mesh.com/wiki/ap51-flash-station
+  DEPENDS:=+libpcap
+endef
+
+# pass optimization flags
+MAKE_FLAGS += \
+       OFLAGS="$(TARGET_CFLAGS)" \
+
+define Package/ap51-flash/install
+       $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ap51-flash $(1)/usr/sbin/
+       $(INSTALL_BIN) ./files/ap51-flash.init $(1)/etc/init.d/ap51-flash
+       $(INSTALL_DATA) ./files/ap51-flash.conf $(1)/etc/config/ap51-flash
+endef
+
+$(eval $(call BuildPackage,ap51-flash))
diff --git a/utils/ap51-flash/files/ap51-flash.conf b/utils/ap51-flash/files/ap51-flash.conf
new file mode 100644 (file)
index 0000000..7c48ab2
--- /dev/null
@@ -0,0 +1,5 @@
+#config flash
+#      option ifname   eth0.1
+#      option rootfs   /tmp/images/openwrt-atheros-root.squashfs
+#      option kernel   /tmp/images/openwrt-atheros-vmlinux.lzma
+##     option ubnt     /tmp/images/openwrt-atheros-ubnt5-squashfs.bin
diff --git a/utils/ap51-flash/files/ap51-flash.init b/utils/ap51-flash/files/ap51-flash.init
new file mode 100644 (file)
index 0000000..ec5bb9e
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2007 OpenWrt.org
+
+START=20
+
+NAME=ap51-flash
+
+start_daemon() {
+       local cfg="$1"
+
+       config_get ifname "$cfg" ifname
+       config_get rootfs "$cfg" rootfs
+       config_get kernel "$cfg" kernel
+       config_get ubntimg "$cfg" ubntimg
+       if [ -n "$ifname" -a -n "$rootfs" -a -n "$kernel" ]; then
+               [ -n "`ls /var/run/$NAME-$ifname.pid 2> /dev/null`" ] && {
+                       echo "Can't start more than one ap51-flash for interface $ifname!"
+                       return 0
+               }
+               start-stop-daemon -S -b -m -p /var/run/$NAME-$ifname.pid -n $NAME -x /usr/sbin/$NAME -- $ifname $rootfs $kernel
+       elif [ -n "$ifname" -a -n "$ubntimg" ]; then
+               [ -n "`ls /var/run/$NAME-$ifname-ubnt.pid 2> /dev/null`" ] && {
+                       echo "Can't start more than one ap51-flash (ubnt) for interface $ifname!"
+                       return 0
+               }
+               start-stop-daemon -S -b -m -p /var/run/$NAME-$ifname-ubnt.pid -n $NAME -x /usr/sbin/$NAME -- $ifname $ubntimg
+       fi
+}
+
+start() {
+       config_load ap51-flash
+       config_foreach start_daemon flash
+}
+
+stop() {
+       # Terminating all ap51-flash processes
+       echo "WARNING: Going to teminate all ap51-flash processes! (hope you made sure that they're not flashing right now)"
+       echo "OR you can stop this with Ctrl+c within 10 seconds"
+       sleep 10
+       local pidfile
+       for pidfile in `ls /var/run/${NAME}-*.pid 2> /dev/null`; do
+               start-stop-daemon -K -s TERM -p "${pidfile}" -n "${NAME}" >/dev/null
+               rm -f "${pidfile}"
+       done
+}
diff --git a/utils/ap51-flash/patches/001-flags.patch b/utils/ap51-flash/patches/001-flags.patch
new file mode 100644 (file)
index 0000000..41c8712
--- /dev/null
@@ -0,0 +1,12 @@
+--- a/Makefile
++++ b/Makefile
+@@ -21,7 +21,8 @@ AR      = $(CROSS)ar
+ STRIP   = $(CROSS)strip
+ OBJCOPY = $(CROSS)objcopy
+ WINDRES = $(CROSS)windres
+-CFLAGS  = -Wall -ggdb -I. -IWpdPack/Include/ -fno-strict-aliasing -fpack-struct -Os
++OFLAGS  = -Os -ggdb
++CFLAGS  = -Wall -I. -IWpdPack/Include/ -fno-strict-aliasing -fpack-struct $(OFLAGS)
+ LIB_OBJS= ap51-flash.o uip.o uip_arp.o timer.o clock-arch.o psock.o packet.o
+ OBJS    = $(LIB_OBJS) main.o
+ AP51_RC = ap51-flash-res