1      Scope of Document

This document describes SPI F-RAM hardware design

2      Requiremen

2.1     Function Requirement

support spi f-ram fm25l16b in linux

2.2     Performance Requirement

NA

3      Hardware Overview

standard spi interface, four line cs sck mosi miso;

4      Functional Description

4.1     Functional Block Diagram

4.2     SPI F-RAM

4.2.1 Overview

advantage:

1) High-endurance 100 trillion (1014) read/writes.

2) Very fast serial peripheral interface

5      Porting

5.1     3.2.0 Kernel porting

Device Drivers  --->

[*] Misc devices  --->

EEPROM support  --->

<*> SPI EEPROMs from most vendors

Register platform source:

static struct spi_eeprom fram = {

.byte_len  = SZ_16K / 8,

.name      = "fm25l16b",

.page_size = 256,

.flags     = EE_ADDR2,

};

static struct spi_board_info am335x_spi0_slave_info[] = {

{

.modalias       = "at25",

.platform_data   = &fram,

.max_speed_hz  = 2 * 1000 * 1000,

.bus_num       = 1,

.chip_select     = 0,

.irq             = -1,

.mode          = SPI_MODE_0,

},

};

/* setup spi0 */

static void spi0_init(int evm_id, int profile)

{

setup_pin_mux(spi0_pin_mux);

spi_register_board_info(am335x_spi0_slave_info,

ARRAY_SIZE(am335x_spi0_slave_info));

return;

}

Kernel log:

at25_proble

at25 spi1.0: 2 KByte fm25l16b eeprom, pagesize 256

Device access interface:

/sys/bus/spi/devices/spi1.0/eeprom

5.2     4.14.40 Kernel porting

Add in kernel configure option

Device Drivers  --->

[*] Misc devices  --->

EEPROM support  --->

<*> SPI EEPROMs from most vendors

Change the dts file for support F-RAM

spi0_pins: pinmux_spi0 {

pinctrl-single,pins = <

AM33XX_IOPAD(0x950, PIN_INPUT_PULLUP | MUX_MODE0) /* spi0_sclk.spi0_sclk */

AM33XX_IOPAD(0x95C, PIN_INPUT_PULLUP | MUX_MODE0) /* spi0_cs0.spi0_cs0 */

AM33XX_IOPAD(0x954, PIN_INPUT_PULLUP | MUX_MODE0) /* spi0_d0.spi0_d0 */

AM33XX_IOPAD(0x958, PIN_INPUT_PULLUP | MUX_MODE0) /* spi0_d1.spi0_d1 */

>;

};

};

&spi0 {

status = "okay";

pinctrl-names = "default";

pinctrl-0 = <&spi0_pins>;

fram@0 {

reg = <0x0>;

compatible = "atmel,at25", "cypress,fm25l16b";

spi-max-frequency = <2000000>;

pagesize = <256>;

size = <2048>;

address-width = <16>;

};

};

Kernel log:

[    1.107399] at25 spi0.0: 2 KByte at25 eeprom, pagesize 256

Device access interface:

/sys/bus/nvmem/devices/spi0.00/nvmem

Note: in kernel 4.14.40 spi eeprom driver was register under nvmem framwork, so the device access interface different from 3.2.0 device interface.

6      Test Method

read/write test code in 3.2.0

int main ( int argc, char** argv )

{

int ret, fd, i, j;

char read_data[256];

char write_data[256];

char offset;

fd = open ( "/sys/bus/spi/devices/spi1.0/eeprom", O_RDWR );

if ( fd < 0 ) {

perror ( "Open at24c08 fail\n" );

return -1;

}

for ( i = 0; i < 256; i++ )

write_data[i] = i;

lseek ( fd, 0 , SEEK_SET );

ret = write ( fd, write_data, 256 );

if ( ret < 0 ) {

printf ( "Write error\n" );

return -1;

}

lseek ( fd, 0 , SEEK_SET );

ret = read ( fd, read_data, 256 );

if ( ret < 0 ) {

printf ( "Read error\n" );

return -1;

} else if ( ret < 256 ) {

perror ( "Incomplete read\n" );

printf ( "%d\n", ret );

return -1;

}

for ( i = 0; i < 256; i++ ) {

if ( i % 16 == 0 )

printf ( "\n" );

printf ( " %03d ", read_data[i] );

}

printf ( "\n" );

}

Using hexdump tool, read spi f-ram data

# hexdump -C  /sys/bus/spi/devices/spi1.0/eeprom

00000000  08 74 65 73 74 5f 70 70  70 00 00 00 00 00 00 00  |.test_ppp.......|

00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000800

read/write test methon in 4.14.40

root@IoTP:/sys/bus/nvmem/devices/spi0.00# echo "./test_123"  >  nvmem

root@IoTP:/sys/bus/nvmem/devices/spi0.00# hexdump -C nvmem

00000000  2e 2f 74 65 73 74 5f 31  32 33 0a 00 00 00 00 00  |./test_123......|

00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

*

00000800

最新文章

  1. &lt;![CDATA[ ]]&gt; 的作用
  2. csharp: DataRelation objects to represent a parent/child/Level relationship
  3. PopupWindow错误:PopupWindow$1.onScrollChanged 出现 NullPointerException和PopupViewContainer.dispatchKeyEvent 出现 NullPointerException
  4. Java 集合深入理解(13):Stack 栈
  5. windows7 图形界面远程 centos6.5
  6. 深入了解一下PYTHON中关于SOCKETSERVER的模块-C
  7. eclipse代码注释的设置
  8. jQuery(5)——动画
  9. 自定义 IP 地址
  10. 2017年1月1日 App Store中的所有应用都必须启用 App Transport Security安全功能
  11. 【前端】react学习阶段总结,学习react、react-router与redux的这些事儿
  12. 理解性能的奥秘——应用程序中慢,SSMS中快(4)——收集解决参数嗅探问题的信息
  13. MSDN i TELL YOU 又更新了,win10 1809版本的 3月29日的
  14. js语言规范_ES5-6-7_个人总结
  15. 选择排序&lt;C#&gt;
  16. Python基础01_介绍_HelloWorld
  17. React 回忆录(二)为什么使用 React?
  18. 在MySQL或者SQLServer中,添加对象后自动返回主键到对象模型中的配置方式
  19. JAVAEE——宜立方商城02:服务中间件dubbo、工程改造为基于soa架构、商品列表实现
  20. Oracle案例02——ORA-12034: &quot;SCOTT&quot;.&quot;USER_TABLE&quot; 上的实体化视图日志比上次刷新后的内容新

热门文章

  1. gentoo emerge简单用法
  2. golang方法和函数的区别
  3. 【C#】上机实验五
  4. Navicat premium工具转储数据表的结构时,datatime字段报错
  5. C#中Unity对象的注册方式与生命周期解析
  6. easy ui 常用控件配置
  7. windows下pyinstaller打包踩坑记录
  8. C++ | 使用const std::map,map::[]时遇到的一个bug
  9. 禁止迅雷极速版被强制升级为迅雷x
  10. CSS是什么