【转载】Serial NOR Flash and U-Boot
转载自:http://blackfin.uclinux.org/doku.php?id=bootloaders:u-boot:serial-flash
U-Boot supports serial NOR flashes which hook up to the Blackfin processor via a 4 wire SPI-compatible interface. Commands are provided for reading/erasing/writing of the device.
In terms of the command line interface, the sf command is the interface to all serial flash operations. It allows you to read/erase/write a sequential range of bytes as well as query the SPI flash. You can also select different flashes at runtime based on the SPI chip select.
In terms of U-Boot code, U-Boot provides a SPI flash framework while the Blackfin port provides a driver for the on-chip SPI controller. Every SPI flash type has its own specific subdriver which can be found in the drivers/mtd/spi/ directory. If the SPI flash you want to use is not supported, you'll have to implement your own subdriver. See the supported flashes section for more information.
sf interface which was introduced with 2009R1 / u-boot-2008.10+. If you're using an older release, please see the eeprom page: serial-flash-eepromSupported Flashes
There is no limit in terms of flash sizes that the SPI interface can support. U-Boot can work with the SPI flash regardless of its size. The current largest is about 128 megabits / 16 megabytes and it works great!
Every SPI flash vendor likes to implement their own command interface with their own extensions. When selecting a SPI flash for your board, you should first make sure it supports the JEDEC identification standard. Everything made recently should comply, but double check the datasheet.
The specific list of parts that are currently supported:
| Vendor | Parts |
|---|---|
| Atmel | AT45DB011D AT45DB021D AT45DB041D AT45DB081D AT45DB161D AT45DB321D AT45DB642D |
| Macronix | MX25L1605D MX25L3205D MX25L6405D MX25L12805D MX25L12855E |
| Spansion | S25FL008A S25FL016A S25FL032A S25FL064A S25FL128P |
| SST | SST25VF040B SST25VF080B SST25VF016B SST25VF032B SST25WF512 SST25WF010 SST25WF020 SST25WF040 |
| ST Micro | M25P16 M25P20 M25P32 M25P40 M25P64 M25P80 M25P128 |
| Winbond | W25X16 W25X32 W25X64 |
Configuration
You will need these defined in your board configuration file in order to enable support for serial flashes.
- CONFIG_BFIN_SPI -- Blackfin on-chip SPI controller
- CONFIG_SPI_FLASH -- SPI Flash subsystem
- CONFIG_CMD_SF -- Command line interface
sf - CONFIG_SF_DEFAULT_SPEED -- speed to run the SPI flash
- CONFIG_SF_DEFAULT_MODE -- by default, SPI_MODE_3 is used (see spi for more info)
If you want to store the U-Boot environment in SPI flash, then use these defines.
- CONFIG_ENV_IS_IN_SPI_FLASH -- store the env in SPI flash
- CONFIG_ENV_SPI_MAX_HZ -- speed to run the SPI flash
- CONFIG_ENV_SPI_MODE -- by default, SPI_MODE_3 is used (see spi for more info)
- CONFIG_ENV_SPI_BUS -- by default, bus 0 is used
- CONFIG_ENV_SPI_CS -- by default, the CS the bootrom uses
Then you should define these according to the parts you have.
- CONFIG_SPI_FLASH_ATMEL
- CONFIG_SPI_FLASH_MACRONIX
- CONFIG_SPI_FLASH_SPANSION
- CONFIG_SPI_FLASH_SST
- CONFIG_SPI_FLASH_STMICRO
- CONFIG_SPI_FLASH_WINBOND
Probing
At runtime, you can detect any SPI flash to make sure things are detected properly. This command must be run first before doing any other SPI flash operation.
bfin> sf probe 2
SF: Got idcode 20 20 15
2048 KiB M25P16 at 0:2 is now current device
Here we can see that there is a 16 megabit ST Micro flash hooked up. Good times.
Reading
You use the sf read command to read a range of bytes from the serial flash into memory. From there, you can do anything you like with it. For example, if we want to read 0x1000 bytes at an offset of 0x300 bytes from the start of the serial flash into external memory at 0x2000000, we'd simply run:
bfin> sf read 0x2000000 0x300 0x1000
bfin> md.b 0x2000000
02000000: 4a e1 c0 ff 10 62 0a e1 04 0a 40 e1 c2 ff 10 93 J....b....@.....
02000010: 22 6c 10 93 48 60 c2 6f 10 97 4a e1 e0 ff 20 e1 "l..H`.o..J... .
02000020: fd 01 0a e1 04 20 88 4f 10 93 c6 6c 27 01 30 05 ..... .O...l'.0.
02000030: 10 00 00 00 4a e1 e0 ff 40 e1 fa 03 0a e1 0c 20 ....J...@......
Again, you do not need to worry about how the serial flash is split up into pages, so you could just as easily read multiple pages/sectors/blocks/whatever with one command.
Erasing
You use the sf erase command to erase pages/sectors of the serial flash. Like any normal flash system, you must erase things before you can write to them, and you must erase on sector boundaries.
For example, if we want to erase the sector starting at 0x30000, then we'd do:
bfin> sf erase 0x30000 0x10000
Here the sector size is 0x10000 bytes.
Writing
You use the sf write command to write a range of bytes from memory into some offset into the serial flash. For example, if we want to write 0x100000 bytes from external memory at 0x20000000 into the serial flash at an offset of 0x0 bytes, we'd simply run:
bfin> sf write 0x20000000 0x0 0x100000
There is no need for you to worry about writing out only a page of data at a time.
Booting
When most people talk about booting, they sometimes forget that there are two aspects of booting a system - chip and hardware initialization (done by the bootloader), and booting the kernel.
Booting the Blackfin (U-Boot in SPI Flash)
This is covered in the booting_methods section.
Booting Linux (Linux in SPI Flash)
This is a simple matter of loading a uImage from SPI flash (via chip select 2), and doing a bootm command on it. For example the following
bfin> set sfboot 'sf probe 2; sf read 0x2000000 0x300 0x100000; bootm 0x2000000'
bfin> set bootcmd run sfboot
bfin> save
The next time this board boots, it will run the sfboot command, which probes the flash at CS 2, loads the image located in offset 0x300, with a length of 0x100000, into memory location 0x2000000, and then does a bootm on it. Simple!
【转载】Serial NOR Flash and U-Boot的更多相关文章
- (30)导入时如何定制spring-boot依赖项的版本【转载】【从零开始学Spring Boot】
此文章转载地址:http://www.tuicool.com/articles/RJJvMj3 请注重作者的版权. spring-boot通过maven的依赖管理为我们写好了很多依赖项及其版本,我们可 ...
- 转载:NOR Flash擦写和原理分析
1. NOR FLASH 的简单介绍 NOR FLASH 是很常见的一种存储芯片,数据掉电不会丢失.NOR FLASH支持Execute On Chip,即程序可以直接在FLASH片内执行(这意味着存 ...
- xilinx的quick boot(1) ——flash的一些内容
xilinx的quick boot(1) --flash,quick boot配置文件,以及中间的一些联系xilinx 配置模式分为SPI,BPI.用过的spi外挂flash是N25Q./////// ...
- 痞子衡嵌入式:飞思卡尔i.MX RT系列MCU启动那些事(1)- Boot简介
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是飞思卡尔i.MX RT系列MCU的BootROM功能简介. 截止目前为止i.MX RT系列已公布的芯片有三款i.MXRT105x, i. ...
- 痞子衡嵌入式:飞思卡尔i.MX RT系列MCU启动那些事(2)- Boot配置(BOOT Pin/eFUSE)
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是飞思卡尔i.MX RT系列MCU的Boot配置. 在上一篇文章 Boot简介 里痞子衡为大家介绍了Boot基本原理以及i.MXRT Bo ...
- 痞子衡嵌入式:飞思卡尔i.MX RT系列MCU启动那些事(13)- 从Serial(1-bit SPI) EEPROM/NOR恢复启动
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是飞思卡尔i.MX RT系列MCU的Serial EEPROM/NOR恢复启动. 在前几篇里痞子衡介绍的Boot Device都属于主动启 ...
- Flash Memory 简介【转】
本文转载自:https://linux.codingbelief.com/zh/storage/emmc/ Flash Memory 是一种非易失性的存储器.在嵌入式系统中通常用于存放系统.应用和数据 ...
- LPCScrypt, DFUSec : USB FLASH download, programming, and security tool, LPC-Link 2 Configuration tool, Firmware Programming
What does this tool do? The LPC18xx/43xx DFUSec utility is a Windows PC tool that provides support f ...
- 痞子衡嵌入式:恩智浦i.MX RTxxx系列MCU启动那些事(1)- Boot简介
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是恩智浦i.MX RTxxx系列MCU的BootROM功能简介. 截止目前为止i.MX RTxxx系列已公布的芯片仅有一款i.MXRT60 ...
随机推荐
- Android中的IOC框架,完全注解方式就可以进行UI绑定和事件绑定
转载请注明出处:http://blog.csdn.net/blog_wang/article/details/38468547 相信很多使用过Afinal和Xutils的朋友会发现框架中自带View控 ...
- 【CUDA学习】全局存储器
全局存储器,即普通的显存,整个网格中的任意线程都能读写全局存储器的任意位置. 存取延时为400-600 clock cycles 非常容易成为性能瓶颈. 访问显存时,读取和存储必须对齐,宽度为4By ...
- 【高德地图API】如何设置Marker的offset?
一些朋友在往地图上添加标注的时候,往往会发现,图片的尖尖角对不上具体的点.比如,我要在上海东方明珠上扎一个点. 首先,我使用取点工具http://lbs.amap.com/console/show/p ...
- Windows搭建SVN
1.服务器下载 VisualSVN 地址:http://subversion.apache.org/packages.html 2.然后下载TortoiseSVN客户端,如果要下中文语言包 也在这个页 ...
- MySQL、PostgreSQL、Ingres r3、MaxDB等开源数据库的详细比较
1.MySQL 5 作为当今最流行的开放源码数据库之一,MySQL数据库为用户提供了一个相对简单的 解决方案,适用于广泛的应用程序部署,能够降低用户的TCO.MySQL是一个多线程.结构化查询语言(S ...
- c#列举和迭代器
列举 - Enumeration 迭代器是一个值序列(集合)上的一个只读且只向前移动的游标.迭代器要么实现了IEnumerator接口,要么实现了IEnumerator<T>接口. 从技术 ...
- Filter之——GZIP全站压缩
GZIP压缩:将压缩后的文本文件,发送给浏览器,减少流量. 一.进行gzip压缩条件: 1.请求头:Accept-Encoding : gzip 告诉服务器,该浏览器支持gzip压缩. 2.响应头: ...
- Gson整合Volley返回对象--GsonRequest
Gson是一个使用映射支持JSON与Java对象之间相互转换的库文件.你可以定义和JSON keys相对应名称的Java对象.把对象传递给传递Gson,然后Gson会帮你为对象填充字段值. 下面是一个 ...
- MediaPlayer 播放assets 文件夹下面的视频报错
Android MediaPlayer 播放assets 文件夹下面的视频报错 报下面的错: java.io.FileNotFoundException: This file can not be o ...
- 构建基于WinRT的WP8.1 App 03:Page控件
单页面模板 通常利用Visual Studio 2013创建的最简单的WP8.1应用是Blank App,它只包含一个不带任何UI的页面,并且没有任何状态管理的逻辑. 该不带任何UI的页面称为Blan ...