Beispiel #1
0
void start_sysinit(void)
{
	char buf[PATH_MAX];
	struct stat tmp_stat;
	time_t tm = 0;

	if (!nvram_match("disable_watchdog", "1")) {
		insmod("imx2_wdt");
		eval("watchdog");
	}
	/*
	 * Setup console 
	 */
	eval("mount", "-o", "remount,rw", "/");
	eval("mkdir", "-p", "/usr/local/nvram");

	cprintf("sysinit() klogctl\n");
	klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel")));
	cprintf("sysinit() get router\n");

	int brand = getRouterBrand();

	//for extension board
	struct ifreq ifr;
	int s;

	fprintf(stderr, "try modules for ethernet adapters\n");
	nvram_set("intel_eth", "0");
	insmod("sky2");
	if (detect_ethernet_devices())
		nvram_set("intel_eth", "1");

	/*
	 * network drivers 
	 */
	detect_wireless_devices();

	if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
		char eabuf[32];

		strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
		ioctl(s, SIOCGIFHWADDR, &ifr);
		nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf));
		nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf));
		close(s);
	}
	eval("ifconfig", "eth0", "promisc");
	eval("ifconfig", "eth1", "promisc");
	/*
	 * Set a sane date 
	 */
	stime(&tm);
	nvram_set("wl0_ifname", "ath0");
	eval("hwclock", "-s");
	eval("i2cset", "-f", "-y", "0", "0x20", "0", "0x0");
	eval("i2cset", "-f", "-y", "0", "0x20", "11", "0x10");
	char *board = nvram_safe_get("DD_BOARD");
	char *board2 = nvram_safe_get("DD_BOARD2");
	if (!strncmp(board, "Gateworks Ventana GW54",22)
	    || !strncmp(board2, "Gateworks Ventana GW54",22))
		sysprintf("gsp_updater -f /etc/gsc_5400_v43.txt 43");

	if (!strncmp(board, "Gateworks Ventana GW53",22)
	    || !strncmp(board2, "Gateworks Ventana GW53",22))
		sysprintf("gsp_updater -f /etc/gsc_5300_v43.txt 43");

	if (!strncmp(board, "Gateworks Ventana GW52",22)
	    || !strncmp(board2, "Gateworks Ventana GW52",22))
		sysprintf("gsp_updater -f /etc/gsc_5200_v43.txt 43");

	if (!strncmp(board, "Gateworks Ventana GW51",22)
	    || !strncmp(board2, "Gateworks Ventana GW51",22))
		sysprintf("gsp_updater -f /etc/gsc_5100_v43.txt 43");

	led_control(LED_POWER, LED_ON);
	led_control(LED_DIAG, LED_OFF);
	led_control(LED_SES, LED_OFF);
	led_control(LED_SES2, LED_OFF);
	led_control(LED_BRIDGE, LED_OFF);
	led_control(LED_WLAN0, LED_OFF);
	led_control(LED_WLAN1, LED_OFF);
	led_control(LED_CONNECTED, LED_OFF);
	sysprintf("echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor");

	return;
}
Beispiel #2
0
void start_sysinit(void)
{
	char buf[PATH_MAX];
	struct stat tmp_stat;
	time_t tm = 0;

	if (!nvram_match("disable_watchdog", "1")) {
		insmod("cns3xxx_wdt");
		eval("watchdog");
	}
	/*
	 * Setup console 
	 */

	cprintf("sysinit() klogctl\n");
	klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel")));
	cprintf("sysinit() get router\n");

	int brand = getRouterBrand();

	//for extension board
	struct ifreq ifr;
	int s;

	fprintf(stderr, "try modules for ethernet adapters\n");
	nvram_set("intel_eth", "0");
	insmod("cns3xxx_eth");
	if (detect_ethernet_devices())
		nvram_set("intel_eth", "1");

	//load mmc drivers
	insmod("mmc_core");
	eval("insmod", "sdhci", "debug_quirks=1");	// workaround for mmc detection issue. 
//      insmod("sdhci");
	insmod("sdhci-pltfm");
	insmod("sdhci-cns3xxx");
	insmod("mmc_block");
	//sata drivers
	insmod("scsi_mod");
	insmod("scsi_wait_scan");
	insmod("scsi_sd_mod");
	insmod("libata");
	insmod("libahci");
	insmod("ahci");
	insmod("cns3xxx_ahci");
	/*
	 * network drivers 
	 */
	detect_wireless_devices();

	if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
		char eabuf[32];

		strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
		ioctl(s, SIOCGIFHWADDR, &ifr);
		nvram_set("et0macaddr",
			  ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data,
				     eabuf));
		nvram_set("et0macaddr_safe",
			  ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data,
				     eabuf));
		close(s);
	}

	/*
	 * Set a sane date 
	 */
	stime(&tm);
	nvram_set("wl0_ifname", "ath0");
	eval("hwclock", "-s");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2391") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2391") )
		sysprintf("gsp_updater -f /etc/gsc_2391_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2389") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2389") )
		sysprintf("gsp_updater -f /etc/gsc_2388_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2388") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2388") )
		sysprintf("gsp_updater -f /etc/gsc_2388_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2387") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2387") )
		sysprintf("gsp_updater -f /etc/gsc_2387_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2386") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2386") )
		sysprintf("gsp_updater -f /etc/gsc_2386_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2384") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2384") )
		sysprintf("gsp_updater -f /etc/gsc_2384_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2383") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2383") )
		sysprintf("gsp_updater -f /etc/gsc_2383_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2382") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2382") )
		sysprintf("gsp_updater -f /etc/gsc_2382_v35.txt");
	if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2380") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2380") )
		sysprintf("gsp_updater -f /etc/gsc_2380_v35.txt");


	writeproc("/proc/irq/51/smp_affinity","2");  //use second core for ethernet interrupts. this should increase performance a little bit
	return;
}
Beispiel #3
0
void start_sysinit(void)
{
	time_t tm = 0;

	char dev[64];
	char *disk = getdisc();

	if (disk == NULL) {
		fprintf(stderr, "no valid dd-wrt partition found, calling shell");
		eval("/bin/sh");
		exit(0);
	}

	FILE *in = fopen("/usr/local/nvram/nvram.db", "rb");

	if (in != NULL) {
		fclose(in);
		mkdir("/tmp/nvram", 0700);
		eval("cp", "/etc/nvram/nvram.db", "/tmp/nvram");
		eval("cp", "/etc/nvram/offsets.db", "/tmp/nvram");
		eval("/usr/sbin/convertnvram");
		nvram_commit();
		eval("rm", "-f", "/etc/nvram/nvram.db");
		eval("rm", "-f", "/etc/nvram/offsets.db");
	}
	//recover nvram if available
	in = fopen("/usr/local/nvram/nvram.bin", "rb");
	if (in == NULL) {
		fprintf(stderr, "recover broken nvram\n");
		sprintf(dev, "/dev/%s", disk);
		in = fopen(dev, "rb");
		fseeko(in, 0, SEEK_END);
		off_t mtdlen = ftello(in);
		fseeko(in, mtdlen - (65536 * 2), SEEK_SET);
		unsigned char *mem = malloc(65536);
		fread(mem, 65536, 1, in);
		fclose(in);
		if (mem[0] == 0x46 && mem[1] == 0x4c && mem[2] == 0x53 && mem[3] == 0x48) {
			fprintf(stderr, "found recovery\n");
			in = fopen("/usr/local/nvram/nvram.bin", "wb");
			if (in != NULL) {
				fwrite(mem, 65536, 1, in);
				fclose(in);
				free(mem);
				eval("sync");
				sleep(5);
				eval("event", "5", "1", "15");
			}
		}
		free(mem);
	} else {
		fclose(in);
	}

	if (!nvram_match("disable_watchdog", "1"))
		eval("watchdog");	// system watchdog
#ifdef HAVE_ERC
	if (isregistered_real() && nvram_match("ree_resetme", "1")) {
		fprintf(stderr, "Restoring REE default nvram\n");
		eval("nvram", "restore", "/etc/defaults/x86ree.backup");
		eval("reboot");
		eval("event", "5", "1", "15");
	}
#endif

	cprintf("sysinit() setup console\n");

	/*
	 * Setup console 
	 */

	cprintf("sysinit() klogctl\n");
	klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel")));
	cprintf("sysinit() get router\n");

	/*
	 * eval("insmod","md5"); eval("insmod","aes"); eval("insmod","blowfish");
	 * eval("insmod","deflate"); eval("insmod","des");
	 * eval("insmod","michael_mic"); eval("insmod","cast5");
	 * eval("insmod","crypto_null"); 
	 */

	detect_ethernet_devices();
	eval("ifconfig", "eth0", "0.0.0.0", "up");
	eval("ifconfig", "eth1", "0.0.0.0", "up");
	eval("ifconfig", "eth2", "0.0.0.0", "up");
	eval("ifconfig", "eth3", "0.0.0.0", "up");

	struct ifreq ifr;
	int s;

	if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
		char eabuf[32];

		strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
		ioctl(s, SIOCGIFHWADDR, &ifr);
		nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf));
		nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf));
		close(s);
	}
	detect_wireless_devices();

	mknod("/dev/rtc", S_IFCHR | 0644, makedev(253, 0));
#ifdef HAVE_CPUTEMP
	// insmod("nsc_gpio");
	// insmod("scx200_gpio");
	// insmod("scx200_i2c");
	// insmod("scx200_acb");
	// insmod("lm77");
#endif

	nvram_set("wl0_ifname", "ath0");
	mknod("/dev/crypto", S_IFCHR | 0644, makedev(10, 70));
	/*
	 * Set a sane date 
	 */
	stime(&tm);
	cprintf("done\n");
	return;
}