Difference between revisions of "DESK-MX8M-L/Deployment/MAC Address programming"

From DAVE Developer's Wiki
Jump to: navigation, search
 
(12 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
 
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
 
|-  
 
|-  
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Version
 
 
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
 
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
 
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
 
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
 
|-
 
|-
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|1.0.0
+
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |{{oldid|16739|2022/07/01}}
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Jun 2022
+
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |First DESK-MX8M-L release
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|First release
 
 
|-
 
|-
 +
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |2023/08/24
 +
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |DESK-MX8M-L-4.0.0 release
 
|}
 
|}
 
<section end=History/>
 
<section end=History/>
 +
__FORCETOC__
  
__FORCETOC__
 
 
<section begin=Body/>
 
<section begin=Body/>
  
Line 24: Line 24:
 
The MAC address is a six-pair set of hexadecimal numbers, for example <code>a1-c2-e3-44-5f-6d</code>. Specifically, in Ethernet, the MAC address is known as the Ethernet Address, which is the unique ID serial number of the Ethernet device in one's computer. MAC Addresses are used in a Local Area Network (LAN) by computers to communicate with each other. Every adapter has a unique MAC address.
 
The MAC address is a six-pair set of hexadecimal numbers, for example <code>a1-c2-e3-44-5f-6d</code>. Specifically, in Ethernet, the MAC address is known as the Ethernet Address, which is the unique ID serial number of the Ethernet device in one's computer. MAC Addresses are used in a Local Area Network (LAN) by computers to communicate with each other. Every adapter has a unique MAC address.
  
In this Application Note, we will describe how to use the i.MX8M eFuse for programming and using the MAC address(es).
+
=== Platform supported===
 +
In this Application Note, we will describe how to use the i.MX8M eFuse for programming and using the MAC address(es) and it applies to the following DAVE <code>i.MX8M family</code> products:
 +
* [[ORCA SOM | ORCA]]
 +
* [[MITO 8M SOM | MITO8M]]
 +
* [[MITO 8M Mini SOM| MITO 8M Mini]]
 +
 
 +
{{ImportantMessage|text=This Application Note has been validated in the [[ORCA SOM | ORCA SOM]]. The commands used have been not validated in the other platform yet.}}
  
 
=== Obtaining a MAC address ===
 
=== Obtaining a MAC address ===
Line 44: Line 50:
 
  eth0: ethernet@30be0000
 
  eth0: ethernet@30be0000
  
If the <code>ethaddr</code> is set and saved in the u-boot environment, it's value is used as the MAC Address:
+
If the <code>ethaddr</code> is set and saved in the u-boot environment, its value is used as the MAC Address:
  
  u-boot=> setenv ethaddr 00:50:C2:1E:AF:CB
+
  u-boot=> setenv ethaddr 00:50:c2:1e:af:a8
 
  u-boot=> saveenv
 
  u-boot=> saveenv
 
  Saving Environment to MMC... Writing to MMC(1)... OK
 
  Saving Environment to MMC... Writing to MMC(1)... OK
Line 55: Line 61:
  
 
The related HW_OCOTP_MAC_ADDR0, HW_OCOTP_MAC_ADDR1, HW_OCOTP_MAC_ADDR2 OTP registers will be used for the purposes illustrated in this AN.
 
The related HW_OCOTP_MAC_ADDR0, HW_OCOTP_MAC_ADDR1, HW_OCOTP_MAC_ADDR2 OTP registers will be used for the purposes illustrated in this AN.
 +
 +
{{ImportantMessage|text='''Warning!!''' eFuse programming is a permanent and non reversible action. Pay attention to the values and commands used during MAC programming.}}
  
 
==== eth0 eFuse programming ====
 
==== eth0 eFuse programming ====
 +
 
U-Boot uses the <code>fuse prog</code> command for writing the MAC address into the eFuse. The MAC address should be divided in high 16 bit and low 32 bits, for example MAC address <code>AB:CD:12:34:56:78</code> for eth0 is then divided into :
 
U-Boot uses the <code>fuse prog</code> command for writing the MAC address into the eFuse. The MAC address should be divided in high 16 bit and low 32 bits, for example MAC address <code>AB:CD:12:34:56:78</code> for eth0 is then divided into :
  
Line 64: Line 73:
 
</pre>
 
</pre>
  
In the following example the MAC address <code>00:50:c2:1e:af:cd</code> is stored in the SOC:
+
In the following example the MAC address <code>00:50:c2:1e:af:a8</code> is stored in the SOC:
 
* (in case of presence) clear the <code>ethaddr</code> u-boot variable
 
* (in case of presence) clear the <code>ethaddr</code> u-boot variable
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 73: Line 82:
 
* program the MAC address in the OPTs with the following commands:
 
* program the MAC address in the OPTs with the following commands:
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
u-boot=> fuse prog 9 0 c21eafcd
+
u-boot=> fuse prog 9 0 c21eafa8
Programming bank 9 word 0x00000000 to 0xc21eafcd...
+
Programming bank 9 word 0x00000000 to 0xc21eafa8...
 
Warning: Programming fuses is an irreversible operation!
 
Warning: Programming fuses is an irreversible operation!
 
         This may brick your system.
 
         This may brick your system.
Line 94: Line 103:
  
 
<pre>
 
<pre>
u-boot=> fuse prog -y 9 0 c21eafcd
+
u-boot=> fuse prog -y 9 0 c21eafa8
 
u-boot=> fuse prog -y 9 1 0050
 
u-boot=> fuse prog -y 9 1 0050
 
</pre>
 
</pre>
Line 106: Line 115:
 
Hit any key to stop autoboot:  0
 
Hit any key to stop autoboot:  0
 
u-boot=> print ethaddr
 
u-boot=> print ethaddr
ethaddr=00:50:c2:1e:af:cd
+
ethaddr=00:50:c2:1e:af:a8
 
u-boot=>
 
u-boot=>
 
</pre>
 
</pre>
Line 118: Line 127:
 
For the second ethernet interface, the above procedure should be repeated in a similar way, except of ''the correct ''eFuse register should be used'':
 
For the second ethernet interface, the above procedure should be repeated in a similar way, except of ''the correct ''eFuse register should be used'':
  
The MAC address should be divided in ''low'' 16 bit and ''high'' 32 bits, for example MAC address <code>00:50:c2:1e:af:ce</code> is stored in the SOC using:
+
The MAC address should be divided in ''low'' 16 bit and ''high'' 32 bits, for example MAC address <code>00:50:c2:1e:af:a9</code> is stored in the SOC using:
  
 
<pre>
 
<pre>
fuse prog -y 9 1 afce0000
+
fuse prog -y 9 1 afa90000
 
fuse prog -y 9 2 0050c21e
 
fuse prog -y 9 2 0050c21e
 
</pre>
 
</pre>
Line 131: Line 140:
 
==== eFuse locking ====
 
==== eFuse locking ====
 
The OTP eFuse registers should be locked in order to avoid unwanted registers (and then MAC addresses) modifications. OTP lock grants the MAC values cannot be modified anymore.
 
The OTP eFuse registers should be locked in order to avoid unwanted registers (and then MAC addresses) modifications. OTP lock grants the MAC values cannot be modified anymore.
 +
 +
{{ImportantMessage|text=If not locked yet, OTP bits can be set to ''''1'''' but not reversed to ''''0'''' value, so some modifications can be applied if the eFuse registers are not locked.
 +
 +
For more information see, for example, the [https://www.nxp.com/webapp/Download?colCode=IMX6SDLRM i.MX6 Dual Lite Reference Manual chap. 47.3.1.3] }}
  
 
The two MAC addresses - even if sharing register <code>bank:9 word:1</code> - can be programmed at different times.
 
The two MAC addresses - even if sharing register <code>bank:9 word:1</code> - can be programmed at different times.
Line 138: Line 151:
 
<pre>
 
<pre>
 
fuse prog -y 0 0 c000
 
fuse prog -y 0 0 c000
 +
</pre>
 +
 +
==== eFuse reading ====
 +
The eFuse registers can be read - after programming - for checking the written values:
 +
 +
<pre class="workstation-terminal">
 +
u-boot=> fuse read 9 0
 +
Reading bank 9:
 +
 +
Word 0x00000000: c21eafa8
 +
u-boot=> fuse read 9 1
 +
Reading bank 9:
 +
 +
Word 0x00000001: afa90050
 +
u-boot=> fuse read 9 2
 +
Reading bank 9:
 +
 +
Word 0x00000002: 0050c21e
 +
u-boot=>
 
</pre>
 
</pre>
  
Line 145: Line 177:
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
root@desk-mx8mp:~# ifconfig
 
root@desk-mx8mp:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:c2:1e:af:cd
+
eth0      Link encap:Ethernet  HWaddr 00:50:c2:1e:af:a8
 
           UP BROADCAST MULTICAST  MTU:1500  Metric:1
 
           UP BROADCAST MULTICAST  MTU:1500  Metric:1
 
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
Line 152: Line 184:
 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  
eth1      Link encap:Ethernet  HWaddr 00:50:c2:1e:af:ce
+
eth1      Link encap:Ethernet  HWaddr 00:50:c2:1e:af:a9
 
           UP BROADCAST MULTICAST  MTU:1500  Metric:1
 
           UP BROADCAST MULTICAST  MTU:1500  Metric:1
 
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0

Latest revision as of 18:21, 27 December 2023

History
Issue Date Notes

2022/07/01

First DESK-MX8M-L release
2023/08/24 DESK-MX8M-L-4.0.0 release



MAC Address programming[edit | edit source]

Every network adapter has a Media Access Control address (usually shortened to MAC address). A MAC address is a six-byte identifying number permanently embedded in the firmware of the adapter, and is readable by the network and the operating system of the device on which the adapter is installed.

The address must follow the standards set by the Institute of Electrical and Electronics Engineers (IEEE), which sets computer networking standards.

The MAC address is a six-pair set of hexadecimal numbers, for example a1-c2-e3-44-5f-6d. Specifically, in Ethernet, the MAC address is known as the Ethernet Address, which is the unique ID serial number of the Ethernet device in one's computer. MAC Addresses are used in a Local Area Network (LAN) by computers to communicate with each other. Every adapter has a unique MAC address.

Platform supported[edit | edit source]

In this Application Note, we will describe how to use the i.MX8M eFuse for programming and using the MAC address(es) and it applies to the following DAVE i.MX8M family products:


200px-Emblem-important.svg.png

This Application Note has been validated in the ORCA SOM. The commands used have been not validated in the other platform yet.

Obtaining a MAC address[edit | edit source]

To obtain a MAC address for your organization, please refer to our Setting the MAC address wiki page with the overall information about this topic.

Permanent storage areas[edit | edit source]

Some SOCs provide programmable OTPs for security, MAC address, boot modes, etc. Usually, some of these are general-purpose registers and can be managed by the user.

In other cases, an external permanent storage device can be used for storing permanent settings like the MAC address: for the i.MX8M product family, DAVE proposes to use the General Purposes eFuses (OTP blocks) on SoC itself for storing permanently the MAC address(es).

MAC address programming on i.MX8M family[edit | edit source]

MAC address configuration in u-boot[edit | edit source]

If the MAC address is not already programmed in the OTPs and the ethaddr u-boot variable is not set, u-boot assignes a random value (different at every power on cycle):

Net:
Warning: ethernet@30be0000 (eth0) using random MAC address - 6e:e5:6d:a2:ea:e5
eth0: ethernet@30be0000

If the ethaddr is set and saved in the u-boot environment, its value is used as the MAC Address:

u-boot=> setenv ethaddr 00:50:c2:1e:af:a8
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(1)... OK
u-boot=>

eFuse bank registers[edit | edit source]

i.MX8M family uses the Bank9 Word0, Word1 and Word2 (if the SoC has two ethernet interfaces) for storing the MAC addresses. The MAC values should be properly divided into the three registers for correct programming.

The related HW_OCOTP_MAC_ADDR0, HW_OCOTP_MAC_ADDR1, HW_OCOTP_MAC_ADDR2 OTP registers will be used for the purposes illustrated in this AN.


200px-Emblem-important.svg.png

Warning!! eFuse programming is a permanent and non reversible action. Pay attention to the values and commands used during MAC programming.

eth0 eFuse programming[edit | edit source]

U-Boot uses the fuse prog command for writing the MAC address into the eFuse. The MAC address should be divided in high 16 bit and low 32 bits, for example MAC address AB:CD:12:34:56:78 for eth0 is then divided into :

fuse prog -y 9 0 0x12345678
fuse prog -y 9 1 0xABCD

In the following example the MAC address 00:50:c2:1e:af:a8 is stored in the SOC:

  • (in case of presence) clear the ethaddr u-boot variable
u-boot=> setenv ethaddr
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(1)... OK
  • program the MAC address in the OPTs with the following commands:
u-boot=> fuse prog 9 0 c21eafa8
Programming bank 9 word 0x00000000 to 0xc21eafa8...
Warning: Programming fuses is an irreversible operation!
         This may brick your system.
         Use this command only if you are sure of what you are doing!

Really perform this fuse programming? <y/N>
y
u-boot=> fuse prog 9 1 0050
Programming bank 9 word 0x00000001 to 0x00000050...
Warning: Programming fuses is an irreversible operation!
         This may brick your system.
         Use this command only if you are sure of what you are doing!

Really perform this fuse programming? <y/N>
y
u-boot=>

If you want to write the eFuse value directly without confirmation, uses the -y parameter with the fuse prog command, as per the previous example:

u-boot=> fuse prog -y 9 0 c21eafa8
u-boot=> fuse prog -y 9 1 0050

At the next boot, the ethaddr value wil be read from the OPTs:

Warning: ethernet@30be0000 using MAC address from ROM
eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
u-boot=> print ethaddr
ethaddr=00:50:c2:1e:af:a8
u-boot=>

The warning message informs that the ethaddr is not present in the u-boot environment and it has been set using the value read from the OTPs. For clearing the warning, it is enough to save the environment with saveenv.

u-boot=> saveenv

eth1 eFuse programming[edit | edit source]

For the second ethernet interface, the above procedure should be repeated in a similar way, except of the correct eFuse register should be used:

The MAC address should be divided in low 16 bit and high 32 bits, for example MAC address 00:50:c2:1e:af:a9 is stored in the SOC using:

fuse prog -y 9 1 afa90000
fuse prog -y 9 2 0050c21e


200px-Emblem-important.svg.png

Be Careful!! Register bank:9 word:1 is shared between first and second interface, so the lowest 16-bits in the register should be set to 0000 avoiding to change the eth0 MAC settings

The eth1addr U-Boot variable is then used for the second ethernet interface MAC address management.

eFuse locking[edit | edit source]

The OTP eFuse registers should be locked in order to avoid unwanted registers (and then MAC addresses) modifications. OTP lock grants the MAC values cannot be modified anymore.


200px-Emblem-important.svg.png

If not locked yet, OTP bits can be set to '1' but not reversed to '0' value, so some modifications can be applied if the eFuse registers are not locked.

For more information see, for example, the i.MX6 Dual Lite Reference Manual chap. 47.3.1.3

The two MAC addresses - even if sharing register bank:9 word:1 - can be programmed at different times.

At the opposite, eFuse lock should be performed for both simultaneously. The registers lock can be forced using the following command:

fuse prog -y 0 0 c000

eFuse reading[edit | edit source]

The eFuse registers can be read - after programming - for checking the written values:

u-boot=> fuse read 9 0
Reading bank 9:

Word 0x00000000: c21eafa8
u-boot=> fuse read 9 1
Reading bank 9:

Word 0x00000001: afa90050
u-boot=> fuse read 9 2
Reading bank 9:

Word 0x00000002: 0050c21e
u-boot=>

Linux kernel MAC address[edit | edit source]

The MAC Address configured in u-boot is passed to the kernel which configures the eth0 and eth1 peripherals with the correct values:

root@desk-mx8mp:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:c2:1e:af:a8
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth1      Link encap:Ethernet  HWaddr 00:50:c2:1e:af:a9
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:43

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:82 errors:0 dropped:0 overruns:0 frame:0
          TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6220 (6.0 KiB)  TX bytes:6220 (6.0 KiB)

root@desk-mx8mp:~#