summaryrefslogtreecommitdiffstats
path: root/obsolete-buildroot/sources/openwrt-wrt54g-router.patch
blob: 4098f792e2001ba4c5eecd24d7a731841170b59a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
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
+	$(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