write MAC address to I.MX 8M Nano from Linux user space

cancel
Showing results for 
Search instead for 
Did you mean: 

write MAC address to I.MX 8M Nano from Linux user space

125 Views
embedded_eng_
Contributor III

Hi,

I have a I.MX 8M Nano chip in my PCB and In need to write to it a MAC address from Linux user space.

I have modified my devicetree to include ocotp, so I can see the nvmem part in sysfs.

/sys/devices/platform/soc@0/{SOME_ID}.bus/{SOME_ID}.ocotp-ctrl/imx-ocotp0/nvmem

 

Now, I need a way to write the MAC address, 

I've tried something like:

fseek(fp, 0x90, SEEK_SET);
fwrite(mac, 1, 6, fp);
fclose(fp);

 

When MAC is the mac address I want to write (little endian).

For example, the MAC address is: aa:bb:b4:11:17:85

This code resulted in:

00000090 85 17 11 b4 00 00 00 00 00 00 00 00 00 00 00 00 |................|

 

Clearly the write failed.

I've expect something like:

00000090  85 17 11 b4 bb aa 00 00  00 00 00 00 00 00 00 00  |................|

 

What am I doing wrong?

How should I change the code in order to make it work?

 

* I'm know that I can write the MAC address using fuse prog in U-boot, or using UUU, but I need it to be in Linux user space.

* I know that the write action is irreversible.

 

Thanks

 

 

0 Kudos
2 Replies

110 Views
igorpadykov
NXP TechSupport
NXP TechSupport
0 Kudos

100 Views
embedded_eng_
Contributor III

Thanks

0 Kudos