uboot_mt7620对SPI flash操作的分析
来源:互联网 发布:什么是网络pos机 编辑:程序博客网 时间:2024/06/05 09:59
接上篇文章,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_CMDLINEprintf(" %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_SERIALprintf(" %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);#endifprintf(" %d: Load Boot Loader code then write to Flash via TFTP. \n", SEL_LOAD_BOOT_WRITE_FLASH);}调用层次为:【./cpu/ralink_soc/start.S: lat9, 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 linuxif (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);}#elseif (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);}#endifelse {printf("***********************************\n");printf("The Linux Image size is too big !! \n");printf("***********************************\n");break;}//cp.linuxargc = 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 bc050000argc= 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进行擦除和写入。
- uboot_mt7620对SPI flash操作的分析
- SPI Flash的操作
- 对Nand flash读操作的分析
- 对Nand flash读操作的分析
- 对Nand flash读操作的分析
- SPI flash操作小计
- 对Nand flash读操作的分析(转)
- STM32 SPI对外部FLASH的访问(转载)
- SPI flash操作时经验教训
- [转载]S3C2410对Nand flash读操作的分析----仔细读下会有新理解的
- spi flash的挂载
- SPI FLASH与NOR FLASH的区别?
- STM32F10X SPI操作flash MX25L64读写数据
- U-boot操作Flash (NOR, NAND & SPI)
- U-Boot操作Flash (NOR, NAND & SPI)
- KL25用SPI操作nor flash
- STM32F10X SPI操作flash MX25L64读写数据
- sTM32F10X SPI操作flash MX25L64读写数据
- hdu 2897 邂逅明下 博弈
- Matlab基本操作函数-angle函数
- hibernate left join 多表连接查询不到结果,但生成的查询语句在数据库可以查询
- 【CQOI 2006】 简单题
- 关于java正则表达式贪婪模式和勉强模式的研究
- uboot_mt7620对SPI flash操作的分析
- Myeclipse中安装Aptana插件操作和步骤
- dowhile的妙用
- Codeforces Round #208 (Div. 2)
- PBSQLScipt 数据库管理工具V3.0
- poj——2063——Investment(dp)
- 学习笔记(一)之示例程序:计算每年的最高温度MaxTemperature
- LeetCode:Candy
- 【重点】让类对象具有比较性,装入TreeSet【用来排序】