请先登录
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
接上篇文章,AR9331系统与mt7620系统对flash的划分是不一样的,AR系统划分为Flash(可能是作为NAND来处理),而mt7620(mips)系统则划分的比较明确,用的是SPI_FLASH。
在uboot的启动界面上,可以看到这样一些信息:
- Please choose the operation:
- 1: Load system code to SDRAM via TFTP.
- 2: Load system code then write to Flash via TFTP.
- 3: Boot system code via Flash (default).
- 4: Entr boot command line interface.
- 7: Load Boot Loader code then write to Flash via Serial.
- 9: Load Boot Loader code then write to Flash via TFTP.
复制代码 于是,
- grep 'write to Flash via TFTP' -r .
复制代码 找到:
- ./lib_mips/board.c: printf(" %d: Load system code then write to Flash via TFTP. \n", SEL_LOAD_LINUX_WRITE_FLASH);
- ./lib_mips/board.c: printf(" %d: Load Boot Loader code then write to Flash via TFTP. \n", SEL_LOAD_BOOT_WRITE_FLASH);
- ./lib_mips/board.c: printf(" \n%d: System Load Linux Kernel then write to Flash via TFTP. \n", SEL_LOAD_LINUX_WRITE_FLASH);
- ./lib_mips/board.c: printf(" \n%d: System Load Boot Loader then write to Flash via TFTP. (.bin)\n", SEL_LOAD_BOOT_WRITE_FLASH);
复制代码 打开board.c一看究竟。
- void OperationSelect(void)
- {
- printf("\nPlease choose the operation: \n");
- printf(" %d: Load system code then write to Flash via Serial. \n", SEL_LOAD_LINUX_WRITE_FLASH_BY_SERIAL);
- printf(" %d: Load system code to SDRAM via TFTP. \n", SEL_LOAD_LINUX_SDRAM);
- printf(" %d: Load system code then write to Flash via TFTP. \n", SEL_LOAD_LINUX_WRITE_FLASH);
- printf(" %d: Boot system code via Flash (default).\n", SEL_BOOT_FLASH);
- #ifdef RALINK_CMDLINE
- printf(" %d: Entr boot command line interface.\n", SEL_ENTER_CLI);
- #endif // RALINK_CMDLINE //
-
- #if defined(ASUS_RTN14U)
- printf(" %d: Load Boot Loader code to SDRAM via Serial. \n", SEL_LOAD_BOOT_SDRAM_VIA_SERIAL);
- #endif
- #ifdef RALINK_UPGRADE_BY_SERIAL
- printf(" %d: Load Boot Loader code then write to Flash via Serial. \n", SEL_LOAD_BOOT_WRITE_FLASH_BY_SERIAL);
- #endif // RALINK_UPGRADE_BY_SERIAL //
-
- #if defined(ASUS_RTN14U)
- printf(" %d: Load Boot Loader code to SDRAM via TFTP. \n", SEL_LOAD_BOOT_SDRAM);
- #endif
- printf(" %d: Load Boot Loader code then write to Flash via TFTP. \n", SEL_LOAD_BOOT_WRITE_FLASH);
- }
复制代码 调用层次为:【./cpu/ralink_soc/start.S: la
t9, board_init_r】→【board_init_r】→【OperationSelect】
- case '2':
- printf(" \n%d: System Load Linux Kernel then write to Flash via TFTP. \n", SEL_LOAD_LINUX_WRITE_FLASH);
- printf(" Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N)\n");
- confirm = getc();
- if (confirm != 'y' && confirm != 'Y') {
- printf(" Operation terminated\n");
- break;
- }
- tftp_config(SEL_LOAD_LINUX_WRITE_FLASH, argv);
- argc= 3;
- setenv("autostart", "no");
- do_tftpb(cmdtp, 0, argc, argv);
-
- #if defined (CFG_ENV_IS_IN_NAND)
- if (1) {
- unsigned int load_address = simple_strtoul(argv[1], NULL, 16);
- ranand_erase_write((u8 *)load_address, CFG_KERN_ADDR-CFG_FLASH_BASE, NetBootFileXferSize);
- }
- #elif defined (CFG_ENV_IS_IN_SPI)
- if (1) {
- unsigned int load_address = simple_strtoul(argv[1], NULL, 16);
- raspi_erase_write((u8 *)load_address, CFG_KERN_ADDR-CFG_FLASH_BASE, NetBootFileXferSize);
- }
- #else //CFG_ENV_IS_IN_FLASH
- #if (defined (ON_BOARD_8M_FLASH_COMPONENT) || defined (ON_BOARD_16M_FLASH_COMPONENT)) && (defined (RT2880_ASIC_BOARD) || defined (RT2880_FPGA_BOARD) || defined (RT3052_MP1))
- //erase linux
- if (NetBootFileXferSize <= (0x400000 - (CFG_BOOTLOADER_SIZE + CFG_CONFIG_SIZE + CFG_FACTORY_SIZE))) {
- e_end = CFG_KERN_ADDR + NetBootFileXferSize;
- if (0 != get_addr_boundary(&e_end))
- break;
- printf("Erase linux kernel block !!\n");
- printf("From 0x%X To 0x%X\n", CFG_KERN_ADDR, e_end);
- flash_sect_erase(CFG_KERN_ADDR, e_end);
- }
- else if (NetBootFileXferSize <= CFG_KERN_SIZE) {
- e_end = PHYS_FLASH_2 + NetBootFileXferSize - (0x400000 - (CFG_BOOTLOADER_SIZE + CFG_CONFIG_SIZE + CFG_FACTORY_SIZE));
- if (0 != get_addr_boundary(&e_end))
- break;
- printf("Erase linux kernel block !!\n");
- printf("From 0x%X To 0x%X\n", CFG_KERN_ADDR, CFG_FLASH_BASE+0x3FFFFF);
- flash_sect_erase(CFG_KERN_ADDR, CFG_FLASH_BASE+0x3FFFFF);
- printf("Erase linux file system block !!\n");
- printf("From 0x%X To 0x%X\n", PHYS_FLASH_2, e_end);
- flash_sect_erase(PHYS_FLASH_2, e_end);
- }
- #else
- if (NetBootFileXferSize <= (bd->bi_flashsize - (CFG_BOOTLOADER_SIZE + CFG_CONFIG_SIZE + CFG_FACTORY_SIZE))) {
- e_end = CFG_KERN_ADDR + NetBootFileXferSize;
- if (0 != get_addr_boundary(&e_end))
- break;
- printf("Erase linux kernel block !!\n");
- printf("From 0x%X To 0x%X\n", CFG_KERN_ADDR, e_end);
- flash_sect_erase(CFG_KERN_ADDR, e_end);
- }
- #endif
- else {
- printf("***********************************\n");
- printf("The Linux Image size is too big !! \n");
- printf("***********************************\n");
- break;
- }
-
- //cp.linux
- argc = 4;
- argv[0]= "cp.linux";
- do_mem_cp(cmdtp, 0, argc, argv);
- #endif //CFG_ENV_IS_IN_FLASH
-
- #ifdef DUAL_IMAGE_SUPPORT
- /* Don't do anything to the firmware upgraded in Uboot, since it may be used for testing */
- setenv("Image1Stable", "1");
- saveenv();
- #endif
-
- //bootm bc050000
- argc= 2;
- sprintf(addr_str, "0x%X", CFG_KERN_ADDR);
- argv[1] = &addr_str[0];
- do_bootm(cmdtp, 0, argc, argv);
- break;
复制代码 调用的是 raspi_erase_write 方法来对spi flash进行擦除和写入。
|