Configuring nvsram (anvo) 1Mb on board with i.mx8mp

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuring nvsram (anvo) 1Mb on board with i.mx8mp

1,256 Views
gaurav_bankar
Contributor II

Hello, 

  I want to configure nvSRAM ANV32AA1W from anvo into my customized board with i.mx8mp processor. 

  I have included it in DTS as follows 

&ecspi2 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>;  
cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>;
status = "okay";
 
nvram: nvram@0 {  
compatible = "anvo,anv32aa1w", "atmel,at25";
reg = <0>;
spi-max-frequency = <20000000>;
spi-cpha;
spi-cpol;
pagesize = <128>;
size = <131072>;
address-width = <24>;
};
};
 
and pinctrl as follows 
 
pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK 0x82
MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI 0x82
MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO 0x82
>;
};
 
pinctrl_ecspi2_cs: ecspi2cs {
fsl,pins = <
MX8MP_IOMUXC_ECSPI2_SS0__GPIO5_IO13 0x40000
>;
};
 
Is this correctly mentioned in the DTS? I am not able to see this device in the /dev directory. How can I access this memory in the user space? 
0 Kudos
Reply
5 Replies

1,111 Views
gaurav_bankar
Contributor II

Hello @Sanket_Parekh

  We have changed our dts to be compatible with microchip mchp23k256/mchp23lcv1024. This is the driver for microchip SPI based sram. 

 Here is the DTS 

&ecspi2 {
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi2>;  
status = "okay";
 
nvram:spi-sram@0{  
#address-cells = <1>;
#size-cells = <1>;  
  compatible = "anvo,anv32aa1w","microchip,mchp23lcv1024";
reg = <0>;
spi-max-frequency = <40000000>;             
 
};
};
 
here is the iomux pincrtl
 
pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK 0x1c2
MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI 0x1c2
MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO 0x82
MX8MP_IOMUXC_ECSPI2_SS0__ECSPI2_SS0 0x1c2
>;
};
 
With this change I am able to get nvram as a mtd device 
 
root@taswp500:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00000000 "spi0.0"
mtd1: 02000000 00010000 "30bb0000.spi"
 
But the erasesize is zero.
 
root@taswp500:/sys/bus/nvmem/devices# ls
imx-ocotp0 mtd0 mtd1
root@taswp500:/sys/bus/nvmem/devices# cd mtd0/
root@taswp500:/sys/bus/nvmem/devices/mtd0# ls -l
total 0
-r--r--r-- 1 root root 4096 Jun 12 10:52 consumers
-r-------- 1 root root 0 Jun 12 10:52 nvmem
drwxr-xr-x 2 root root 0 Jun 12 10:52 power
lrwxrwxrwx 1 root root 0 Jun 12 10:08 subsystem -> ../../../../../../../../../../../bus/nvmem
-r--r--r-- 1 root root 4096 Jun 12 10:52 suppliers
-r--r--r-- 1 root root 4096 Jun 12 10:52 type
-rw-r--r-- 1 root root 4096 Jun 12 10:08 uevent
 
As per your previous comment,  I am not able to read/write at /sys/bus/nvmem/devices/<device_name>/nvmem. 
What should I do next? 
 
 
 
0 Kudos
Reply

1,147 Views
gaurav_bankar
Contributor II

Hello, 

  Thank you for your reply.

I have made the necessary changes as per above suggestions

 CONFIG_NVMEM = y and CONFIG_EEPROM_AT25=y

I have also changed iomux pincrtl as follows 

pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX8MP_IOMUXC_ECSPI2_SCLK__ECSPI2_SCLK 0x1c2
MX8MP_IOMUXC_ECSPI2_MOSI__ECSPI2_MOSI 0x1c2
MX8MP_IOMUXC_ECSPI2_MISO__ECSPI2_MISO 0x82
MX8MP_IOMUXC_ECSPI2_SS0__GPIO5_IO13 0x82
>;
};
 
But I am not getting any devices in /sys/bus/nvmem/devices/. 
Am I still missing anything? Please suggest any solution. Thank you.
0 Kudos
Reply

1,203 Views
gaurav_bankar
Contributor II

Hello @Sanket_Parekh , 

 Thank you for the clarification. I will make sure the option is enabled in the kernel configuration and test it. Here is the bootlog. 

 Also after everything is correct will I get an entry in /dev as /dev/nvram? How will my nvram be mounted in the rootfs?

0 Kudos
Reply

1,182 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @gaurav_bankar 

I hope you are doing well.
 
Please add the below-mentioned option in the kernel for the nvmem interface.
CONFIG_NVMEM = y
 
Please use the below command to list nvmem devices.
# ls /sys/bus/nvmem/devices/
 
Also after everything is correct will I get an entry in /dev as /dev/nvram?
[Ans]: /dev/nvram might not be available 
 
 One can read nvmem data using the below-mentioned command.
# hexdump /sys/bus/nvmem/devices/<device_name>/nvmem
 
One can read/write nvmem data at /sys/bus/nvmem/devices/<device_name>/nvmem.
 
Please refer to the below-mentioned kernel documentation.
 
Thanks & Regards,

Sanket Parekh

0 Kudos
Reply

1,224 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport
 
I hope you are doing well.
 
device tree changes look correct.
 
Please make sure that the driver with compatible properties "anvo,anv32aa1w", "atmel,at25"; is correctly enabled in the kernel configuration.
 
Please make sure that below mentioned option is enabled in the kernel configuration.
CONFIG_EEPROM_AT25=y
 
Please share boot logs for further debugging.
 
Thanks & Regards
Sanket Parekh
0 Kudos
Reply