文章目录

  • 前言
    • 具体用法
    • 使用范例
    • 如何验证读写效果
  • 一、进入Uboot命令行模式

前言

 U-boot中如果支持spi/qspi flash,那么可以在U-Boot的命令行模式下使用sf的erase,read,write命令来操作spi flash.

  • sf read用来读取flash数据到内存
  • sf write写内存数据到flash
  • sf erase擦除指定位置,指定长度的flash内容,擦除后内容全为1即0xff。

具体用法

sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus and chip select

sf read addr offset len - read len' bytes starting atoffset’ to memory at `addr’

sf write addr offset len - write len' bytes from memor ataddr’ to flash at `offset’

sf erase offset [+]len - erase len' bytes fromoffset’ +len' round uplen’ to block size

sf update addr offset len - erase and write len' bytes from memory ataddr’ to flash at `offset’

使用范例

sf probe 0

在使用sf read sf write之前,一定要调用sf probe

sf write 0x82000000 0x0 0x20000

把内存0x8200 0000处的数据, 写入flash的偏移0x0, 写入数据长度为0x20000(128KB), 操作偏移和长度最小单位是Byte

sf read 0x82000000 0x10000 0x20000

把flash偏移0x10000(64KB)处, 长度为0x20000(128KB)的数据, 写入到内存0x82000000, 操作偏移和长度最小单位是Byte

sf erase 0x0 0x10000

擦除偏移0x0处, 到0x10000之间的擦除块, 擦除操作是以erase block为单位的, 要求offset和len参数必须是erase block对齐的

如何验证读写效果

可以结合uboot md命令, sf read, sf write都涉及到内存操作, 可以用md查看内存数据

md 0x0 0x100

打印0开始, 长度范围256字节的内存数据

一、进入Uboot命令行模式

=> help
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootefi - Boots an EFI payload from memory
bootelf - Boot from an ELF image in memory
bootm   - boot application image from memory
bootmenu- ANSI terminal bootmenu
bootp   - boot image via network using BOOTP/TFTP protocol
bootvx  - Boot vxWorks from an ELF image
bootz   - boot Linux zImage image from memory
clrlogo - fill the boot logo area with black
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dhcp    - boot image via network using DHCP/TFTP protocol
dm      - Driver model low level access
echo    - echo args to console
editenv - edit environment variable
env     - environment handling commands
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
ext4load- load binary file from a Ext4 filesystem
ext4ls  - list files in a directory (default /)
ext4size- determine a file's size
false   - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatsize - determine a file's size
fatwrite- write file into a dos filesystem
fdt     - flattened device tree utility commands
fstype  - Look up a filesystem type
go      - start application at address 'addr'
gpio    - query and control gpio pins
help    - print command description/usage
iminfo  - print header information for application image
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
load    - load binary file from a filesystem
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
ls      - list files in a directory (default /)
md      - memory display
meminfo - display memory information
mii     - MII utility commands
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mw      - memory write (fill)
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
part    - disk partition related commands
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
pxe     - commands to get and boot from pxe files
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
save    - save file to a filesystem
saveenv - save environment variables to persistent storage
setenv  - set environment variables
setexpr - set environment variable as the result of eval expression
sf      - SPI flash sub-system
showvar - print local hushshell variables
size    - determine a file's size
sleep   - delay execution for some time
source  - run script from memory
sspi    - SPI utility command
sysboot - command to get and boot from syslinux files
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version
=>

使用命令help sf

=> help sf
sf - SPI flash sub-systemUsage:
sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI busand chip select
sf read addr offset|partition len       - read `len' bytes starting at`offset' or from start of mtd`partition'to memory at `addr'
sf write addr offset|partition len      - write `len' bytes from memoryat `addr' to flash at `offset'or to start of mtd `partition'
sf erase offset|partition [+]len        - erase `len' bytes from `offset'or from start of mtd `partition'`+len' round up `len' to block size
sf update addr offset|partition len     - erase and write `len' bytes from memoryat `addr' to flash at `offset'or to start of mtd `partition'
sf protect lock/unlock sector len       - protect/unprotect 'len' bytes startingat address 'sector'=> sf probe
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB

嵌入式Linux--U-Boot(八)SPI Flash命令使用相关推荐

  1. linux spi 工作模式,嵌入式linux系统的开发——SPI Bit-banging方法的实现

    前言 SPI(Serial Peripheral Interface)是一种应用广泛的通信总线,通常微处理器上会集成SPI模块以支持该通信协议,输出正确的信号的时序,并保证时序间同步,实现与外部SPI ...

  2. 【linux学习笔记八】常用命令

    查询与自动挂载 #查询系统中已经挂载的设备 mount#依据配置文件/etc/fstab的内容,自动挂载 mount -a 挂载命令格式 mount [-t 文件系统] [-o 特殊选项] 设备文件名 ...

  3. loading linux img2a,嵌入式Linux中initrd的应用--浅析ramdisk、ramfs、initrd和initramfs

    看到这样的一句话很让我费解,因为似乎我理解为这样做能够提高一点嵌入式linux启动速度,我对此是非常地感兴趣 自此,就开始了我的解惑之旅 首先需要知道的是ramdisk和ramfs http://ww ...

  4. 嵌入式Linux驱动笔记--转自风筝丶

    为了阅读学习方便,将系列博客的网址进行粘贴,感谢原博客的分享. 嵌入式Linux驱动笔记(一)------第一个LED驱动程序 嵌入式Linux驱动笔记(二)------定时器 嵌入式Linux驱动笔 ...

  5. 嵌入式linux的运行过程,嵌入式linux的启动流程--详解

    开门见山: 1.嵌入式linux启动第一步----Boot Loader Boot Loader在这里我就不细说了,详细分析起来的话有很多内容,网上也有很多讲解很详细的文章.这段小程序中我们可以初始化 ...

  6. 嵌入式 Linux 入门(十、Linux 下的 C 编程)

    嵌入式 Linux 入门第十课,聊聊 linux 下的 C 编程...... 矜辰所致 插一句,问题讨论群在文末的推广,以后大家提问可以在群中,即便我不在也能看到历史记录. 目录 前言 一.C 语言编 ...

  7. 嵌入式linux的u-boot系统启动过程,嵌入式linux操作系统u-boot启动顺序以及代码解析...

    嵌入式linux操作系统u-boot启动顺序以及代码解析 (9页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 9.9 积分 Bootloader/u-bo ...

  8. ESP32 ECO3 手动启用 Secure Boot V2 与 flash 加密流程

    本篇文档用来说明 ESP32 ECO3 芯片同时使能 Secure Boot V2 和 flash 加密的操作流程,其中,flash 加密使用发布模式(Release Mode),使用主机生成的密钥对 ...

  9. 嵌入式linux与windows之间的tftp文件传输(保姆级)

    目录 前言 一.为什么要文件传输 二.利用共享文件夹(简要流程) 三.tftp传输与环境搭建 四.传输前的准备工作 五.测试准备工作是否完成 六.传输文件 6.1.windows中tftp32的配置 ...

最新文章

  1. 在Facebook做产品是一种什么样的体验?
  2. Apk打包-签名过程
  3. 小爱同学与小冰将实现联合进步
  4. Spring Boot + Security + Thymeleaf + Activiti 快速开发平台项目
  5. 探究 Spring 的定时任务配置
  6. 第一部分----HTML的基本结构与基本标签
  7. android中xmlns的作用
  8. 4.PHP核心技术与最佳实践 --- 数据库(队列)
  9. ASP.NET---动态生成Word文档
  10. NTPWEdit通过直接修改SAM文件离线更改密码
  11. AdapterVIew
  12. 新人Unity下载安装
  13. charles请求转发_使用Charles代理进行请求转发
  14. xp计算机怎样看ip地址,XP电脑ip地址怎么查看?XP系统怎么样查看电脑的IP地址?...
  15. 2021年最值得推荐的29个开源软件,想提升自己的程序员赶快收藏
  16. 什么是“秒杀”?为什么传统项目中也有“秒杀”的概念?一起来分析一下.
  17. OCPC不起量该怎么办?从这四个方面着手,轻松起量
  18. Android获取设备ID号
  19. 申宝证券-题材股活跃沪指尾盘收红
  20. 用mysql查询图书的信息_PHP+MySQL 利用mysql_fetch_row模糊查询图书信息

热门文章

  1. 【ERP】ERP发展阶段有哪些?对ERP发展各个阶段概念的理解(20年3月29日第二章学习笔记)
  2. 为什么要cssc初始化
  3. MT7620的WIFI带机量
  4. linux系统移植篇(二)—— Uboot使用介绍
  5. 广工 AnyviewC 数据结构习题 第四章
  6. 杰理之PC端下载烧录工具(需要配合强制升级工具)【篇】
  7. C# 开发WCF基本步骤(以控制台为宿主)
  8. 如何自学维修计算机,怎样快速学习汽车电脑维修?从入门到精通
  9. 源码分享篇:使用Python进行QQ批量登录
  10. Linux(Ubuntu16)下gedit自动补齐代码功能