From bb17a19fcc7f7d10369eed7f6c8662f6e4df9d4b Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 17 Dec 2009 17:36:04 +0100 Subject: enable cfgfs and atm - make cfgfs work for ag241 - split mtd to separate package to control dependencies - update linux-atm package to latest upstream - enable atm kernel module building --- package/Config.in | 4 +- package/cfgfs/Config.in | 2 + package/cfgfs/Makefile | 9 +- package/cfgfs/src/mtd.c | 379 --------------------- package/iptables/Config.in | 10 - package/linux-atm/Config.in | 9 +- package/linux-atm/Config.in.lib | 10 + package/linux-atm/Makefile | 8 +- package/linux-atm/patches/patch-src_Makefile_in | 12 +- package/linux-atm/patches/patch-src_led_main_c | 11 - .../linux-atm/patches/patch-src_qgen_Makefile_in | 29 +- package/linux-atm/patches/patch-src_qgen_ql_l_c | 12 - .../linux-atm/patches/patch-src_sigd_Makefile_in | 7 +- package/linux-atm/patches/patch-src_sigd_cfg_l_c | 12 - package/linux-atm/patches/patch-src_sigd_cfg_l_l | 10 + .../linux-atm/patches/patch-src_switch_Makefile_in | 11 + package/linux-atm/patches/patch-src_switch_cfg_l_c | 12 - package/linux-atm/patches/patch-src_switch_cfg_l_l | 10 + .../patches/patch-src_switch_debug_Makefile_in | 7 +- .../patches/patch-src_switch_tcp_Makefile_in | 9 +- .../linux-atm/patches/patch-src_test_Makefile_in | 12 - package/linux-atm/patches/patch-src_test_ispl_l_c | 12 - package/linux-atm/patches/patch-src_test_ttcp_c | 21 -- package/mtd/Config.in | 9 + package/mtd/Makefile | 32 ++ package/mtd/src/mtd.c | 379 +++++++++++++++++++++ 26 files changed, 499 insertions(+), 539 deletions(-) delete mode 100644 package/cfgfs/src/mtd.c create mode 100644 package/linux-atm/Config.in.lib delete mode 100644 package/linux-atm/patches/patch-src_led_main_c delete mode 100644 package/linux-atm/patches/patch-src_qgen_ql_l_c delete mode 100644 package/linux-atm/patches/patch-src_sigd_cfg_l_c create mode 100644 package/linux-atm/patches/patch-src_sigd_cfg_l_l create mode 100644 package/linux-atm/patches/patch-src_switch_Makefile_in delete mode 100644 package/linux-atm/patches/patch-src_switch_cfg_l_c create mode 100644 package/linux-atm/patches/patch-src_switch_cfg_l_l delete mode 100644 package/linux-atm/patches/patch-src_test_Makefile_in delete mode 100644 package/linux-atm/patches/patch-src_test_ispl_l_c delete mode 100644 package/linux-atm/patches/patch-src_test_ttcp_c create mode 100644 package/mtd/Config.in create mode 100644 package/mtd/Makefile create mode 100644 package/mtd/src/mtd.c (limited to 'package') diff --git a/package/Config.in b/package/Config.in index 1cc29c402..c6f714d74 100644 --- a/package/Config.in +++ b/package/Config.in @@ -55,6 +55,7 @@ source "package/dosfstools/Config.in" source "package/e2fsprogs/Config.in" source "package/fuse/Config.in" source "package/mdadm/Config.in" +source "package/mtd/Config.in" source "package/lvm/Config.in" source "package/parted/Config.in" source "package/util-linux-ng/Config.in" @@ -236,6 +237,7 @@ endmenu menu "Firewall / Routing / Bridging" source "package/arpd/Config.in" source "package/bridge-utils/Config.in" +source "package/linux-atm/Config.in" source "package/cutter/Config.in" source "package/ebtables/Config.in" source "package/ether-wake/Config.in" @@ -243,7 +245,6 @@ source "package/iproute2/Config.in" source "package/ipset/Config.in" source "package/iptables/Config.in" source "package/knock/Config.in" -source "package/linux-atm/Config.in" source "package/macchanger/Config.in" source "package/netstat-nat/Config.in" source "package/quagga/Config.in" @@ -407,6 +408,7 @@ source "package/id3lib/Config.in" source "package/libao/Config.in" source "package/libaudiofile/Config.in" source "package/libart/Config.in" +source "package/linux-atm/Config.in.lib" source "package/libcli/Config.in" source "package/curl/Config.in.lib" source "package/libdaemon/Config.in" diff --git a/package/cfgfs/Config.in b/package/cfgfs/Config.in index fcda6c97e..911027433 100644 --- a/package/cfgfs/Config.in +++ b/package/cfgfs/Config.in @@ -5,11 +5,13 @@ config ADK_PACKAGE_CFGFS select BUSYBOX_MD5SUM select BUSYBOX_XARGS select BUSYBOX_FEATURE_SORT_BIG + select ADK_PACKAGE_MTD depends on \ ADK_LINUX_X86_ALIX1C || \ ADK_LINUX_X86_ALIX2D || \ ADK_LINUX_X86_WRAP || \ ADK_LINUX_CRIS_FOXBOARD || \ + ADK_LINUX_MIPS_AG241 || \ ADK_LINUX_MIPS_RB532 default y help diff --git a/package/cfgfs/Makefile b/package/cfgfs/Makefile index 50d571e90..17ab5e6a7 100644 --- a/package/cfgfs/Makefile +++ b/package/cfgfs/Makefile @@ -5,7 +5,7 @@ include ${TOPDIR}/rules.mk PKG_NAME:= cfgfs PKG_VERSION:= 1.0.6 -PKG_RELEASE:= 3 +PKG_RELEASE:= 4 PKG_DESCR:= compressed config filesystem PKG_SECTION:= base @@ -21,14 +21,11 @@ BUILD_STYLE:= auto do-configure: mkdir -p ${WRKBUILD} ${CP} ./src/* ${WRKBUILD} - ${TARGET_CC} ${TCPPFLAGS} ${TCFLAGS} -o ${WRKBUILD}/mtd ${WRKBUILD}/mtd.c do-install: ${INSTALL_DIR} ${IDIR_CFGFS}/sbin ${INSTALL_BIN} ${WRKBUILD}/fwcf.sh ${IDIR_CFGFS}/sbin/cfgfs - ${INSTALL_BIN} ${WRKBUILD}/fwcf.helper.out ${IDIR_CFGFS}/sbin/cfgfs.helper -ifeq ($(ARCH),cris) - ${INSTALL_BIN} ${WRKBUILD}/mtd ${IDIR_CFGFS}/sbin/mtd -endif + ${INSTALL_BIN} ${WRKBUILD}/fwcf.helper.out \ + ${IDIR_CFGFS}/sbin/cfgfs.helper include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/cfgfs/src/mtd.c b/package/cfgfs/src/mtd.c deleted file mode 100644 index 6812c5e31..000000000 --- a/package/cfgfs/src/mtd.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * mtd - simple memory technology device manipulation tool - * - * Copyright (c) 2006, 2007 Thorsten Glaser - * Copyright (C) 2005 Waldemar Brodkorb , - * Felix Fietkau - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The code is based on the linux-mtd examples. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define BUFSIZE (16 * 1024) -#define MAX_ARGS 8 - -#define DEBUG - -int mtd_check(char *); -int mtd_unlock(const char *); -int mtd_open(const char *, int); -int mtd_erase(const char *); -int mtd_write(int, const char *, int, bool); -void usage(void) __attribute__((noreturn)); - -char buf[BUFSIZE]; -int buflen; - -int -mtd_check(char *mtd) -{ - struct mtd_info_user mtdInfo; - int fd; - - fd = mtd_open(mtd, O_RDWR | O_SYNC); - if(fd < 0) { - fprintf(stderr, "Could not open mtd device: %s\n", mtd); - return 0; - } - - if(ioctl(fd, MEMGETINFO, &mtdInfo)) { - fprintf(stderr, "Could not get MTD device info from %s\n", mtd); - close(fd); - return 0; - } - - close(fd); - return 1; -} - -int -mtd_unlock(const char *mtd) -{ - int fd; - struct mtd_info_user mtdInfo; - struct erase_info_user mtdLockInfo; - - fd = mtd_open(mtd, O_RDWR | O_SYNC); - if(fd < 0) { - fprintf(stderr, "Could not open mtd device: %s\n", mtd); - exit(1); - } - - if(ioctl(fd, MEMGETINFO, &mtdInfo)) { - fprintf(stderr, "Could not get MTD device info from %s\n", mtd); - close(fd); - exit(1); - } - - mtdLockInfo.start = 0; - mtdLockInfo.length = mtdInfo.size; - if(ioctl(fd, MEMUNLOCK, &mtdLockInfo)) { - close(fd); - return 0; - } - - close(fd); - return 0; -} - -int -mtd_open(const char *mtd, int flags) -{ - FILE *fp; - char dev[PATH_MAX]; - int i; - - if ((fp = fopen("/proc/mtd", "r"))) { - while (fgets(dev, sizeof(dev), fp)) { - if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) { - snprintf(dev, sizeof(dev), "/dev/mtd%d", i); - fclose(fp); - return open(dev, flags); - } - } - fclose(fp); - } - - return open(mtd, flags); -} - -int -mtd_erase(const char *mtd) -{ - int fd; - struct mtd_info_user mtdInfo; - struct erase_info_user mtdEraseInfo; - - fd = mtd_open(mtd, O_RDWR | O_SYNC); - if(fd < 0) { - fprintf(stderr, "Could not open mtd device: %s\n", mtd); - exit(1); - } - - if(ioctl(fd, MEMGETINFO, &mtdInfo)) { - fprintf(stderr, "Could not get MTD device info from %s\n", mtd); - close(fd); - exit(1); - } - - mtdEraseInfo.length = mtdInfo.erasesize; - - for (mtdEraseInfo.start = 0; - mtdEraseInfo.start < mtdInfo.size; - mtdEraseInfo.start += mtdInfo.erasesize) { - - ioctl(fd, MEMUNLOCK, &mtdEraseInfo); - if(ioctl(fd, MEMERASE, &mtdEraseInfo)) { - fprintf(stderr, "Could not erase MTD device: %s\n", mtd); - close(fd); - exit(1); - } - } - - close(fd); - return 0; - -} - -int -mtd_write(int imagefd, const char *mtd, int quiet, bool do_erase) -{ - int fd, result; - size_t r, w, e; - struct mtd_info_user mtdInfo; - struct erase_info_user mtdEraseInfo; - - fd = mtd_open(mtd, O_RDWR | O_SYNC); - if(fd < 0) { - fprintf(stderr, "Could not open mtd device: %s\n", mtd); - exit(1); - } - - if(ioctl(fd, MEMGETINFO, &mtdInfo)) { - fprintf(stderr, "Could not get MTD device info from %s\n", mtd); - close(fd); - exit(1); - } - - r = w = e = 0; - if (!quiet) - fprintf(stderr, " [ ]"); - - for (;;) { - /* buffer may contain data already (from trx check) */ - r = buflen; - r += read(imagefd, buf + buflen, BUFSIZE - buflen); - w += r; - - /* EOF */ - if (r <= 0) break; - - /* need to erase the next block before writing data to it */ - while (do_erase && w > e) { - mtdEraseInfo.start = e; - mtdEraseInfo.length = mtdInfo.erasesize; - - if (!quiet) - fprintf(stderr, "\b\b\b[e]"); - /* erase the chunk */ - if (ioctl (fd,MEMERASE,&mtdEraseInfo) < 0) { - fprintf(stderr, "Erasing mtd failed: %s\n", mtd); - exit(1); - } - e += mtdInfo.erasesize; - } - - if (!quiet) - fprintf(stderr, "\b\b\b[w]"); - - if ((result = write(fd, buf, r)) < (ssize_t)r) { - if (result < 0) { - fprintf(stderr, "Error writing image.\n"); - exit(1); - } else { - fprintf(stderr, "Insufficient space.\n"); - exit(1); - } - } - - buflen = 0; - } - if (!quiet) - fprintf(stderr, "\b\b\b\b"); - - close(fd); - return 0; -} - -void -usage(void) -{ - fprintf(stderr, "Usage: mtd [ ...] [ ...] \n\n" - "The device is in the format of mtdX (eg: mtd4) or its label.\n" - "mtd recognises these commands:\n" - " unlock unlock the device\n" - " erase erase all data on device\n" - " write |- write (use - for stdin) to device\n" - "Following options are available:\n" - " -q quiet mode (once: no [w] on writing,\n" - " twice: no status messages)\n" - " -e erase before executing the command\n\n" - "Example: To write linux.trx to mtd1 labeled as linux\n" - " mtd write linux.trx linux\n\n"); - exit(1); -} - -int -main(int argc, char **argv) -{ - int ch, i, imagefd = -1, quiet, unlocked; - char *erase[MAX_ARGS], *device; - const char *imagefile = NULL; - enum { - CMD_ERASE, - CMD_WRITE, - CMD_UNLOCK - } cmd; - - erase[0] = NULL; - buflen = 0; - quiet = 0; - - while ((ch = getopt(argc, argv, "Fqe:")) != -1) - switch (ch) { - case 'F': - quiet = 1; - /* FALLTHROUGH */ - case 'q': - quiet++; - break; - case 'e': - i = 0; - while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS)) - i++; - - erase[i++] = optarg; - erase[i] = NULL; - break; - - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (argc < 2) - usage(); - - if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) { - cmd = CMD_UNLOCK; - device = argv[1]; - } else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) { - cmd = CMD_ERASE; - device = argv[1]; - } else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) { - cmd = CMD_WRITE; - device = argv[2]; - - if (strcmp(argv[1], "-") == 0) { - imagefile = ""; - imagefd = 0; - } else { - imagefile = argv[1]; - if ((imagefd = open(argv[1], O_RDONLY)) < 0) { - fprintf(stderr, "Couldn't open image file: %s!\n", imagefile); - exit(1); - } - } - - if (!mtd_check(device)) { - fprintf(stderr, "Can't open device for writing!\n"); - exit(1); - } - } else { - usage(); - } - - sync(); - - i = 0; - unlocked = 0; - while (erase[i] != NULL) { - if (quiet < 2) - fprintf(stderr, "Unlocking %s ...\n", erase[i]); - mtd_unlock(erase[i]); - if (quiet < 2) - fprintf(stderr, "Erasing %s ...\n", erase[i]); - mtd_erase(erase[i]); - if (strcmp(erase[i], device) == 0) - /* this means that is unlocked and erased */ - unlocked = 1; - i++; - } - - if (!unlocked) { - if (quiet < 2) - fprintf(stderr, "Unlocking %s ...\n", device); - mtd_unlock(device); - } - - switch (cmd) { - case CMD_UNLOCK: - break; - case CMD_ERASE: - if (unlocked) { - fprintf(stderr, "Already erased: %s\n", device); - break; - } - if (quiet < 2) - fprintf(stderr, "Erasing %s ...\n", device); - mtd_erase(device); - break; - case CMD_WRITE: - if (quiet < 2) - fprintf(stderr, "Writing from %s to %s ... ", imagefile, device); - mtd_write(imagefd, device, quiet, (unlocked == 0)); - if (quiet < 2) - fprintf(stderr, "\n"); - break; - } - - sync(); - return 0; -} diff --git a/package/iptables/Config.in b/package/iptables/Config.in index 5b82599ad..56dd79cc9 100644 --- a/package/iptables/Config.in +++ b/package/iptables/Config.in @@ -21,16 +21,6 @@ config ADK_PACKAGE_IPTABLES http://www.iptables.org/ -config ADK_PACKAGE_IPTABLES_UTILS - prompt "iptables-utils.................. Save and restore utilities" - tristate - default n - depends on ADK_PACKAGE_IPTABLES - help - iptables-save and iptables-restore for Iptables (IPv4) - - http://www.iptables.org/ - config ADK_PACKAGE_IP6TABLES prompt "ip6tables......................... IPv6 firewall administration tool" tristate diff --git a/package/linux-atm/Config.in b/package/linux-atm/Config.in index e89db02d1..3991c679f 100644 --- a/package/linux-atm/Config.in +++ b/package/linux-atm/Config.in @@ -2,20 +2,13 @@ config ADK_COMPILE_LINUX_ATM bool default n help - -config ADK_PACKAGE_LIBATM - prompt "libatm............................. ATM Library for Linux" - tristate - default n - depends on !ADK_HOST_FREEBSD - help - ATM Library for linux config ADK_PACKAGE_BR2684CTL prompt "br2684ctl......................... RFC2684 bridging utility" tristate default n select ADK_PACKAGE_LIBATM + select ADK_COMPILE_LINUX_ATM depends on !ADK_HOST_FREEBSD help Utility for setting up ATM RFC2684 bridging mode. diff --git a/package/linux-atm/Config.in.lib b/package/linux-atm/Config.in.lib new file mode 100644 index 000000000..6c3e92d21 --- /dev/null +++ b/package/linux-atm/Config.in.lib @@ -0,0 +1,10 @@ +config ADK_PACKAGE_LIBATM + prompt "libatm............................ ATM Library for Linux" + tristate + default n + select ADK_COMPILE_LINUX_ATM + select ADK_KPACKAGE_KMOD_ATM + depends on !ADK_HOST_FREEBSD + help + ATM Library for linux. + diff --git a/package/linux-atm/Makefile b/package/linux-atm/Makefile index edb277885..2f32e7aa8 100644 --- a/package/linux-atm/Makefile +++ b/package/linux-atm/Makefile @@ -4,14 +4,16 @@ include ${TOPDIR}/rules.mk PKG_NAME:= linux-atm -PKG_VERSION:= 2.5.0 +PKG_VERSION:= 2.5.1 PKG_RELEASE:= 1 -PKG_MD5SUM:= 0b45a0e801fac7093ce4b0cadf419965 -PKG_DESCR:= ATM library for linux +PKG_MD5SUM:= 9560b0e1f410a05b849dfdab465dd758 +PKG_DESCR:= ATM library and tools for Linux PKG_SECTION:= libs PKG_URL:= http://linux-atm.sourceforge.net PKG_SITES:= ${MASTER_SITE_SOURCEFORGE:=linux-atm/} +DISTFILES:= ${PKG_NAME}-${PKG_VERSION}.tgz + PKG_DESCR_1:= br2684ctl PKG_DEPENDS_1:= libatm PKG_SECTION_1:= net diff --git a/package/linux-atm/patches/patch-src_Makefile_in b/package/linux-atm/patches/patch-src_Makefile_in index be1ca26b5..843577f7f 100644 --- a/package/linux-atm/patches/patch-src_Makefile_in +++ b/package/linux-atm/patches/patch-src_Makefile_in @@ -1,11 +1,11 @@ ---- linux-atm-2.5.0.orig/src/Makefile.in 2007-12-29 21:31:30.000000000 +0100 -+++ linux-atm-2.5.0/src/Makefile.in 2009-12-11 15:54:54.000000000 +0100 -@@ -179,7 +179,7 @@ target_os = @target_os@ - target_vendor = @target_vendor@ +--- linux-atm-2.5.1.orig/src/Makefile.in 2009-11-30 17:21:16.000000000 +0100 ++++ linux-atm-2.5.1/src/Makefile.in 2009-12-17 16:12:07.284420844 +0100 +@@ -214,7 +214,7 @@ target_vendor = @target_vendor@ + top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ --SUBDIRS = include lib test debug qgen saal sigd maint arpd ilmid man led lane \ -+SUBDIRS = include lib debug qgen saal sigd maint arpd ilmid man led lane \ +-SUBDIRS = include lib test debug qgen q2931 saal sigd maint arpd ilmid man led lane \ ++SUBDIRS = include lib debug qgen q2931 saal sigd maint arpd ilmid man led lane \ mpoad oamd switch config extra br2684 all: all-recursive diff --git a/package/linux-atm/patches/patch-src_led_main_c b/package/linux-atm/patches/patch-src_led_main_c deleted file mode 100644 index 63c5b5e9b..000000000 --- a/package/linux-atm/patches/patch-src_led_main_c +++ /dev/null @@ -1,11 +0,0 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/led/main.c 2005-10-06 19:27:50.000000000 +0200 -+++ linux-atm-2.5.0/src/led/main.c 2009-06-01 22:38:27.000000000 +0200 -@@ -31,6 +31,7 @@ - #endif - - /* Global includes */ -+#include - #include - #include - #include diff --git a/package/linux-atm/patches/patch-src_qgen_Makefile_in b/package/linux-atm/patches/patch-src_qgen_Makefile_in index 5c4bf490e..211ff90ff 100644 --- a/package/linux-atm/patches/patch-src_qgen_Makefile_in +++ b/package/linux-atm/patches/patch-src_qgen_Makefile_in @@ -1,33 +1,20 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/qgen/Makefile.in 2007-12-29 21:31:35.000000000 +0100 -+++ linux-atm-2.5.0/src/qgen/Makefile.in 2009-05-29 22:15:30.511416896 +0200 -@@ -92,9 +92,9 @@ AWK = @AWK@ - CC = @CC_FOR_BUILD@ - CCDEPMODE = @CCDEPMODE@ - CC_FOR_BUILD = @CC_FOR_BUILD@ --CFLAGS = @CFLAGS@ -+CFLAGS = -I../include +--- linux-atm-2.5.1.orig/src/qgen/Makefile.in 2009-11-30 17:21:18.000000000 +0100 ++++ linux-atm-2.5.1/src/qgen/Makefile.in 2009-12-17 16:17:11.216421967 +0100 +@@ -91,7 +91,7 @@ CC_FOR_BUILD = @CC_FOR_BUILD@ + CFLAGS = @CFLAGS_FOR_BUILD@ + CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -+CPPFLAGS = ++CPPFLAGS = CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ -@@ -116,7 +116,7 @@ INSTALL_DATA = @INSTALL_DATA@ +@@ -114,7 +114,7 @@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -+LDFLAGS= ++LDFLAGS = LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -208,7 +208,7 @@ top_srcdir = @top_srcdir@ - qgen_SOURCES = common.c common.h file.c file.h first.c ql_y.y ql_l.l qgen.c \ - qgen.h second.c third.c - --qgen_LDADD = -lfl -+qgen_LDADD = - q_dump_SOURCES = common.c - q_dump_LDADD = qd.dump.standalone.o - # FIXME: paulsch: We don't really depend on qd.dump.o or q.out.o here, but this diff --git a/package/linux-atm/patches/patch-src_qgen_ql_l_c b/package/linux-atm/patches/patch-src_qgen_ql_l_c deleted file mode 100644 index ac01bebfb..000000000 --- a/package/linux-atm/patches/patch-src_qgen_ql_l_c +++ /dev/null @@ -1,12 +0,0 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/qgen/ql_l.c 2007-12-24 20:46:13.000000000 +0100 -+++ linux-atm-2.5.0/src/qgen/ql_l.c 2009-05-29 22:10:55.010199430 +0200 -@@ -23,6 +23,8 @@ - - /* end standard C headers. */ - -+int yywrap(void) { return 1; } -+ - /* flex integer type definitions */ - - #ifndef FLEXINT_H diff --git a/package/linux-atm/patches/patch-src_sigd_Makefile_in b/package/linux-atm/patches/patch-src_sigd_Makefile_in index d48ea25e7..faa5a1385 100644 --- a/package/linux-atm/patches/patch-src_sigd_Makefile_in +++ b/package/linux-atm/patches/patch-src_sigd_Makefile_in @@ -1,7 +1,6 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/sigd/Makefile.in 2007-12-29 21:31:36.000000000 +0100 -+++ linux-atm-2.5.0/src/sigd/Makefile.in 2009-05-29 22:17:18.374156943 +0200 -@@ -223,7 +223,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s +--- linux-atm-2.5.1.orig/src/sigd/Makefile.in 2009-11-30 17:21:19.000000000 +0100 ++++ linux-atm-2.5.1/src/sigd/Makefile.in 2009-12-17 16:21:42.636433571 +0100 +@@ -244,7 +244,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s $(top_builddir)/src/lib/libatm.la \ $(top_builddir)/src/saal/libsaal.a diff --git a/package/linux-atm/patches/patch-src_sigd_cfg_l_c b/package/linux-atm/patches/patch-src_sigd_cfg_l_c deleted file mode 100644 index 91ace0a91..000000000 --- a/package/linux-atm/patches/patch-src_sigd_cfg_l_c +++ /dev/null @@ -1,12 +0,0 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/sigd/cfg_l.c 2007-12-24 20:46:31.000000000 +0100 -+++ linux-atm-2.5.0/src/sigd/cfg_l.c 2009-05-29 22:21:00.552981945 +0200 -@@ -23,6 +23,8 @@ - - /* end standard C headers. */ - -+int yywrap(void) { return 1; } -+ - /* flex integer type definitions */ - - #ifndef FLEXINT_H diff --git a/package/linux-atm/patches/patch-src_sigd_cfg_l_l b/package/linux-atm/patches/patch-src_sigd_cfg_l_l new file mode 100644 index 000000000..38bde1e58 --- /dev/null +++ b/package/linux-atm/patches/patch-src_sigd_cfg_l_l @@ -0,0 +1,10 @@ +--- linux-atm-2.5.1.orig/src/sigd/cfg_l.l 2004-09-25 13:25:48.000000000 +0200 ++++ linux-atm-2.5.1/src/sigd/cfg_l.l 2009-12-17 16:26:08.528422011 +0100 +@@ -16,6 +16,7 @@ + + #include "cfg_y.h" + ++int yywrap(void) { return 1; } + + static int lineno = 1; + static int token; /* f@#%ing flex doesn't grok return after BEGIN */ diff --git a/package/linux-atm/patches/patch-src_switch_Makefile_in b/package/linux-atm/patches/patch-src_switch_Makefile_in new file mode 100644 index 000000000..4a2981839 --- /dev/null +++ b/package/linux-atm/patches/patch-src_switch_Makefile_in @@ -0,0 +1,11 @@ +--- linux-atm-2.5.1.orig/src/switch/Makefile.in 2009-11-30 17:21:19.000000000 +0100 ++++ linux-atm-2.5.1/src/switch/Makefile.in 2009-12-17 16:30:47.392542123 +0100 +@@ -249,7 +249,7 @@ target_vendor = @target_vendor@ + top_build_prefix = @top_build_prefix@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ +-SUBDIRS = . debug tcp ++SUBDIRS = . tcp + noinst_LIBRARIES = libsw.a + swc_SOURCES = swc.c swc.h + swc_LDADD = $(top_builddir)/src/lib/libatm.la diff --git a/package/linux-atm/patches/patch-src_switch_cfg_l_c b/package/linux-atm/patches/patch-src_switch_cfg_l_c deleted file mode 100644 index c0f08dc69..000000000 --- a/package/linux-atm/patches/patch-src_switch_cfg_l_c +++ /dev/null @@ -1,12 +0,0 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/switch/cfg_l.c 2007-12-24 20:47:23.000000000 +0100 -+++ linux-atm-2.5.0/src/switch/cfg_l.c 2009-05-29 22:27:33.024571460 +0200 -@@ -23,6 +23,8 @@ - - /* end standard C headers. */ - -+int yywrap(void) { return 1; } -+ - /* flex integer type definitions */ - - #ifndef FLEXINT_H diff --git a/package/linux-atm/patches/patch-src_switch_cfg_l_l b/package/linux-atm/patches/patch-src_switch_cfg_l_l new file mode 100644 index 000000000..ec00bc66b --- /dev/null +++ b/package/linux-atm/patches/patch-src_switch_cfg_l_l @@ -0,0 +1,10 @@ +--- linux-atm-2.5.1.orig/src/switch/cfg_l.l 2001-10-10 00:33:08.000000000 +0200 ++++ linux-atm-2.5.1/src/switch/cfg_l.l 2009-12-17 16:37:59.408538574 +0100 +@@ -15,6 +15,7 @@ + + #include "cfg_y.h" + ++int yywrap(void) { return 1; } + + static int lineno = 1; + static int token; /* f@#%ing flex doesn't grok return after BEGIN */ diff --git a/package/linux-atm/patches/patch-src_switch_debug_Makefile_in b/package/linux-atm/patches/patch-src_switch_debug_Makefile_in index 34f1db7da..2d8fa57d2 100644 --- a/package/linux-atm/patches/patch-src_switch_debug_Makefile_in +++ b/package/linux-atm/patches/patch-src_switch_debug_Makefile_in @@ -1,7 +1,6 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/switch/debug/Makefile.in 2007-12-29 21:31:36.000000000 +0100 -+++ linux-atm-2.5.0/src/switch/debug/Makefile.in 2009-05-29 22:23:13.656360541 +0200 -@@ -191,7 +191,7 @@ sw_debug_SOURCES = debug.c +--- linux-atm-2.5.1.orig/src/switch/debug/Makefile.in 2009-11-30 17:21:19.000000000 +0100 ++++ linux-atm-2.5.1/src/switch/debug/Makefile.in 2009-12-17 16:28:31.520542232 +0100 +@@ -199,7 +199,7 @@ sw_debug_SOURCES = debug.c sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \ $(top_builddir)/src/lib/libatm.la diff --git a/package/linux-atm/patches/patch-src_switch_tcp_Makefile_in b/package/linux-atm/patches/patch-src_switch_tcp_Makefile_in index e40a65b23..f23a64405 100644 --- a/package/linux-atm/patches/patch-src_switch_tcp_Makefile_in +++ b/package/linux-atm/patches/patch-src_switch_tcp_Makefile_in @@ -1,12 +1,11 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/switch/tcp/Makefile.in 2007-12-29 21:31:37.000000000 +0100 -+++ linux-atm-2.5.0/src/switch/tcp/Makefile.in 2009-05-29 22:35:16.037506912 +0200 -@@ -191,7 +191,7 @@ sw_tcp_SOURCES = tcpsw.c +--- linux-atm-2.5.1.orig/src/switch/tcp/Makefile.in 2009-11-30 17:21:19.000000000 +0100 ++++ linux-atm-2.5.1/src/switch/tcp/Makefile.in 2009-12-17 16:33:08.832418828 +0100 +@@ -199,7 +199,7 @@ sw_tcp_SOURCES = tcpsw.c sw_tcp_XTRAS = $(top_builddir)/src/switch/libsw.a \ $(top_builddir)/src/lib/libatm.la -sw_tcp_LDADD = $(sw_tcp_XTRAS) -lfl -+sw_tcp_LDADD = $(sw_tcp_XTRAS) ++sw_tcp_LDADD = $(sw_tcp_XTRAS) sw_tcp_DEPENDENCIES = $(sw_tcp_XTRAS) EXTRA_DIST = mkfiles README all: all-am diff --git a/package/linux-atm/patches/patch-src_test_Makefile_in b/package/linux-atm/patches/patch-src_test_Makefile_in deleted file mode 100644 index af972e59e..000000000 --- a/package/linux-atm/patches/patch-src_test_Makefile_in +++ /dev/null @@ -1,12 +0,0 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/test/Makefile.in 2007-12-29 21:31:37.000000000 +0100 -+++ linux-atm-2.5.0/src/test/Makefile.in 2009-05-29 21:38:58.834444157 +0200 -@@ -275,7 +275,7 @@ br_SOURCES = br.c - bw_SOURCES = bw.c - isp_SOURCES = isp.c isp.h ispl_y.y ispl_l.l - isp_XTRAS = $(LDADD) --isp_LDADD = $(isp_XTRAS) -lfl -+isp_LDADD = $(isp_XTRAS) - isp_DEPENDENCIES = $(isp_XTRAS) errnos.inc - window_SOURCES = window.c - CLEANFILES = errnos.inc diff --git a/package/linux-atm/patches/patch-src_test_ispl_l_c b/package/linux-atm/patches/patch-src_test_ispl_l_c deleted file mode 100644 index e7a8af5f2..000000000 --- a/package/linux-atm/patches/patch-src_test_ispl_l_c +++ /dev/null @@ -1,12 +0,0 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/test/ispl_l.c 2007-12-24 20:46:06.000000000 +0100 -+++ linux-atm-2.5.0/src/test/ispl_l.c 2009-05-29 21:41:01.398113709 +0200 -@@ -23,6 +23,8 @@ - - /* end standard C headers. */ - -+int yywrap(void) { return 1; } -+ - /* flex integer type definitions */ - - #ifndef FLEXINT_H diff --git a/package/linux-atm/patches/patch-src_test_ttcp_c b/package/linux-atm/patches/patch-src_test_ttcp_c deleted file mode 100644 index e436e9d9d..000000000 --- a/package/linux-atm/patches/patch-src_test_ttcp_c +++ /dev/null @@ -1,21 +0,0 @@ -$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ ---- linux-atm-2.5.0.orig/src/test/ttcp.c 2005-04-18 18:18:28.000000000 +0200 -+++ linux-atm-2.5.0/src/test/ttcp.c 2009-05-29 21:27:32.488378268 +0200 -@@ -331,7 +331,7 @@ int no_check = 0; - /* xmitr */ - if (optind == argc) - goto usage; -- bzero((char *)&sinhim, sizeof(sinhim)); -+ memset((char *)&sinhim, 0, sizeof(sinhim)); - if (atoi(host) > 0 ) { - /* Numeric */ - sinhim.sin_family = AF_INET; -@@ -345,7 +345,7 @@ int no_check = 0; - if ((addr=gethostbyname(host)) == NULL) - err("bad hostname"); - sinhim.sin_family = addr->h_addrtype; -- bcopy(addr->h_addr,(char*)&addr_tmp, addr->h_length); -+ memcpy((char*)&addr_tmp, addr->h_addr, addr->h_length); - #if defined(cray) - sinhim.sin_addr = addr_tmp; - #else diff --git a/package/mtd/Config.in b/package/mtd/Config.in new file mode 100644 index 000000000..aacc297b5 --- /dev/null +++ b/package/mtd/Config.in @@ -0,0 +1,9 @@ +config ADK_PACKAGE_MTD + prompt "mtd................................ mtd utility" + tristate + depends on \ + ADK_LINUX_CRIS_FOXBOARD || \ + ADK_LINUX_MIPS_AG241 + default n + help + MTD utility. diff --git a/package/mtd/Makefile b/package/mtd/Makefile new file mode 100644 index 000000000..67aa1f30c --- /dev/null +++ b/package/mtd/Makefile @@ -0,0 +1,32 @@ +# 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:= mtd +PKG_VERSION:= 1.0 +PKG_RELEASE:= 1 +PKG_DESCR:= MTD utility +PKG_SECTION:= base + +WRKDIST= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION} +NO_DISTFILES:= 1 + +include ${TOPDIR}/mk/package.mk + +$(eval $(call PKG_template,MTD,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION})) + +BUILD_STYLE:= manual +INSTALL_STYLE:= manual + +do-build: + mkdir -p ${WRKBUILD} + ${CP} ./src/* ${WRKBUILD} + ${TARGET_CC} ${TCPPFLAGS} ${TCFLAGS} -o ${WRKBUILD}/mtd \ + ${WRKBUILD}/mtd.c + +do-install: + ${INSTALL_DIR} ${IDIR_MTD}/sbin + ${INSTALL_BIN} ${WRKBUILD}/mtd ${IDIR_MTD}/sbin/mtd + +include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/mtd/src/mtd.c b/package/mtd/src/mtd.c new file mode 100644 index 000000000..6812c5e31 --- /dev/null +++ b/package/mtd/src/mtd.c @@ -0,0 +1,379 @@ +/* + * mtd - simple memory technology device manipulation tool + * + * Copyright (c) 2006, 2007 Thorsten Glaser + * Copyright (C) 2005 Waldemar Brodkorb , + * Felix Fietkau + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The code is based on the linux-mtd examples. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define BUFSIZE (16 * 1024) +#define MAX_ARGS 8 + +#define DEBUG + +int mtd_check(char *); +int mtd_unlock(const char *); +int mtd_open(const char *, int); +int mtd_erase(const char *); +int mtd_write(int, const char *, int, bool); +void usage(void) __attribute__((noreturn)); + +char buf[BUFSIZE]; +int buflen; + +int +mtd_check(char *mtd) +{ + struct mtd_info_user mtdInfo; + int fd; + + fd = mtd_open(mtd, O_RDWR | O_SYNC); + if(fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd); + return 0; + } + + if(ioctl(fd, MEMGETINFO, &mtdInfo)) { + fprintf(stderr, "Could not get MTD device info from %s\n", mtd); + close(fd); + return 0; + } + + close(fd); + return 1; +} + +int +mtd_unlock(const char *mtd) +{ + int fd; + struct mtd_info_user mtdInfo; + struct erase_info_user mtdLockInfo; + + fd = mtd_open(mtd, O_RDWR | O_SYNC); + if(fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd); + exit(1); + } + + if(ioctl(fd, MEMGETINFO, &mtdInfo)) { + fprintf(stderr, "Could not get MTD device info from %s\n", mtd); + close(fd); + exit(1); + } + + mtdLockInfo.start = 0; + mtdLockInfo.length = mtdInfo.size; + if(ioctl(fd, MEMUNLOCK, &mtdLockInfo)) { + close(fd); + return 0; + } + + close(fd); + return 0; +} + +int +mtd_open(const char *mtd, int flags) +{ + FILE *fp; + char dev[PATH_MAX]; + int i; + + if ((fp = fopen("/proc/mtd", "r"))) { + while (fgets(dev, sizeof(dev), fp)) { + if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) { + snprintf(dev, sizeof(dev), "/dev/mtd%d", i); + fclose(fp); + return open(dev, flags); + } + } + fclose(fp); + } + + return open(mtd, flags); +} + +int +mtd_erase(const char *mtd) +{ + int fd; + struct mtd_info_user mtdInfo; + struct erase_info_user mtdEraseInfo; + + fd = mtd_open(mtd, O_RDWR | O_SYNC); + if(fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd); + exit(1); + } + + if(ioctl(fd, MEMGETINFO, &mtdInfo)) { + fprintf(stderr, "Could not get MTD device info from %s\n", mtd); + close(fd); + exit(1); + } + + mtdEraseInfo.length = mtdInfo.erasesize; + + for (mtdEraseInfo.start = 0; + mtdEraseInfo.start < mtdInfo.size; + mtdEraseInfo.start += mtdInfo.erasesize) { + + ioctl(fd, MEMUNLOCK, &mtdEraseInfo); + if(ioctl(fd, MEMERASE, &mtdEraseInfo)) { + fprintf(stderr, "Could not erase MTD device: %s\n", mtd); + close(fd); + exit(1); + } + } + + close(fd); + return 0; + +} + +int +mtd_write(int imagefd, const char *mtd, int quiet, bool do_erase) +{ + int fd, result; + size_t r, w, e; + struct mtd_info_user mtdInfo; + struct erase_info_user mtdEraseInfo; + + fd = mtd_open(mtd, O_RDWR | O_SYNC); + if(fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd); + exit(1); + } + + if(ioctl(fd, MEMGETINFO, &mtdInfo)) { + fprintf(stderr, "Could not get MTD device info from %s\n", mtd); + close(fd); + exit(1); + } + + r = w = e = 0; + if (!quiet) + fprintf(stderr, " [ ]"); + + for (;;) { + /* buffer may contain data already (from trx check) */ + r = buflen; + r += read(imagefd, buf + buflen, BUFSIZE - buflen); + w += r; + + /* EOF */ + if (r <= 0) break; + + /* need to erase the next block before writing data to it */ + while (do_erase && w > e) { + mtdEraseInfo.start = e; + mtdEraseInfo.length = mtdInfo.erasesize; + + if (!quiet) + fprintf(stderr, "\b\b\b[e]"); + /* erase the chunk */ + if (ioctl (fd,MEMERASE,&mtdEraseInfo) < 0) { + fprintf(stderr, "Erasing mtd failed: %s\n", mtd); + exit(1); + } + e += mtdInfo.erasesize; + } + + if (!quiet) + fprintf(stderr, "\b\b\b[w]"); + + if ((result = write(fd, buf, r)) < (ssize_t)r) { + if (result < 0) { + fprintf(stderr, "Error writing image.\n"); + exit(1); + } else { + fprintf(stderr, "Insufficient space.\n"); + exit(1); + } + } + + buflen = 0; + } + if (!quiet) + fprintf(stderr, "\b\b\b\b"); + + close(fd); + return 0; +} + +void +usage(void) +{ + fprintf(stderr, "Usage: mtd [ ...] [ ...] \n\n" + "The device is in the format of mtdX (eg: mtd4) or its label.\n" + "mtd recognises these commands:\n" + " unlock unlock the device\n" + " erase erase all data on device\n" + " write |- write (use - for stdin) to device\n" + "Following options are available:\n" + " -q quiet mode (once: no [w] on writing,\n" + " twice: no status messages)\n" + " -e erase before executing the command\n\n" + "Example: To write linux.trx to mtd1 labeled as linux\n" + " mtd write linux.trx linux\n\n"); + exit(1); +} + +int +main(int argc, char **argv) +{ + int ch, i, imagefd = -1, quiet, unlocked; + char *erase[MAX_ARGS], *device; + const char *imagefile = NULL; + enum { + CMD_ERASE, + CMD_WRITE, + CMD_UNLOCK + } cmd; + + erase[0] = NULL; + buflen = 0; + quiet = 0; + + while ((ch = getopt(argc, argv, "Fqe:")) != -1) + switch (ch) { + case 'F': + quiet = 1; + /* FALLTHROUGH */ + case 'q': + quiet++; + break; + case 'e': + i = 0; + while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS)) + i++; + + erase[i++] = optarg; + erase[i] = NULL; + break; + + case '?': + default: + usage(); + } + argc -= optind; + argv += optind; + + if (argc < 2) + usage(); + + if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) { + cmd = CMD_UNLOCK; + device = argv[1]; + } else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) { + cmd = CMD_ERASE; + device = argv[1]; + } else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) { + cmd = CMD_WRITE; + device = argv[2]; + + if (strcmp(argv[1], "-") == 0) { + imagefile = ""; + imagefd = 0; + } else { + imagefile = argv[1]; + if ((imagefd = open(argv[1], O_RDONLY)) < 0) { + fprintf(stderr, "Couldn't open image file: %s!\n", imagefile); + exit(1); + } + } + + if (!mtd_check(device)) { + fprintf(stderr, "Can't open device for writing!\n"); + exit(1); + } + } else { + usage(); + } + + sync(); + + i = 0; + unlocked = 0; + while (erase[i] != NULL) { + if (quiet < 2) + fprintf(stderr, "Unlocking %s ...\n", erase[i]); + mtd_unlock(erase[i]); + if (quiet < 2) + fprintf(stderr, "Erasing %s ...\n", erase[i]); + mtd_erase(erase[i]); + if (strcmp(erase[i], device) == 0) + /* this means that is unlocked and erased */ + unlocked = 1; + i++; + } + + if (!unlocked) { + if (quiet < 2) + fprintf(stderr, "Unlocking %s ...\n", device); + mtd_unlock(device); + } + + switch (cmd) { + case CMD_UNLOCK: + break; + case CMD_ERASE: + if (unlocked) { + fprintf(stderr, "Already erased: %s\n", device); + break; + } + if (quiet < 2) + fprintf(stderr, "Erasing %s ...\n", device); + mtd_erase(device); + break; + case CMD_WRITE: + if (quiet < 2) + fprintf(stderr, "Writing from %s to %s ... ", imagefile, device); + mtd_write(imagefd, device, quiet, (unlocked == 0)); + if (quiet < 2) + fprintf(stderr, "\n"); + break; + } + + sync(); + return 0; +} -- cgit v1.2.3