3 Copyright 2005, Broadcom Corporation
6 THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7 KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8 SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9 FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
17 #include <sys/ioctl.h>
18 #include <sys/mount.h>
23 #include <sys/reboot.h>
26 #include <sys/types.h>
28 #include <sys/sysinfo.h>
33 #define SHELL "/bin/sh"
35 static int fatalsigs
[] = {
46 static int initsigs
[] = {
56 static char *defenv
[] = {
59 "PATH=/usr/bin:/bin:/usr/sbin:/sbin",
65 /* Set terminal settings to reasonable defaults */
66 static void set_term(int fd
)
72 /* set control chars */
73 tty
.c_cc
[VINTR
] = 3; /* C-c */
74 tty
.c_cc
[VQUIT
] = 28; /* C-\ */
75 tty
.c_cc
[VERASE
] = 127; /* C-? */
76 tty
.c_cc
[VKILL
] = 21; /* C-u */
77 tty
.c_cc
[VEOF
] = 4; /* C-d */
78 tty
.c_cc
[VSTART
] = 17; /* C-q */
79 tty
.c_cc
[VSTOP
] = 19; /* C-s */
80 tty
.c_cc
[VSUSP
] = 26; /* C-z */
82 /* use line dicipline 0 */
86 tty
.c_cflag
&= CBAUD
|CBAUDEX
|CSIZE
|CSTOPB
|PARENB
|PARODD
;
87 tty
.c_cflag
|= CREAD
|HUPCL
|CLOCAL
;
91 tty
.c_iflag
= ICRNL
| IXON
| IXOFF
;
94 tty
.c_oflag
= OPOST
| ONLCR
;
98 ISIG
| ICANON
| ECHO
| ECHOE
| ECHOK
| ECHOCTL
| ECHOKE
| IEXTEN
;
100 tcsetattr(fd
, TCSANOW
, &tty
);
103 static int console_init(void)
108 ioctl(0, TIOCNOTTY
, 0);
115 if ((fd
= open(_PATH_CONSOLE
, O_RDWR
)) < 0) {
116 /* Avoid debug messages is redirected to socket packet if no exist a UART chip, added by honor, 2003-12-04 */
117 open("/dev/null", O_RDONLY
);
118 open("/dev/null", O_WRONLY
);
119 open("/dev/null", O_WRONLY
);
120 perror(_PATH_CONSOLE
);
127 ioctl(0, TIOCSCTTY
, 1);
128 tcsetpgrp(0, getpgrp());
135 * Waits for a file descriptor to change status or unblocked signal
136 * @param fd file descriptor
137 * @param timeout seconds to wait before timing out or 0 for no timeout
138 * @return 1 if descriptor changed status or 0 if timed out or -1 on error
140 static int waitfor(int fd
, int timeout
)
143 struct timeval tv
= { timeout
, 0 };
147 return select(fd
+ 1, &rfds
, NULL
, NULL
, (timeout
> 0) ? &tv
: NULL
);
150 static pid_t
run_shell(int timeout
, int nowait
)
155 /* Wait for user input */
156 if (waitfor(STDIN_FILENO
, timeout
) <= 0) return 0;
158 switch (pid
= fork()) {
163 /* Reset signal handlers set for parent process */
164 for (sig
= 0; sig
< (_NSIG
-1); sig
++)
165 signal(sig
, SIG_DFL
);
169 printf("\n\nTomato %s\n\n", tomato_version
);
171 /* Now run it. The new program will take over this PID,
172 * so nothing further in init.c should be run. */
173 execve(SHELL
, (char *[]) { SHELL
, NULL
}, defenv
);
175 /* We're still here? Some error happened. */
183 waitpid(pid
, NULL
, 0);
189 int console_main(int argc
, char *argv
[])
191 for (;;) run_shell(0, 0);
196 static void shutdn(int rb
)
202 _dprintf("shutdn rb=%d\n", rb
);
205 for (i
= 0; i
< sizeof(fatalsigs
) / sizeof(fatalsigs
[0]); i
++)
206 sigaddset(&ss
, fatalsigs
[i
]);
207 for (i
= 0; i
< sizeof(initsigs
) / sizeof(initsigs
[0]); i
++)
208 sigaddset(&ss
, initsigs
[i
]);
209 sigprocmask(SIG_BLOCK
, &ss
, NULL
);
211 for (i
= 30; i
> 0; --i
) {
212 if (((act
= check_action()) == ACT_IDLE
) || (act
== ACT_REBOOT
)) break;
213 _dprintf("Busy with %d. Waiting before shutdown... %d\n", act
, i
);
216 set_action(ACT_REBOOT
);
218 // Disconnect pppd - need this for PPTP/L2TP to finish gracefully
232 umount("/jffs"); // may hang if not
238 for (i
= 4; i
> 0; --i
) {
249 reboot(rb
? RB_AUTOBOOT
: RB_HALT_SYSTEM
);
256 static void handle_fatalsigs(int sig
)
258 _dprintf("fatal sig=%d\n", sig
);
262 /* Fixed the race condition & incorrect code by using sigwait()
263 * instead of pause(). But SIGCHLD is a problem, since other
264 * code: 1) messes with it and 2) depends on CHLD being caught so
265 * that the pid gets immediately reaped instead of left a zombie.
266 * Pidof still shows the pid, even though it's in zombie state.
267 * So this SIGCHLD handler reaps and then signals the mainline by
270 static void handle_reap(int sig
)
276 static int check_nv(const char *name
, const char *value
)
279 if (!nvram_match("manual_boot_nv", "1")) {
280 if (((p
= nvram_get(name
)) == NULL
) || (strcmp(p
, value
) != 0)) {
281 _dprintf("Error: Critical variable %s is invalid. Resetting.\n", name
);
282 nvram_set(name
, value
);
289 static inline int invalid_mac(const char *mac
)
291 return (!mac
|| !(*mac
) || strncasecmp(mac
, "00:90:4c", 8) == 0);
294 static int find_sercom_mac_addr(void)
297 unsigned char m
[6], s
[18];
299 sprintf(s
, MTD_DEV(%dro
), 0);
300 if ((fp
= fopen(s
, "rb"))) {
301 fseek(fp
, 0x1ffa0, SEEK_SET
);
302 fread(m
, sizeof(m
), 1, fp
);
304 sprintf(s
, "%02X:%02X:%02X:%02X:%02X:%02X",
305 m
[0], m
[1], m
[2], m
[3], m
[4], m
[5]);
306 nvram_set("et0macaddr", s
);
307 return !invalid_mac(s
);
312 static int find_dir320_mac_addr(void)
316 int i
, part
, size
, found
= 0;
318 if (!mtd_getinfo("board_data", &part
, &size
))
320 sprintf(s
, MTD_DEV(%dro
), part
);
322 if ((fp
= fopen(s
, "rb"))) {
323 buffer
= malloc(size
);
324 memset(buffer
, 0, size
);
325 fread(buffer
, size
, 1, fp
);
326 if (!memcmp(buffer
, "RGCFG1", 6)) {
327 for (i
= 6; i
< size
- 24; i
++) {
328 if (!memcmp(buffer
+ i
, "lanmac=", 7)) {
329 memcpy(s
, buffer
+ i
+ 7, 17);
331 nvram_set("et0macaddr", s
);
334 else if (!memcmp(buffer
+ i
, "wanmac=", 7)) {
335 memcpy(s
, buffer
+ i
+ 7, 17);
337 nvram_set("il0macaddr", s
);
340 nvram_set("et0macaddr", s
);
351 strcpy(s
, nvram_safe_get("wl0_hwaddr"));
353 nvram_set("et0macaddr", s
);
358 static int init_vlan_ports(void)
361 int model
= get_model();
365 switch (check_hw_type()) {
366 case HW_BCM5352E
: // G v4, GS v3, v4
367 dirty
|= check_nv("vlan0ports", "3 2 1 0 5*");
372 dirty
|= check_nv("vlan0ports", "0 5*");
373 dirty
|= check_nv("vlan1ports", "1 5");
374 dirty
|= check_nv("vlan_enable", "1");
378 case MODEL_WL500GPv2
:
381 if (nvram_match("vlan1ports", "0 5u")) // 520GU or 330GE or WL500GE?
382 dirty
|= check_nv("vlan1ports", "0 5");
383 else if (nvram_match("vlan1ports", "4 5u"))
384 dirty
|= check_nv("vlan1ports", "4 5");
387 dirty
|= check_nv("vlan0ports", "1 2 3 4 5*");
388 dirty
|= check_nv("vlan1ports", "0 5");
392 dirty
|= (nvram_get("vlan2ports") != NULL
);
393 nvram_unset("vlan2ports");
394 dirty
|= check_nv("vlan0ports", "1 2 3 4 5*");
395 dirty
|= check_nv("vlan1ports", "0 5");
397 case MODEL_WRT310Nv1
:
398 dirty
|= check_nv("vlan1ports", "1 2 3 4 8*");
399 dirty
|= check_nv("vlan2ports", "0 8");
402 dirty
|= check_nv("vlan0ports", "0 1 2 3 5*");
403 dirty
|= check_nv("vlan1ports", "4 5");
408 case MODEL_WNR3500LV2
:
411 dirty
|= check_nv("vlan1ports", "4 3 2 1 8*");
412 dirty
|= check_nv("vlan2ports", "0 8");
415 dirty
|= check_nv("vlan1ports", "1 2 3 4 8*");
416 dirty
|= check_nv("vlan2ports", "0 8");
417 dirty
|= check_nv("boot_wait", "on");
418 dirty
|= check_nv("wait_time", "5");
421 dirty
|= check_nv("vlan1ports", "1 2 3 4 8*");
422 dirty
|= check_nv("vlan2ports", "0 8");
423 dirty
|= check_nv("ledbh0", "11");
424 dirty
|= check_nv("ledbh1", "11");
425 dirty
|= check_nv("ledbh2", "11");
426 dirty
|= check_nv("ledbh11", "136");
427 // must flash tt through tftp.
428 dirty
|= check_nv("boot_wait", "on");
429 dirty
|= check_nv("wait_time", "5");
432 dirty
|= check_nv("vlan2ports", "0 1 2 3 5*");
433 dirty
|= check_nv("vlan1ports", "4 5");
436 dirty
|= check_nv("vlan1ports", "4 5");
437 dirty
|= check_nv("vlan2ports", "3 2 1 0 5*");
439 case MODEL_WNR2000v2
:
440 dirty
|= check_nv("vlan1ports", "4 3 2 1 5*");
441 dirty
|= check_nv("vlan2ports", "0 5");
445 dirty
|= check_nv("vlan1ports", "1 2 3 4 5*");
446 dirty
|= check_nv("vlan2ports", "0 5");
448 case MODEL_RG200E_CA
:
449 dirty
|= check_nv("vlan1ports", "4 3 2 1 5*");
450 dirty
|= check_nv("vlan2ports", "0 5");
453 dirty
|= check_nv("vlan1ports", "4 5");
457 dirty
|= check_nv("vlan0ports", "1 2 3 4 5*");
458 dirty
|= check_nv("vlan1ports", "0 5");
463 dirty
|= check_nv("vlan0ports", "3 2 1 0 5*");
464 dirty
|= check_nv("vlan1ports", "4 5");
466 case MODEL_WRT610Nv2
:
467 case MODEL_F5D8235v3
:
468 dirty
|= check_nv("vlan1ports", "1 2 3 4 8*");
469 dirty
|= check_nv("vlan2ports", "0 8");
473 dirty
|= check_nv("vlan1ports", "3 2 1 0 8*");
474 dirty
|= check_nv("vlan2ports", "4 8");
483 dirty
|= check_nv("vlan1ports", "0 1 2 3 5*");
484 dirty
|= check_nv("vlan2ports", "4 5");
488 dirty
|= check_nv("vlan1ports", "1 2 3 4 5*");
489 dirty
|= check_nv("vlan2ports", "0 5");
495 case MODEL_WNDR3700v3
:
496 dirty
|= check_nv("vlan1ports", "0 1 2 3 8*");
497 dirty
|= check_nv("vlan2ports", "4 8");
500 case MODEL_WNDR3400v2
:
501 // Note port order is important (or reversed display, if "0 1 2 3 5*" used for vlan1ports) -> doesn't work, invert in Web GUI
502 dirty
|= check_nv("vlan1ports", "0 1 2 3 5*");
503 // And change "4 5u" to "4 5" to make WAN port work
504 dirty
|= check_nv("vlan2ports", "4 5");
507 dirty
|= check_nv("vlan1ports", "4 3 2 1 8*");
508 dirty
|= check_nv("vlan2ports", "4 8");
509 dirty
|= check_nv("boot_wait", "on");
510 dirty
|= check_nv("wait_time", "5");
512 case MODEL_TDN6
: //bwq518
513 dirty
|= check_nv("vlan1ports", "1 2 3 4 5*");
514 dirty
|= check_nv("vlan2ports", "0 5");
515 dirty
|= check_nv("boot_wait", "on");
516 dirty
|= check_nv("wait_time", "5");
518 case MODEL_WRT160Nv3
:
519 if (nvram_match("vlan1ports", "1 2 3 4 5*")) {
520 // fix lan port numbering on CSE41, CSE51
521 dirty
|= check_nv("vlan1ports", "4 3 2 1 5*");
523 else if (nvram_match("vlan1ports", "1 2 3 4 8*")) {
525 dirty
|= check_nv("vlan1ports", "4 3 2 1 8*");
534 static void check_bootnv(void)
542 dirty
= check_nv("wl0_leddc", "0x640000") | check_nv("wl1_leddc", "0x640000");
546 dirty
|= check_nv("vlan0hwname", "et0");
547 dirty
|= check_nv("vlan1hwname", "et0");
550 dirty
|= check_nv("wl0gpio0", "130");
554 // need to cleanup some variables...
555 if ((nvram_get("t_model") == NULL
) && (nvram_get("MyFirmwareVersion") != NULL
)) {
556 nvram_unset("MyFirmwareVersion");
557 nvram_set("restore_defaults", "1");
561 dirty
|= check_nv("wl0gpio1", "0x02");
564 /* fix WL500W mac adresses for WAN port */
565 if (invalid_mac(nvram_get("et1macaddr"))) {
566 strcpy(mac
, nvram_safe_get("et0macaddr"));
568 dirty
|= check_nv("et1macaddr", mac
);
570 dirty
|= check_nv("wl0gpio0", "0x88");
573 dirty
|= check_nv("sdram_init", "0x0009"); // 32MB; defaults: 0x000b, 0x0009
574 dirty
|= check_nv("wl0gpio0", "136");
576 case MODEL_WL500GPv2
:
578 dirty
|= check_nv("wl0gpio1", "136");
581 dirty
|= check_nv("vlan0hwname", "et0");
582 dirty
|= check_nv("vlan1hwname", "et0");
583 dirty
|= check_nv("boardflags", "0x00000100"); // set BFL_ENETVLAN
584 nvram_unset("wl0gpio0");
587 if (strlen(nvram_safe_get("et0macaddr")) == 12 ||
588 strlen(nvram_safe_get("il0macaddr")) == 12) {
589 dirty
|= find_dir320_mac_addr();
591 if (nvram_get("vlan2hwname") != NULL
) {
592 nvram_unset("vlan2hwname");
595 dirty
|= check_nv("wandevs", "vlan1");
596 dirty
|= check_nv("vlan1hwname", "et0");
597 dirty
|= check_nv("wl0gpio0", "8");
598 dirty
|= check_nv("wl0gpio1", "0");
599 dirty
|= check_nv("wl0gpio2", "0");
600 dirty
|= check_nv("wl0gpio3", "0");
603 dirty
|= check_nv("wandevs", "vlan1");
604 dirty
|= check_nv("vlan0hwname", "et0");
605 dirty
|= check_nv("vlan1hwname", "et0");
608 if (invalid_mac(nvram_get("et0macaddr"))) {
609 dirty
|= find_sercom_mac_addr();
612 case MODEL_WRT160Nv1
:
613 case MODEL_WRT310Nv1
:
615 dirty
|= check_nv("wl0gpio0", "8");
619 dirty
|= check_nv("boardflags", "0x00000710"); // needed to enable USB
620 dirty
|= check_nv("vlan2hwname", "et0");
621 dirty
|= check_nv("ledbh0", "7");
623 case MODEL_WNR3500LV2
:
624 dirty
|= check_nv("vlan2hwname", "et0");
626 case MODEL_WNR2000v2
:
627 dirty
|= check_nv("ledbh5", "8");
630 dirty
|= check_nv("reset_gpio", "5");
631 dirty
|= check_nv("ledbh0", "136");
632 dirty
|= check_nv("ledbh1", "11");
633 /* fall through, same as RT-N16 */
635 dirty
|= check_nv("vlan2hwname", "et0");
638 case MODEL_RG200E_CA
:
640 dirty
|= check_nv("vlan1hwname", "et0");
641 dirty
|= check_nv("vlan2hwname", "et0");
642 dirty
|= check_nv("boardflags", "0x710"); // set BFL_ENETVLAN, enable VLAN
643 dirty
|= check_nv("reset_gpio", "30");
645 case MODEL_WRT610Nv2
:
646 dirty
|= check_nv("vlan2hwname", "et0");
647 dirty
|= check_nv("pci/1/1/ledbh2", "8");
648 dirty
|= check_nv("sb/1/ledbh1", "8");
649 if (invalid_mac(nvram_get("pci/1/1/macaddr"))) {
650 strcpy(mac
, nvram_safe_get("et0macaddr"));
652 dirty
|= check_nv("pci/1/1/macaddr", mac
);
659 case MODEL_F5D8235v3
:
660 if (nvram_match("sb/1/macaddr", nvram_safe_get("et0macaddr"))) {
661 strcpy(mac
, nvram_safe_get("et0macaddr"));
663 dirty
|= check_nv("sb/1/macaddr", mac
);
665 dirty
|= check_nv("pci/1/1/macaddr", mac
);
668 dirty
|= check_nv("vlan2hwname", "et0");
669 if (strncasecmp(nvram_safe_get("pci/2/1/macaddr"), "00:90:4c", 8) == 0) {
670 strcpy(mac
, nvram_safe_get("et0macaddr"));
672 dirty
|= check_nv("pci/2/1/macaddr", mac
);
676 dirty
|= check_nv("vlan2hwname", "et0");
677 if (strncasecmp(nvram_safe_get("pci/1/1/macaddr"), "00:90:4c", 8) == 0 ||
678 strncasecmp(nvram_safe_get("sb/1/macaddr"), "00:90:4c", 8) == 0) {
679 strcpy(mac
, nvram_safe_get("et0macaddr"));
681 dirty
|= check_nv("sb/1/macaddr", mac
);
683 dirty
|= check_nv("pci/1/1/macaddr", mac
);
687 case MODEL_WNDR3700v3
:
688 // Have to check MAC addresses, specific configuration needed:
689 // Part of MAC information is in CFE, the rest in board_data (which easily gets broken when playing with firmware ... :-))
690 // Note that after a clean (30/30/30) reset, addresses are "broken" ... but the code below fixes them, tied to et0macaddr!
691 // Also, CFE will update what it sees based on NVRAM ...
692 // so after 30/30/30 reset it sees different values than after a full Tomato boot (that fixes these, updating NVRAM)
693 // Use this approach for all WNDR routers (here, and below)
694 dirty
|= check_nv("vlan2hwname", "et0");
695 strcpy(mac
, nvram_safe_get("et0macaddr"));
697 dirty
|= check_nv("sb/1/macaddr", mac
);
699 dirty
|= check_nv("pci/1/1/macaddr", mac
);
702 case MODEL_WNDR3400v2
:
703 dirty
|= check_nv("vlan2hwname", "et0");
704 strcpy(mac
, nvram_safe_get("et0macaddr"));
706 dirty
|= check_nv("sb/1/macaddr", mac
);
708 if (model
== MODEL_WNDR3400
)
709 dirty
|= check_nv("pci/1/1/macaddr", mac
);
711 dirty
|= check_nv("wl1_hwaddr", mac
);
712 // Have to check wl ifname(s) ... if not set before eth config, 5 GHz radio does not come up properly
713 //dirty |= check_nv("wl0_ifname", "eth1");
714 dirty
|= check_nv("wl1_ifname", "eth2");
722 case MODEL_WRT160Nv3
:
725 dirty
|= check_nv("vlan2hwname", "et0");
730 if (strncmp(nvram_safe_get("pmon_ver"), "CFE", 3) != 0) return;
732 hardware
= check_hw_type();
733 if (!nvram_get("boardtype") ||
734 !nvram_get("boardnum") ||
735 !nvram_get("boardflags") ||
736 !nvram_get("clkfreq") ||
737 !nvram_get("os_flash_addr") ||
738 !nvram_get("dl_ram_addr") ||
739 !nvram_get("os_ram_addr") ||
740 !nvram_get("scratch") ||
741 !nvram_get("et0macaddr") ||
742 ((hardware
!= HW_BCM4704_BCM5325F
) && (!nvram_get("vlan0ports") || !nvram_get("vlan0hwname")))) {
743 _dprintf("Unable to find critical settings, erasing NVRAM\n");
748 dirty
|= check_nv("aa0", "3");
749 dirty
|= check_nv("wl0gpio0", "136");
750 dirty
|= check_nv("wl0gpio2", "0");
751 dirty
|= check_nv("wl0gpio3", "0");
752 dirty
|= check_nv("cctl", "0");
753 dirty
|= check_nv("ccode", "0");
757 /* Lower the DDR ram drive strength , the value will be stable for all boards
758 Latency 3 is more stable for all ddr 20050420 by honor */
759 dirty
|= check_nv("sdram_init", "0x010b");
760 dirty
|= check_nv("sdram_config", "0x0062");
761 if (!nvram_match("debug_clkfix", "0")) {
762 dirty
|= check_nv("clkfreq", "216");
765 nvram_set("sdram_ncdl", "0x0");
767 dirty
|= check_nv("pa0itssit", "62");
768 dirty
|= check_nv("pa0b0", "0x15eb");
769 dirty
|= check_nv("pa0b1", "0xfa82");
770 dirty
|= check_nv("pa0b2", "0xfe66");
771 //dirty |= check_nv("pa0maxpwr", "0x4e");
773 case HW_BCM5352E
: // G v4, GS v3, v4
774 dirty
|= check_nv("sdram_init", "0x010b");
775 dirty
|= check_nv("sdram_config", "0x0062");
777 nvram_set("sdram_ncdl", "0x0");
779 dirty
|= check_nv("pa0itssit", "62");
780 dirty
|= check_nv("pa0b0", "0x168b");
781 dirty
|= check_nv("pa0b1", "0xfabf");
782 dirty
|= check_nv("pa0b2", "0xfeaf");
783 //dirty |= check_nv("pa0maxpwr", "0x4e");
786 dirty
|= check_nv("pa0itssit", "62");
787 dirty
|= check_nv("pa0b0", "0x1326");
788 dirty
|= check_nv("pa0b1", "0xFB51");
789 dirty
|= check_nv("pa0b2", "0xFE87");
790 //dirty |= check_nv("pa0maxpwr", "0x4e");
792 case HW_BCM4704_BCM5325F
:
796 dirty
|= check_nv("pa0itssit", "62");
797 dirty
|= check_nv("pa0b0", "0x170c");
798 dirty
|= check_nv("pa0b1", "0xfa24");
799 dirty
|= check_nv("pa0b2", "0xfe70");
800 //dirty |= check_nv("pa0maxpwr", "0x48");
807 dirty
|= init_vlan_ports();
811 REBOOT
: // do a simple reboot
818 static int init_nvram(void)
820 unsigned long features
;
830 sprintf(s
, "%d", model
);
831 nvram_set("t_model", s
);
840 name
= "WRT54G/GS/GL";
841 switch (check_hw_type()) {
843 nvram_set("gpio2", "adm_eecs");
844 nvram_set("gpio3", "adm_eesk");
845 nvram_unset("gpio4");
846 nvram_set("gpio5", "adm_eedi");
847 nvram_set("gpio6", "adm_rc");
850 nvram_unset("gpio2");
851 nvram_unset("gpio3");
852 nvram_unset("gpio4");
853 nvram_unset("gpio5");
854 nvram_unset("gpio6");
857 nvram_set("opo", "0x0008");
858 nvram_set("ag0", "0x02");
861 nvram_set("gpio2", "ses_led");
862 nvram_set("gpio3", "ses_led2");
863 nvram_set("gpio4", "ses_button");
864 features
= SUP_SES
| SUP_WHAM_LED
;
871 if (!nvram_match("t_fix1", (char *)name
)) {
872 nvram_set("lan_ifnames", "vlan0 eth1");
873 nvram_set("gpio2", "ses_button");
874 nvram_set("reset_gpio", "7");
876 nvram_set("pa0itssit", "62");
877 nvram_set("pa0b0", "0x1542");
878 nvram_set("pa0b1", "0xfacb");
879 nvram_set("pa0b2", "0xfec7");
880 //nvram_set("pa0maxpwr", "0x4c");
883 case MODEL_WRTSL54GS
:
886 features
= SUP_SES
| SUP_WHAM_LED
;
891 features
= SUP_SES
| SUP_AOSS_LED
| SUP_BRAU
;
894 case MODEL_WZRRSG54HP
:
897 features
= SUP_SES
| SUP_AOSS_LED
| SUP_HPAMP
;
899 case MODEL_WZRRSG54HP
:
900 name
= "WZR-RS-G54HP";
907 features
= SUP_SES
| SUP_AOSS_LED
| SUP_BRAU
| SUP_HPAMP
;
911 bf
= strtoul(nvram_safe_get("boardflags"), NULL
, 0);
917 if ( nvram_is_empty("wlx_hpamp") || nvram_match("wlx_hpamp", "")) {
918 if (nvram_get_int("wl_txpwr") > 10) nvram_set("wl_txpwr", "10");
919 nvram_set("wlx_hpamp", "1");
920 nvram_set("wlx_hperx", "0");
924 if (nvram_match("wlx_hpamp", "0")) {
930 if (nvram_match("wlx_hperx", "0")) {
937 sprintf(s
, "0x%lX", n
);
938 nvram_set("boardflags", s
);
942 syslog(LOG_WARNING
, "Unexpected: boardflag=%lX", bf
);
953 features
= SUP_SES
| SUP_AOSS_LED
;
955 case MODEL_WHR2A54G54
:
957 name
= "WHR2-A54G54";
958 features
= SUP_SES
| SUP_AOSS_LED
| SUP_BRAU
;
963 features
= SUP_SES
| SUP_AOSS_LED
;
968 features
= SUP_SES
| SUP_AOSS_LED
;
973 features
= SUP_SES
| SUP_AOSS_LED
;
983 features
= SUP_SES
| SUP_AOSS_LED
;
992 features
= SUP_NONVE
;
996 name
= "WR850G v2/v3";
997 features
= SUP_NONVE
;
1004 nvram_set("usb_ohci", "-1");
1006 if (!nvram_match("t_fix1", (char *)name
)) {
1007 nvram_set("lan_ifnames", "vlan0 eth1 eth2 eth3"); // set to "vlan0 eth2" by DD-WRT; default: vlan0 eth1
1013 features
= SUP_SES
| SUP_80211N
;
1015 nvram_set("usb_ohci", "-1");
1023 nvram_set("usb_uhci", "-1");
1026 case MODEL_WX6615GT
:
1039 case MODEL_WLA2G54L
:
1042 if (!nvram_match("t_fix1", (char *)name
)) {
1043 nvram_set("lan_ifnames", "vlan0 eth1 eth2");
1044 nvram_set("wl_ifname", "eth1");
1045 nvram_set("wan_ifname", "none");
1050 name
= "TrueMobile 2300";
1059 #ifndef WL_BSS_INFO_VERSION
1060 #error WL_BSS_INFO_VERSION
1062 #if WL_BSS_INFO_VERSION >= 108
1068 nvram_set("opo", "12");
1074 features
= SUP_SES
| SUP_AOSS_LED
| SUP_BRAU
;
1076 nvram_set("opo", "0x0008");
1077 nvram_set("ag0", "0x0C");
1079 #ifdef CONFIG_BCMWL5
1083 features
= SUP_SES
| SUP_80211N
;
1084 if (!nvram_match("t_fix1", (char *)name
)) {
1085 #ifdef TCONFIG_USBAP
1086 nvram_set("wl1_hwaddr", nvram_safe_get("0:macaddr"));
1087 nvram_set("ehciirqt", "3");
1088 nvram_set("qtdc_pid", "48407");
1089 nvram_set("qtdc_vid", "2652");
1090 nvram_set("qtdc0_ep", "4");
1091 nvram_set("qtdc0_sz", "0");
1092 nvram_set("qtdc1_ep", "18");
1093 nvram_set("qtdc1_sz", "10");
1094 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1095 nvram_set("landevs", "vlan1 wl0 wl1");
1096 nvram_set("wl0_ifname", "wl0");
1097 nvram_set("wl1_ifname", "wl1");
1099 nvram_set("lan_ifnames", "vlan1 eth1");
1100 nvram_set("landevs", "vlan1 wl0");
1102 nvram_set("wl_ifname", "eth1");
1103 nvram_set("wan_ifnameX", "vlan2");
1104 nvram_set("wandevs", "vlan2");
1107 case MODEL_DIR620C1
:
1109 name
= "Dir-620 C1";
1110 features
= SUP_SES
| SUP_80211N
;
1111 if (!nvram_match("t_fix1", (char *)name
)) {
1112 #ifdef TCONFIG_USBAP
1113 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1114 nvram_set("landevs", "vlan1 wl0 wl1");
1115 nvram_set("wl0_ifname", "eth1");
1116 nvram_set("wl1_ifname", "eth2");
1118 nvram_set("lan_ifnames", "vlan1 eth1");
1119 nvram_set("landevs", "vlan1 wl0");
1121 nvram_set("wan_ifnameX", "vlan2");
1122 nvram_set("wl_ifname", "eth1");
1129 features
= SUP_SES
| SUP_80211N
;
1131 nvram_set("usb_uhci", "-1");
1133 if (!nvram_match("t_fix1", (char *)name
)) {
1134 nvram_set("lan_ifnames", "vlan1 eth1");
1135 nvram_set("wan_ifname", "vlan2");
1136 nvram_set("wan_ifnames", "vlan2");
1137 nvram_set("wan_ifnameX", "vlan2");
1138 nvram_set("wl_ifname", "eth1");
1144 features
= SUP_SES
| SUP_80211N
;
1146 nvram_set("usb_uhci", "-1");
1148 if (!nvram_match("t_fix1", (char *)name
)) {
1149 nvram_set("lan_ifnames", "vlan1 eth1");
1150 nvram_set("wan_ifname", "vlan2");
1151 nvram_set("wan_ifnames", "vlan2");
1152 nvram_set("wan_ifnameX", "vlan2");
1153 nvram_set("wl_ifname", "eth1");
1156 case MODEL_RG200E_CA
:
1159 features
= SUP_SES
| SUP_80211N
;
1161 nvram_set("usb_uhci", "-1");
1163 if (!nvram_match("t_fix1", (char *)name
)) {
1164 nvram_set("lan_ifnames", "vlan1 eth1");
1165 nvram_set("wan_ifname", "vlan2");
1166 nvram_set("wan_ifnames", "vlan2");
1167 nvram_set("wan_ifnameX", "vlan2");
1168 nvram_set("wl_ifname", "eth1");
1174 features
= SUP_SES
| SUP_80211N
;
1176 nvram_set("usb_uhci", "-1");
1178 if (!nvram_match("t_fix1", (char *)name
)) {
1179 nvram_set("lan_ifnames", "vlan1 eth1");
1180 nvram_set("wan_ifname", "vlan2");
1181 nvram_set("wan_ifnames", "vlan2");
1182 nvram_set("wan_ifnameX", "vlan2");
1183 nvram_set("wl_ifname", "eth1");
1189 features
= SUP_SES
| SUP_80211N
;
1191 nvram_set("usb_uhci", "-1");
1193 if (!nvram_match("t_fix1", (char *)name
)) {
1194 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1195 nvram_set("wan_ifnameX", "vlan2");
1196 nvram_set("wan_ifnames", "vlan2");
1197 nvram_set("wan_ifnameX", "vlan2");
1198 nvram_set("wl_ifnames", "eth1 eth2");
1199 nvram_set("wl_ifname", "eth1");
1200 nvram_set("wl0_ifname", "eth1");
1201 nvram_set("wl1_ifname", "eth2");
1202 nvram_set("wl0_bw_cap","3");
1203 nvram_set("wl0_chanspec","1l");
1204 nvram_set("wl1_bw_cap","7");
1205 nvram_set("wl1_chanspec","36/80");
1206 nvram_set("blink_5g_interface","eth2");
1207 //nvram_set("landevs", "vlan1 wl0 wl1");
1208 //nvram_set("wandevs", "vlan2");
1211 nvram_set("wl0_hwaddr", nvram_safe_get("sb/1/macaddr"));
1212 nvram_set("wl1_hwaddr", nvram_safe_get("0:macaddr"));
1218 features
= SUP_SES
| SUP_80211N
;
1220 nvram_set("usb_uhci", "-1");
1222 if (!nvram_match("t_fix1", (char *)name
)) {
1223 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1224 nvram_set("wan_ifnameX", "vlan2");
1225 nvram_set("wan_ifnames", "vlan2");
1226 nvram_set("wan_ifnameX", "vlan2");
1227 nvram_set("wl_ifnames", "eth1 eth2");
1228 nvram_set("wl_ifname", "eth1");
1229 nvram_set("wl0_ifname", "eth1");
1230 nvram_set("wl1_ifname", "eth2");
1231 nvram_set("wl0_bw_cap","3");
1232 nvram_set("wl0_chanspec","1l");
1233 nvram_set("wl1_bw_cap","7");
1234 nvram_set("wl1_chanspec","36/80");
1235 nvram_set("blink_5g_interface","eth2");
1238 nvram_set("wl0_hwaddr", nvram_safe_get("sb/1/macaddr"));
1239 nvram_set("wl1_hwaddr", nvram_safe_get("0:macaddr"));
1245 name
= nvram_match("boardrev", "0x1153") ? "RT-N10P" : "RT-N10";
1246 features
= SUP_SES
| SUP_80211N
;
1247 if (!nvram_match("t_fix1", (char *)name
)) {
1248 nvram_set("lan_ifnames", "vlan0 eth1");
1249 nvram_set("wan_ifnameX", "vlan1");
1250 nvram_set("wl_ifname", "eth1");
1256 features
= SUP_SES
| SUP_80211N
;
1258 nvram_set("usb_uhci", "-1");
1260 if (!nvram_match("t_fix1", (char *)name
)) {
1261 nvram_set("lan_ifnames", "vlan0 eth1");
1262 nvram_set("wan_ifnameX", "vlan1");
1263 nvram_set("wl_ifname", "eth1");
1269 features
= SUP_SES
| SUP_BRAU
| SUP_80211N
;
1270 if (!nvram_match("t_fix1", (char *)name
)) {
1271 nvram_set("lan_ifnames", "vlan0 eth1");
1272 nvram_set("wan_ifnameX", "vlan1");
1273 nvram_set("wl_ifname", "eth1");
1279 features
= SUP_80211N
;
1280 if (!nvram_match("t_fix1", (char *)name
)) {
1281 nvram_set("lan_ifnames", "vlan0 eth1");
1282 nvram_set("wan_ifnameX", "vlan1");
1283 nvram_set("wl_ifname", "eth1");
1289 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
;
1291 nvram_set("usb_uhci", "-1");
1293 if (!nvram_match("t_fix1", (char *)name
)) {
1294 nvram_set("lan_ifnames", "vlan1 eth1");
1295 nvram_set("wan_iface", "vlan2");
1296 nvram_set("wan_ifname", "vlan2");
1297 nvram_set("wan_ifnameX", "vlan2");
1298 nvram_set("wan_ifnames", "vlan2");
1299 nvram_set("wl_ifname", "eth1");
1305 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
;
1307 nvram_set("usb_uhci", "-1");
1309 if (!nvram_match("t_fix1", (char *)name
)) {
1310 nvram_set("lan_ifnames", "vlan1 eth1");
1311 nvram_set("wan_ifnameX", "vlan2");
1312 nvram_set("wl_ifname", "eth1");
1313 nvram_set("vlan_enable", "1");
1319 name
= nvram_match("boardrev", "0x1446") ? "RT-N53 A1" : "RT-N53";
1320 features
= SUP_SES
| SUP_80211N
;
1321 #if defined(LINUX26) && defined(TCONFIG_USBAP)
1322 if (nvram_get_int("usb_storage") == 1) nvram_set("usb_storage", "-1");
1324 if (!nvram_match("t_fix1", (char *)name
)) {
1325 #ifdef TCONFIG_USBAP
1326 nvram_set("wl1_hwaddr", nvram_safe_get("0:macaddr"));
1327 nvram_set("ehciirqt", "3");
1328 nvram_set("qtdc_pid", "48407");
1329 nvram_set("qtdc_vid", "2652");
1330 nvram_set("qtdc0_ep", "4");
1331 nvram_set("qtdc0_sz", "0");
1332 nvram_set("qtdc1_ep", "18");
1333 nvram_set("qtdc1_sz", "10");
1334 nvram_set("lan_ifnames", "vlan2 eth1 eth2");
1335 nvram_set("landevs", "vlan2 wl0 wl1");
1336 nvram_set("wl1_ifname", "eth2");
1338 nvram_set("lan_ifnames", "vlan2 eth1");
1339 nvram_set("landevs", "vlan2 wl0");
1341 nvram_set("lan_ifname", "br0");
1342 nvram_set("wl_ifname", "eth1");
1343 nvram_set("wl0_ifname", "eth1");
1344 nvram_set("wan_ifnameX", "vlan1");
1345 nvram_set("wandevs", "vlan1");
1346 nvram_unset("vlan0ports");
1351 #ifdef TCONFIG_AC66U
1353 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
| SUP_80211AC
;
1356 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
;
1357 #if defined(LINUX26) && defined(TCONFIG_MICROSD)
1358 if (nvram_get_int("usb_mmc") == -1) nvram_set("usb_mmc", "1");
1363 nvram_set("usb_uhci", "-1");
1365 if (!nvram_match("t_fix1", (char *)name
)) {
1366 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1367 nvram_set("wan_ifnameX", "vlan2");
1368 nvram_set("wl_ifnames", "eth1 eth2");
1369 #ifdef TCONFIG_AC66U
1370 nvram_set("wl_ifname", "eth1");
1371 nvram_set("wl0_ifname", "eth1");
1372 nvram_set("wl1_ifname", "eth2");
1374 nvram_set("landevs", "vlan1 wl0 wl1");
1375 nvram_set("wandevs", "vlan2");
1376 #ifndef TCONFIG_AC66U
1377 #if defined(LINUX26) && defined(TCONFIG_USB)
1378 nvram_set("usb_noled", "1-1.4"); /* SD/MMC Card */
1381 nvram_set("wl1_bw_cap","7");
1382 nvram_set("wl1_chanspec","36/80");
1383 nvram_set("wl0_bw_cap","3");
1384 nvram_set("wl0_chanspec","1l");
1385 nvram_set("blink_5g_interface","eth2");
1388 strcpy(s
, nvram_safe_get("et0macaddr"));
1390 nvram_set("wl0_hwaddr", s
);
1392 nvram_set("wl1_hwaddr", s
);
1394 // bcm4360ac_defaults
1395 nvram_set("pci/2/1/aa2g", "0");
1396 nvram_set("pci/2/1/aa5g", "7");
1397 nvram_set("pci/2/1/aga0", "71");
1398 nvram_set("pci/2/1/aga1", "71");
1399 nvram_set("pci/2/1/aga2", "71");
1400 nvram_set("pci/2/1/agbg0", "133");
1401 nvram_set("pci/2/1/agbg1", "133");
1402 nvram_set("pci/2/1/agbg2", "133");
1403 nvram_set("pci/2/1/antswitch", "0");
1404 nvram_set("pci/2/1/cckbw202gpo", "0");
1405 nvram_set("pci/2/1/cckbw20ul2gpo", "0");
1406 nvram_set("pci/2/1/dot11agofdmhrbw202gpo", "0");
1407 nvram_set("pci/2/1/femctrl", "3");
1408 nvram_set("pci/2/1/papdcap2g", "0");
1409 nvram_set("pci/2/1/tworangetssi2g", "0");
1410 nvram_set("pci/2/1/pdgain2g", "4");
1411 nvram_set("pci/2/1/epagain2g", "0");
1412 nvram_set("pci/2/1/tssiposslope2g", "1");
1413 nvram_set("pci/2/1/gainctrlsph", "0");
1414 nvram_set("pci/2/1/papdcap5g", "0");
1415 nvram_set("pci/2/1/tworangetssi5g", "0");
1416 nvram_set("pci/2/1/pdgain5g", "4");
1417 nvram_set("pci/2/1/epagain5g", "0");
1418 nvram_set("pci/2/1/tssiposslope5g", "1");
1419 nvram_set("pci/2/1/maxp2ga0", "76");
1420 nvram_set("pci/2/1/maxp2ga1", "76");
1421 nvram_set("pci/2/1/maxp2ga2", "76");
1422 nvram_set("pci/2/1/mcsbw202gpo", "0");
1423 nvram_set("pci/2/1/mcsbw402gpo", "0");
1424 nvram_set("pci/2/1/measpower", "0x7f");
1425 nvram_set("pci/2/1/measpower1", "0x7f");
1426 nvram_set("pci/2/1/measpower2", "0x7f");
1427 nvram_set("pci/2/1/noiselvl2ga0", "31");
1428 nvram_set("pci/2/1/noiselvl2ga1", "31");
1429 nvram_set("pci/2/1/noiselvl2ga2", "31");
1430 nvram_set("pci/2/1/noiselvl5gha0", "31");
1431 nvram_set("pci/2/1/noiselvl5gha1", "31");
1432 nvram_set("pci/2/1/noiselvl5gha2", "31");
1433 nvram_set("pci/2/1/noiselvl5gla0", "31");
1434 nvram_set("pci/2/1/noiselvl5gla1", "31");
1435 nvram_set("pci/2/1/noiselvl5gla2", "31");
1436 nvram_set("pci/2/1/noiselvl5gma0", "31");
1437 nvram_set("pci/2/1/noiselvl5gma1", "31");
1438 nvram_set("pci/2/1/noiselvl5gma2", "31");
1439 nvram_set("pci/2/1/noiselvl5gua0", "31");
1440 nvram_set("pci/2/1/noiselvl5gua1", "31");
1441 nvram_set("pci/2/1/noiselvl5gua2", "31");
1442 nvram_set("pci/2/1/ofdmlrbw202gpo", "0");
1443 nvram_set("pci/2/1/pa2ga0", "0xfe72,0x14c0,0xfac7");
1444 nvram_set("pci/2/1/pa2ga1", "0xfe80,0x1472,0xfabc");
1445 nvram_set("pci/2/1/pa2ga2", "0xfe82,0x14bf,0xfad9");
1446 nvram_set("pci/2/1/pcieingress_war", "15");
1447 nvram_set("pci/2/1/phycal_tempdelta", "255");
1448 nvram_set("pci/2/1/rawtempsense", "0x1ff");
1449 nvram_set("pci/2/1/rxchain", "7");
1450 nvram_set("pci/2/1/rxgainerr2g", "0xffff");
1451 nvram_set("pci/2/1/rxgainerr5g", "0xffff,0xffff,0xffff,0xffff");
1452 nvram_set("pci/2/1/rxgains2gelnagaina0", "0");
1453 nvram_set("pci/2/1/rxgains2gelnagaina1", "0");
1454 nvram_set("pci/2/1/rxgains2gelnagaina2", "0");
1455 nvram_set("pci/2/1/rxgains2gtrelnabypa0", "0");
1456 nvram_set("pci/2/1/rxgains2gtrelnabypa1", "0");
1457 nvram_set("pci/2/1/rxgains2gtrelnabypa2", "0");
1458 nvram_set("pci/2/1/rxgains2gtrisoa0", "0");
1459 nvram_set("pci/2/1/rxgains2gtrisoa1", "0");
1460 nvram_set("pci/2/1/rxgains2gtrisoa2", "0");
1461 nvram_set("pci/2/1/sar2g", "18");
1462 nvram_set("pci/2/1/sar5g", "15");
1463 nvram_set("pci/2/1/sromrev", "11");
1464 nvram_set("pci/2/1/subband5gver", "0x4");
1465 nvram_set("pci/2/1/tempcorrx", "0x3f");
1466 nvram_set("pci/2/1/tempoffset", "255");
1467 nvram_set("pci/2/1/temps_hysteresis", "15");
1468 nvram_set("pci/2/1/temps_period", "15");
1469 nvram_set("pci/2/1/tempsense_option", "0x3");
1470 nvram_set("pci/2/1/tempsense_slope", "0xff");
1471 nvram_set("pci/2/1/tempthresh", "255");
1472 nvram_set("pci/2/1/txchain", "7");
1473 nvram_set("pci/2/1/ledbh0", "2");
1474 nvram_set("pci/2/1/ledbh1", "5");
1475 nvram_set("pci/2/1/ledbh2", "4");
1476 nvram_set("pci/2/1/ledbh3", "11");
1477 nvram_set("pci/2/1/ledbh10", "7");
1479 //force EU country for eth2
1480 nvram_set("pci/2/1/ccode", "EU");
1481 #endif // TCONFIG_AC66U
1484 #ifdef CONFIG_BCMWL6
1488 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
| SUP_80211AC
;
1490 nvram_set("usb_uhci", "-1");
1492 if (!nvram_match("t_fix1", (char *)name
)) {
1493 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1494 nvram_set("wan_ifnameX", "vlan2");
1495 nvram_set("wl_ifnames", "eth1 eth2");
1496 nvram_set("wl_ifname", "eth1");
1497 nvram_set("wl0_ifname", "eth2");
1498 nvram_set("wl1_ifname", "eth1");
1499 nvram_set("wl0_bw_cap","7");
1500 nvram_set("wl0_chanspec","36/80");
1501 nvram_set("wl1_bw_cap","3");
1502 nvram_set("wl1_chanspec","1l");
1503 nvram_set("blink_5g_interface","eth1");
1504 //nvram_set("landevs", "vlan1 wl0 wl1");
1505 //nvram_set("wandevs", "vlan2");
1508 strcpy(s
, nvram_safe_get("et0macaddr"));
1509 nvram_set("wl0_hwaddr", nvram_safe_get("0:macaddr"));
1510 nvram_set("wl1_hwaddr", nvram_safe_get("1:macaddr"));
1512 // fix ssid according to 5G(eth2) and 2.4G(eth1)
1513 nvram_set("wl_ssid","Tomato50");
1514 nvram_set("wl0_ssid","Tomato50");
1515 nvram_set("wl1_ssid","Tomato24");
1520 if (nvram_match("product", "WLI-H4-D1300")) {
1521 name
= "WLI-H4-D1300";
1523 else if (nvram_match("product", "WZR-D1100H")) {
1524 name
= "WZR-D1100H";
1527 name
= "WZR-D1800H";
1529 features
= SUP_SES
| SUP_AOSS_LED
| SUP_80211N
| SUP_1000ET
| SUP_80211AC
;
1531 nvram_set("usb_uhci", "-1");
1533 if (!nvram_match("t_fix1", (char *)name
)) {
1534 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1535 nvram_set("wan_ifnameX", "vlan2");
1536 nvram_set("wl_ifnames", "eth1 eth2");
1537 nvram_set("wl_ifname", "eth1");
1538 nvram_set("wl0_ifname", "eth2");
1539 nvram_set("wl1_ifname", "eth1");
1540 nvram_set("wl0_bw_cap","7");
1541 nvram_set("wl0_chanspec","36/80");
1542 nvram_set("wl1_bw_cap","3");
1543 nvram_set("wl1_chanspec","1l");
1544 nvram_set("blink_5g_interface","eth1");
1547 strcpy(s
, nvram_safe_get("et0macaddr"));
1550 for (i
= 0; i
< strlen(s
); i
++) if ( s
[i
] == '-') s
[i
] = ':';
1551 nvram_set("et0macaddr",s
);
1553 nvram_set("wl0_hwaddr", s
);
1555 nvram_set("wl1_hwaddr", s
);
1557 // fix ssid according to 5G(eth2) and 2.4G(eth1)
1558 nvram_set("wl_ssid","Tomato50");
1559 nvram_set("wl0_ssid","Tomato50");
1560 nvram_set("wl1_ssid","Tomato24");
1562 nvram_set("pci/2/1/maxp2ga0", "0x70");
1563 nvram_set("pci/2/1/maxp2ga1", "0x70");
1564 nvram_set("pci/2/1/maxp2ga2", "0x70");
1565 nvram_set("pci/2/1/maxp5ga0", "0x6A");
1566 nvram_set("pci/2/1/maxp5ga1", "0x6A");
1567 nvram_set("pci/2/1/maxp5ga2", "0x6A");
1568 nvram_set("pci/2/1/cckbw202gpo", "0x5555");
1569 nvram_set("pci/2/1/cckbw20ul2gpo", "0x5555");
1570 nvram_set("pci/2/1/legofdmbw202gpo", "0x97555555");
1571 nvram_set("pci/2/1/legofdmbw20ul2gpo", "0x97555555");
1572 nvram_set("pci/2/1/mcsbw202gpo", "0xDA755555");
1573 nvram_set("pci/2/1/mcsbw20ul2gpo", "0xDA755555");
1574 nvram_set("pci/2/1/mcsbw402gpo", "0xFC965555");
1575 nvram_set("pci/2/1/cckbw205gpo", "0x5555");
1576 nvram_set("pci/2/1/cckbw20ul5gpo", "0x5555");
1577 nvram_set("pci/2/1/legofdmbw205gpo", "0x97555555");
1578 nvram_set("pci/2/1/legofdmbw20ul5gpo", "0x97555555");
1579 nvram_set("pci/2/1/legofdmbw205gmpo", "0x77777777");
1580 nvram_set("pci/2/1/legofdmbw20ul5gmpo", "0x77777777");
1581 nvram_set("pci/2/1/legofdmbw205ghpo", "0x77777777");
1582 nvram_set("pci/2/1/legofdmbw20ul5ghpo", "0x77777777");
1583 nvram_set("pci/2/1/mcsbw205ghpo", "0x77777777");
1584 nvram_set("pci/2/1/mcsbw20ul5ghpo", "0x77777777");
1585 nvram_set("pci/2/1/mcsbw205gpo", "0xDA755555");
1586 nvram_set("pci/2/1/mcsbw20ul5gpo", "0xDA755555");
1587 nvram_set("pci/2/1/mcsbw405gpo", "0xFC965555");
1588 nvram_set("pci/2/1/mcsbw405ghpo", "0x77777777");
1589 nvram_set("pci/2/1/mcsbw405ghpo", "0x77777777");
1590 nvram_set("pci/2/1/mcs32po", "0x7777");
1591 nvram_set("pci/2/1/legofdm40duppo", "0x0000");
1592 nvram_set("pci/1/1/maxp5ga0", "104,104,104,104");
1593 nvram_set("pci/1/1/maxp5ga1", "104,104,104,104");
1594 nvram_set("pci/1/1/maxp5ga2", "104,104,104,104");
1595 nvram_set("pci/1/1/mcsbw205glpo", "0xBB975311");
1596 nvram_set("pci/1/1/mcsbw405glpo", "0xBB975311");
1597 nvram_set("pci/1/1/mcsbw805glpo", "0xBB975311");
1598 nvram_set("pci/1/1/mcsbw205gmpo", "0xBB975311");
1599 nvram_set("pci/1/1/mcsbw405gmpo", "0xBB975311");
1600 nvram_set("pci/1/1/mcsbw805gmpo", "0xBB975311");
1601 nvram_set("pci/1/1/mcsbw205ghpo", "0xBB975311");
1602 nvram_set("pci/1/1/mcsbw405ghpo", "0xBB975311");
1603 nvram_set("pci/1/1/mcsbw805ghpo", "0xBB975311");
1605 //force US country for 5G eth1, modified by bwq518
1606 nvram_set("pci/1/1/ccode", "US");
1607 nvram_set("wl1_country_code", "US");
1608 nvram_set("regulation_domain_5G", "US");
1611 case MODEL_EA6500V1
:
1614 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
| SUP_80211AC
;
1616 nvram_set("usb_uhci", "-1");
1618 if (!nvram_match("t_fix1", (char *)name
)) {
1619 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1620 nvram_set("wan_ifnameX", "vlan2");
1621 nvram_set("wl_ifnames", "eth1 eth2");
1622 nvram_set("wl_ifname", "eth1");
1623 nvram_set("wl0_ifname", "eth1");
1624 nvram_set("wl1_ifname", "eth2");
1625 nvram_set("wl0_bw_cap","7");
1626 nvram_set("wl0_chanspec","36/80");
1627 nvram_set("wl1_bw_cap","3");
1628 nvram_set("wl1_chanspec","1l");
1629 nvram_set("blink_5g_interface","eth1");
1631 // fix ssid according to 5G(eth1) and 2.4G(eth2)
1632 nvram_set("wl_ssid","Tomato50");
1633 nvram_set("wl0_ssid","Tomato50");
1634 nvram_set("wl1_ssid","Tomato24");
1636 //force US country for 5G eth1, modified by bwq518
1637 nvram_set("pci/1/1/ccode", nvram_safe_get("ccode"));
1638 nvram_set("regulation_domain_5G", nvram_safe_get("ccode"));
1641 #endif // CONFIG_BCMWL6
1642 case MODEL_WNR3500L
:
1644 name
= "WNR3500L/U/v2";
1645 features
= SUP_SES
| SUP_AOSS_LED
| SUP_80211N
| SUP_1000ET
;
1646 if (!nvram_match("t_fix1", (char *)name
)) {
1647 nvram_set("sromrev", "3");
1648 nvram_set("lan_ifnames", "vlan1 eth1");
1649 nvram_set("wan_ifnameX", "vlan2");
1650 nvram_set("wl_ifname", "eth1");
1653 case MODEL_WNR3500LV2
:
1655 name
= "WNR3500L v2";
1656 features
= SUP_SES
| SUP_AOSS_LED
| SUP_80211N
| SUP_1000ET
;
1657 if (!nvram_match("t_fix1", (char *)name
)) {
1658 nvram_set("lan_ifnames", "vlan1 eth1");
1659 nvram_set("wan_ifnameX", "vlan2");
1660 nvram_set("wl_ifname", "eth1");
1663 case MODEL_WNR2000v2
:
1665 name
= "WNR2000 v2";
1666 features
= SUP_SES
| SUP_AOSS_LED
| SUP_80211N
;
1667 if (!nvram_match("t_fix1", (char *)name
)) {
1668 nvram_set("lan_ifnames", "vlan0 eth1");
1669 nvram_set("wan_ifnameX", "vlan1");
1670 nvram_set("wl_ifname", "eth1");
1677 case MODEL_F5D8235v3
:
1679 features
= SUP_SES
| SUP_80211N
;
1682 name
= "Share Max N300 (F7D3301/F7D7301) v1";
1685 name
= "Share N300 (F7D3302/F7D7302) v1";
1688 name
= "Play Max / N600 HD (F7D4301/F7D8301) v1";
1691 name
= "Play N600 (F7D4302/F7D8302) v1";
1693 case MODEL_F5D8235v3
:
1694 name
= "N F5D8235-4 v3";
1698 nvram_set("usb_uhci", "-1");
1700 if (!nvram_match("t_fix1", (char *)name
)) {
1701 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1702 nvram_set("wan_ifnameX", "vlan2");
1703 nvram_set("landevs", "vlan1 wl0 wl1");
1704 nvram_set("wandevs", "vlan2");
1710 name
= nvram_safe_get("boot_hw_model");
1711 ver
= nvram_safe_get("boot_hw_ver");
1712 features
= SUP_SES
| SUP_80211N
;
1713 if (!nvram_match("t_fix1", (char *)name
)) {
1714 nvram_set("lan_ifnames", "vlan1 eth1");
1715 nvram_set("wan_ifnameX", "vlan2");
1716 nvram_set("wl_ifname", "eth1");
1721 name
= nvram_safe_get("boot_hw_model");
1722 ver
= nvram_safe_get("boot_hw_ver");
1723 features
= SUP_SES
| SUP_80211N
;
1725 nvram_set("usb_uhci", "-1");
1727 if (!nvram_match("t_fix1", (char *)name
)) {
1728 nvram_set("lan_ifnames", "vlan1 eth1");
1729 nvram_set("wan_ifnameX", "vlan2");
1730 nvram_set("wl_ifname", "eth1");
1735 name
= nvram_safe_get("boot_hw_model");
1736 ver
= nvram_safe_get("boot_hw_ver");
1737 features
= SUP_SES
| SUP_80211N
;
1738 #if defined(LINUX26) && defined(TCONFIG_USBAP)
1739 if (nvram_get_int("usb_storage") == 1) nvram_set("usb_storage", "-1");
1741 if (!nvram_match("t_fix1", (char *)name
)) {
1742 #ifdef TCONFIG_USBAP
1743 nvram_set("wl1_hwaddr", nvram_safe_get("0:macaddr"));
1744 nvram_set("ehciirqt", "3");
1745 nvram_set("qtdc_pid", "48407");
1746 nvram_set("qtdc_vid", "2652");
1747 nvram_set("qtdc0_ep", "4");
1748 nvram_set("qtdc0_sz", "0");
1749 nvram_set("qtdc1_ep", "18");
1750 nvram_set("qtdc1_sz", "10");
1751 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1752 nvram_set("landevs", "vlan1 wl0 wl1");
1753 nvram_set("wl0_ifname", "eth1");
1754 nvram_set("wl1_ifname", "eth2");
1756 nvram_set("lan_ifnames", "vlan1 eth1");
1757 nvram_set("landevs", "vlan1 wl0");
1759 nvram_set("wan_ifnameX", "vlan2");
1760 nvram_set("wl_ifname", "eth1");
1766 name
= nvram_safe_get("boot_hw_model");
1767 ver
= nvram_safe_get("boot_hw_ver");
1768 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
;
1770 nvram_set("usb_uhci", "-1");
1772 if (!nvram_match("t_fix1", (char *)name
)) {
1773 #ifdef TCONFIG_USBAP
1774 nvram_set("wl1_hwaddr", nvram_safe_get("usb/0xBD17/macaddr"));
1775 nvram_set("ehciirqt", "3");
1776 nvram_set("qtdc_pid", "48407");
1777 nvram_set("qtdc_vid", "2652");
1778 nvram_set("qtdc0_ep", "4");
1779 nvram_set("qtdc0_sz", "0");
1780 nvram_set("qtdc1_ep", "18");
1781 nvram_set("qtdc1_sz", "10");
1782 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1783 nvram_set("landevs", "vlan1 wl0 wl1");
1784 nvram_set("wl0_ifname", "eth1");
1785 nvram_set("wl1_ifname", "eth2");
1787 nvram_set("lan_ifnames", "vlan1 eth1");
1788 nvram_set("landevs", "vlan1 wl0");
1790 nvram_set("wl_ifname", "eth1");
1791 nvram_set("wan_ifnameX", "vlan2");
1795 case MODEL_WRT160Nv3
:
1796 // same as M10, M20, WRT310Nv2, E1000v1
1798 name
= nvram_safe_get("boot_hw_model");
1799 ver
= nvram_safe_get("boot_hw_ver");
1800 if (nvram_match("boot_hw_model", "E100")){
1803 if (nvram_match("boot_hw_model", "M10") || nvram_match("boot_hw_model", "M20")){
1806 features
= SUP_SES
| SUP_80211N
| SUP_WHAM_LED
;
1807 if (!nvram_match("t_fix1", (char *)name
)) {
1808 nvram_set("lan_ifnames", "vlan1 eth1");
1809 nvram_set("wan_ifnameX", "vlan2");
1810 nvram_set("wl_ifname", "eth1");
1815 name
= nvram_match("boardrev", "0x1307") ? "E2000" : "WRT320N";
1816 features
= SUP_SES
| SUP_80211N
| SUP_WHAM_LED
| SUP_1000ET
;
1817 if (!nvram_match("t_fix1", (char *)name
)) {
1818 nvram_set("lan_ifnames", "vlan1 eth1");
1819 nvram_set("wan_ifnameX", "vlan2");
1820 nvram_set("wl_ifname", "eth1");
1823 case MODEL_WRT610Nv2
:
1825 name
= nvram_match("boot_hw_model", "E300") ? "E3000" : "WRT610N v2";
1826 features
= SUP_SES
| SUP_80211N
| SUP_WHAM_LED
| SUP_1000ET
;
1828 nvram_set("usb_uhci", "-1");
1830 if (!nvram_match("t_fix1", (char *)name
)) {
1831 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1832 nvram_set("wan_ifnameX", "vlan2");
1833 nvram_set("wl_ifname", "eth1");
1839 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
;
1841 nvram_set("usb_uhci", "-1");
1843 if (!nvram_match("t_fix1", (char *)name
)) {
1844 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1845 nvram_set("wan_ifnameX", "vlan2");
1846 nvram_set("wl_ifname", "eth1");
1849 case MODEL_WNDR4000
:
1852 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
;
1853 // Don't auto-start blink, as shift register causes other LED's to blink slightly because of this.
1854 // Rather, turn on in startup script if desired ... so disable the line below.
1855 // nvram_set("blink_wl", "1");
1857 nvram_set("usb_uhci", "-1");
1859 if (!nvram_match("t_fix1", (char *)name
)) {
1860 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1861 nvram_set("wan_ifnameX", "vlan2");
1862 nvram_set("wl_ifname", "eth1");
1865 // Set Key Parameters for Wireless Interfaces: SB (Southbridge) and PCI, to configure HW (as Netgear intends)
1866 // Credit for the nvram_tuple approach below goes to DD-WRT (borrowed here for simplicity)!
1867 // Parameters optimized based on clean Netgear build (NVRAM extracted and checked vs. Tomato 30/30/30 Reset version of NVRAM)
1868 struct nvram_tuple wndr4000_sb_1_params
[] = {
1870 {"cck2gpo", "0x1111", 0},
1871 //{"ccode", "EU", 0},
1872 {"cddpo", "0x1111", 0},
1873 {"extpagain2g", "3", 0},
1874 {"maxp2ga0", "0x56", 0},
1875 {"maxp2ga1", "0x56", 0},
1876 {"mcs2gpo0", "0x1000", 0},
1877 {"mcs2gpo1", "0x7531", 0},
1878 {"mcs2gpo2", "0x2111", 0},
1879 {"mcs2gpo3", "0xA864", 0},
1880 {"mcs2gpo4", "0x3333", 0},
1881 {"mcs2gpo5", "0x9864", 0},
1882 {"mcs2gpo6", "0x3333", 0},
1883 {"mcs2gpo7", "0xB975", 0},
1884 {"ofdm2gpo", "0x75331111", 0},
1885 {"pa2gw0a0", "0xFEA6", 0},
1886 {"pa2gw0a1", "0xFE9E", 0},
1887 {"pa2gw1a0", "0x191D", 0},
1888 {"pa2gw1a1", "0x1809", 0},
1889 {"pa2gw2a0", "0xFA18", 0},
1890 {"pa2gw2a1", "0xFA4B", 0},
1891 {"regrev", "15", 0},
1892 {"stbcpo", "0x1111", 0},
1898 * set router's extra parameters
1900 struct nvram_tuple
*basic_params
= NULL
;
1901 struct nvram_tuple
*extra_params
= NULL
;
1902 extra_params
= wndr4000_sb_1_params
;
1903 while (extra_params
->name
) {
1904 sprintf(s
, "sb/1/%s", extra_params
->name
);
1905 nvram_set(s
, extra_params
->value
);
1909 struct nvram_tuple wndr4000_pci_1_1_params
[] = {
1911 {"boardflags2", "0x04000000", 0},
1913 {"extpagain2g", "0", 0},
1914 {"extpagain5g", "0", 0},
1915 {"legofdm40duppo", "0x2222", 0},
1916 {"legofdmbw205ghpo", "0x88642100", 0},
1917 {"legofdmbw205gmpo", "0x33221100", 0},
1918 {"legofdmbw20ul5ghpo", "0x88642100", 0},
1919 {"legofdmbw20ul5gmpo", "0x33221100", 0},
1920 {"maxp5ga0", "0x4E", 0},
1921 {"maxp5ga1", "0x4E", 0},
1922 {"maxp5ga2", "0x4E", 0},
1923 {"maxp5gha0", "0x4E", 0},
1924 {"maxp5gha1", "0x4E", 0},
1925 {"maxp5gha2", "0x4E", 0},
1926 {"maxp5gla0", "0x48", 0},
1927 {"maxp5gla1", "0x48", 0},
1928 {"maxp5gla2", "0x48", 0},
1929 {"mcs32po", "0x2222", 0},
1930 {"mcsbw205ghpo", "0x88642100", 0},
1931 {"mcsbw205glpo", "0x11000000", 0},
1932 {"mcsbw205gmpo", "0x44221100", 0},
1933 {"mcsbw20ul5ghpo", "0x88642100", 0},
1934 {"mcsbw20ul5glpo", "0x11000000", 0},
1935 {"mcsbw20ul5gmpo", "0x44221100", 0},
1936 {"mcsbw405ghpo", "0x99875310", 0},
1937 {"mcsbw405glpo", "0x33222222", 0},
1938 {"mcsbw405gmpo", "0x66443322", 0},
1939 {"pa5ghw1a1", "0x155F", 0},
1940 {"pa5ghw2a1", "0xFAB0", 0},
1941 {"regrev", "15", 0},
1946 * set router's extra parameters
1948 extra_params
= wndr4000_pci_1_1_params
;
1949 while (extra_params
->name
) {
1950 sprintf(s
, "pci/1/1/%s", extra_params
->name
);
1951 nvram_set(s
, extra_params
->value
);
1955 case MODEL_WNDR3700v3
:
1957 name
= "WNDR3700v3";
1958 features
= SUP_SES
| SUP_80211N
| SUP_1000ET
;
1959 // Don't auto-start blink, as shift register causes other LED's to blink slightly because of this.
1960 // Rather, turn on in startup script if desired ... so disable the line below.
1961 // nvram_set("blink_wl", "1");
1963 nvram_set("usb_uhci", "-1");
1965 if (!nvram_match("t_fix1", (char *)name
)) {
1966 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
1967 nvram_set("wan_ifnameX", "vlan2");
1968 nvram_set("wl_ifname", "eth1");
1971 // Set Key Parameters for Wireless Interfaces: SB (Southbridge) and PCI, to configure HW (as Netgear intends)
1972 // Credit for the nvram_tuple approach below goes to DD-WRT (borrowed here for simplicity)!
1973 // Parameters optimized based on clean Netgear build (NVRAM extracted and checked vs. Tomato 30/30/30 Reset version of NVRAM)
1974 struct nvram_tuple wndr3700v3_sb_1_params
[] = {
1976 {"cck2gpo", "0x1111", 0},
1977 //{"ccode", "EU", 0},
1978 {"cddpo", "0x1111", 0},
1979 {"extpagain2g", "3", 0},
1980 {"maxp2ga0", "0x56", 0},
1981 {"maxp2ga1", "0x56", 0},
1982 {"mcs2gpo0", "0x1000", 0},
1983 {"mcs2gpo1", "0x7531", 0},
1984 {"mcs2gpo2", "0x2111", 0},
1985 {"mcs2gpo3", "0xA864", 0},
1986 {"mcs2gpo4", "0x3333", 0},
1987 {"mcs2gpo5", "0x9864", 0},
1988 {"mcs2gpo6", "0x3333", 0},
1989 {"mcs2gpo7", "0xB975", 0},
1990 {"ofdm2gpo", "0x75331111", 0},
1991 {"pa2gw0a0", "0xFEA6", 0},
1992 {"pa2gw0a1", "0xFE9E", 0},
1993 {"pa2gw1a0", "0x191D", 0},
1994 {"pa2gw1a1", "0x1809", 0},
1995 {"pa2gw2a0", "0xFA18", 0},
1996 {"pa2gw2a1", "0xFA4B", 0},
1997 {"regrev", "15", 0},
1998 {"stbcpo", "0x1111", 0},
2004 * set router's extra parameters
2006 extra_params
= wndr3700v3_sb_1_params
;
2007 while (extra_params
->name
) {
2008 sprintf(s
, "sb/1/%s", extra_params
->name
);
2009 nvram_set(s
, extra_params
->value
);
2013 struct nvram_tuple wndr3700v3_pci_1_1_params
[] = {
2015 {"boardflags2", "0x04000000", 0},
2017 {"extpagain2g", "0", 0},
2018 {"extpagain5g", "0", 0},
2019 {"legofdm40duppo", "0x2222", 0},
2020 {"legofdmbw205ghpo", "0x88642100", 0},
2021 {"legofdmbw205gmpo", "0x33221100", 0},
2022 {"legofdmbw20ul5ghpo", "0x88642100", 0},
2023 {"legofdmbw20ul5gmpo", "0x33221100", 0},
2024 {"maxp5ga0", "0x4E", 0},
2025 {"maxp5ga1", "0x4E", 0},
2026 {"maxp5ga2", "0x4E", 0},
2027 {"maxp5gha0", "0x4E", 0},
2028 {"maxp5gha1", "0x4E", 0},
2029 {"maxp5gha2", "0x4E", 0},
2030 {"maxp5gla0", "0x48", 0},
2031 {"maxp5gla1", "0x48", 0},
2032 {"maxp5gla2", "0x48", 0},
2033 {"mcs32po", "0x2222", 0},
2034 {"mcsbw205ghpo", "0x88642100", 0},
2035 {"mcsbw205glpo", "0x11000000", 0},
2036 {"mcsbw205gmpo", "0x44221100", 0},
2037 {"mcsbw20ul5ghpo", "0x88642100", 0},
2038 {"mcsbw20ul5glpo", "0x11000000", 0},
2039 {"mcsbw20ul5gmpo", "0x44221100", 0},
2040 {"mcsbw405ghpo", "0x99875310", 0},
2041 {"mcsbw405glpo", "0x33222222", 0},
2042 {"mcsbw405gmpo", "0x66443322", 0},
2043 {"pa5ghw1a1", "0x155F", 0},
2044 {"pa5ghw2a1", "0xFAB0", 0},
2045 {"regrev", "15", 0},
2050 * set router's extra parameters
2052 extra_params
= wndr3700v3_pci_1_1_params
;
2053 while (extra_params
->name
) {
2054 sprintf(s
, "pci/1/1/%s", extra_params
->name
);
2055 nvram_set(s
, extra_params
->value
);
2059 case MODEL_WNDR3400
:
2062 features
= SUP_SES
| SUP_80211N
;
2063 // Don't auto-start blink, as shift register causes other LED's to blink slightly because of this.
2064 // Rather, turn on in startup script if desired ... so disable the line below.
2065 // nvram_set("blink_wl", "1");
2067 nvram_set("usb_uhci", "-1");
2069 if (!nvram_match("t_fix1", (char *)name
)) {
2070 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
2071 nvram_set("wan_ifnameX", "vlan2");
2072 nvram_set("wl_ifname", "eth1");
2075 // Set Key Parameters for Wireless Interfaces: SB (Southbridge) and PCI, to configure HW (as Netgear intends)
2076 // Credit for the nvram_tuple approach below goes to DD-WRT (borrowed here for simplicity)!
2077 // Parameters optimized based on clean Netgear build (NVRAM extracted and checked vs. Tomato 30/30/30 Reset version of NVRAM)
2078 struct nvram_tuple wndr3400_sb_1_params
[] = {
2083 {"antswctl2g", "2", 0},
2084 {"antswitch", "0", 0},
2086 {"bwduppo", "0", 0},
2087 {"cck2gpo", "0x0000", 0},
2090 {"extpagain2g", "2", 0},
2091 {"itt2ga0", "0x20", 0},
2092 {"itt2ga1", "0x20", 0},
2094 {"ledbh1", "11", 0},
2095 {"ledbh2", "11", 0},
2096 {"ledbh3", "11", 0},
2097 {"leddc", "0xffff", 0},
2098 {"maxp2ga0", "0x56", 0},
2099 {"maxp2ga1", "0x56", 0},
2100 {"mcs2gpo0", "0x2222", 0},
2101 {"mcs2gpo1", "0xa642", 0},
2102 {"mcs2gpo2", "0x6666", 0},
2103 {"mcs2gpo3", "0xa866", 0},
2104 {"mcs2gpo4", "0x8888", 0},
2105 {"mcs2gpo5", "0xa888", 0},
2106 {"mcs2gpo6", "0x8888", 0},
2107 {"mcs2gpo7", "0xcc88", 0},
2108 {"ofdm2gpo", "0x54400000", 0},
2109 {"pa2gw0a0", "0xfeca", 0},
2110 {"pa2gw0a1", "0xfebd", 0},
2111 {"pa2gw1a0", "0x17dd", 0},
2112 {"pa2gw1a1", "0x16ba", 0},
2113 {"pa2gw2a0", "0xfa8e", 0},
2114 {"pa2gw2a1", "0xfab1", 0},
2115 {"pdetrange2g", "2", 0},
2116 {"regrev", "39", 0},
2117 {"rxchain", "3", 0},
2118 {"sromrev", "8", 0},
2120 {"triso2g", "3", 0},
2121 {"tssipos2g", "1", 0},
2122 {"txchain", "3", 0},
2124 /* {"sromrev", "8", 0},
2125 {"ccode", "ALL", 0},
2127 {"ledbh0", "11", 0},
2128 {"ledbh1", "11", 0},
2129 {"ledbh2", "11", 0},
2130 {"ledbh3", "11", 0},
2132 {"leddc", "0xffff", 0},
2133 {"txchain", "3", 0},
2134 {"rxchain", "3", 0},
2135 {"antswitch", "0", 0},
2139 {"itt2ga0", "0x20", 0},
2140 {"maxp2ga0", "0x48", 0},
2141 {"pa2gw0a0", "0xFEA5", 0},
2142 {"pa2gw1a0", "0x17B2", 0},
2143 {"pa2gw2a0", "0xFA73", 0},
2144 {"itt2ga1", "0x20", 0},
2145 {"maxp2ga1", "0x48", 0},
2146 {"pa2gw0a1", "0xfeba", 0},
2147 {"pa2gw1a1", "0x173c", 0},
2148 {"pa2gw2a1", "0xfa9b", 0},
2149 {"tssipos2g", "1", 0},
2150 {"extpagain2g", "2", 0},
2151 {"pdetrange2g", "2", 0},
2152 {"triso2g", "3", 0},
2153 {"antswctl2g", "2", 0},
2154 {"cck2gpo", "0x0000", 0},
2155 {"ofdm2gpo", "0x66666666", 0},
2156 {"mcs2gpo0", "0x6666", 0},
2157 {"mcs2gpo1", "0x6666", 0},
2158 {"mcs2gpo2", "0x6666", 0},
2159 {"mcs2gpo3", "0x6666", 0},
2160 {"mcs2gpo4", "0x6666", 0},
2161 {"mcs2gpo5", "0x6666", 0},
2162 {"mcs2gpo6", "0x6666", 0},
2163 {"mcs2gpo7", "0x6666", 0},
2167 {"bwduppo", "0", 0},
2172 * set router's extra parameters
2174 extra_params
= wndr3400_sb_1_params
;
2175 while (extra_params
->name
) {
2176 sprintf(s
, "sb/1/%s", extra_params
->name
);
2177 nvram_set(s
, extra_params
->value
);
2181 struct nvram_tuple wndr3400_pci_1_1_params
[] = {
2186 {"antswctl2g", "0", 0},
2187 {"antswctl5g", "0", 0},
2188 {"antswitch", "0", 0},
2189 {"bw405ghpo/bw405glpo/bw405gpo/bw402gpo", "0x2", 0},
2191 {"bwduppo", "0", 0},
2193 {"cdd5ghpo/cdd5glpo/cdd5gpo/cdd2gpo", "0x0", 0},
2195 {"extpagain5g", "2", 0},
2196 {"itt5ga0", "0x3e", 0},
2197 {"itt5ga1", "0x3e", 0},
2199 {"ledbh1", "0xffff", 0},
2200 {"ledbh2", "0xffff", 0},
2201 {"ledbh3", "0xffff", 0},
2202 {"leddc", "0xffff", 0},
2203 {"maxp5ga0", "0x4E", 0},
2204 {"maxp5ga1", "0x4E", 0},
2205 {"maxp5gha0", "0x4A", 0},
2206 {"maxp5gha1", "0x4A", 0},
2207 {"maxp5gla0", "0x3E", 0},
2208 {"maxp5gla1", "0x3E", 0},
2209 {"mcs5ghpo0", "0x4200", 0},
2210 {"mcs5ghpo1", "0x6664", 0},
2211 {"mcs5ghpo2", "0x4200", 0},
2212 {"mcs5ghpo3", "0x6664", 0},
2213 {"mcs5ghpo4", "0x4200", 0},
2214 {"mcs5ghpo5", "0x6664", 0},
2215 {"mcs5ghpo6", "0x4200", 0},
2216 {"mcs5ghpo7", "0x6664", 0},
2217 {"mcs5glpo0", "0x0000", 0},
2218 {"mcs5glpo1", "0x2200", 0},
2219 {"mcs5glpo2", "0x0000", 0},
2220 {"mcs5glpo3", "0x2200", 0},
2221 {"mcs5glpo4", "0x0000", 0},
2222 {"mcs5glpo5", "0x2200", 0},
2223 {"mcs5glpo6", "0x0000", 0},
2224 {"mcs5glpo7", "0x2200", 0},
2225 {"mcs5gpo0", "0x4200", 0},
2226 {"mcs5gpo1", "0x6664", 0},
2227 {"mcs5gpo2", "0x4200", 0},
2228 {"mcs5gpo3", "0x6664", 0},
2229 {"mcs5gpo4", "0x4200", 0},
2230 {"mcs5gpo5", "0x6664", 0},
2231 {"mcs5gpo6", "0x4200", 0},
2232 {"mcs5gpo7", "0x6664", 0},
2233 {"ofdm5ghpo0", "0x0000", 0},
2234 {"ofdm5ghpo1", "0x2000", 0},
2235 {"ofdm5glpo0", "0x0000", 0},
2236 {"ofdm5glpo1", "0x0000", 0},
2237 {"ofdm5gpo0", "0x0000", 0},
2238 {"ofdm5gpo1", "0x2000", 0},
2239 {"pa5ghw0a0", "0xfe98", 0},
2240 {"pa5ghw0a1", "0xfead", 0},
2241 {"pa5ghw1a0", "0x15c0", 0},
2242 {"pa5ghw1a1", "0x1539", 0},
2243 {"pa5ghw2a0", "0xfa9c", 0},
2244 {"pa5ghw2a1", "0xfab9", 0},
2245 {"pa5glw0a0", "0xfe87", 0},
2246 {"pa5glw0a1", "0xfe9a", 0},
2247 {"pa5glw1a0", "0x1637", 0},
2248 {"pa5glw1a1", "0x1591", 0},
2249 {"pa5glw2a0", "0xfa8e", 0},
2250 {"pa5glw2a1", "0xfabc", 0},
2251 {"pa5gw0a0", "0xfe9b", 0},
2252 {"pa5gw0a1", "0xfe9b", 0},
2253 {"pa5gw1a0", "0x153f", 0},
2254 {"pa5gw1a1", "0x1576", 0},
2255 {"pa5gw2a0", "0xfaae", 0},
2256 {"pa5gw2a1", "0xfaa5", 0},
2257 {"pdetrange5g", "4", 0},
2258 {"regrev", "39", 0},
2259 {"rxchain", "3", 0},
2260 {"sromrev", "8", 0},
2261 {"stbc5ghpo/stbc5glpo/stbc5gpo/stbc2gpo", "0x0", 0},
2263 {"triso5g", "3", 0},
2264 {"tssipos5g", "1", 0},
2265 {"txchain", "3", 0},
2266 {"wdup405ghpo/wdup405glpo/wdup405gpo/wdup402gpo", "0x0", 0},
2268 /* {"sromrev", "8", 0},
2269 {"ccode", "ALL", 0},
2272 {"ledbh1", "0x11", 0},
2273 {"ledbh2", "0x11", 0},
2274 {"ledbh3", "0x11", 0},
2275 {"leddc", "0xffff", 0},
2276 {"txchain", "3", 0},
2277 {"rxchain", "3", 0},
2278 {"antswitch", "0", 0},
2282 {"bwduppo", "0", 0},
2286 {"itt5ga0", "0x3e", 0},
2287 {"maxp5ga0", "0x4A", 0},
2288 {"maxp5gha0", "0x4A", 0},
2289 {"maxp5gla0", "0x4A", 0},
2290 {"pa5gw0a0", "0xFEF9", 0},
2291 {"pa5gw1a0", "0x164B", 0},
2292 {"pa5gw2a0", "0xFADD", 0},
2293 {"pa5glw0a0", "0xFEF9", 0},
2294 {"pa5glw1a0", "0x154B", 0},
2295 {"pa5glw2a0", "0xFAFD", 0},
2296 {"pa5ghw0a0", "0xfeda", 0},
2297 {"pa5ghw1a0", "0x1612", 0},
2298 {"pa5ghw2a0", "0xfabe", 0},
2299 {"tssipos5g", "1", 0},
2300 {"extpagain5g", "2", 0},
2301 {"pdetrange5g", "4", 0},
2302 {"triso5g", "3", 0},
2303 {"antswctl2g", "0", 0},
2304 {"antswctl5g", "0", 0},
2305 {"itt5ga1", "0x3e", 0},
2306 {"maxp5ga1", "0x4A", 0},
2307 {"maxp5gha1", "0x4A", 0},
2308 {"maxp5gla1", "0x4A", 0},
2309 {"pa5gw0a1", "0xff31", 0},
2310 {"pa5gw1a1", "0x1697", 0},
2311 {"pa5gw2a1", "0xfb08", 0},
2312 {"pa5glw0a1", "0xFF31", 0},
2313 {"pa5glw1a1", "0x1517", 0},
2314 {"pa5glw2a1", "0xFB2F", 0},
2315 {"pa5ghw0a1", "0xff18", 0},
2316 {"pa5ghw1a1", "0x1661", 0},
2317 {"pa5ghw2a1", "0xfafe", 0},
2318 {"ofdm5gpo0", "0x0000", 0},
2319 {"ofdm5gpo1", "0x2000", 0},
2320 {"ofdm5glpo0", "0x0000", 0},
2321 {"ofdm5glpo1", "0x2000", 0},
2322 {"ofdm5ghpo0", "0x0000", 0},
2323 {"ofdm5ghpo1", "0x2000", 0},
2324 {"mcs5gpo0", "0x4200", 0},
2325 {"mcs5gpo1", "0x6664", 0},
2326 {"mcs5gpo2", "0x4200", 0},
2327 {"mcs5gpo3", "0x6664", 0},
2328 {"mcs5gpo4", "0x4200", 0},
2329 {"mcs5gpo5", "0x6664", 0},
2330 {"mcs5gpo6", "0x4200", 0},
2331 {"mcs5gpo7", "0x6664", 0},
2332 {"mcs5glpo0", "0x4200", 0},
2333 {"mcs5glpo1", "0x6664", 0},
2334 {"mcs5glpo2", "0x4200", 0},
2335 {"mcs5glpo3", "0x6664", 0},
2336 {"mcs5glpo4", "0x4200", 0},
2337 {"mcs5glpo5", "0x6664", 0},
2338 {"mcs5glpo6", "0x4200", 0},
2339 {"mcs5glpo7", "0x6664", 0},
2340 {"mcs5ghpo0", "0x4200", 0},
2341 {"mcs5ghpo1", "0x6664", 0},
2342 {"mcs5ghpo2", "0x4200", 0},
2343 {"mcs5ghpo3", "0x6664", 0},
2344 {"mcs5ghpo4", "0x4200", 0},
2345 {"mcs5ghpo5", "0x6664", 0},
2346 {"mcs5ghpo6", "0x4200", 0},
2347 {"mcs5ghpo7", "0x6664", 0},
2348 {"cdd5ghpo/cdd5glpo/cdd5gpo/cdd2gpo", "0x0", 0},
2349 {"stbc5ghpo/stbc5glpo/stbc5gpo/stbc2gpo", "0x0", 0},
2350 {"bw405ghpo/bw405glpo/bw405gpo/bw402gpo", "0x2", 0},
2351 {"wdup405ghpo/wdup405glpo/wdup405gpo/wdup402gpo", "0x0",
2357 * set router's extra parameters
2359 extra_params
= wndr3400_pci_1_1_params
;
2360 while (extra_params
->name
) {
2361 sprintf(s
, "pci/1/1/%s", extra_params
->name
);
2362 nvram_set(s
, extra_params
->value
);
2368 case MODEL_WNDR3400v2
:
2370 name
= "WNDR3400v2";
2371 features
= SUP_SES
| SUP_80211N
;
2372 // Don't auto-start blink, as shift register causes other LED's to blink slightly because of this.
2373 // Rather, turn on in startup script if desired ... so disable the line below.
2374 // nvram_set("blink_wl", "1");
2376 nvram_set("usb_uhci", "-1");
2378 if (!nvram_match("t_fix1", (char *)name
)) {
2379 nvram_set("lan_ifnames", "vlan1 eth1 eth2");
2380 nvram_set("wan_ifnameX", "vlan2");
2381 nvram_set("wl_ifname", "eth1");
2385 #endif // CONFIG_BCMWL5
2390 // The 330gE has only one wired port which can act either as WAN or LAN.
2391 // Failsafe mode is to have it start as a LAN port so you can get an IP
2392 // address via DHCP and access the router config page.
2393 if (!nvram_match("t_fix1", (char *)name
)) {
2394 nvram_set("wl_ifname", "eth1");
2395 nvram_set("lan_ifnames", "eth1");
2396 nvram_set("wan_ifnameX", "eth0");
2397 nvram_set("wan_islan", "1");
2398 nvram_set("wan_proto", "disabled");
2401 case MODEL_WL500GPv2
:
2403 name
= "WL-500gP v2";
2406 nvram_set("usb_uhci", "-1");
2414 nvram_set("usb_uhci", "-1");
2419 name
= "WL-500g Deluxe";
2420 // features = SUP_SES;
2422 nvram_set("usb_ohci", "-1");
2424 if (!nvram_match("t_fix1", (char *)name
)) {
2425 nvram_set("wl_ifname", "eth1");
2426 nvram_set("lan_ifnames", "vlan0 eth1");
2427 nvram_set("wan_ifnameX", "vlan1");
2428 nvram_unset("wl0gpio0");
2435 if (!nvram_match("t_fix1", (char *)name
)) {
2436 nvram_set("wan_ifnameX", "vlan1");
2437 nvram_set("wl_ifname", "eth1");
2442 name
= "ZXV10 H618B";
2443 features
= SUP_SES
| SUP_AOSS_LED
;
2445 nvram_set("usb_uhci", "-1");
2447 if (!nvram_match("t_fix1", (char *)name
)) {
2448 nvram_set("lan_ifnames", "vlan0 eth1");
2449 nvram_set("wan_ifname", "vlan1");
2450 nvram_set("wan_ifnames", "vlan1");
2451 nvram_set("wan_ifnameX", "vlan1");
2452 nvram_set("wl_ifname", "eth1");
2455 case MODEL_WL1600GL
:
2460 #endif // WL_BSS_INFO_VERSION >= 108
2461 case MODEL_WZRG300N
:
2464 features
= SUP_SES
| SUP_AOSS_LED
| SUP_BRAU
| SUP_80211N
;
2466 case MODEL_WRT160Nv1
:
2469 name
= (model
== MODEL_WRT300N
) ? "WRT300N v1" : "WRT160N v1";
2470 features
= SUP_SES
| SUP_80211N
;
2471 if (!nvram_match("t_fix1", (char *)name
)) {
2472 nvram_set("wan_ifnameX", "eth1");
2473 nvram_set("lan_ifnames", "eth0 eth2");
2476 case MODEL_WRT310Nv1
:
2478 name
= "WRT310N v1";
2479 features
= SUP_SES
| SUP_80211N
| SUP_WHAM_LED
| SUP_1000ET
;
2480 if (!nvram_match("t_fix1", (char *)name
)) {
2481 nvram_set("lan_ifnames", "vlan1 eth1");
2482 nvram_set("wan_ifnameX", "vlan2");
2483 nvram_set("wl_ifname", "eth1");
2489 nvram_set("t_fix1", name
);
2490 if (ver
&& strcmp(ver
, "")) {
2491 sprintf(s
, "%s %s v%s", mfr
, name
, ver
);
2493 sprintf(s
, "%s %s", mfr
, name
);
2497 snprintf(s
, sizeof(s
), "%s %d/%s/%s/%s/%s", mfr
, check_hw_type(),
2498 nvram_safe_get("boardtype"), nvram_safe_get("boardnum"), nvram_safe_get("boardrev"), nvram_safe_get("boardflags"));
2501 nvram_set("t_model_name", s
);
2503 nvram_set("pa0maxpwr", "400"); // allow Tx power up tp 400 mW, needed for ND only
2505 sprintf(s
, "0x%lX", features
);
2506 nvram_set("t_features", s
);
2509 note: set wan_ifnameX if wan_ifname needs to be overriden
2512 if (nvram_is_empty("wan_ifnameX")) {
2514 nvram_set("wan_ifnameX", ((strtoul(nvram_safe_get("boardflags"), NULL
, 0) & BFL_ENETVLAN
) ||
2515 (check_hw_type() == HW_BCM4712
)) ? "vlan1" : "eth1");
2517 p
= nvram_safe_get("wan_ifname");
2518 if ((*p
== 0) || (nvram_match("wl_ifname", p
))) {
2519 p
= ((strtoul(nvram_safe_get("boardflags"), NULL
, 0) & BFL_ENETVLAN
) ||
2520 (check_hw_type() == HW_BCM4712
)) ? "vlan1" : "eth1";
2522 nvram_set("wan_ifnameX", p
);
2526 //!!TB - do not force country code here to allow nvram override
2527 //nvram_set("wl_country", "JP");
2528 //nvram_set("wl_country_code", "JP");
2529 nvram_set("wan_get_dns", "");
2530 nvram_set("wan_get_domain", "");
2531 nvram_set("ppp_get_ip", "");
2532 nvram_set("action_service", "");
2533 nvram_set("jffs2_format", "0");
2534 nvram_set("rrules_radio", "-1");
2535 nvram_unset("https_crt_gen");
2536 nvram_unset("log_wmclear");
2538 nvram_set("ipv6_get_dns", "");
2540 #ifdef TCONFIG_MEDIA_SERVER
2541 nvram_unset("ms_rescan");
2543 if (nvram_get_int("http_id_gen") == 1) nvram_unset("http_id");
2545 nvram_unset("sch_rboot_last");
2546 nvram_unset("sch_rcon_last");
2547 nvram_unset("sch_c1_last");
2548 nvram_unset("sch_c2_last");
2549 nvram_unset("sch_c3_last");
2551 nvram_set("brau_state", "");
2552 if ((features
& SUP_BRAU
) == 0) nvram_set("script_brau", "");
2553 if ((features
& SUP_SES
) == 0) nvram_set("sesx_script", "");
2555 if ((features
& SUP_1000ET
) == 0) nvram_set("jumbo_frame_enable", "0");
2557 // compatibility with old versions
2558 if (nvram_match("wl_net_mode", "disabled")) {
2559 nvram_set("wl_radio", "0");
2560 nvram_set("wl_net_mode", "mixed");
2566 /* Get the special files from nvram and copy them to disc.
2567 * These were files saved with "nvram setfile2nvram <filename>".
2568 * Better hope that they were saved with full pathname.
2570 static void load_files_from_nvram(void)
2574 char buf
[NVRAM_SPACE
];
2576 if (nvram_getall(buf
, sizeof(buf
)) != 0)
2579 for (name
= buf
; *name
; name
+= strlen(name
) + 1) {
2580 if (strncmp(name
, "FILE:", 5) == 0) { /* This special name marks a file to get. */
2581 if ((cp
= strchr(name
, '=')) == NULL
)
2584 syslog(LOG_INFO
, "Loading file '%s' from nvram", name
+ 5);
2585 nvram_nvram2file(name
, name
+ 5);
2586 if (memcmp(".autorun", cp
- 8, 9) == 0)
2590 /* Start any autorun files that may have been loaded into one of the standard places. */
2592 run_nvscript(".autorun", NULL
, 3);
2595 #if defined(LINUX26) && defined(TCONFIG_USB)
2596 static inline void tune_min_free_kbytes(void)
2598 struct sysinfo info
;
2600 memset(&info
, 0, sizeof(struct sysinfo
));
2602 if (info
.totalram
>= 55 * 1024 * 1024) {
2603 // If we have 64MB+ RAM, tune min_free_kbytes
2604 // to reduce page allocation failure errors.
2605 f_write_string("/proc/sys/vm/min_free_kbytes", "8192", 0, 0);
2610 static void sysinit(void)
2612 static int noconsole
= 0;
2613 static const time_t tm
= 0;
2621 mount("proc", "/proc", "proc", 0, NULL
);
2622 mount("tmpfs", "/tmp", "tmpfs", 0, NULL
);
2625 mount("devfs", "/dev", "tmpfs", MS_MGC_VAL
| MS_NOATIME
, NULL
);
2626 mknod("/dev/null", S_IFCHR
| 0666, makedev(1, 3));
2627 mknod("/dev/console", S_IFCHR
| 0600, makedev(5, 1));
2628 mount("sysfs", "/sys", "sysfs", MS_MGC_VAL
, NULL
);
2629 mkdir("/dev/shm", 0777);
2630 mkdir("/dev/pts", 0777);
2631 mknod("/dev/pts/ptmx", S_IRWXU
|S_IFCHR
, makedev(5, 2));
2632 mknod("/dev/pts/0", S_IRWXU
|S_IFCHR
, makedev(136, 0));
2633 mknod("/dev/pts/1", S_IRWXU
|S_IFCHR
, makedev(136, 1));
2634 mount("devpts", "/dev/pts", "devpts", MS_MGC_VAL
, NULL
);
2637 if (console_init()) noconsole
= 1;
2641 static const char *mkd
[] = {
2642 "/tmp/etc", "/tmp/var", "/tmp/home", "/tmp/mnt",
2643 "/tmp/splashd", //!!Victek
2644 "/tmp/share", "/var/webmon", // !!TB
2645 "/var/log", "/var/run", "/var/tmp", "/var/lib", "/var/lib/misc",
2646 "/var/spool", "/var/spool/cron", "/var/spool/cron/crontabs",
2647 "/tmp/var/wwwext", "/tmp/var/wwwext/cgi-bin", // !!TB - CGI support
2651 for (i
= 0; mkd
[i
]; ++i
) {
2652 mkdir(mkd
[i
], 0755);
2654 mkdir("/var/lock", 0777);
2655 mkdir("/var/tmp/dhcp", 0777);
2656 mkdir("/home/root", 0700);
2657 chmod("/tmp", 0777);
2658 f_write("/etc/hosts", NULL
, 0, 0, 0644); // blank
2659 f_write("/etc/fstab", NULL
, 0, 0, 0644); // !!TB - blank
2660 simple_unlock("cron");
2661 simple_unlock("firewall");
2662 simple_unlock("restrictions");
2665 if ((d
= opendir("/rom/etc")) != NULL
) {
2666 while ((de
= readdir(d
)) != NULL
) {
2667 if (de
->d_name
[0] == '.') continue;
2668 snprintf(s
, sizeof(s
), "%s/%s", "/rom/etc", de
->d_name
);
2669 snprintf(t
, sizeof(t
), "%s/%s", "/etc", de
->d_name
);
2674 symlink("/proc/mounts", "/etc/mtab");
2676 #ifdef TCONFIG_SAMBASRV
2677 if ((d
= opendir("/usr/codepages")) != NULL
) {
2678 while ((de
= readdir(d
)) != NULL
) {
2679 if (de
->d_name
[0] == '.') continue;
2680 snprintf(s
, sizeof(s
), "/usr/codepages/%s", de
->d_name
);
2681 snprintf(t
, sizeof(t
), "/usr/share/%s", de
->d_name
);
2689 eval("hotplug2", "--coldplug");
2692 static const char *dn
[] = {
2693 "null", "zero", "random", "urandom", "full", "ptmx", "nvram",
2696 for (i
= 0; dn
[i
]; ++i
) {
2697 snprintf(s
, sizeof(s
), "/dev/%s", dn
[i
]);
2700 chmod("/dev/gpio", 0660);
2703 set_action(ACT_IDLE
);
2705 for (i
= 0; defenv
[i
]; ++i
) {
2710 printf("\n\nHit ENTER for console...\n\n");
2717 // disable IPv6 by default on all interfaces
2718 f_write_string("/proc/sys/net/ipv6/conf/default/disable_ipv6", "1", 0, 0);
2721 for (i
= 0; i
< sizeof(fatalsigs
) / sizeof(fatalsigs
[0]); i
++) {
2722 signal(fatalsigs
[i
], handle_fatalsigs
);
2724 signal(SIGCHLD
, handle_reap
);
2726 #ifdef CONFIG_BCMWL5
2727 // ctf must be loaded prior to any other modules
2728 if (nvram_invmatch("ctf_disable", "1"))
2737 switch (hardware
= check_hw_type()) {
2739 modprobe("bcm57xx");
2750 eval("nvram", "defaults", "--initcheck");
2753 // set the packet size
2754 if (nvram_get_int("jumbo_frame_enable")) {
2755 // only set the size here - 'enable' flag is set by the driver
2756 // eval("et", "robowr", "0x40", "0x01", "0x1F"); // (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)
2757 eval("et", "robowr", "0x40", "0x05", nvram_safe_get("jumbo_frame_size"));
2760 klogctl(8, NULL
, nvram_get_int("console_loglevel"));
2762 #if defined(LINUX26) && defined(TCONFIG_USB)
2763 tune_min_free_kbytes();
2766 set_host_domain_name();
2772 //#ifdef CONFIG_BCMWL6
2776 if (!noconsole
) xstart("console");
2778 i
= nvram_get_int("sesx_led");
2779 led(LED_AMBER
, (i
& 1) != 0);
2780 led(LED_WHITE
, (i
& 2) != 0);
2781 led(LED_AOSS
, (i
& 4) != 0);
2782 led(LED_BRIDGE
, (i
& 8) != 0);
2786 int init_main(int argc
, char *argv
[])
2792 nvram_unset("debug_rc_svc");
2796 sigemptyset(&sigset
);
2797 for (i
= 0; i
< sizeof(initsigs
) / sizeof(initsigs
[0]); i
++) {
2798 sigaddset(&sigset
, initsigs
[i
]);
2800 sigprocmask(SIG_BLOCK
, &sigset
, NULL
);
2802 #if defined(DEBUG_NOISY)
2803 nvram_set("debug_logeval", "1");
2804 nvram_set("debug_cprintf", "1");
2805 nvram_set("debug_cprintf_file", "1");
2806 nvram_set("debug_ddns", "1");
2811 state
= SIGUSR2
; /* START */
2814 TRACE_PT("main loop signal/state=%d\n", state
);
2817 case SIGUSR1
: /* USER1: service handler */
2821 case SIGHUP
: /* RESTART */
2822 case SIGINT
: /* STOP */
2823 case SIGQUIT
: /* HALT */
2824 case SIGTERM
: /* REBOOT */
2826 unlink("/var/notice/sysup");
2828 if( nvram_match( "webmon_bkp", "1" ) )
2829 xstart( "/usr/sbin/webmon_bkp", "hourly" ); // make a copy before halt/reboot router
2831 run_nvscript("script_shut", NULL
, 10);
2839 if ((state
== SIGTERM
/* REBOOT */) ||
2840 (state
== SIGQUIT
/* HALT */)) {
2841 remove_storage_main(1);
2844 shutdn(state
== SIGTERM
/* REBOOT */);
2847 if (state
== SIGINT
/* STOP */) {
2851 // SIGHUP (RESTART) falls through
2853 case SIGUSR2
: /* START */
2854 SET_LED(RELEASE_WAN_CONTROL
);
2857 load_files_from_nvram();
2860 fd
= file_lock("usb"); // hold off automount processing
2863 xstart("/usr/sbin/mymotd", "init");
2864 run_nvscript("script_init", NULL
, 2);
2866 file_unlock(fd
); // allow to process usb hotplug events
2869 * On RESTART some partitions can stay mounted if they are busy at the moment.
2870 * In that case USB drivers won't unload, and hotplug won't kick off again to
2871 * remount those drives that actually got unmounted. Make sure to remount ALL
2872 * partitions here by simulating hotplug event.
2874 if (state
== SIGHUP
/* RESTART */)
2875 add_remove_usbhost("-1", 1);
2886 #ifdef CONFIG_BCMWL5
2888 /* Restart NAS one more time - for some reason without
2889 * this the new driver doesn't always bring WDS up.
2896 syslog(LOG_INFO
, "%s: Tomato %s", nvram_safe_get("t_model_name"), tomato_version
);
2898 // System is up, set LEDs. Set “WHITE” LED to GREEN (power LED). Note that AMBER / DIAG = amber for power LED (across all HW?).
2899 led(LED_DIAG
, LED_OFF
);
2900 led(LED_WHITE
, LED_ON
);
2901 led(LED_AOSS
, LED_ON
);
2902 notice_set("sysup", "");
2906 chld_reap(0); /* Periodically reap zombies. */
2908 sigwait(&sigset
, &state
);
2914 int reboothalt_main(int argc
, char *argv
[])
2916 int reboot
= (strstr(argv
[0], "reboot") != NULL
);
2917 puts(reboot
? "Rebooting..." : "Shutting down...");
2920 kill(1, reboot
? SIGTERM
: SIGQUIT
);
2922 /* In the case we're hung, we'll get stuck and never actually reboot.
2923 * The only way out is to pull power.
2924 * So after 'reset_wait' seconds (default: 20), forcibly crash & restart.
2927 int wait
= nvram_get_int("reset_wait") ? : 20;
2928 if ((wait
< 10) || (wait
> 120)) wait
= 10;
2930 f_write("/proc/sysrq-trigger", "s", 1, 0 , 0); /* sync disks */
2932 puts("Still running... Doing machine reset.");
2934 f_write("/proc/sysrq-trigger", "s", 1, 0 , 0); /* sync disks */
2936 f_write("/proc/sysrq-trigger", "b", 1, 0 , 0); /* machine reset */