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

am335x system upgrade kernel f-ram fm25l16b(十六)的更多相关文章

  1. am335x system upgrade kernel usb stroage(十)

    1      Scope of Document This document describes USB hardware design, support stardard usb2.0 port o ...

  2. am335x system upgrade kernel emmc(十八)

    1      Scope of Document This document describes EMMC hardware design 2      Requiremen 2.1     Func ...

  3. am335x system upgrade kernel tf(五)

    1      Scope of Document This document describes TF hardware design 2      Requiremen 2.1     Functi ...

  4. am335x system upgrade kernel ethernet(四)

    1      Scope of Document This document describes ethernet hardware design and porting KZS8081 to ubo ...

  5. am335x system upgrade kernel gpio(九)

    1      Hardware Overview gpio interface,pin map: AM335X_I2C0_W_C----------------------MCASP0_AXR1 /* ...

  6. am335x system upgrade kernel can(八)

    1      Scope of Document This document describes can bus hardware design and can bus driver developm ...

  7. am335x system upgrade kernel uart(七)

    1      Scope of Document This document describes UART hardware design, uart driver porting 2      Re ...

  8. am335x system upgrade kernel i2c rtc eeprom(六)

    1      Scope of Document This document describes i2c bus hardware design and support i2c-devices: ee ...

  9. am335x system upgrade kernel ec20 simcom7600ce(十一)

    1      Scope of Document This document describes 4G hardware design, support quectel ec20 4G module/ ...

随机推荐

  1. JSP页面验证码实现

    首先在JSP页面加上生成图片的链接 <img type="image" src="auth/authCode" id="codeImage&qu ...

  2. 百度云服务接口错误:Parameter invalid, the key input with filter parameter is not searchfilter column key

    百度LBS云服务接口: 地址:http://lbsyun.baidu.com/index.php?title=lbscloud/api/geosearch 访问接口:http://api.map.ba ...

  3. Java线程volatile(二)

    volatile:使变量在多个线程中可见 在java 中每个线程都会有一块工作内存区,其中存放着所有线程共享的主内存中变量的拷贝.当线程执行时,在自己的工作内存区操作这些变量,为了存取一个共享的变量, ...

  4. 如何为非常不确定的行为(如并发)设计安全的 API,使用这些 API 时如何确保安全

    原文:如何为非常不确定的行为(如并发)设计安全的 API,使用这些 API 时如何确保安全 .NET 中提供了一些线程安全的类型,如 ConcurrentDictionary<TKey, TVa ...

  5. 使用 SetParent 制作父子窗口的时候,如何设置子窗口的窗口样式以避免抢走父窗口的焦点

    原文:使用 SetParent 制作父子窗口的时候,如何设置子窗口的窗口样式以避免抢走父窗口的焦点 制作传统 Win32 程序以及 Windows Forms 程序的时候,一个用户看起来独立的窗口本就 ...

  6. C#使用Selenium

    介绍: Selenium 是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.支持的浏览器包括IE(7, 8, 9, 10, 11),Mozilla ...

  7. Bootstraps 4 引入报错 Error: Bootstrap tooltips require Tether

    问题: 解决办法 (http://github.hubspot.com/tether/) Bootstrap 4 needs Tether, so you need to include tether ...

  8. 【译】Python数据结构

    本章将更详细地描述您已经学到的一些内容,并添加了一些新的内容. 5.1 关于列表的更多内容 列表数据类型有一些更多的方法. 以下是列表对象的所有方法: list.append(x) 将项目添加到列表的 ...

  9. zubax_gnss移植到STM32F407

    源码下载:https://github.com/Zubax/zubax_gnss.git 源码默认支持STM32F107芯片 STM32 HAL库测试:zubax_gnss\bootloader\zu ...

  10. mysql FORMAT() 格式化后的数字运算出错

    原文链接 FORMAT()  之后   会满三位加逗号, 在此基础上进行数字运算的时候会出现预料之外的结果, 建议使用 : convert(param, decimal(12,2)) cast(par ...