openwrtv4/obsolete-buildroot/sources/openwrt/patches/wrt54g-router.patch

240 lines
6 KiB
Diff

diff -bBurN WRT54G/release/src/router/rc/Makefile-openwrt WRT54G.new/release/src/router/rc/Makefile-openwrt
--- WRT54G/release/src/router/rc/Makefile-openwrt 1969-12-31 18:00:00.000000000 -0600
+++ WRT54G.new/release/src/router/rc/Makefile-openwrt 2004-03-03 16:23:40.000000000 -0600
@@ -0,0 +1,44 @@
+# Copyright 2001-2003, Broadcom Corporation
+# All Rights Reserved.
+#
+#
+# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE
+#
+
+#
+# Router Wireless Interface Configuration Utility Makefile
+#
+# Copyright 2003, Broadcom Corporation
+# All Rights Reserved.
+#
+#
+# $Id: Makefile,v 1.2 2004/01/13 00:55:58 mbm Exp $
+#
+
+CFLAGS += -I. -I$(TOP)/shared -I$(SRCBASE)/include -Wall
+#CFLAGS += -g -DDEBUG
+CFLAGS += -s -Os
+LDFLAGS += -L$(TOP)/shared -lshared -L$(TOP)/nvram -lnvram
+
+OBJS := mtd.o crc.o #http.o
+
+vpath %.c $(TOP)/shared $(SRCBASE)/rts/src
+
+all: mtd
+
+clean:
+ rm -f *.o mtd
+
+install: all
+ install -d $(INSTALLDIR)/sbin
+ install mtd $(INSTALLDIR)/sbin
+ $(STRIP) $(INSTALLDIR)/sbin/mtd
+
+mtd.o: mtd.c
+ $(CC) -c $^ $(CFLAGS) $(CPPFLAGS) -DOPENWRT_MTD #-DOPENWRT_MTD_HTTP_GET
+
+mtd: $(OBJS)
+ $(CC) -o $@ $^ $(LDFLAGS)
diff -bBurN WRT54G/release/src/router/rc/mtd.c WRT54G.new/release/src/router/rc/mtd.c
--- WRT54G/release/src/router/rc/mtd.c 2004-01-19 20:34:50.000000000 -0600
+++ WRT54G.new/release/src/router/rc/mtd.c 2004-03-03 16:24:42.000000000 -0600
@@ -37,6 +37,86 @@
#include <cy_conf.h>
#include <utils.h>
+
+#ifdef OPENWRT_MTD
+
+extern int
+mtd_open(const char *mtd, int flags);
+extern int
+mtd_erase(const char *mtd);
+extern int
+mtd_write(const char *path, const char *mtd);
+
+/* Slightly modified version of mtd_erase. */
+int
+mtd_unlock(const char *mtd)
+{
+ int mtd_fd;
+ mtd_info_t mtd_info;
+ erase_info_t erase_info;
+
+ /* Open MTD device */
+ if ((mtd_fd = mtd_open(mtd, O_RDWR)) < 0) {
+ perror(mtd);
+ return errno;
+ }
+
+ /* Get sector size */
+ if (ioctl(mtd_fd, MEMGETINFO, &mtd_info) != 0) {
+ perror(mtd);
+ close(mtd_fd);
+ return errno;
+ }
+
+ erase_info.length = mtd_info.erasesize;
+
+ for (erase_info.start = 0;
+ erase_info.start < mtd_info.size;
+ erase_info.start += mtd_info.erasesize) {
+ (void) ioctl(mtd_fd, MEMUNLOCK, &erase_info);
+/* if (ioctl(mtd_fd, MEMERASE, &erase_info) != 0) { */
+/* perror(mtd); */
+/* close(mtd_fd); */
+/* return errno; */
+/* } */
+ }
+
+ close(mtd_fd);
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ if(argc == 3 && strcasecmp(argv[1],"unlock")==0) {
+ printf("Unlocking %s\n",argv[2]);
+ return mtd_unlock(argv[2]);
+ }
+ if(argc == 3 && strcasecmp(argv[1],"erase")==0) {
+ printf("Erasing %s\n",argv[2]);
+ return mtd_erase(argv[2]);
+ }
+ if(argc == 4 && strcasecmp(argv[1],"write")==0) {
+ printf("writing %s to %s\n",argv[2],argv[3]);
+ return mtd_write(argv[2],argv[3]);
+ }
+
+ printf("no valid command given\n");
+ return -1;
+}
+
+#ifndef OPENWRT_MTD_HTTP_GET
+/* Dummy routines when no http support. */
+int
+http_get(const char *server, char *buf, size_t count, off_t offset)
+{
+ printf("error opening %s\n",server);
+ exit(-1);
+}
+#endif
+
+#define check_action() (fp ? ACT_IDLE : ACT_WEBS_UPGRADE)
+
+#endif
+
/*
* Open an MTD device
* @param mtd path to or partition name of MTD device
diff -bBurN WRT54G/release/src/router/shared/Makefile-openwrt WRT54G.new/release/src/router/shared/Makefile-openwrt
--- WRT54G/release/src/router/shared/Makefile-openwrt 1969-12-31 18:00:00.000000000 -0600
+++ WRT54G.new/release/src/router/shared/Makefile-openwrt 2004-03-03 12:39:17.000000000 -0600
@@ -0,0 +1,41 @@
+#
+# Linux router shared code Makefile
+#
+# Copyright 2001-2003, Broadcom Corporation
+# All Rights Reserved.
+#
+# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+#
+# $Id: Makefile,v 1.3 2004/01/13 00:51:09 mbm Exp $
+#
+ifneq ($(wildcard $(SRCBASE)/cy_conf.mak),)
+ include $(SRCBASE)/cy_conf.mak
+endif
+
+CFLAGS += -I. -I$(SRCBASE)/include -Wall -I$(SRCBASE)/
+#CFLAGS += -g -DDEBUG
+CFLAGS += -s -Os
+LDFLAGS += -L.
+
+all: libshared.so
+
+install: all
+ install -d $(INSTALLDIR)/usr/lib
+ install -m 755 libshared.so $(INSTALLDIR)/usr/lib
+ $(STRIP) $(INSTALLDIR)/usr/lib/libshared.so
+
+clean:
+ rm -f *.o *.so
+
+libshared.so: shutils.o wl.o wl_linux.o defaults.o linux_timer.o
+ $(LD) -shared -o $@ $^
+
+build_date.o: build_date.c
+
+build_date:
+ echo "const char *builddate = \"`date`\";" > build_date.c
+
+*.o: $(CY_DEPS)
diff -bBurN WRT54GS/release/src/router/nvram/nvram_linux.c-dist WRT54GS.new/release/src/router/nvram/nvram_linux.c
--- WRT54GS/release/src/router/nvram/nvram_linux.c-dist 2004-03-30 10:04:10.000000000 -0600
+++ WRT54GS/release/src/router/nvram/nvram_linux.c 2004-03-30 10:10:09.000000000 -0600
@@ -27,8 +27,10 @@
#include <typedefs.h>
#include <bcmnvram.h>
#include <nvram_convert.h>
+#ifndef OPENWRT_NVRAM
#include <shutils.h>
#include <utils.h>
+#endif
#define PATH_DEV_NVRAM "/dev/nvram"
@@ -182,6 +184,20 @@
{
int ret;
+#ifdef OPENWRT_NVRAM
+ fprintf(stderr, "nvram_commit(): start\n");
+
+ if (nvram_fd < 0)
+ if ((ret = nvram_init(NULL)))
+ return ret;
+
+ ret = ioctl(nvram_fd, NVRAM_MAGIC, NULL);
+
+ if (ret < 0)
+ perror(PATH_DEV_NVRAM);
+
+ fprintf(stderr, "nvram_commit(): end\n");
+#else
cprintf("nvram_commit(): start\n");
if((check_action() == ACT_IDLE) ||
@@ -200,6 +216,7 @@
}
else
cprintf("nvram_commit(): nothing to do...\n");
+#endif
return ret;
}
@@ -272,6 +289,7 @@
return j;
}
+#ifndef OPENWRT_NVRAM
int
check_action(void)
{
@@ -318,3 +336,5 @@
return 0;
}
+
+#endif