接上篇文章,AR9331系統(tǒng)與mt7620系統(tǒng)對(duì)flash的劃分是不一樣的,AR系統(tǒng)劃分為Flash(可能是作為NAND來(lái)處理),而mt7620(mips)系統(tǒng)則劃分的比較明確,用的是SPI_FLASH。
在uboot的啟動(dòng)界面上,可以看到這樣一些信息:
- 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);
打開(kāi)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);
- }
調(diào)用層次為:【./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))
-
- 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;
- }
-
-
- argc = 4;
- argv[0]= "cp.linux";
- do_mem_cp(cmdtp, 0, argc, argv);
- #endif //CFG_ENV_IS_IN_FLASH
-
- #ifdef DUAL_IMAGE_SUPPORT
-
- setenv("Image1Stable", "1");
- saveenv();
- #endif
-
-
- argc= 2;
- sprintf(addr_str, "0x%X", CFG_KERN_ADDR);
- argv[1] = &addr_str[0];
- do_bootm(cmdtp, 0, argc, argv);
- break;
調(diào)用的是 raspi_erase_write 方法來(lái)對(duì)spi flash進(jìn)行擦除和寫(xiě)入。
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。