summaryrefslogtreecommitdiff
path: root/packages/u-boot/u-boot-1.1.4/u-boot-fw_printenv.patch
blob: 5e33452d11a78ec002d62bb01a3fd79b524f6125 (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
--- u-boot/tools/env/fw_env.c	2006-03-17 17:21:00.000000000 -0800
+++ u-boot/tools/env/fw_env.c	2006-03-17 17:53:41.000000000 -0800
@@ -31,8 +31,9 @@
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <linux/mtd/mtd.h>
+#include <mtd/mtd-user.h>
 #include "fw_env.h"
+#include "config.h"
 
 typedef unsigned char uchar;
 
@@ -54,8 +55,6 @@
 #define ENVSIZE(i)    envdevices[(i)].env_size
 #define DEVESIZE(i)   envdevices[(i)].erase_size
 
-#define CFG_ENV_SIZE ENVSIZE(curdev)
-
 #define ENV_SIZE      getenvsize()
 
 typedef struct environment_s {
@@ -418,8 +417,8 @@
 			fdr = fd;
 		}
 		printf ("Unlocking flash...\n");
-		erase.length = DEVESIZE (otherdev);
-		erase.start = DEVOFFSET (otherdev);
+		erase.length = DEVESIZE (otherdev)*2;
+		erase.start = 0;
 		ioctl (fdr, MEMUNLOCK, &erase);
 
 		if (HaveRedundEnv) {
@@ -439,7 +438,7 @@
 					strerror (errno));
 				return (-1);
 			}
-			if (lseek (fdr, DEVOFFSET (otherdev) + CFG_ENV_SIZE, SEEK_SET)
+			if (lseek (fdr, DEVESIZE(otherdev), SEEK_SET)
 				== -1) {
 				fprintf (stderr, "seek error on %s: %s\n",
 					DEVNAME (otherdev),
@@ -458,7 +457,7 @@
 		printf ("Erasing old environment...\n");
 
 		erase.length = DEVESIZE (otherdev);
-		erase.start = DEVOFFSET (otherdev);
+		erase.start = DEVESIZE (otherdev);
 		if (ioctl (fdr, MEMERASE, &erase) != 0) {
 			fprintf (stderr, "MTD erase error on %s: %s\n",
 				DEVNAME (otherdev),
@@ -469,6 +468,22 @@
 		printf ("Done\n");
 
 		printf ("Writing environment to %s...\n", DEVNAME (otherdev));
+		if (resid) {
+			if (lseek(fdr, DEVESIZE(otherdev), SEEK_SET)
+					== -1) {
+				fprintf(stderr, "seek error on %s: %s\n",
+						DEVNAME(otherdev),
+						strerror(errno));
+				return -1;
+			}
+			if (write (fdr, data, resid) != resid) {
+				fprintf (stderr,
+					"write error on %s: %s\n",
+					DEVNAME (curdev), strerror (errno));
+				return (-1);
+			}
+			free (data);
+		}
 		if (lseek (fdr, DEVOFFSET (otherdev), SEEK_SET) == -1) {
 			fprintf (stderr,
 				"seek error on %s: %s\n",
@@ -487,15 +502,6 @@
 				DEVNAME (otherdev), strerror (errno));
 			return (-1);
 		}
-		if (resid) {
-			if (write (fdr, data, resid) != resid) {
-				fprintf (stderr,
-					"write error on %s: %s\n",
-					DEVNAME (curdev), strerror (errno));
-				return (-1);
-			}
-			free (data);
-		}
 		if (HaveRedundEnv) {
 			/* change flag on current active env partition */
 			if (lseek (fd, DEVOFFSET (curdev) + sizeof (ulong), SEEK_SET)
@@ -514,8 +520,8 @@
 		}
 		printf ("Done\n");
 		printf ("Locking ...\n");
-		erase.length = DEVESIZE (otherdev);
-		erase.start = DEVOFFSET (otherdev);
+		erase.length = DEVESIZE (otherdev)*2;
+		erase.start = 0;
 		ioctl (fdr, MEMLOCK, &erase);
 		if (HaveRedundEnv) {
 			erase.length = DEVESIZE (curdev);
--- u-boot/tools/env/fw_env.h	2006-03-17 17:16:37.000000000 -0800
+++ u-boot/tools/env/fw_env.h	2006-03-17 17:53:41.000000000 -0800
@@ -27,25 +27,17 @@
  * See included "fw_env.config" sample file (TRAB board)
  * for notes on configuration.
  */
-#define CONFIG_FILE     "/etc/fw_env.config"
+//#define CONFIG_FILE     "/etc/fw_env.config"
 
-#define HAVE_REDUND /* For systems with 2 env sectors */
-#define DEVICE1_NAME      "/dev/mtd1"
-#define DEVICE2_NAME      "/dev/mtd2"
-#define DEVICE1_OFFSET    0x0000
-#define ENV1_SIZE         0x4000
-#define DEVICE1_ESIZE     0x4000
-#define DEVICE2_OFFSET    0x0000
-#define ENV2_SIZE         0x4000
-#define DEVICE2_ESIZE     0x4000
-
-#define CONFIG_BAUDRATE		115200
-#define CONFIG_BOOTDELAY	5	/* autoboot after 5 seconds	*/
-#define CONFIG_BOOTCOMMAND							\
-	"bootp; " 								\
-	"setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} " 	\
-	"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " 	\
-	"bootm"
+//#define HAVE_REDUND /* For systems with 2 env sectors */
+#define DEVICE1_NAME      "/dev/mtd0"
+//#define DEVICE2_NAME      "/dev/mtd2"
+#define DEVICE1_OFFSET    CFG_ENV_ADDR
+#define ENV1_SIZE         CFG_ENV_SIZE
+#define DEVICE1_ESIZE     CFG_ENV_SECT_SIZE
+//#define DEVICE2_OFFSET    0x0000
+//#define ENV2_SIZE         0x4000
+//#define DEVICE2_ESIZE     0x4000
 
 extern		void  fw_printenv(int argc, char *argv[]);
 extern unsigned char *fw_getenv  (unsigned char *name);