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

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

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

1,469 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
5 Replies

1,010 Views
sneha_mohan
Contributor I

hello embedded_eng_, did the above patch fix your issue, i am facing similar issue while trying to write the mac address to the nvmem. Only 4 bytes are getting updated out of the 6 bytes. I already have the above patches(suggested by NXP) present in my driver code, but that didn't fix the issue for me. Could you please let me know how you tackled this issue.

Thanks in Advance, Sneha

0 Kudos

977 Views
embedded_eng_
Contributor III

Hi,

I don't remember if I used the patch, but I do remember that I ended writing the MAC address with a c code, splitting the MAC address to 2 different words.

0 Kudos

1,096 Views
sneha_mohan
Contributor I

Hello team,

I have a I.MX 8M Plus chip on my PCB and In need to write to it a MAC address from Linux user space. The patch mentioned in the https://community.nxp.com/t5/i-MX-Processors/OCOTP-write-support-on-i-mx8m/m-p/825028?commentID=1161... is already present in drivers/nvmem/imx-ocotp.c. Could you please let me know how to write the MAC address from userspace for Aa:Bb:Cc:Dd:Ee:Ff. I dont want to risk corrupting the board

0 Kudos

1,454 Views
igorpadykov
NXP Employee
NXP Employee
0 Kudos

1,444 Views
embedded_eng_
Contributor III

Thanks

0 Kudos