IMX6 - How to use nvmem driver to read out a specific OCOTP value (e.g., HW_OCOTP_MAC0) in bash

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IMX6 - How to use nvmem driver to read out a specific OCOTP value (e.g., HW_OCOTP_MAC0) in bash

1,447件の閲覧回数
hmliu
Contributor I

Hello,

we tried to use nvmem driver instead of fsl_otp driver for OCOTP read on imx6 board.

The nvmem driver works good and we can use hexdump -C nvmem to read out the OCOTP value.

In next step, we want to have some thing similar to those, which are given by fsl_otp driver, so that we can also use command in bash shell like cat HW_OCOTP_MAC0 to read out a specific value.

[/sys/fsl_otp]ls
...
HW_OCOTP_MAC0
HW_OCOTP_MAC1
...
[/sys/fsl_otp]# cat HW_OCOTP_MAC0
0x3306ea24

So we think maybe we can do this by changing the dts file: we modified our dts file and added two childnode (e.g., MAC0 and MAC1) under ocotp-fuse section.

      ocotp: ocotp-ctrl@021bc000 {
        compatible = "syscon";
        reg = <0x021bc000 0x4000>;
        clocks = <&clks 128>;
      };

      ocotp-fuse@021bc000 {
        compatible = "fsl,imx6q-ocotp";
        reg = <0x021bc000 0x4000>;
        clocks = <&clks 128>;

        //Subnodes:
        MAC0:mac_addr0@620 {
          compatible = "fsl,imx6q-ocotp";
          reg = <0x620 0x4>;
        };

        MAC1:mac_addr1@630 {
          compatible = "fsl,imx6q-ocotp";
          reg = <0x630 0x4>;
        };
      };

We built a new image and ran it on our device. However, we can not read out the specific OCOTP value for e.g, mac_addr0. Under mac_addr0@620 directory, is it possible to also have a nvmem interface, so that we can use hexdump -C nvmem to read out the MAC0 value?

[/sys/devices/soc0/soc/2100000.aips-bus/21bc000.ocotp-fuse/imx-ocotp0]# ls
nvmem      of_node    power      subsystem  type       uevent
[/sys/firmware/devicetree/base/soc/aips-bus@02100000/ocotp-fuse@021bc000]# ls -l 
-r--r--r--    1 root     root             8 Apr  9 09:24 clocks
-r--r--r--    1 root     root            16 Apr  9 09:24 compatible
drwxr-xr-x    2 root     root             0 Apr  9 09:24 mac_addr0@620
drwxr-xr-x    2 root     root             0 Apr  9 09:24 mac_addr1@630
-r--r--r--    1 root     root            11 Apr  9 09:24 name
-r--r--r--    1 root     root             8 Apr  9 09:24 reg
[/sys/firmware/devicetree/base/soc/aips-bus@02100000/ocotp-fuse@021bc000/mac_addr0@620]# ls
compatible  name        reg

Any help would be great! I am new to imx6 board and dts file. I am not sure that i did it in the right way. It would be nice for me, if i am able to read out  only the HW_OCOTP_MAC0 value in bash shell just like by using fsl_otp driver.

best,

hmliu

ラベル(2)
0 件の賞賛
2 返答(返信)

1,437件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi Hangmao

 

for nvmem one can look at

https://community.nxp.com/t5/i-MX-Processors/OCOTP-write-support-on-i-mx8m/td-p/825028

 

Best regards
igor

0 件の賞賛

1,424件の閲覧回数
hmliu
Contributor I

Hi Igor,

thanks for the reply!

I looked at the link you posted and managed to use fread() to read out the HW_OCOTP_MAC0 value.

I stored its value to a file, so that i can use cat command to get the value in the linux shell.

Btw,

do you think we can also do this by just changing the dts file? For example, we add multiple sub-nodes under ocotp-fuse@021bc000 section.

 

Best,

Hangmao

0 件の賞賛