最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】uboot eeprom read用法

Uboot crifan 4731浏览 0评论

uboot eeprom read

[U-Boot-Users] how to use ‘eeprom read’ command

<code>&gt; =&gt; help eeprom
&gt; eeprom read  devaddr addr off cnt
&gt; eeprom write devaddr addr off cnt
&gt;        - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'
&gt; 
&gt; --------------------------------------------------------------------------
&gt; 
&gt; I want to access boot eprom which is at 'devaddr' 0x54 and offset '0' to 
&gt; '10'.
&gt; 
&gt; But I am not clear what ro pass for the 'addr' argument.
&gt; 
&gt; Regards,
&gt; Sachin Rane

IIRC, &quot;addr&quot; is the memory (RAM) address that you read the eeprom data 
into or is the source tow rite the eeprom data out.  To read your i2c 
device 0x54, you would do something like:
   eeprom read 54 0 0 10
and then would be able to see the 16 bytes of data with the md command:
   md 0
</code>

bootloaders:u-boot:serial-flash-eeprom [Analog Devices Open Source| Mixed-signal and Digital Signal Processing ICs]

Querying

At runtime, you can interrogate the SPI flash to make sure things are detected properly.

bfin> eeprom info

SPI Device: S25LF032 0x01 (Spansion) 0x02 0x16

Parameters: num sectors = 64, sector size = 65536, write size = 256

Flash Size: 32 mbit (4 mbyte)

Status: 0x00

Here we can see that there is a 32 megabit Spansion flash hooked up. Good times.

Reading

You use the eeprom 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> eeprom read 0x2000000 0x300 0x1000

EEPROM @0x0 read: addr 02000000 off 0300 count 4096 … done

bfin> md.b 0x2000000

02000000: 0e e1 00 10 4e e1 b0 ff 90 61 10 3e 01 60 21 36 ….N….a.>.`!6

02000010: 29 36 31 36 39 36 01 3c 19 3c fc 31 00 e3 56 00 )61696.<.<.1..V.

02000020: 03 60 43 e1 00 20 98 09 03 18 00 e3 91 31 0e 60 .`C.. …….1.`

02000030: 00 e3 4c 00 02 e1 34 00 42 e1 fc 03 03 e1 00 00 ..L…4.B…….

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.

You can ignore the @0x0 output in the output above. It does not apply to serial flashes.

Writing

You use the eeprom 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> eeprom write 0x20000000 0x0 0x100000

EEPROM @0x0 write: addr 20000000 off 0000 count 1048576 … …………………………..done

There is no need for you to issue a separate erase command as the U-Boot driver will take care of that. There is also no need for you to worry about writing out only a page of data at a time.

You can ignore the @0x0 output in the output above. It does not apply to serial flashes.

U-Boot I2C EEPROM

u-boot移植随笔:EEPROM移植及测试 – 木草山人和水田居士的小窝 – 博客频道 – CSDN.NET

EEPROM @0x50 read: addr 33000000  off 0000  count 8 … done  

LATE2440> md.b 33000000 8         读出的为0  

33000000: 00 00 00 00 00 00 00 00    ……..  

LATE2440> mm.b 33000000          修改内存中的数据  

33000000: 00 ? 6c  

33000001: 00 ? 61  

33000002: 00 ? 74  

33000003: 00 ? 65  

33000004: 00 ? 20  

33000005: 00 ? 6c  

33000006: 00 ? 65  

33000007: 00 ? 65  

33000008: 00 ? q 退出  

LATE2440> md.b 33000000 8    检查内存数据是否正确  

33000000: 6c 61 74 65 20 6c 65 65    late lee  

LATE2440> eeprom write 33000000 0 8  写到eeprom中  

   

EEPROM @0x50 write: addr 33000000  off 0000  count 8 … done  

LATE2440> eeprom read 33000030 0 8 读到另一个地址  

   

EEPROM @0x50 read: addr 33000030  off 0000  count 8 … done  

LATE2440> md.b 33000030 8    查看这个地址  

33000030: 6c 61 74 65 20 6c 65 65    late lee  

   

重启后再读到另一个地址  

LATE2440> eeprom read 30008000 0 8  

   

EEPROM @0x50 read: addr 30008000  off 0000  count 8 … done  

LATE2440> md.b 30008000 8  查看  

30008000: 6c 61 74 65 20 6c 65 65    late lee  

LATE2440> mm.b 30008000  修改  

30008000: 6c ? 4c  

30008001: 61 ?  (回车)  

30008002: 74 ?   

30008003: 65 ?   

30008004: 20 ?   

30008005: 6c ? 4c  

30008006: 65 ?   

30008007: 65 ?   

30008008: 00 ? q 退出  

LATE2440> eeprom write 30008000 0 8 写入eeprom  

   

EEPROM @0x50 write: addr 30008000  off 0000  count 8 … done  

LATE2440> eeprom read 30000000 0 8 读到另一个地址  

   

EEPROM @0x50 read: addr 30000000  off 0000  count 8 … done  

LATE2440> md.b 30000000 8 查看  

30000000: 4c 61 74 65 20 4c 65 65    Late Lee  

LATE2440>   

   

注:进行eeprom操作出现的地址、数据等等,均为16进制。   

    转载请注明:在路上 » 【整理】uboot eeprom read用法

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.182 seconds, using 22.12MB memory