void menu_shell(void)
{
	char c;
	char cmd_buf[256];
	static int mode=0;
	while (1) {
	/*
	check the download modes 
	0 for usb download
	1 for tftp download
	2 for serial(kermit) download
	3 for serial(xmode) download
	4 for sd/mmc download
	5 for usb storage download
	*/

	//bBootFrmNORFlash == 1 ==> NOR BOOT
	//bBootFrmNORFlash == 0 ==> NAND BOOT

	main_menu_usage(mode);

	c = awaitkey(-1, NULL);
	printf("%c\n", c);
	switch (c) {
	case 'c': {
		mode++;
		if(mode>=6) mode=0;
		break;
	} case 's': {
		system_setting_shell();
		break;
	} case 'b': {
		strcpy(cmd_buf, "bootd");
		run_command(cmd_buf, 0);
		break;
	} case 'f': {
		if (bBootFrmNORFlash == 1)
			strcpy(cmd_buf, "mtdpart default; nand erase;saveenv");
		else {
			printf("\nBoot From NAND !\nNot erase bootloader.\n ");
			strcpy(cmd_buf, "mtdpart default; nand erase 0x00080000; saveenv");
		}

		run_command(cmd_buf, 0);
		break;
	} case 'm': {
		multiboot_shell();
		break;
	} case 'r': {
		strcpy(cmd_buf, "reset");
		run_command(cmd_buf, 0);
		break;
	} case 'p': {
		strcpy(cmd_buf, "mtdparts");
		run_command(cmd_buf, 0);
		printf("\nPress any key...\n");
		awaitkey(-1, NULL);
		break;
	} case 'e': {
		printf("Erase u-boot-env...");
		run_command("nand erase uboot-env;reset",0);
		break;
	} case  27: case 'q': {
		return;
		break;

	} case '0': {
		printf("\n# Warning: U-Boot ==> NOR FLASH !\nThis operation may brick your board ! Continue ? (y/n)");
		c = awaitkey(-1, NULL);
		if (c=='n'||c=='N') break;
		printf("\nDownload U-boot Bootloader ... \n");
		if(download(mode, DEFAULT_DL_RAM_BASE)<0) break;
		strcpy(cmd_buf, "protect off all;erase 0x0000 +0x80000;cp.b ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " 0x0 0x80000"); //protect off all;erase 0x0000 +0x80000;cp.b <dl_addr> 0x0 0x80000
		if (simple_strtoul(getenv ("filesize"), NULL, 16)>16)
			run_command(cmd_buf, 0);
		break;
	} case '1': {
		printf("\n# Warning: U-Boot ==> NAND FLASH !\nThis operation may brick your board ! Continue ? (y/n)");
		c = awaitkey(-1, NULL);
		if (c=='n'||c=='N') break;
		printf("\nDownload U-boot Bootloader ... \n");
		if(download(mode, DEFAULT_DL_RAM_BASE)<0) break;
		strcpy(cmd_buf, "nand erase uboot; nand write ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " uboot"); //nand erase uboot; nand write <dl_addr> uboot
		if (simple_strtoul(getenv ("filesize"), NULL, 16)>16)
			run_command(cmd_buf, 0);
		break;
	} case '2': {
		printf("\nDownLoad uImage Kernel ... \n");
		download(mode, DEFAULT_DL_RAM_BASE);
		strcpy(cmd_buf, "nand erase kernel; nand write ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " kernel"); //nand erase kernel; nand write <dl_addr> kernel
		if (simple_strtoul(getenv ("filesize"), NULL, 16)>0x10) {
			run_command(cmd_buf, 0);
			//nboot <kernel_addr> kernel;bootm
			strcpy(cmd_buf, "nboot ");
			strcat(cmd_buf, DEFAULT_KERNEL_RAM_BASE);
			strcat(cmd_buf, " kernel;bootm");
			setenv("bootcmd", cmd_buf);
			run_command("saveenv", 0);
		}
		break;
	} case '3': {
		printf("\nDownLoad zImage Kernel ... \n");
		download(mode, DEFAULT_DL_RAM_BASE);
		strcpy(cmd_buf, "nand erase kernel; nand write ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " kernel"); //nand erase kernel; nand write <dl_addr> kernel
		if (simple_strtoul(getenv ("filesize"), NULL, 16)>0x10) {
			run_command(cmd_buf, 0);
			//nand read <kernel_addr> kernel;bootz
			strcpy(cmd_buf, "nand read ");
			strcat(cmd_buf, DEFAULT_KERNEL_RAM_BASE);
			strcat(cmd_buf, " kernel;bootz");
			setenv("bootcmd", cmd_buf);
			run_command("saveenv", 0);
		}
		break;
	} case '4': {
		printf("\nDownLoad squashfs rootfs ... \n");
		download(mode, DEFAULT_DL_RAM_BASE);
		strcpy(cmd_buf, "nand erase rootfs; nand write ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " rootfs ");
		strcat(cmd_buf, getenv ("filesize")); //nand erase rootfs; nand write <dl_addr> rootfs <filesize>
		printf("Received File Size: 0X%s\n", getenv ("filesize"));
		if (simple_strtoul(getenv ("filesize"), NULL, 16)>0x10) {
			run_command(cmd_buf, 0);
			run_command("setenv bootargs root=/dev/mtdblock3  console=ttySAC0 rootfstype=squashfs,ext2;saveenv", 0);
		}
		break;
	} case '5': { //jffs2
		printf("\nDownLoad jffs rootfs ... \n");
		download(mode, DEFAULT_DL_RAM_BASE);
		strcpy(cmd_buf, "nand erase rootfs; nand write ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " rootfs ");
		strcat(cmd_buf, getenv ("filesize")); //nand erase rootfs; nand write <dl_addr> rootfs <filesize>
		printf("Received File Size: 0X%s\n", getenv ("filesize"));
		run_command(cmd_buf, 0);
		run_command("setenv bootargs noinitrd root=/dev/mtdblock3  console=ttySAC0 rootfstype=jffs2;saveenv", 0);
		break;
	} case '6': { //yaffs
		printf("\nDownLoad yaffs2 rootfs ... \n");
		download(mode, DEFAULT_DL_RAM_BASE);
		strcpy(cmd_buf, "nand erase rootfs; nand write.yaffs ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " rootfs ");
		strcat(cmd_buf, getenv ("filesize")); //nand erase rootfs; nand write.yaffs <dl_addr> rootfs <filesize>
		printf("Received File Size: 0X%s\n", getenv ("filesize"));
		run_command(cmd_buf, 0);
		run_command("setenv bootargs noinitrd root=/dev/mtdblock3  console=ttySAC0 rootfstype=yaffs2;saveenv", 0);
		break;
	} case '7': {
		if(download(mode, DEFAULT_KERNEL_RAM_BASE) < 0) break;
		strcpy(cmd_buf, "bootm ");
		strcat(cmd_buf, DEFAULT_KERNEL_RAM_BASE);
		strcat(cmd_buf, " ; bootz"); //bootm <kernel_addr>;bootz
		if (simple_strtoul(getenv ("filesize"), NULL, 16)>16)
			run_command(cmd_buf, 0);
		break;
	} case '8': {
		printf("Download application to %s...\n", DEFAULT_DL_RAM_BASE);
		printf("Clean Memory at %s Len 0x400000...", DEFAULT_DL_RAM_BASE);
		strcpy(cmd_buf, "mw.b ");
		strcat(cmd_buf, DEFAULT_DL_RAM_BASE);
		strcat(cmd_buf, " 0xFF 0x400000"); //mw.b <dl_addr> 0xFF 0x400000
		run_command(cmd_buf, 0);
		printf("OK\n");
		if (download(mode, DEFAULT_DL_RAM_BASE)>=0)
			strcpy(cmd_buf, "go ");
			strcat(cmd_buf, DEFAULT_DL_RAM_BASE); // go <dl_addr>
			run_command(cmd_buf, 0);
		break;
	} case 'l': {
		printf("Current Boot Command Line \'bootargs\': %s\n",getenv("bootargs"));
		printf("New Boot Command Line \'bootargs\': ");
		memset(console_buffer,NULL,CONFIG_SYS_CBSIZE);
		readline(NULL);
		printf("Save Boot Command Line \'bootargs\' ? (n/y) ");
		c = awaitkey(-1, NULL);
		if(c=='y'||c=='Y') {
			setenv("bootargs",console_buffer);
			run_command("saveenv",0);
			break;
		}
	}
	}
    }
}
Beispiel #2
0
void menu_shell(void)
{
    char c;
    char cmd_buf[256];
    static int mode=0;
    while (1)
    {
      /*
      check the download modes 
      0 for usb download
      1 for tftp download
      3 for serial download
      */
	main_menu_usage(mode);
	
        c = awaitkey(-1, NULL);
        printf("%c\n", c);
        switch (c)
        {
        case 'c':
        {
	    mode=!mode;
            break;
	}
        case 's':
        {
	    system_setting_shell();
            break;
	}
        case 'b':
        {
//            strcpy(cmd_buf, "usbslave 1 0x800000; nand erase boot; nand write 0x800000 boot $(filesize)");
            strcpy(cmd_buf, "bootd");
            run_command(cmd_buf, 0);
            break;
        }
        case 'f':
        {
#if 0
	    if (bBootFrmNORFlash == 1)
            strcpy(cmd_buf, "mtdpart default; nand erase;saveenv");
	    else
	    {
	    printf("\nBoot From NAND !\nNot erase bootloader.\n ");
            strcpy(cmd_buf, "mtdpart default; nand erase 0x00080000; saveenv");
	    }
            run_command(cmd_buf, 0);
#else
	  printf("\nNot Supported!\n ");
#endif
            break;
        }
	case 'm':
	  multiboot_shell();
	  break;
        case 'r':
        {
            run_command("reset", 0);
            break;
        }
        case 'v':
        {
#if 0
            strcpy(cmd_buf, "mtdparts");
            run_command(cmd_buf, 0);
	    printf("\nPress any key...\n");
	    awaitkey(-1, NULL);
#else
	  printf("\nNot Supported!\n ");
#endif
            break;
        }
	case 'e':
	{
	    printf("Reset u-boot-env...");
            run_command("env default -f;saveenv;reset",0);
            break;
	}
        case  27:
        case 'q':
        {
            return;
            break;
        }
        case '0':
        {
	  if(bBootFrmNORFlash)
	  {
	    printf("\nWarning!This operation will be brick your board!!!continue?(y/n)");
	    c = awaitkey(-1, NULL);
	    if (c=='n'||c=='N')
	    break;  
	  }
	    printf("\nDownload U-boot Bootloader ... \n");
	    if(download(mode)<0)
	    break;
	    if(chk_image())
	    {
	    strcpy(cmd_buf, "sf probe 0;sf erase 0x0 0x100000;sf write 0x800000 0x0 0x100000");
	    }
	    else
	    {
	      printf("Image is not U-boot SPI image!!!abort!\n");
	    }
	    {
	    if (simple_strtoul(getenv ("filesize"), NULL, 16)>4)
            run_command(cmd_buf, 0);
	    }
            break;
        }
        case '1':
        {
	    printf("\nDownLoad b-boot nand ... \n");
            break;
        }
	case '2': 
	{
	    printf("\nDownLoad Kernel ... \n");
	    break;
	}
        case '3':
        {
	    printf("\nDownLoad Kernel ... \n");
	    download(mode);
	    break;
        }
	case '4': //jffs2
	{
		printf("\nDownLoad rootfs ... \n");
		break;
	}

	case '5': 
	{

		printf("\nDownLoad DDNAS Firmware ... \n");
		download(mode);
		strcpy(cmd_buf, "sf probe 0;sf erase 0x100000 0xf00000;sf write 0x800000 0x100000 0xf00000");
		if(chk_image()==0)
		{
		run_command(cmd_buf, 0);
//		run_command(" bsetenvootargs noinitrd root=/dev/mtdblock3  console=ttySAC0 rootfstype=yaffs2;saveenv", 0);
		}
		else
		  printf("Firmware error!");
		break;
	}
        case '6':
	{
            break;	  
         }
	case '7': 
	{
	    run_command("rescue", 0);
	    break;
	}
        case '8':
        {
	    printf("Current command line:%s\n",getenv("bootargs"));
	    printf("New command line:");
	    memset(console_buffer,NULL,CONFIG_SYS_CBSIZE);
	    readline(NULL);
//	    strcat(cmd_buf, console_buffer);   
	    printf("Save new command line ?(y/n)");
	    c = awaitkey(-1, NULL);
	    
	    if(c=='y'||c=='Y')
	    {setenv("bootargs",console_buffer); run_command("saveenv",0);break;}
	}
        }
    }
}
void menu_shell(void)
{
	char keyselect;
	char cmd_buf[200];

	while (1)
	{
		main_menu_usage(USE_USB_DOWN);
		keyselect = getc();
		printf("%c\n", keyselect);
		switch (keyselect)
		{
			case '1':
			{

				strcpy(cmd_buf, "dnw 0x21000000; nand erase 0x0 0x80000; nand write 0x21000000 0x0 0x80000");

				run_command(cmd_buf, 0);
				break;
			}
			
			

			case '2':
			{

				strcpy(cmd_buf, "dnw 0x21000000; nand erase 0x400000 0x500000; nand write 0x21000000 0x300000 0x500000");

				run_command(cmd_buf, 0);
				break;
			}


			case '3':
			{
//#ifdef CONFIG_MTD_DEVICE
//				strcpy(cmd_buf, "dnw 0x21000000; nand erase root; nand write.yaffs 0x21000000 root $(filesize)");
//#else
				strcpy(cmd_buf, "dnw 0x21000000; nand erase 0xe00000 0xF8D0000; nand write.yaffs 0x21000000 0xe00000 $(filesize)");
//#endif /* CONFIG_MTD_DEVICE */
				run_command(cmd_buf, 0);
				break;
			}

			case '4':
			{
				char addr_buff[12];
				printf("Enter download address:(eg: 0x21000000)\n");
				readline(NULL);
				strcpy(addr_buff,console_buffer);
				sprintf(cmd_buf, "dnw %s;go %s", addr_buff, addr_buff);
				run_command(cmd_buf, 0);
				break;
			}

			case '5':
			{

				printf("Start Linux ...\n");
//#ifdef CONFIG_MTD_DEVICE
//				strcpy(cmd_buf, "nand read 0x21000000 kernel;bootm 0x21000000");
//#else
				strcpy(cmd_buf, "nand read 0x21000000 0x300000 0x500000;bootm 0x21000000");
//#endif /* CONFIG_MTD_DEVICE */
				run_command(cmd_buf, 0);
				break;
			}

			case '6':
			{
				strcpy(cmd_buf, "nand erase 0 ");
				run_command(cmd_buf, 0);
				break;
			}

			
#ifdef CONFIG_TINY210
			case 'Q':
			case 'q':
			{
				return;	
				break;
			}
#endif
		}
				
	}
}
Beispiel #4
0
void menu_shell(void)
{
    char c;
    char cmd_buf[200];
    char *p = NULL;
    unsigned long size;

    while (1)
    {
        main_menu_usage();
        c = awaitkey(-1, NULL);
        printf("%c\n", c);
        switch (c)
        {
            case 'u':
            {
                strcpy(cmd_buf, "usbslave 1 0x30000000; nand erase.part bootloader; nand write.jffs2 0x30000000 bootloader $filesize");
                run_command(cmd_buf, 0);
                break;
            }
            
            case 'k':
            {
                strcpy(cmd_buf, "usbslave 1 0x30000000; nand erase.part kernel; nand write.jffs2 0x30000000 kernel $filesize");
                run_command(cmd_buf, 0);
                break;
            }

            case 'y':
            {
                strcpy(cmd_buf, "usbslave 1 0x30000000; nand erase.part root; nand write.yaffs 0x30000000 root $filesize");
                run_command(cmd_buf, 0);
                break;
            }

            case 'd':
            {
                extern volatile u32 downloadAddress;
                extern int download_run;
                
                download_run = 1;
                strcpy(cmd_buf, "usbslave 1");
                run_command(cmd_buf, 0);
                download_run = 0;
                sprintf(cmd_buf, "go %x", downloadAddress);
                run_command(cmd_buf, 0);
                break;
            }

            case 'b':
            {
                printf("Booting Linux ...\n");
                strcpy(cmd_buf, "nand read.jffs2 0x32000000 kernel; bootm 0x32000000");
                run_command(cmd_buf, 0);
                break;
            }

            case 's':
            {
                param_menu_shell();
                break;
            }

            case 'r':
            {
				strcpy(cmd_buf, "reset");
				run_command(cmd_buf, 0);
                break;
            }
            
            case 'q':
            {
                return;    
                break;
            }

        }
                
    }
}