Commit 4a6fd34b267dbf4a72080ab9a085bb45c63660fb
1 parent
69f8f827d5
Exists in
master
and in
55 other branches
* Patch by Lutz Dennig, 10 Apr 2003:
Update for R360MPI board * Add new meaning to "autostart" environment variable: If set to "no", a standalone image passed to the "bootm" command will be copied to the load address (and eventually uncompressed), but NOT be started. This can be used to load and uncompress arbitrary data. * Set max brightness for MN11236 displays on TRAB board
Showing 8 changed files with 402 additions and 343 deletions Side-by-side Diff
CHANGELOG
... | ... | @@ -2,11 +2,23 @@ |
2 | 2 | Changes since U-Boot 0.3.0: |
3 | 3 | ====================================================================== |
4 | 4 | |
5 | +* Patch by Lutz Dennig, 10 Apr 2003: | |
6 | + Update for R360MPI board | |
7 | + | |
8 | +* Add new meaning to "autostart" environment variable: | |
9 | + If set to "no", a standalone image passed to the | |
10 | + "bootm" command will be copied to the load address | |
11 | + (and eventually uncompressed), but NOT be started. | |
12 | + This can be used to load and uncompress arbitrary | |
13 | + data. | |
14 | + | |
5 | 15 | * Patch by Stefan Roese, 10 Apr 2003: |
6 | - Changed DHCP client to use ip address from server option field #54 | |
7 | - from the OFFER-paket in the server option field #54 in the REQUEST- | |
8 | - paket. This fixes a problem using a Windows 2000 DHCP server, where | |
9 | - the DHCP-server is not the TFTP-server. | |
16 | + Changed DHCP client to use IP address from server option field #54 | |
17 | + from the OFFER packet in the server option field #54 in the REQUEST | |
18 | + packet. This fixes a problem using a Windows 2000 DHCP server, | |
19 | + where the DHCP-server is not the TFTP-server. | |
20 | + | |
21 | +* Set max brightness for MN11236 displays on TRAB board | |
10 | 22 | |
11 | 23 | * Add support for TQM862L modules |
12 | 24 |
README
... | ... | @@ -1918,6 +1918,12 @@ |
1918 | 1918 | be automatically started (by internally calling |
1919 | 1919 | "bootm") |
1920 | 1920 | |
1921 | + If set to "no", a standalone image passed to the | |
1922 | + "bootm" command will be copied to the load address | |
1923 | + (and eventually uncompressed), but NOT be started. | |
1924 | + This can be used to load and uncompress arbitrary | |
1925 | + data. | |
1926 | + | |
1921 | 1927 | initrd_high - restrict positioning of initrd images: |
1922 | 1928 | If this variable is not set, initrd images will be |
1923 | 1929 | copied to the highest possible address in RAM; this |
board/r360mpi/r360mpi.c
... | ... | @@ -126,12 +126,12 @@ |
126 | 126 | memctl->memc_mar = 0x00000088; |
127 | 127 | |
128 | 128 | /* |
129 | - * Map controller bank 1 to the SDRAM bank at | |
129 | + * Map controller bank 2 to the SDRAM bank at | |
130 | 130 | * preliminary address - these have to be modified after the |
131 | 131 | * SDRAM size has been determined. |
132 | 132 | */ |
133 | - memctl->memc_or1 = CFG_OR1_PRELIM; | |
134 | - memctl->memc_br1 = CFG_BR1_PRELIM; | |
133 | + memctl->memc_or2 = CFG_OR2_PRELIM; | |
134 | + memctl->memc_br2 = CFG_BR2_PRELIM; | |
135 | 135 | |
136 | 136 | memctl->memc_mamr = CFG_MAMR_8COL & (~(MAMR_PTAE)); /* no refresh yet */ |
137 | 137 | |
138 | 138 | |
... | ... | @@ -139,9 +139,9 @@ |
139 | 139 | |
140 | 140 | /* perform SDRAM initializsation sequence */ |
141 | 141 | |
142 | - memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */ | |
142 | + memctl->memc_mcr = 0x80004105; /* SDRAM bank 0 */ | |
143 | 143 | udelay (200); |
144 | - memctl->memc_mcr = 0x80002230; /* SDRAM bank 0 - execute twice */ | |
144 | + memctl->memc_mcr = 0x80004230; /* SDRAM bank 0 - execute twice */ | |
145 | 145 | udelay (200); |
146 | 146 | |
147 | 147 | memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */ |
... | ... | @@ -153,7 +153,7 @@ |
153 | 153 | * |
154 | 154 | * try 8 column mode |
155 | 155 | */ |
156 | - size8 = dram_size (CFG_MAMR_8COL, (ulong *) SDRAM_BASE1_PRELIM, | |
156 | + size8 = dram_size (CFG_MAMR_8COL, (ulong *) SDRAM_BASE2_PRELIM, | |
157 | 157 | SDRAM_MAX_SIZE); |
158 | 158 | |
159 | 159 | udelay (1000); |
160 | 160 | |
... | ... | @@ -161,13 +161,13 @@ |
161 | 161 | /* |
162 | 162 | * try 9 column mode |
163 | 163 | */ |
164 | - size9 = dram_size (CFG_MAMR_9COL, (ulong *) SDRAM_BASE1_PRELIM, | |
164 | + size9 = dram_size (CFG_MAMR_9COL, (ulong *) SDRAM_BASE2_PRELIM, | |
165 | 165 | SDRAM_MAX_SIZE); |
166 | 166 | |
167 | 167 | if (size8 < size9) { /* leave configuration at 9 columns */ |
168 | 168 | size_b0 = size9; |
169 | 169 | /* debug ("SDRAM Bank 0 in 9 column mode: %ld MB\n", size >> 20); */ |
170 | - } else { /* back to 8 columns */ | |
170 | + } else { /* back to 8 columns */ | |
171 | 171 | size_b0 = size8; |
172 | 172 | memctl->memc_mamr = CFG_MAMR_8COL; |
173 | 173 | udelay (500); |
... | ... | @@ -200,6 +200,47 @@ |
200 | 200 | |
201 | 201 | udelay (10000); |
202 | 202 | |
203 | +#ifdef CONFIG_CAN_DRIVER | |
204 | + /* Initialize OR3 / BR3 */ | |
205 | + memctl->memc_or3 = CFG_OR3_CAN; /* switch GPLB_5 to GPLA_5 */ | |
206 | + memctl->memc_br3 = CFG_BR3_CAN; | |
207 | + | |
208 | + /* Initialize MBMR */ | |
209 | + memctl->memc_mbmr = MAMR_GPL_B4DIS; /* GPL_B4 works as UPWAITB */ | |
210 | + | |
211 | + /* Initialize UPMB for CAN: single read */ | |
212 | + memctl->memc_mdr = 0xFFFFC004; | |
213 | + memctl->memc_mcr = 0x0100 | UPMB; | |
214 | + | |
215 | + memctl->memc_mdr = 0x0FFFD004; | |
216 | + memctl->memc_mcr = 0x0101 | UPMB; | |
217 | + | |
218 | + memctl->memc_mdr = 0x0FFFC000; | |
219 | + memctl->memc_mcr = 0x0102 | UPMB; | |
220 | + | |
221 | + memctl->memc_mdr = 0x3FFFC004; | |
222 | + memctl->memc_mcr = 0x0103 | UPMB; | |
223 | + | |
224 | + memctl->memc_mdr = 0xFFFFDC05; | |
225 | + memctl->memc_mcr = 0x0104 | UPMB; | |
226 | + | |
227 | + /* Initialize UPMB for CAN: single write */ | |
228 | + memctl->memc_mdr = 0xFFFCC004; | |
229 | + memctl->memc_mcr = 0x0118 | UPMB; | |
230 | + | |
231 | + memctl->memc_mdr = 0xCFFCD004; | |
232 | + memctl->memc_mcr = 0x0119 | UPMB; | |
233 | + | |
234 | + memctl->memc_mdr = 0x0FFCC000; | |
235 | + memctl->memc_mcr = 0x011A | UPMB; | |
236 | + | |
237 | + memctl->memc_mdr = 0x7FFCC004; | |
238 | + memctl->memc_mcr = 0x011B | UPMB; | |
239 | + | |
240 | + memctl->memc_mdr = 0xFFFDCC05; | |
241 | + memctl->memc_mcr = 0x011C | UPMB; | |
242 | +#endif | |
243 | + | |
203 | 244 | return (size_b0); |
204 | 245 | } |
205 | 246 | |
... | ... | @@ -213,8 +254,8 @@ |
213 | 254 | * - short between data lines |
214 | 255 | */ |
215 | 256 | |
216 | -static long int dram_size (long int mamr_value, long int *base, | |
217 | - long int maxsize) | |
257 | +static long int dram_size (long int mamr_value, | |
258 | + long int *base, long int maxsize) | |
218 | 259 | { |
219 | 260 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
220 | 261 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
221 | 262 | |
... | ... | @@ -257,10 +298,10 @@ |
257 | 298 | |
258 | 299 | /* ------------------------------------------------------------------------- */ |
259 | 300 | |
260 | -void r360_pwm_write (uchar reg, uchar val) | |
301 | +void r360_i2c_lcd_write (uchar data0, uchar data1) | |
261 | 302 | { |
262 | - if (i2c_write (CFG_I2C_PWM_ADDR, reg, 1, &val, 1)) { | |
263 | - printf ("Can't write PWM register 0x%02X.\n", reg); | |
303 | + if (i2c_write (CFG_I2C_LCD_ADDR, data0, 1, &data1, 1)) { | |
304 | + printf("Can't write lcd data 0x%02X 0x%02X.\n", data0, data1); | |
264 | 305 | } |
265 | 306 | } |
266 | 307 | |
267 | 308 | |
... | ... | @@ -271,11 +312,9 @@ |
271 | 312 | */ |
272 | 313 | |
273 | 314 | /* Number of bytes returned from Keyboard Controller */ |
274 | -#define KEYBD_KEY_MAX 20 /* maximum key number */ | |
275 | -#define KEYBD_DATALEN ((KEYBD_KEY_MAX + 7) / 8) /* normal key scan data */ | |
315 | +#define KEYBD_KEY_MAX 16 /* maximum key number */ | |
316 | +#define KEYBD_DATALEN ((KEYBD_KEY_MAX + 7) / 8) /* normal key scan data */ | |
276 | 317 | |
277 | -static uchar kbd_addr = CFG_I2C_KBD_ADDR; | |
278 | - | |
279 | 318 | static uchar *key_match (uchar *); |
280 | 319 | |
281 | 320 | int misc_init_r (void) |
282 | 321 | |
... | ... | @@ -287,14 +326,14 @@ |
287 | 326 | |
288 | 327 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); |
289 | 328 | |
290 | - i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN); | |
329 | + i2c_read (CFG_I2C_KEY_ADDR, 0, 0, kbd_data, KEYBD_DATALEN); | |
291 | 330 | |
292 | 331 | for (i = 0; i < KEYBD_DATALEN; ++i) { |
293 | 332 | sprintf (keybd_env + i + i, "%02X", kbd_data[i]); |
294 | 333 | } |
295 | 334 | setenv ("keybd", keybd_env); |
296 | 335 | |
297 | - str = strdup (key_match (kbd_data)); /* decode keys */ | |
336 | + str = strdup (key_match (keybd_env)); /* decode keys */ | |
298 | 337 | |
299 | 338 | #ifdef CONFIG_PREBOOT /* automatically configure "preboot" command on key match */ |
300 | 339 | setenv ("preboot", str); /* set or delete definition */ |
301 | 340 | |
302 | 341 | |
303 | 342 | |
... | ... | @@ -324,16 +363,13 @@ |
324 | 363 | static uchar kbd_magic_prefix[] = "key_magic"; |
325 | 364 | static uchar kbd_command_prefix[] = "key_cmd"; |
326 | 365 | |
327 | -static uchar *key_match (uchar * kbd_data) | |
366 | +static uchar *key_match (uchar * kbd_str) | |
328 | 367 | { |
329 | - uchar compare[KEYBD_DATALEN]; | |
330 | 368 | uchar magic[sizeof (kbd_magic_prefix) + 1]; |
331 | 369 | uchar cmd_name[sizeof (kbd_command_prefix) + 1]; |
332 | - uchar key_mask; | |
333 | - uchar *str, *nxt, *suffix; | |
370 | + uchar *str, *suffix; | |
334 | 371 | uchar *kbd_magic_keys; |
335 | 372 | char *cmd; |
336 | - int i; | |
337 | 373 | |
338 | 374 | /* |
339 | 375 | * The following string defines the characters that can pe appended |
340 | 376 | |
341 | 377 | |
342 | 378 | |
343 | 379 | |
344 | 380 | |
345 | 381 | |
346 | 382 | |
347 | 383 | |
348 | 384 | |
... | ... | @@ -343,62 +379,48 @@ |
343 | 379 | * "key_magic" is checked (old behaviour); the string "125" causes |
344 | 380 | * checks for "key_magic1", "key_magic2" and "key_magic5", etc. |
345 | 381 | */ |
346 | - if ((kbd_magic_keys = getenv ("magic_keys")) == NULL) | |
347 | - kbd_magic_keys = ""; | |
382 | + if ((kbd_magic_keys = getenv ("magic_keys")) != NULL) { | |
383 | + /* loop over all magic keys; | |
384 | + * use '\0' suffix in case of empty string | |
385 | + */ | |
386 | + for (suffix = kbd_magic_keys; | |
387 | + *suffix || suffix == kbd_magic_keys; | |
388 | + ++suffix) { | |
389 | + sprintf (magic, "%s%c", kbd_magic_prefix, *suffix); | |
348 | 390 | |
349 | - /* loop over all magic keys; | |
350 | - * use '\0' suffix in case of empty string | |
351 | - */ | |
352 | - for (suffix=kbd_magic_keys; *suffix || suffix==kbd_magic_keys; ++suffix) { | |
353 | - sprintf (magic, "%s%c", kbd_magic_prefix, *suffix); | |
354 | 391 | #if 0 |
355 | - printf ("### Check magic \"%s\"\n", magic); | |
392 | + printf ("### Check magic \"%s\"\n", magic); | |
356 | 393 | #endif |
357 | 394 | |
358 | - memcpy(compare, kbd_data, KEYBD_DATALEN); | |
395 | + if ((str = getenv (magic)) != 0) { | |
359 | 396 | |
360 | - for (str = getenv(magic); str != NULL; str = (*nxt) ? nxt+1 : nxt) { | |
361 | - uchar c; | |
362 | - | |
363 | - c = (uchar) simple_strtoul (str, (char **) (&nxt), 16); | |
364 | - | |
365 | - if (str == nxt) /* invalid character */ | |
366 | - break; | |
367 | - | |
368 | - if (c >= KEYBD_KEY_MAX) /* bad key number */ | |
369 | - goto next_magic; | |
370 | - | |
371 | - key_mask = 0x80 >> (c % 8); | |
372 | - | |
373 | - if (!(compare[c / 8] & key_mask)) /* key not pressed */ | |
374 | - goto next_magic; | |
375 | - | |
376 | - compare[c / 8] &= ~key_mask; | |
377 | - } | |
378 | - | |
379 | - for (i=0; i<KEYBD_DATALEN; i++) | |
380 | - if (compare[i]) /* key(s) not released */ | |
381 | - goto next_magic; | |
382 | - | |
383 | - sprintf (cmd_name, "%s%c", kbd_command_prefix, *suffix); | |
384 | - | |
385 | - cmd = getenv (cmd_name); | |
386 | 397 | #if 0 |
387 | - printf ("### Set PREBOOT to $(%s): \"%s\"\n", | |
388 | - cmd_name, cmd ? cmd : "<<NULL>>"); | |
398 | + printf ("### Compare \"%s\" \"%s\"\n", | |
399 | + kbd_str, str); | |
389 | 400 | #endif |
390 | - *kbd_data = *suffix; | |
391 | - return (cmd); | |
401 | + if (strcmp (kbd_str, str) == 0) { | |
402 | + sprintf (cmd_name, "%s%c", | |
403 | + kbd_command_prefix, | |
404 | + *suffix); | |
392 | 405 | |
393 | - next_magic:; | |
406 | + if ((cmd = getenv (cmd_name)) != 0) { | |
407 | +#if 0 | |
408 | + printf ("### Set PREBOOT to $(%s): \"%s\"\n", | |
409 | + cmd_name, cmd); | |
410 | +#endif | |
411 | + return (cmd); | |
412 | + } | |
413 | + } | |
414 | + } | |
415 | + } | |
394 | 416 | } |
395 | 417 | #if 0 |
396 | 418 | printf ("### Delete PREBOOT\n"); |
397 | 419 | #endif |
398 | - *kbd_data = ' = '\0';'; | |
420 | + *kbd_str = ' = '\0';'; | |
399 | 421 | return (NULL); |
400 | 422 | } |
401 | -#endif /* CONFIG_PREBOOT */ | |
423 | +#endif /* CONFIG_PREBOOT */ | |
402 | 424 | |
403 | 425 | /* Read Keyboard status */ |
404 | 426 | int do_kbd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
... | ... | @@ -410,7 +432,7 @@ |
410 | 432 | i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); |
411 | 433 | |
412 | 434 | /* Read keys */ |
413 | - i2c_read (kbd_addr, 0, 0, kbd_data, KEYBD_DATALEN); | |
435 | + i2c_read (CFG_I2C_KEY_ADDR, 0, 0, kbd_data, KEYBD_DATALEN); | |
414 | 436 | |
415 | 437 | puts ("Keys:"); |
416 | 438 | for (i = 0; i < KEYBD_DATALEN; ++i) { |
board/trab/vfd.c
... | ... | @@ -486,7 +486,11 @@ |
486 | 486 | /* frame buffer endadr */ |
487 | 487 | rLCDSADDR2 = (gd->fb_base + FRAME_BUF_SIZE) >> 1; |
488 | 488 | rLCDSADDR3 = ((256/4)); |
489 | - rLCDCON2 = 0x000DC000; | |
489 | +rLCDCON2 = 0x000DC000; | |
490 | + if(gd->vfd_type == VFD_TYPE_MN11236) | |
491 | + rLCDCON2 = 37 << 14; /* MN11236: 38 lines */ | |
492 | + else | |
493 | + rLCDCON2 = 55 << 14; /* T119C: 56 lines */ | |
490 | 494 | rLCDCON3 = 0x0051000A; |
491 | 495 | rLCDCON4 = 0x00000001; |
492 | 496 | if (gd->vfd_type && vfd_inv_data) |
common/cmd_bootm.c
... | ... | @@ -287,12 +287,17 @@ |
287 | 287 | |
288 | 288 | switch (hdr->ih_type) { |
289 | 289 | case IH_TYPE_STANDALONE: |
290 | - appl = (int (*)(cmd_tbl_t *, int, int, char *[]))ntohl(hdr->ih_ep); | |
291 | 290 | if (iflag) |
292 | 291 | enable_interrupts(); |
293 | 292 | |
293 | + /* load (and uncompress), but don't start if "autostart" | |
294 | + * is set to "no" | |
295 | + */ | |
296 | + if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0)) | |
297 | + return 0; | |
298 | + appl = (int (*)(cmd_tbl_t *, int, int, char *[]))ntohl(hdr->ih_ep); | |
294 | 299 | (*appl)(cmdtp, flag, argc-1, &argv[1]); |
295 | - break; | |
300 | + return 0; | |
296 | 301 | case IH_TYPE_KERNEL: |
297 | 302 | case IH_TYPE_MULTI: |
298 | 303 | /* handled below */ |
cpu/mpc8xx/lcd.c
... | ... | @@ -177,6 +177,8 @@ |
177 | 177 | /* |
178 | 178 | * Sharp LQ057Q3DC02 display. Active, color, single scan. |
179 | 179 | */ |
180 | +#define LCD_DF 12 | |
181 | + | |
180 | 182 | static vidinfo_t panel_info = { |
181 | 183 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
182 | 184 | 3, 0, 0, 1, 1, 15, 4, 0, 3 |
183 | 185 | |
... | ... | @@ -260,11 +262,11 @@ |
260 | 262 | * Emerging Display Technologies 320x240. Passive, monochrome, single scan. |
261 | 263 | */ |
262 | 264 | #define LCD_BPP LCD_MONOCHROME |
263 | -#define LCD_DF 20 | |
265 | +#define LCD_DF 10 | |
264 | 266 | |
265 | 267 | static vidinfo_t panel_info = { |
266 | 268 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW, |
267 | - LCD_BPP, 0, 0, 0, 0, 0, 15, 0, 0 | |
269 | + LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0 | |
268 | 270 | }; |
269 | 271 | #endif |
270 | 272 | /*----------------------------------------------------------------------*/ |
271 | 273 | |
272 | 274 | |
273 | 275 | |
... | ... | @@ -977,15 +979,18 @@ |
977 | 979 | c |= 0x07; /* Power on CCFL, Enable CCFL, Chip Enable LCD */ |
978 | 980 | pic_write (0x60, c); |
979 | 981 | } |
980 | -#elif defined(CONFIG_R360MPI) | |
982 | +#endif /* CONFIG_LWMON */ | |
983 | + | |
984 | +#if defined(CONFIG_R360MPI) | |
981 | 985 | { |
982 | - extern void r360_pwm_write (uchar reg, uchar val); | |
986 | + extern void r360_i2c_lcd_write (uchar data0, uchar data1); | |
983 | 987 | |
984 | - r360_pwm_write(8, 1); | |
985 | - r360_pwm_write(0, 4); | |
986 | - r360_pwm_write(1, 6); | |
988 | + r360_i2c_lcd_write(0x10, 0x01); | |
989 | + r360_i2c_lcd_write(0x20, 0x01); | |
990 | + r360_i2c_lcd_write(0x3F, 0xFF); | |
991 | + r360_i2c_lcd_write(0x47, 0xFF); | |
987 | 992 | } |
988 | -#endif /* CONFIG_LWMON */ | |
993 | +#endif /* CONFIG_R360MPI */ | |
989 | 994 | } |
990 | 995 | |
991 | 996 | /*----------------------------------------------------------------------*/ |
992 | 997 | |
... | ... | @@ -1003,10 +1008,12 @@ |
1003 | 1008 | } |
1004 | 1009 | #elif defined(CONFIG_R360MPI) |
1005 | 1010 | { |
1006 | - extern void r360_pwm_write (uchar reg, uchar val); | |
1011 | + extern void r360_i2c_lcd_write (uchar data0, uchar data1); | |
1007 | 1012 | |
1008 | - r360_pwm_write(0, 0); | |
1009 | - r360_pwm_write(1, 0); | |
1013 | + r360_i2c_lcd_write(0x10, 0x00); | |
1014 | + r360_i2c_lcd_write(0x20, 0x00); | |
1015 | + r360_i2c_lcd_write(0x30, 0x00); | |
1016 | + r360_i2c_lcd_write(0x40, 0x00); | |
1010 | 1017 | } |
1011 | 1018 | #endif /* CONFIG_LWMON */ |
1012 | 1019 | /* Disable the LCD panel */ |
include/configs/R360MPI.h
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | #define CONFIG_8xx_CONS_SMC1 1 /* Console is on SMC1 */ |
48 | 48 | #undef CONFIG_8xx_CONS_SMC2 |
49 | 49 | #undef CONFIG_8xx_CONS_NONE |
50 | -#define CONFIG_BAUDRATE 9600 /* console baudrate = 9600bps */ | |
50 | +#define CONFIG_BAUDRATE 115200 /* console baudrate in bps */ | |
51 | 51 | #if 0 |
52 | 52 | #define CONFIG_BOOTDELAY -1 /* autoboot disabled */ |
53 | 53 | #else |
... | ... | @@ -83,7 +83,7 @@ |
83 | 83 | #endif /* CONFIG_LCD */ |
84 | 84 | #endif |
85 | 85 | |
86 | -#undef CONFIG_CAN_DRIVER /* CAN Driver support disabled */ | |
86 | +#define CONFIG_CAN_DRIVER /* CAN Driver support enabled */ | |
87 | 87 | |
88 | 88 | #define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAULT | CONFIG_BOOTP_BOOTFILESIZE) |
89 | 89 | |
... | ... | @@ -113,9 +113,9 @@ |
113 | 113 | else immr->im_cpm.cp_pbdat &= ~PB_SCL |
114 | 114 | #define I2C_DELAY udelay(50) |
115 | 115 | |
116 | -#define CFG_I2C_PWM_ADDR 0x58 /* Power management coprocessor */ | |
117 | -#define CFG_I2C_KBD_ADDR 0x50 /* Keyboard coprocessor */ | |
118 | -#define CFG_I2C_TERM_ADDR 0x49 /* Temperature Sensors */ | |
116 | +#define CFG_I2C_LCD_ADDR 0x8 /* LCD Control */ | |
117 | +#define CFG_I2C_KEY_ADDR 0x9 /* Keyboard coprocessor */ | |
118 | +#define CFG_I2C_TEM_ADDR 0x49 /* Temperature Sensors */ | |
119 | 119 | |
120 | 120 | #define CONFIG_COMMANDS ( CONFIG_CMD_DFL | \ |
121 | 121 | CFG_CMD_DHCP | \ |
122 | 122 | |
... | ... | @@ -232,11 +232,7 @@ |
232 | 232 | *----------------------------------------------------------------------- |
233 | 233 | * PCMCIA config., multi-function pin tri-state |
234 | 234 | */ |
235 | -#ifndef CONFIG_CAN_DRIVER | |
236 | 235 | #define CFG_SIUMCR (SIUMCR_DBGC00 | SIUMCR_DBPC00 | SIUMCR_MLRC01) |
237 | -#else /* we must activate GPL5 in the SIUMCR for CAN */ | |
238 | -#define CFG_SIUMCR (SIUMCR_DBGC11 | SIUMCR_DBPC00 | SIUMCR_MLRC01) | |
239 | -#endif /* CONFIG_CAN_DRIVER */ | |
240 | 236 | |
241 | 237 | /*----------------------------------------------------------------------- |
242 | 238 | * TBSCR - Time Base Status and Control 11-26 |
243 | 239 | |
244 | 240 | |
245 | 241 | |
... | ... | @@ -362,20 +358,31 @@ |
362 | 358 | |
363 | 359 | |
364 | 360 | /* |
365 | - * BR1 and OR1 (SDRAM) | |
361 | + * BR2 and OR2 (SDRAM) | |
366 | 362 | * |
367 | 363 | */ |
368 | -#define SDRAM_BASE1_PRELIM 0x00000000 /* SDRAM bank #0 */ | |
364 | +#define SDRAM_BASE2_PRELIM 0x00000000 /* SDRAM bank #0 */ | |
369 | 365 | #define SDRAM_MAX_SIZE 0x04000000 /* max 64 MB per bank */ |
370 | 366 | |
371 | -#define CFG_PRELIM_OR1_AM 0xF8000000 /* OR addr mask */ | |
367 | +#define CFG_PRELIM_OR2_AM 0xF8000000 /* OR addr mask */ | |
372 | 368 | |
373 | 369 | /* SDRAM timing: Multiplexed addresses, GPL5 output to GPL5_A (don't care) */ |
374 | 370 | #define CFG_OR_TIMING_SDRAM (OR_ACS_DIV1 | OR_CSNT_SAM | \ |
375 | 371 | OR_SCY_0_CLK | OR_G5LS) |
376 | 372 | |
377 | -#define CFG_OR1_PRELIM (CFG_PRELIM_OR1_AM | CFG_OR_TIMING_SDRAM ) | |
378 | -#define CFG_BR1_PRELIM ((SDRAM_BASE1_PRELIM & BR_BA_MSK) | BR_MS_UPMA | BR_V ) | |
373 | +#define CFG_OR2_PRELIM (CFG_PRELIM_OR2_AM | CFG_OR_TIMING_SDRAM ) | |
374 | +#define CFG_BR2_PRELIM ((SDRAM_BASE2_PRELIM & BR_BA_MSK) | BR_MS_UPMA | BR_V ) | |
375 | + | |
376 | +/* | |
377 | + * BR3 and OR3 (CAN Controller) | |
378 | + */ | |
379 | +#ifdef CONFIG_CAN_DRIVER | |
380 | +#define CFG_CAN_BASE 0xC0000000 /* CAN base address */ | |
381 | +#define CFG_CAN_OR_AM 0xFFFF8000 /* 32 kB address mask */ | |
382 | +#define CFG_OR3_CAN (CFG_CAN_OR_AM | OR_G5LA |OR_BI) | |
383 | +#define CFG_BR3_CAN ((CFG_CAN_BASE & BR_BA_MSK) | \ | |
384 | + BR_PS_8 | BR_MS_UPMB | BR_V) | |
385 | +#endif /* CONFIG_CAN_DRIVER */ | |
379 | 386 | |
380 | 387 | |
381 | 388 | /* |
tools/env/fw_env.c
Changes suppressed. Click to show
1 | 1 | /* |
2 | - * (C) Copyright 2000 | |
2 | + * (C) Copyright 2000-2003 | |
3 | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | 4 | * |
5 | 5 | * See file CREDITS for list of people who contributed to this |
... | ... | @@ -12,7 +12,7 @@ |
12 | 12 | * |
13 | 13 | * This program is distributed in the hope that it will be useful, |
14 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | 16 | * GNU General Public License for more details. |
17 | 17 | * |
18 | 18 | * You should have received a copy of the GNU General Public License |
19 | 19 | |
... | ... | @@ -34,16 +34,16 @@ |
34 | 34 | #include <linux/mtd/mtd.h> |
35 | 35 | #include "fw_env.h" |
36 | 36 | |
37 | -typedef unsigned char uchar; | |
37 | +typedef unsigned char uchar; | |
38 | 38 | |
39 | 39 | #define CMD_GETENV "fw_printenv" |
40 | 40 | #define CMD_SETENV "fw_setenv" |
41 | 41 | |
42 | 42 | typedef struct envdev_s { |
43 | - uchar devname[16]; /* Device name */ | |
44 | - ulong devoff; /* Device offset */ | |
45 | - ulong env_size; /* environment size */ | |
46 | - ulong erase_size; /* device erase size */ | |
43 | + uchar devname[16]; /* Device name */ | |
44 | + ulong devoff; /* Device offset */ | |
45 | + ulong env_size; /* environment size */ | |
46 | + ulong erase_size; /* device erase size */ | |
47 | 47 | } envdev_t; |
48 | 48 | |
49 | 49 | static envdev_t envdevices[2]; |
... | ... | @@ -59,8 +59,8 @@ |
59 | 59 | #define ENV_SIZE getenvsize() |
60 | 60 | |
61 | 61 | typedef struct environment_s { |
62 | - ulong crc; /* CRC32 over data bytes */ | |
63 | - uchar flags; /* active or obsolete */ | |
62 | + ulong crc; /* CRC32 over data bytes */ | |
63 | + uchar flags; /* active or obsolete */ | |
64 | 64 | uchar *data; |
65 | 65 | } env_t; |
66 | 66 | |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | 71 | |
72 | 72 | |
73 | 73 | |
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | 79 | |
80 | 80 | |
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | 87 | |
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | 91 | |
92 | 92 | |
93 | 93 | |
94 | 94 | |
... | ... | @@ -77,92 +77,94 @@ |
77 | 77 | |
78 | 78 | static uchar default_environment[] = { |
79 | 79 | #if defined(CONFIG_BOOTARGS) |
80 | - "bootargs=" CONFIG_BOOTARGS ""\0"" | |
80 | + "bootargs=" CONFIG_BOOTARGS ""\0"" | |
81 | 81 | #endif |
82 | 82 | #if defined(CONFIG_BOOTCOMMAND) |
83 | - "bootcmd=" CONFIG_BOOTCOMMAND ""\0"" | |
83 | + "bootcmd=" CONFIG_BOOTCOMMAND ""\0"" | |
84 | 84 | #endif |
85 | 85 | #if defined(CONFIG_RAMBOOTCOMMAND) |
86 | - "ramboot=" CONFIG_RAMBOOTCOMMAND ""\0"" | |
86 | + "ramboot=" CONFIG_RAMBOOTCOMMAND ""\0"" | |
87 | 87 | #endif |
88 | 88 | #if defined(CONFIG_NFSBOOTCOMMAND) |
89 | - "nfsboot=" CONFIG_NFSBOOTCOMMAND ""\0"" | |
89 | + "nfsboot=" CONFIG_NFSBOOTCOMMAND ""\0"" | |
90 | 90 | #endif |
91 | 91 | #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) |
92 | - "bootdelay=" MK_STR(CONFIG_BOOTDELAY) ""\0"" | |
92 | + "bootdelay=" MK_STR (CONFIG_BOOTDELAY) ""\0"" | |
93 | 93 | #endif |
94 | 94 | #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) |
95 | - "baudrate=" MK_STR(CONFIG_BAUDRATE) ""\0"" | |
95 | + "baudrate=" MK_STR (CONFIG_BAUDRATE) ""\0"" | |
96 | 96 | #endif |
97 | 97 | #ifdef CONFIG_LOADS_ECHO |
98 | - "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) ""\0"" | |
98 | + "loads_echo=" MK_STR (CONFIG_LOADS_ECHO) ""\0"" | |
99 | 99 | #endif |
100 | 100 | #ifdef CONFIG_ETHADDR |
101 | - "ethaddr=" MK_STR(CONFIG_ETHADDR) ""\0"" | |
101 | + "ethaddr=" MK_STR (CONFIG_ETHADDR) ""\0"" | |
102 | 102 | #endif |
103 | 103 | #ifdef CONFIG_ETH1ADDR |
104 | - "eth1addr=" MK_STR(CONFIG_ETH1ADDR) ""\0"" | |
104 | + "eth1addr=" MK_STR (CONFIG_ETH1ADDR) ""\0"" | |
105 | 105 | #endif |
106 | 106 | #ifdef CONFIG_ETH2ADDR |
107 | - "eth2addr=" MK_STR(CONFIG_ETH2ADDR) ""\0"" | |
107 | + "eth2addr=" MK_STR (CONFIG_ETH2ADDR) ""\0"" | |
108 | 108 | #endif |
109 | 109 | #ifdef CONFIG_ETHPRIME |
110 | - "ethprime=" CONFIG_ETHPRIME ""\0"" | |
110 | + "ethprime=" CONFIG_ETHPRIME ""\0"" | |
111 | 111 | #endif |
112 | 112 | #ifdef CONFIG_IPADDR |
113 | - "ipaddr=" MK_STR(CONFIG_IPADDR) ""\0"" | |
113 | + "ipaddr=" MK_STR (CONFIG_IPADDR) ""\0"" | |
114 | 114 | #endif |
115 | 115 | #ifdef CONFIG_SERVERIP |
116 | - "serverip=" MK_STR(CONFIG_SERVERIP) ""\0"" | |
116 | + "serverip=" MK_STR (CONFIG_SERVERIP) ""\0"" | |
117 | 117 | #endif |
118 | 118 | #ifdef CFG_AUTOLOAD |
119 | - "autoload=" CFG_AUTOLOAD ""\0"" | |
119 | + "autoload=" CFG_AUTOLOAD ""\0"" | |
120 | 120 | #endif |
121 | 121 | #ifdef CONFIG_ROOTPATH |
122 | - "rootpath=" MK_STR(CONFIG_ROOTPATH) ""\0"" | |
122 | + "rootpath=" MK_STR (CONFIG_ROOTPATH) ""\0"" | |
123 | 123 | #endif |
124 | 124 | #ifdef CONFIG_GATEWAYIP |
125 | - "gatewayip=" MK_STR(CONFIG_GATEWAYIP) ""\0"" | |
125 | + "gatewayip=" MK_STR (CONFIG_GATEWAYIP) ""\0"" | |
126 | 126 | #endif |
127 | 127 | #ifdef CONFIG_NETMASK |
128 | - "netmask=" MK_STR(CONFIG_NETMASK) ""\0"" | |
128 | + "netmask=" MK_STR (CONFIG_NETMASK) ""\0"" | |
129 | 129 | #endif |
130 | 130 | #ifdef CONFIG_HOSTNAME |
131 | - "hostname=" MK_STR(CONFIG_HOSTNAME) ""\0"" | |
131 | + "hostname=" MK_STR (CONFIG_HOSTNAME) ""\0"" | |
132 | 132 | #endif |
133 | 133 | #ifdef CONFIG_BOOTFILE |
134 | - "bootfile=" MK_STR(CONFIG_BOOTFILE) ""\0"" | |
134 | + "bootfile=" MK_STR (CONFIG_BOOTFILE) ""\0"" | |
135 | 135 | #endif |
136 | 136 | #ifdef CONFIG_LOADADDR |
137 | - "loadaddr=" MK_STR(CONFIG_LOADADDR) ""\0"" | |
137 | + "loadaddr=" MK_STR (CONFIG_LOADADDR) ""\0"" | |
138 | 138 | #endif |
139 | 139 | #ifdef CONFIG_PREBOOT |
140 | - "preboot=" CONFIG_PREBOOT ""\0"" | |
140 | + "preboot=" CONFIG_PREBOOT ""\0"" | |
141 | 141 | #endif |
142 | 142 | #ifdef CONFIG_CLOCKS_IN_MHZ |
143 | - "clocks_in_mhz=" "1" ""\0"" | |
143 | + "clocks_in_mhz=" "1" ""\0"" | |
144 | 144 | #endif |
145 | 145 | #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) |
146 | - "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) ""\0"" | |
146 | + "pcidelay=" MK_STR (CONFIG_PCI_BOOTDELAY) ""\0"" | |
147 | 147 | #endif |
148 | 148 | #ifdef CONFIG_EXTRA_ENV_SETTINGS |
149 | 149 | CONFIG_EXTRA_ENV_SETTINGS |
150 | 150 | #endif |
151 | - "\0" /* Termimate env_t data with 2 NULs */ | |
151 | + "\0" /* Termimate env_t data with 2 NULs */ | |
152 | 152 | }; |
153 | 153 | |
154 | -static int flash_io (int mode); | |
155 | -static uchar *envmatch(uchar *s1, uchar *s2); | |
156 | -static int env_init(void); | |
157 | -static int parse_config(void); | |
154 | +static int flash_io (int mode); | |
155 | +static uchar *envmatch (uchar * s1, uchar * s2); | |
156 | +static int env_init (void); | |
157 | +static int parse_config (void); | |
158 | + | |
158 | 159 | #if defined(CONFIG_FILE) |
159 | -static int get_config(char *); | |
160 | +static int get_config (char *); | |
160 | 161 | #endif |
161 | -static inline ulong getenvsize(void) | |
162 | +static inline ulong getenvsize (void) | |
162 | 163 | { |
163 | - ulong rc = CFG_ENV_SIZE - sizeof(long); | |
164 | + ulong rc = CFG_ENV_SIZE - sizeof (long); | |
165 | + | |
164 | 166 | if (HaveRedundEnv) |
165 | - rc -= sizeof(char); | |
167 | + rc -= sizeof (char); | |
166 | 168 | return rc; |
167 | 169 | } |
168 | 170 | |
169 | 171 | |
170 | 172 | |
171 | 173 | |
... | ... | @@ -174,20 +176,20 @@ |
174 | 176 | { |
175 | 177 | uchar *env, *nxt; |
176 | 178 | |
177 | - if (env_init()) | |
179 | + if (env_init ()) | |
178 | 180 | return (NULL); |
179 | 181 | |
180 | - for (env=environment.data; *env; env=nxt+1) { | |
182 | + for (env = environment.data; *env; env = nxt + 1) { | |
181 | 183 | uchar *val; |
182 | 184 | |
183 | - for (nxt=env; *nxt; ++nxt) { | |
185 | + for (nxt = env; *nxt; ++nxt) { | |
184 | 186 | if (nxt >= &environment.data[ENV_SIZE]) { |
185 | 187 | fprintf (stderr, "## Error: " |
186 | 188 | "environment not terminated\n"); |
187 | 189 | return (NULL); |
188 | 190 | } |
189 | 191 | } |
190 | - val=envmatch(name, env); | |
192 | + val = envmatch (name, env); | |
191 | 193 | if (!val) |
192 | 194 | continue; |
193 | 195 | return (val); |
194 | 196 | |
195 | 197 | |
... | ... | @@ -199,17 +201,17 @@ |
199 | 201 | * Print the current definition of one, or more, or all |
200 | 202 | * environment variables |
201 | 203 | */ |
202 | -void fw_printenv(int argc, char *argv[]) | |
204 | +void fw_printenv (int argc, char *argv[]) | |
203 | 205 | { |
204 | 206 | uchar *env, *nxt; |
205 | 207 | int i, n_flag; |
206 | 208 | |
207 | - if (env_init()) | |
209 | + if (env_init ()) | |
208 | 210 | return; |
209 | 211 | |
210 | - if (argc == 1) { /* Print all env variables */ | |
211 | - for (env=environment.data; *env; env=nxt+1) { | |
212 | - for (nxt=env; *nxt; ++nxt) { | |
212 | + if (argc == 1) { /* Print all env variables */ | |
213 | + for (env = environment.data; *env; env = nxt + 1) { | |
214 | + for (nxt = env; *nxt; ++nxt) { | |
213 | 215 | if (nxt >= &environment.data[ENV_SIZE]) { |
214 | 216 | fprintf (stderr, "## Error: " |
215 | 217 | "environment not terminated\n"); |
216 | 218 | |
... | ... | @@ -217,12 +219,12 @@ |
217 | 219 | } |
218 | 220 | } |
219 | 221 | |
220 | - printf("%s\n", env); | |
222 | + printf ("%s\n", env); | |
221 | 223 | } |
222 | 224 | return; |
223 | 225 | } |
224 | 226 | |
225 | - if (strcmp(argv[1], "-n") == 0) { | |
227 | + if (strcmp (argv[1], "-n") == 0) { | |
226 | 228 | n_flag = 1; |
227 | 229 | ++argv; |
228 | 230 | --argc; |
229 | 231 | |
230 | 232 | |
231 | 233 | |
232 | 234 | |
233 | 235 | |
234 | 236 | |
... | ... | @@ -235,32 +237,31 @@ |
235 | 237 | n_flag = 0; |
236 | 238 | } |
237 | 239 | |
238 | - for (i=1; i<argc; ++i) { /* print single env variables */ | |
240 | + for (i = 1; i < argc; ++i) { /* print single env variables */ | |
239 | 241 | uchar *name = argv[i]; |
240 | 242 | uchar *val = NULL; |
241 | 243 | |
242 | - for (env=environment.data; *env; env=nxt+1) { | |
244 | + for (env = environment.data; *env; env = nxt + 1) { | |
243 | 245 | |
244 | - for (nxt=env; *nxt; ++nxt) { | |
246 | + for (nxt = env; *nxt; ++nxt) { | |
245 | 247 | if (nxt >= &environment.data[ENV_SIZE]) { |
246 | 248 | fprintf (stderr, "## Error: " |
247 | 249 | "environment not terminated\n"); |
248 | 250 | return; |
249 | 251 | } |
250 | 252 | } |
251 | - val=envmatch(name, env); | |
253 | + val = envmatch (name, env); | |
252 | 254 | if (val) { |
253 | 255 | if (!n_flag) { |
254 | 256 | fputs (name, stdout); |
255 | - putc ('=', stdout); | |
257 | + putc ('=', stdout); | |
256 | 258 | } |
257 | - puts (val); | |
259 | + puts (val); | |
258 | 260 | break; |
259 | 261 | } |
260 | 262 | } |
261 | 263 | if (!val) |
262 | - fprintf (stderr, "## Error: \"%s\" not defined\n", | |
263 | - name); | |
264 | + fprintf (stderr, "## Error: \"%s\" not defined\n", name); | |
264 | 265 | } |
265 | 266 | } |
266 | 267 | |
... | ... | @@ -274,7 +275,7 @@ |
274 | 275 | */ |
275 | 276 | int fw_setenv (int argc, char *argv[]) |
276 | 277 | { |
277 | - int i, len; | |
278 | + int i, len; | |
278 | 279 | uchar *env, *nxt; |
279 | 280 | uchar *oldval = NULL; |
280 | 281 | uchar *name; |
... | ... | @@ -283,7 +284,7 @@ |
283 | 284 | return (EINVAL); |
284 | 285 | } |
285 | 286 | |
286 | - if (env_init()) | |
287 | + if (env_init ()) | |
287 | 288 | return (errno); |
288 | 289 | |
289 | 290 | name = argv[1]; |
290 | 291 | |
... | ... | @@ -291,15 +292,15 @@ |
291 | 292 | /* |
292 | 293 | * search if variable with this name already exists |
293 | 294 | */ |
294 | - for (env=environment.data; *env; env=nxt+1) { | |
295 | - for (nxt=env; *nxt; ++nxt) { | |
295 | + for (nxt = env = environment.data; *env; env = nxt + 1) { | |
296 | + for (nxt = env; *nxt; ++nxt) { | |
296 | 297 | if (nxt >= &environment.data[ENV_SIZE]) { |
297 | 298 | fprintf (stderr, "## Error: " |
298 | 299 | "environment not terminated\n"); |
299 | 300 | return (EINVAL); |
300 | 301 | } |
301 | 302 | } |
302 | - if ((oldval=envmatch(name, env)) != NULL) | |
303 | + if ((oldval = envmatch (name, env)) != NULL) | |
303 | 304 | break; |
304 | 305 | } |
305 | 306 | |
... | ... | @@ -311,7 +312,7 @@ |
311 | 312 | * Ethernet Address and serial# can be set only once |
312 | 313 | */ |
313 | 314 | if ((strcmp (name, "ethaddr") == 0) || |
314 | - (strcmp (name, "serial#") == 0) ) { | |
315 | + (strcmp (name, "serial#") == 0)) { | |
315 | 316 | fprintf (stderr, "Can't overwrite \"%s\"\n", name); |
316 | 317 | return (EROFS); |
317 | 318 | } |
318 | 319 | |
319 | 320 | |
320 | 321 | |
... | ... | @@ -336,20 +337,19 @@ |
336 | 337 | /* |
337 | 338 | * Append new definition at the end |
338 | 339 | */ |
339 | - for (env=environment.data; *env || *(env+1); ++env) | |
340 | - ; | |
340 | + for (env = environment.data; *env || *(env + 1); ++env); | |
341 | 341 | if (env > environment.data) |
342 | 342 | ++env; |
343 | 343 | /* |
344 | 344 | * Overflow when: |
345 | 345 | * "name" + "=" + "val" +"\0\0" > CFG_ENV_SIZE - (env-environment) |
346 | 346 | */ |
347 | - len = strlen(name) + 2; | |
347 | + len = strlen (name) + 2; | |
348 | 348 | /* add '=' for first arg, ' ' for all others */ |
349 | - for (i=2; i<argc; ++i) { | |
350 | - len += strlen(argv[i]) + 1; | |
349 | + for (i = 2; i < argc; ++i) { | |
350 | + len += strlen (argv[i]) + 1; | |
351 | 351 | } |
352 | - if (len > (&environment.data[ENV_SIZE]-env)) { | |
352 | + if (len > (&environment.data[ENV_SIZE] - env)) { | |
353 | 353 | fprintf (stderr, |
354 | 354 | "Error: environment overflow, \"%s\" deleted\n", |
355 | 355 | name); |
356 | 356 | |
357 | 357 | |
358 | 358 | |
359 | 359 | |
... | ... | @@ -357,26 +357,24 @@ |
357 | 357 | } |
358 | 358 | while ((*env = *name++) != '\0') |
359 | 359 | env++; |
360 | - for (i=2; i<argc; ++i) { | |
360 | + for (i = 2; i < argc; ++i) { | |
361 | 361 | uchar *val = argv[i]; |
362 | 362 | |
363 | - *env = (i==2) ? '=' : ' '; | |
364 | - while ((*++env = *val++) != '\0') | |
365 | - ; | |
363 | + *env = (i == 2) ? '=' : ' '; | |
364 | + while ((*++env = *val++) != '\0'); | |
366 | 365 | } |
367 | 366 | |
368 | 367 | /* end is marked with double '\0' */ |
369 | 368 | *++env = '\0'; |
370 | 369 | |
371 | -WRITE_FLASH: | |
370 | + WRITE_FLASH: | |
372 | 371 | |
373 | 372 | /* Update CRC */ |
374 | - environment.crc = crc32(0, environment.data, ENV_SIZE); | |
373 | + environment.crc = crc32 (0, environment.data, ENV_SIZE); | |
375 | 374 | |
376 | 375 | /* write environment back to flash */ |
377 | 376 | if (flash_io (O_RDWR)) { |
378 | - fprintf (stderr, | |
379 | - "Error: can't write fw_env to flash\n"); | |
377 | + fprintf (stderr, "Error: can't write fw_env to flash\n"); | |
380 | 378 | return (-1); |
381 | 379 | } |
382 | 380 | |
383 | 381 | |
384 | 382 | |
385 | 383 | |
386 | 384 | |
387 | 385 | |
388 | 386 | |
389 | 387 | |
390 | 388 | |
391 | 389 | |
392 | 390 | |
393 | 391 | |
394 | 392 | |
395 | 393 | |
396 | 394 | |
397 | 395 | |
398 | 396 | |
399 | 397 | |
400 | 398 | |
401 | 399 | |
402 | 400 | |
403 | 401 | |
404 | 402 | |
405 | 403 | |
406 | 404 | |
407 | 405 | |
408 | 406 | |
409 | 407 | |
410 | 408 | |
411 | 409 | |
412 | 410 | |
413 | 411 | |
414 | 412 | |
415 | 413 | |
416 | 414 | |
417 | 415 | |
... | ... | @@ -389,166 +387,172 @@ |
389 | 387 | erase_info_t erase; |
390 | 388 | char *data; |
391 | 389 | |
392 | - if ((fd = open(DEVNAME(curdev), mode)) < 0) { | |
393 | - fprintf (stderr, | |
394 | - "Can't open %s: %s\n", | |
395 | - DEVNAME(curdev), strerror(errno)); | |
390 | + if ((fd = open (DEVNAME (curdev), mode)) < 0) { | |
391 | + fprintf (stderr, | |
392 | + "Can't open %s: %s\n", | |
393 | + DEVNAME (curdev), strerror (errno)); | |
396 | 394 | return (-1); |
397 | 395 | } |
398 | 396 | |
399 | - len = sizeof(environment.crc); | |
397 | + len = sizeof (environment.crc); | |
400 | 398 | if (HaveRedundEnv) { |
401 | - len += sizeof(environment.flags); | |
399 | + len += sizeof (environment.flags); | |
402 | 400 | } |
403 | 401 | |
404 | 402 | if (mode == O_RDWR) { |
405 | 403 | if (HaveRedundEnv) { |
406 | 404 | /* switch to next partition for writing */ |
407 | 405 | otherdev = !curdev; |
408 | - if ((fdr = open(DEVNAME(otherdev), mode)) < 0) { | |
409 | - fprintf (stderr, | |
410 | - "Can't open %s: %s\n", | |
411 | - DEVNAME(otherdev), strerror(errno)); | |
406 | + if ((fdr = open (DEVNAME (otherdev), mode)) < 0) { | |
407 | + fprintf (stderr, | |
408 | + "Can't open %s: %s\n", | |
409 | + DEVNAME (otherdev), | |
410 | + strerror (errno)); | |
412 | 411 | return (-1); |
413 | 412 | } |
414 | 413 | } else { |
415 | 414 | otherdev = curdev; |
416 | 415 | fdr = fd; |
417 | 416 | } |
418 | - printf("Unlocking flash...\n"); | |
419 | - erase.length = DEVESIZE(otherdev); | |
420 | - erase.start = DEVOFFSET(otherdev); | |
417 | + printf ("Unlocking flash...\n"); | |
418 | + erase.length = DEVESIZE (otherdev); | |
419 | + erase.start = DEVOFFSET (otherdev); | |
421 | 420 | ioctl (fdr, MEMUNLOCK, &erase); |
422 | 421 | |
423 | 422 | if (HaveRedundEnv) { |
424 | - erase.length = DEVESIZE(curdev); | |
425 | - erase.start = DEVOFFSET(curdev); | |
423 | + erase.length = DEVESIZE (curdev); | |
424 | + erase.start = DEVOFFSET (curdev); | |
426 | 425 | ioctl (fd, MEMUNLOCK, &erase); |
427 | 426 | environment.flags = active_flag; |
428 | 427 | } |
429 | 428 | |
430 | - printf("Done\n"); | |
431 | - resid = DEVESIZE(otherdev) - CFG_ENV_SIZE; | |
429 | + printf ("Done\n"); | |
430 | + resid = DEVESIZE (otherdev) - CFG_ENV_SIZE; | |
432 | 431 | if (resid) { |
433 | - if ((data = malloc(resid)) == NULL) { | |
434 | - fprintf(stderr, | |
435 | - "Cannot malloc %d bytes: %s\n", | |
436 | - resid, strerror(errno)); | |
432 | + if ((data = malloc (resid)) == NULL) { | |
433 | + fprintf (stderr, | |
434 | + "Cannot malloc %d bytes: %s\n", | |
435 | + resid, | |
436 | + strerror (errno)); | |
437 | 437 | return (-1); |
438 | 438 | } |
439 | - if (lseek (fdr, DEVOFFSET(otherdev) + CFG_ENV_SIZE, SEEK_SET) == -1) { | |
440 | - fprintf (stderr, | |
441 | - "seek error on %s: %s\n", | |
442 | - DEVNAME(otherdev), strerror(errno)); | |
439 | + if (lseek (fdr, DEVOFFSET (otherdev) + CFG_ENV_SIZE, SEEK_SET) | |
440 | + == -1) { | |
441 | + fprintf (stderr, "seek error on %s: %s\n", | |
442 | + DEVNAME (otherdev), | |
443 | + strerror (errno)); | |
443 | 444 | return (-1); |
444 | 445 | } |
445 | 446 | if ((rc = read (fdr, data, resid)) != resid) { |
446 | 447 | fprintf (stderr, |
447 | - "read error on %s: %s\n", | |
448 | - DEVNAME(otherdev), strerror(errno)); | |
448 | + "read error on %s: %s\n", | |
449 | + DEVNAME (otherdev), | |
450 | + strerror (errno)); | |
449 | 451 | return (-1); |
450 | 452 | } |
451 | 453 | } |
452 | 454 | |
453 | - printf("Erasing old environment...\n"); | |
455 | + printf ("Erasing old environment...\n"); | |
454 | 456 | |
455 | - erase.length = DEVESIZE(otherdev); | |
456 | - erase.start = DEVOFFSET(otherdev); | |
457 | + erase.length = DEVESIZE (otherdev); | |
458 | + erase.start = DEVOFFSET (otherdev); | |
457 | 459 | if (ioctl (fdr, MEMERASE, &erase) != 0) { |
458 | 460 | fprintf (stderr, "MTD erase error on %s: %s\n", |
459 | - DEVNAME(otherdev), strerror(errno)); | |
461 | + DEVNAME (otherdev), | |
462 | + strerror (errno)); | |
460 | 463 | return (-1); |
461 | 464 | } |
462 | 465 | |
463 | - printf("Done\n"); | |
466 | + printf ("Done\n"); | |
464 | 467 | |
465 | - printf("Writing environment to %s...\n",DEVNAME(otherdev)); | |
466 | - if (lseek (fdr, DEVOFFSET(otherdev), SEEK_SET) == -1) { | |
468 | + printf ("Writing environment to %s...\n", DEVNAME (otherdev)); | |
469 | + if (lseek (fdr, DEVOFFSET (otherdev), SEEK_SET) == -1) { | |
467 | 470 | fprintf (stderr, |
468 | - "seek error on %s: %s\n", | |
469 | - DEVNAME(otherdev), strerror(errno)); | |
471 | + "seek error on %s: %s\n", | |
472 | + DEVNAME (otherdev), strerror (errno)); | |
470 | 473 | return (-1); |
471 | 474 | } |
472 | - if (write(fdr, &environment, len) != len) { | |
475 | + if (write (fdr, &environment, len) != len) { | |
473 | 476 | fprintf (stderr, |
474 | - "CRC write error on %s: %s\n", | |
475 | - DEVNAME(otherdev), strerror(errno)); | |
477 | + "CRC write error on %s: %s\n", | |
478 | + DEVNAME (otherdev), strerror (errno)); | |
476 | 479 | return (-1); |
477 | 480 | } |
478 | - if (write(fdr, environment.data, ENV_SIZE) != ENV_SIZE) { | |
481 | + if (write (fdr, environment.data, ENV_SIZE) != ENV_SIZE) { | |
479 | 482 | fprintf (stderr, |
480 | - "Write error on %s: %s\n", | |
481 | - DEVNAME(otherdev), strerror(errno)); | |
483 | + "Write error on %s: %s\n", | |
484 | + DEVNAME (otherdev), strerror (errno)); | |
482 | 485 | return (-1); |
483 | 486 | } |
484 | 487 | if (resid) { |
485 | 488 | if (write (fdr, data, resid) != resid) { |
486 | 489 | fprintf (stderr, |
487 | - "write error on %s: %s\n", | |
488 | - DEVNAME(curdev), strerror(errno)); | |
490 | + "write error on %s: %s\n", | |
491 | + DEVNAME (curdev), strerror (errno)); | |
489 | 492 | return (-1); |
490 | 493 | } |
491 | - free(data); | |
494 | + free (data); | |
492 | 495 | } |
493 | 496 | if (HaveRedundEnv) { |
494 | 497 | /* change flag on current active env partition */ |
495 | - if (lseek (fd, DEVOFFSET(curdev) + sizeof(ulong), SEEK_SET) == -1) { | |
496 | - fprintf (stderr, | |
497 | - "seek error on %s: %s\n", | |
498 | - DEVNAME(curdev), strerror(errno)); | |
498 | + if (lseek (fd, DEVOFFSET (curdev) + sizeof (ulong), SEEK_SET) | |
499 | + == -1) { | |
500 | + fprintf (stderr, "seek error on %s: %s\n", | |
501 | + DEVNAME (curdev), strerror (errno)); | |
499 | 502 | return (-1); |
500 | 503 | } |
501 | - if (write (fd, &obsolete_flag, sizeof(obsolete_flag)) != | |
502 | - sizeof(obsolete_flag)) { | |
504 | + if (write (fd, &obsolete_flag, sizeof (obsolete_flag)) != | |
505 | + sizeof (obsolete_flag)) { | |
503 | 506 | fprintf (stderr, |
504 | - "Write error on %s: %s\n", | |
505 | - DEVNAME(curdev), strerror(errno)); | |
507 | + "Write error on %s: %s\n", | |
508 | + DEVNAME (curdev), strerror (errno)); | |
506 | 509 | return (-1); |
507 | 510 | } |
508 | 511 | } |
509 | - printf("Done\n"); | |
510 | - printf("Locking ...\n"); | |
511 | - erase.length = DEVESIZE(otherdev); | |
512 | - erase.start = DEVOFFSET(otherdev); | |
512 | + printf ("Done\n"); | |
513 | + printf ("Locking ...\n"); | |
514 | + erase.length = DEVESIZE (otherdev); | |
515 | + erase.start = DEVOFFSET (otherdev); | |
513 | 516 | ioctl (fdr, MEMLOCK, &erase); |
514 | 517 | if (HaveRedundEnv) { |
515 | - erase.length = DEVESIZE(curdev); | |
516 | - erase.start = DEVOFFSET(curdev); | |
518 | + erase.length = DEVESIZE (curdev); | |
519 | + erase.start = DEVOFFSET (curdev); | |
517 | 520 | ioctl (fd, MEMLOCK, &erase); |
518 | - if (close(fdr)) { | |
521 | + if (close (fdr)) { | |
519 | 522 | fprintf (stderr, |
520 | - "I/O error on %s: %s\n", | |
521 | - DEVNAME(otherdev), strerror(errno)); | |
523 | + "I/O error on %s: %s\n", | |
524 | + DEVNAME (otherdev), | |
525 | + strerror (errno)); | |
522 | 526 | return (-1); |
523 | 527 | } |
524 | 528 | } |
525 | - printf("Done\n"); | |
529 | + printf ("Done\n"); | |
526 | 530 | } else { |
527 | 531 | |
528 | - if (lseek (fd, DEVOFFSET(curdev), SEEK_SET) == -1) { | |
532 | + if (lseek (fd, DEVOFFSET (curdev), SEEK_SET) == -1) { | |
529 | 533 | fprintf (stderr, |
530 | - "seek error on %s: %s\n", | |
531 | - DEVNAME(curdev), strerror(errno)); | |
534 | + "seek error on %s: %s\n", | |
535 | + DEVNAME (curdev), strerror (errno)); | |
532 | 536 | return (-1); |
533 | 537 | } |
534 | 538 | if (read (fd, &environment, len) != len) { |
535 | 539 | fprintf (stderr, |
536 | - "CRC read error on %s: %s\n", | |
537 | - DEVNAME(curdev), strerror(errno)); | |
540 | + "CRC read error on %s: %s\n", | |
541 | + DEVNAME (curdev), strerror (errno)); | |
538 | 542 | return (-1); |
539 | 543 | } |
540 | 544 | if ((rc = read (fd, environment.data, ENV_SIZE)) != ENV_SIZE) { |
541 | 545 | fprintf (stderr, |
542 | - "Read error on %s: %s\n", | |
543 | - DEVNAME(curdev), strerror(errno)); | |
546 | + "Read error on %s: %s\n", | |
547 | + DEVNAME (curdev), strerror (errno)); | |
544 | 548 | return (-1); |
545 | 549 | } |
546 | 550 | } |
547 | 551 | |
548 | - if (close(fd)) { | |
552 | + if (close (fd)) { | |
549 | 553 | fprintf (stderr, |
550 | - "I/O error on %s: %s\n", | |
551 | - DEVNAME(curdev), strerror(errno)); | |
554 | + "I/O error on %s: %s\n", | |
555 | + DEVNAME (curdev), strerror (errno)); | |
552 | 556 | return (-1); |
553 | 557 | } |
554 | 558 | |
555 | 559 | |
556 | 560 | |
... | ... | @@ -562,22 +566,21 @@ |
562 | 566 | * If the names match, return the value of s2, else NULL. |
563 | 567 | */ |
564 | 568 | |
565 | -static uchar * | |
566 | -envmatch (uchar *s1, uchar *s2) | |
569 | +static uchar *envmatch (uchar * s1, uchar * s2) | |
567 | 570 | { |
568 | 571 | |
569 | 572 | while (*s1 == *s2++) |
570 | 573 | if (*s1++ == '=') |
571 | - return(s2); | |
572 | - if (*s1 == '\0' && *(s2-1) == '=') | |
573 | - return(s2); | |
574 | - return(NULL); | |
574 | + return (s2); | |
575 | + if (*s1 == '\0' && *(s2 - 1) == '=') | |
576 | + return (s2); | |
577 | + return (NULL); | |
575 | 578 | } |
576 | 579 | |
577 | 580 | /* |
578 | 581 | * Prevent confusion if running from erased flash memory |
579 | 582 | */ |
580 | -static int env_init(void) | |
583 | +static int env_init (void) | |
581 | 584 | { |
582 | 585 | int crc1, crc1_ok; |
583 | 586 | uchar *addr1; |
584 | 587 | |
585 | 588 | |
586 | 589 | |
587 | 590 | |
588 | 591 | |
589 | 592 | |
590 | 593 | |
591 | 594 | |
592 | 595 | |
593 | 596 | |
594 | 597 | |
595 | 598 | |
596 | 599 | |
597 | 600 | |
598 | 601 | |
599 | 602 | |
600 | 603 | |
601 | 604 | |
602 | 605 | |
603 | 606 | |
604 | 607 | |
605 | 608 | |
606 | 609 | |
607 | 610 | |
608 | 611 | |
609 | 612 | |
610 | 613 | |
611 | 614 | |
... | ... | @@ -585,151 +588,142 @@ |
585 | 588 | int crc2, crc2_ok; |
586 | 589 | uchar flag1, flag2, *addr2; |
587 | 590 | |
588 | - if (parse_config()) /* should fill envdevices */ | |
591 | + if (parse_config ()) /* should fill envdevices */ | |
589 | 592 | return 1; |
590 | - | |
593 | + | |
591 | 594 | if ((addr1 = calloc (1, ENV_SIZE)) == NULL) { |
592 | - fprintf (stderr, | |
593 | - "Not enough memory for environment (%ld bytes)\n", | |
594 | - ENV_SIZE); | |
595 | + fprintf (stderr, | |
596 | + "Not enough memory for environment (%ld bytes)\n", | |
597 | + ENV_SIZE); | |
595 | 598 | return (errno); |
596 | 599 | } |
597 | - | |
600 | + | |
598 | 601 | /* read environment from FLASH to local buffer */ |
599 | 602 | environment.data = addr1; |
600 | 603 | curdev = 0; |
601 | 604 | if (flash_io (O_RDONLY)) { |
602 | 605 | return (errno); |
603 | 606 | } |
604 | - | |
605 | - crc1_ok = ((crc1 = crc32(0, environment.data, ENV_SIZE)) | |
607 | + | |
608 | + crc1_ok = ((crc1 = crc32 (0, environment.data, ENV_SIZE)) | |
606 | 609 | == environment.crc); |
607 | 610 | if (!HaveRedundEnv) { |
608 | 611 | if (!crc1_ok) { |
609 | - fprintf (stderr, | |
610 | - "Warning: Bad CRC, using default environment\n"); | |
612 | + fprintf (stderr, | |
613 | + "Warning: Bad CRC, using default environment\n"); | |
611 | 614 | environment.data = default_environment; |
612 | - free(addr1); | |
615 | + free (addr1); | |
613 | 616 | } |
614 | 617 | } else { |
615 | 618 | flag1 = environment.flags; |
616 | - | |
619 | + | |
617 | 620 | curdev = 1; |
618 | 621 | if ((addr2 = calloc (1, ENV_SIZE)) == NULL) { |
619 | - fprintf (stderr, | |
620 | - "Not enough memory for environment (%ld bytes)\n", | |
621 | - ENV_SIZE); | |
622 | + fprintf (stderr, | |
623 | + "Not enough memory for environment (%ld bytes)\n", | |
624 | + ENV_SIZE); | |
622 | 625 | return (errno); |
623 | - } | |
626 | + } | |
624 | 627 | environment.data = addr2; |
625 | - | |
628 | + | |
626 | 629 | if (flash_io (O_RDONLY)) { |
627 | 630 | return (errno); |
628 | 631 | } |
629 | - | |
630 | - crc2_ok = ((crc2 = crc32(0, environment.data, ENV_SIZE)) | |
632 | + | |
633 | + crc2_ok = ((crc2 = crc32 (0, environment.data, ENV_SIZE)) | |
631 | 634 | == environment.crc); |
632 | 635 | flag2 = environment.flags; |
633 | - | |
634 | - if (crc1_ok && ! crc2_ok) { | |
635 | - environment.data = addr1; | |
636 | + | |
637 | + if (crc1_ok && !crc2_ok) { | |
638 | + environment.data = addr1; | |
636 | 639 | environment.flags = flag1; |
637 | 640 | environment.crc = crc1; |
638 | 641 | curdev = 0; |
639 | - free(addr2); | |
640 | - } | |
641 | - else if (! crc1_ok && crc2_ok) { | |
642 | - environment.data = addr2; | |
642 | + free (addr2); | |
643 | + } else if (!crc1_ok && crc2_ok) { | |
644 | + environment.data = addr2; | |
643 | 645 | environment.flags = flag2; |
644 | 646 | environment.crc = crc2; |
645 | 647 | curdev = 1; |
646 | - free(addr1); | |
647 | - } | |
648 | - else if (! crc1_ok && ! crc2_ok) { | |
649 | - fprintf (stderr, | |
650 | - "Warning: Bad CRC, using default environment\n"); | |
648 | + free (addr1); | |
649 | + } else if (!crc1_ok && !crc2_ok) { | |
650 | + fprintf (stderr, | |
651 | + "Warning: Bad CRC, using default environment\n"); | |
651 | 652 | environment.data = default_environment; |
652 | 653 | curdev = 0; |
653 | - free(addr2); | |
654 | - free(addr1); | |
655 | - } | |
656 | - else if (flag1 == active_flag && flag2 == obsolete_flag) { | |
657 | - environment.data = addr1; | |
654 | + free (addr2); | |
655 | + free (addr1); | |
656 | + } else if (flag1 == active_flag && flag2 == obsolete_flag) { | |
657 | + environment.data = addr1; | |
658 | 658 | environment.flags = flag1; |
659 | 659 | environment.crc = crc1; |
660 | 660 | curdev = 0; |
661 | - free(addr2); | |
662 | - } | |
663 | - else if (flag1 == obsolete_flag && flag2 == active_flag) { | |
664 | - environment.data = addr2; | |
661 | + free (addr2); | |
662 | + } else if (flag1 == obsolete_flag && flag2 == active_flag) { | |
663 | + environment.data = addr2; | |
665 | 664 | environment.flags = flag2; |
666 | 665 | environment.crc = crc2; |
667 | 666 | curdev = 1; |
668 | - free(addr1); | |
669 | - } | |
670 | - else if (flag1 == flag2) { | |
671 | - environment.data = addr1; | |
667 | + free (addr1); | |
668 | + } else if (flag1 == flag2) { | |
669 | + environment.data = addr1; | |
672 | 670 | environment.flags = flag1; |
673 | 671 | environment.crc = crc1; |
674 | 672 | curdev = 0; |
675 | - free(addr2); | |
676 | - } | |
677 | - else if (flag1 == 0xFF) { | |
678 | - environment.data = addr1; | |
673 | + free (addr2); | |
674 | + } else if (flag1 == 0xFF) { | |
675 | + environment.data = addr1; | |
679 | 676 | environment.flags = flag1; |
680 | 677 | environment.crc = crc1; |
681 | 678 | curdev = 0; |
682 | - free(addr2); | |
683 | - } | |
684 | - else if (flag2 == 0xFF) { | |
685 | - environment.data = addr2; | |
679 | + free (addr2); | |
680 | + } else if (flag2 == 0xFF) { | |
681 | + environment.data = addr2; | |
686 | 682 | environment.flags = flag2; |
687 | 683 | environment.crc = crc2; |
688 | 684 | curdev = 1; |
689 | - free(addr1); | |
685 | + free (addr1); | |
690 | 686 | } |
691 | 687 | } |
692 | 688 | return (0); |
693 | 689 | } |
694 | 690 | |
695 | 691 | |
696 | -static int parse_config() | |
692 | +static int parse_config () | |
697 | 693 | { |
698 | 694 | struct stat st; |
699 | 695 | |
700 | 696 | #if defined(CONFIG_FILE) |
701 | 697 | /* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */ |
702 | - if (get_config(CONFIG_FILE)) { | |
698 | + if (get_config (CONFIG_FILE)) { | |
703 | 699 | fprintf (stderr, |
704 | - "Cannot parse config file: %s\n", | |
705 | - strerror(errno)); | |
700 | + "Cannot parse config file: %s\n", strerror (errno)); | |
706 | 701 | return 1; |
707 | 702 | } |
708 | - | |
709 | 703 | #else |
710 | - strcpy(DEVNAME(0), DEVICE1_NAME); | |
711 | - DEVOFFSET(0) = DEVICE1_OFFSET; | |
712 | - ENVSIZE(0) = ENV1_SIZE; | |
713 | - DEVESIZE(0) = DEVICE1_ESIZE; | |
704 | + strcpy (DEVNAME (0), DEVICE1_NAME); | |
705 | + DEVOFFSET (0) = DEVICE1_OFFSET; | |
706 | + ENVSIZE (0) = ENV1_SIZE; | |
707 | + DEVESIZE (0) = DEVICE1_ESIZE; | |
714 | 708 | #ifdef HAVE_REDUND |
715 | - strcpy(DEVNAME(1), DEVICE2_NAME); | |
716 | - DEVOFFSET(1) = DEVICE2_OFFSET; | |
717 | - ENVSIZE(1) = ENV2_SIZE; | |
718 | - DEVESIZE(1) = DEVICE2_ESIZE; | |
709 | + strcpy (DEVNAME (1), DEVICE2_NAME); | |
710 | + DEVOFFSET (1) = DEVICE2_OFFSET; | |
711 | + ENVSIZE (1) = ENV2_SIZE; | |
712 | + DEVESIZE (1) = DEVICE2_ESIZE; | |
719 | 713 | HaveRedundEnv = 1; |
720 | 714 | #endif |
721 | 715 | #endif |
722 | - if (stat (DEVNAME(0), &st)) { | |
723 | - fprintf (stderr, | |
724 | - "Cannot access MTD device %s: %s\n", | |
725 | - DEVNAME(0), strerror(errno)); | |
716 | + if (stat (DEVNAME (0), &st)) { | |
717 | + fprintf (stderr, | |
718 | + "Cannot access MTD device %s: %s\n", | |
719 | + DEVNAME (0), strerror (errno)); | |
726 | 720 | return 1; |
727 | 721 | } |
728 | - | |
729 | - if (HaveRedundEnv && stat (DEVNAME(1), &st)) { | |
730 | - fprintf (stderr, | |
731 | - "Cannot access MTD device %s: %s\n", | |
732 | - DEVNAME(2), strerror(errno)); | |
722 | + | |
723 | + if (HaveRedundEnv && stat (DEVNAME (1), &st)) { | |
724 | + fprintf (stderr, | |
725 | + "Cannot access MTD device %s: %s\n", | |
726 | + DEVNAME (2), strerror (errno)); | |
733 | 727 | return 1; |
734 | 728 | } |
735 | 729 | return 0; |
736 | 730 | |
737 | 731 | |
738 | 732 | |
739 | 733 | |
... | ... | @@ -743,26 +737,28 @@ |
743 | 737 | int rc; |
744 | 738 | char dump[128]; |
745 | 739 | |
746 | - if ((fp = fopen(fname, "r")) == NULL) { | |
740 | + if ((fp = fopen (fname, "r")) == NULL) { | |
747 | 741 | return 1; |
748 | 742 | } |
749 | 743 | |
750 | - while ((i < 2) && | |
751 | - ((rc = fscanf (fp, "%s %lx %lx %lx", | |
752 | - DEVNAME(i), &DEVOFFSET(i), &ENVSIZE(i), &DEVESIZE(i))) != EOF)) { | |
744 | + while ((i < 2) && ((rc = fscanf (fp, "%s %lx %lx %lx", | |
745 | + DEVNAME (i), | |
746 | + &DEVOFFSET (i), | |
747 | + &ENVSIZE (i), | |
748 | + &DEVESIZE (i) )) != EOF)) { | |
753 | 749 | |
754 | 750 | /* Skip incomplete conversions and comment strings */ |
755 | - if ((rc < 3) || (*DEVNAME(i) == '#')) { | |
756 | - fgets (dump, sizeof(dump), fp); /* Consume till end */ | |
751 | + if ((rc < 3) || (*DEVNAME (i) == '#')) { | |
752 | + fgets (dump, sizeof (dump), fp); /* Consume till end */ | |
757 | 753 | continue; |
758 | 754 | } |
759 | 755 | |
760 | 756 | i++; |
761 | 757 | } |
762 | - fclose(fp); | |
763 | - | |
758 | + fclose (fp); | |
759 | + | |
764 | 760 | HaveRedundEnv = i - 1; |
765 | - if (!i) { /* No valid entries found */ | |
761 | + if (!i) { /* No valid entries found */ | |
766 | 762 | errno = EINVAL; |
767 | 763 | return 1; |
768 | 764 | } else |