⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btldr_ui.c~

📁 针对德州仪器DM270开发板的bootloader,其实现了内核的下载以及文件系统的下载
💻 C~
📖 第 1 页 / 共 4 页
字号:
      i=CFI_START_ADDR;      j=7;      while (i<(CFI_END_ADDR+1)) 	{	  if (j==7) 	    {	      util_printf("\n   %x = %b", i, cfi_array[i]);	      j=0;	    }	  else 	    {	      util_printf(" %b", cfi_array[i]);	      j++;	    }	  i+=1;	}    }  util_printf("\n");  sector_count=build_sector_map(sector_map, SECTOR_MAP_SIZE);  util_printf("\n   Flash Sector Map (%d sectors)\n", sector_count);  i=0;  j=3;  while (i<sector_count)   {    if (j==3)       {	util_printf("\n   %x = %X", i, sector_map[i]);	j=0;      }    else     {      util_printf(" %X", sector_map[i]);      j++;    }    i+=1;  }  util_printf("\n");  util_printf("\n");  util_printf("Hit any key to continue");  util_gets(cmd, CMDMAX);}#endif/****************************** Routine: Description:   I added this to facilitate   debugging while porting   rrload to the omap710, where   we can't use Luaterbach. ******************************/#ifdef BSPCONF_BTLDR_MEMORY_DEBUGstatic void dump_memory(void){  char addrstr[11];  char lenstr[11];  int i, addr, len;  util_printf(" (Enter values in hex)\n");          for (i = 0; i < sizeof(addrstr); i++)    addrstr[i] = 0;  for (i = 0; i < sizeof(lenstr); i++)    lenstr[i] = 0;          util_printf(" Address? ");  util_gets(addrstr, sizeof(addrstr) - 1);  util_strip_CRLF(addrstr);  i = (addrstr[1] == 'x') ? 2 : 0; /* skip the '0x' if it's there */  util_hexstrtoint(addrstr + i, &addr);  util_printf("addr = %d\n", addr);  util_printf(" Length? ");  util_gets(lenstr, sizeof(lenstr) - 1);  util_strip_CRLF(lenstr);  i = (lenstr[1] == 'x') ? 2 : 0; /* skip the '0x' if it's there */  util_hexstrtoint(lenstr + i, &len);  util_printf("len = %d\n");  while(len) {    int rlen = (len < 8) ? len : 8;    len -= rlen;    util_printf("%X: ", addr);    while(rlen) {      util_printf("%b ", *((char *)addr));      addr++;      rlen--;    }    util_printf("\n");  }  util_printf("Hit any key to continue\n");  util_gets(cmd, CMDMAX);}#endif#ifndef BSPCONF_BTLDR_NO_MENUS/****************************** Routine: Description: ******************************/static void menu_mode(void){  while (1) {    clear();    util_printf(  "+-------------------------------------+\n"  );    util_printf(  "|           Welcome to the            |\n"  );    util_printf(  "|        IP_Camera  bootloader        |\n"  );    util_printf(  "|                                     |\n"  );    // Note: the ForUpGrade is defined and set to either 1 or 0    // by each of the linker scripts used to create the two    // versions of the rrload image.#if ( BSPCONF_KERNEL_COMPRESSED == 1 ) ||  ( BSPCONF_FS_COMPRESSED == 1 )    if (&ForUpGrade) {      util_printf(  "|  Version: v%s z **ForUpGrade**  |\n", RRLOAD_VERSION);    }    else {      util_printf(  "|  Version: v%s z                 |\n",RRLOAD_VERSION);    }#else    if (&ForUpGrade) {      util_printf(  "|  Version: v%s ***ForUpGrade***  |\n",RRLOAD_VERSION);    }    else {      util_printf(  "|  Version: v%s            |\n",RRLOAD_VERSION);      util_printf(  "|  PMP Version: %x                  |\n",PMP_RRLOAD_VER);    }#endif    util_printf(  "|  Datecode: %s                |\n", RRLOAD_DATECODE);#if DSC21    util_printf(  "|  Platform: DSC21                    |\n");#elif DSC24    util_printf(  "|  Platform: DSC24                    |\n");#elif DSC25    util_printf(  "|  Platform: DSC25 chip rev: %d.%d      |\n",                   chip_major(), chip_minor());#elif DM270    util_printf(  "|  Platform:  DM270                   |\n");//    util_printf(  "|  ARM clock: %d kHz               |\n", ARM_CLK/1000);//    util_printf(  "|  SDRAM clock: %d kHz            |\n", SDRAM_CLK/1000);    util_printf(  "|  64Mbyte sdram                      |\n");#elif OMAP1510    util_printf(  "|  Platform: OMAP1510                 |\n");#elif DM310    util_printf(  "|  Platform: DM310                    |\n");#elif OMAP710    util_printf(  "|  Platform: OMAP710                  |\n");#elif C5471    util_printf(  "|  Platform: C5471                    |\n");#endif    util_printf(  "+-------------------------------------+\n"  );    util_printf(  "\n"                                         );    util_printf(  "MAIN MENU\n"                                );    util_printf(  "---------\n"                                );    util_printf(  "  1. Load [comp] from I/O port...\n"        );    util_printf(  "  2. Store RAM [comp] to Flash...\n"        );    util_printf(  "  3. View/Edit Params...\n"                 );    util_printf(  "  4. Boot Kernel/filesystem (boot_auto)\n"  );    util_printf(  "  5. CmdLine Mode\n"                        );#ifdef BSPCONF_BTLDR_MEMORY_DEBUG    util_printf(  "  %c. Dump memory\n", MEMORY_DEBUG_CHAR     );#endif#ifdef BSPCONF_BTLDR_MEMMAP_DEBUG    util_printf(  "  %c. Print memory map\n", MEMMAP_DEBUG_CHAR );#endif#ifdef BSPCONF_BTLDR_CS8900_DEBUG    util_printf(  "  %c. Print CS8900A memory map\n", CS8900_DEBUG_CHAR );#endif#ifdef BSPCONF_BTLDR_FLASH_DEBUG    util_printf(  "  f. Print flash chip information\n"        );#endif#ifdef BSPCONF_BTLDR_MEMORY_DEBUG    util_printf(  "  m. Modify memory\n"                       );#endif//#ifdef BSPCONF_BTLDR_MEMORY_DEBUG    util_printf(  "  v. Verify SDRAM image\n"                  );//#endif    util_printf(  "\n"                                         );    util_printf(  "  r. Run Default Boot Cmd\n"                );    util_printf(  "  E. Erase [comp] from Flash...\n"          );    util_printf(  "\n"                                         );    util_printf(  "  Which? "                                  );    util_gets(cmd,CMDMAX);    switch (cmd[0]) {    case '1':      copy_to_SDRAM_menu1();      break;    case '2':      copy_to_flash_menu();      break;    case '3':      params_edit_menu();      break;    case '4':      cmd_boot_kernel(TRUE,progress_meter,METER_INTERV);      break;    case '5':      return;#ifdef BSPCONF_BTLDR_MEMORY_DEBUG    case MEMORY_DEBUG_CHAR:      dump_memory();      break;#endif#ifdef BSPCONF_BTLDR_MEMMAP_DEBUG    case MEMMAP_DEBUG_CHAR:      print_memory_map();      break;#endif#ifdef BSPCONF_BTLDR_CS8900_DEBUG    case CS8900_DEBUG_CHAR:      print_cs8900_memory();      break;#endif#ifdef BSPCONF_BTLDR_FLASH_DEBUG    case 'f':      print_flash_info();      break;#endif#ifdef BSPCONF_BTLDR_MEMORY_DEBUG    case 'm':      modify_memory();      break;#endif//#ifdef BSPCONF_BTLDR_MEMORY_DEBUG    case 'v':      verify_sdram_menu();      break;//#endif    case 'r':      process_default_boot_cmd(par->CMD_FIELD); // ... if there is one.      break;    case 'E': // *debug* temp case      do_erase_flash();      break;    default:      break;    }  }}#endif/****************************** Routine: Description: ******************************/static void process_default_boot_cmd(unsigned char *command){#ifdef BSPCONF_BTLDR_FAST_BOOT  if ( 0 != command[0] ) {    top_level_parse(command);  }#else  #define BOOT_TIMEOUT 3  unsigned char ch = 0;  int i;  if ( 0 != command[0] ) {    // Yes, the user has configured rrload with a "rr Default Boot Command".    // --- rrload UI based monitor/bootloader mode --    // Present the user with a count down window for which he/she    // can indicate that they would like to break away from whatever    // automatic boot command would happen and instead present the    // bootloader's UI. Of course, in the event the default boot command    // is non-exitent the UI will be presented regardless.    clear();    util_printf("Default Cmd: %s\n",command);    util_printf("Press <Enter> before countdown expires to intercept.\n",BOOT_TIMEOUT);    for (i=BOOT_TIMEOUT; i>0; i--) {      util_printf("%d\n",i);      display_board_digit(i);      //ch = io_getc(10);   // look for a key for x msec.      ch = io_getc(100); // look for a key for x msec.      if (ch > 0) break;    }	//Added By Lee...	if(pmu_OnkeyCheck()) //wakeup by not onkey		waitOnKey();     if (!ch) {      // Perform the user configured "automatic boot command".      util_printf("executing\n");      top_level_parse(command);    }  }#endif}#if DSC21# define PROC_NAME "dsc21"#elif DSC24# define PROC_NAME "dsc24"#elif DSC25# define PROC_NAME "dsc25"#elif DM270# define PROC_NAME "dm270"#elif C5471# define PROC_NAME "c5471"#elif OMAP1510# define PROC_NAME "omap1510"#elif DM310# define PROC_NAME "dm310"#elif OMAP710# define PROC_NAME "omap710"#elif TI925# define PROC_NAME "ti925"#endif#if ( BSPCONF_KERNEL_COMPRESSED == 1 )#define LINUX_FILE_NAME "linux.gz.rr." PROC_NAME#else#define LINUX_FILE_NAME "linux.rr." PROC_NAME#endif#if ( BSPCONF_FS_COMPRESSED == 1 )#define FS_FILE_NAME "fs.img.gz.rr." PROC_NAME#else#define FS_FILE_NAME "fs.img.rr." PROC_NAME#endif/****************************** Routine: Description: ******************************/int main(int argc, char *argv[]){        meter_line_len=0;// afraxus added//  REG 0x30594 = 0x2000;  // clear// afraxus added //	quit_discharge();		  //pmu_BootInit();  btldr_init();//  REG 0x3058E = 0x2000;  // set  unlock_flash(); // We'll keep flash unlocked the whole                  // time the bootloader is running until                  // it is time to transfer control to the                   // kernel at which time we first lock                  // flash. Hopefully this will prevent                  // corrupted flash that might otherwise                  // result in a run-away program randomly                  // jumping into the flash logic of the                  // bootloader image still laying around                  // in ram from its prior run.//  REG 0x30594 = 0x2000;  // clear  par = cmd_get_params();//  REG 0x3058E = 0x2000;  // set  // First, Set up a few defaults.  if (0 == par->MODE_FIELD[0]) {    util_strncpy(par->MODE_FIELD,  "menu",  par->MAX_STR_LEN);  }  if (0 == par->FORMAT_FIELD[0]) {    util_strncpy(par->FORMAT_FIELD,"rrbin", par->MAX_STR_LEN);  }  if (0 == par->PORT_FIELD[0]) {    { // *debug*      if (0 == par->PORT_FIELD[0])  { util_strncpy(par->PORT_FIELD, "serial",par->MAX_STR_LEN); }      if (0 == par->server_IP[0])   { util_strncpy(par->server_IP,BSPCONF_NETWORK_SOURCE_IP, par->MAX_STR_LEN); }      if (0 == par->server_MAC[0])  { util_strncpy(par->server_MAC,BSPCONF_NETWORK_SOURCE_MAC, par->MAX_STR_LEN); }      if (0 == par->device_IP[0])   { util_strncpy(par->device_IP,BSPCONF_NETWORK_TARGET_IP, par->MAX_STR_LEN); }      if (0 == par->device_MAC[0])  { util_strncpy(par->device_MAC,BSPCONF_NETWORK_TARGET_MAC, par->MAX_STR_LEN); }      if (0 == par->kernel_path[0]) { util_strncpy(par->kernel_path, LINUX_FILE_NAME, par->MAX_STR_LEN); }      if (0 == par->filesys_path[0]){ util_strncpy(par->filesys_path, FS_FILE_NAME, par->MAX_STR_LEN); }#if defined(DSC24_OSD)      if (0 == par->OSD_path[0]){ util_strncpy(par->OSD_path,"logo.img.rr", par->MAX_STR_LEN); }      if (0 == par->OSD_path[0]){ util_strncpy(par->OSD_enable,"no", par->MAX_STR_LEN); }#endif    }  }  if (0 == par->CON_FIELD[0]) {    util_strncpy(par->CON_FIELD,"serial", par->MAX_STR_LEN);    switch (par->CON_FIELD[0]) {      case 'S':      case 's':        io_change_con(SER);        break;      case 'P':      case 'p':        io_change_con(PAR);        break;#ifdef USE_USB      case 'U':      case 'u':        io_change_con(USB);        break;#endif    }  }#ifdef BSPCONF_BTLDR_NO_MENUS  par->MODE_FIELD[0]= 'C';#endif  if (('C' == par->MODE_FIELD[0]) || ('c' == par->MODE_FIELD[0])) {    // Command-line mode requested, so....    UI_mode = 'C';    util_printf(  "\n+-------------------------------------+\n"  );    // Note: the ForUpGrade is defined and set to either 1 or 0    // by each of the linker scripts used to create the two    // versions of the rrload image.    if (&ForUpGrade) {    util_printf(  "|  - rrload -     ***ForUpGrade***    |\n"  );    }    else {    util_printf(  "|  - rrload -                         |\n"  );    }#if ( BSPCONF_KERNEL_COMPRESSED == 1 ) ||  ( BSPCONF_FS_COMPRESSED == 1 )    util_printf(  "|  version %s z                      |\n",RRLOAD_VERSION);#else    util_printf(  "|  version %s            |\n",RRLOAD_VERSION);#endif#if DSC21    util_printf(  "|  platform: DSC21                    |\n");#elif DSC24    util_printf(  "|  platform: DSC24                    |\n");#elif DSC25    util_printf(  "|  platform: DSC25 chip rev: %d.%d      |\n",                   chip_major(), chip_minor());#elif DM270    util_printf(  "|  platform:  DM270                   |\n");//    util_printf(  "|  ARM clock: %d kHz               |\n", ARM_CLK/1000);#elif OMAP1510    util_printf(  "|  platform: OMAP1510                 |\n");#elif DM310    util_printf(  "|  platform: DM310                    |\n");#elif OMAP710    util_printf(  "|  platform: OMAP710                  |\n");#elif C5471    util_printf(  "|  platform: C5471                    |\n");#endif    util_printf(  "+-------------------------------------+\n"  );    util_printf("\n");  }  else {    // ...otherwise, *any* other MODE_FIELD puts us in menu mode.    UI_mode = 'M';  }  process_default_boot_cmd(par->CMD_FIELD); // ... if there is one.  // Next, kick off the bootloader UI; either cmd line or menu mode.  while (1) {#ifndef BSPCONF_BTLDR_NO_MENUS    if ('M' == UI_mode) {      menu_mode();      UI_mode = 'C';  // toggle mode.    }#endif    if ('C' == UI_mode) {      cmd_line_mode();      UI_mode = 'M'; // toggle mode.    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -