AnsweredAssumed Answered

i.MX6 SX OTP MAC

Question asked by Samuel Patton on Dec 12, 2018
Latest reply on Jul 2, 2019 by Samuel Patton

I have a simple script I've been using to program the OTP MAC registers, worked fine on the current boards. Just got new rev of boards and now MAC2 will not program, always shows as 0x0; MAC0/MAC1 program just fine. Any idea's?

 

root@cpng:~# la /sys/fsl_otp/HW_OCOTP_MAC*
-rw------- 1 root root 4096 Oct 5 11:13 /sys/fsl_otp/HW_OCOTP_MAC0
-rw------- 1 root root 4096 Oct 5 11:13 /sys/fsl_otp/HW_OCOTP_MAC1
-rw------- 1 root root 4096 Oct 5 11:13 /sys/fsl_otp/HW_OCOTP_MAC2
root@cpng:~# cat /sys/fsl_otp/HW_OCOTP_MAC*
0x4b007053
0x7054001f
0x0
root@cpng:~# cat macaddr

#!/bin/sh

 

if [ "$1" = "" ]
then
    echo "Usage: macaddr <colon seperated MAC address>"
    exit 1
fi

 

mac_addr0=$1

 

# get each byte of MAC address 0
mac0_byte0=`echo ${mac_addr0} | cut -d: -f6`
mac0_byte1=`echo ${mac_addr0} | cut -d: -f5`
mac0_byte2=`echo ${mac_addr0} | cut -d: -f4`
mac0_byte3=`echo ${mac_addr0} | cut -d: -f3`
mac0_byte4=`echo ${mac_addr0} | cut -d: -f2`
mac0_byte5=`echo ${mac_addr0} | cut -d: -f1`

 

# if they passed a second MAC address, use it
if [ "$2" != "" ]
then
    mac_addr1=$2

    # get each byte of MAC address 1
    mac1_byte0=`echo ${mac_addr1} | cut -d: -f6`
    mac1_byte1=`echo ${mac_addr1} | cut -d: -f5`
    mac1_byte2=`echo ${mac_addr1} | cut -d: -f4`
    mac1_byte3=`echo ${mac_addr1} | cut -d: -f3`
    mac1_byte4=`echo ${mac_addr1} | cut -d: -f2`
    mac1_byte5=`echo ${mac_addr1} | cut -d: -f1`

else
    # if not, use MAC address 0 and increment byte0
    mac1_byte0=`printf %X $((0x$mac0_byte0 + 1))`
    mac1_byte1=$mac0_byte1
    mac1_byte2=$mac0_byte2
    mac1_byte3=$mac0_byte3
    mac1_byte4=$mac0_byte4
    mac1_byte5=$mac0_byte5
fi

 

# mash it all together into 3 32-bit values
MAC0=${mac0_byte3}${mac0_byte2}${mac0_byte1}${mac0_byte0}
MAC1=${mac1_byte1}${mac1_byte0}${mac0_byte5}${mac0_byte4}
MAC2=${mac1_byte5}${mac1_byte4}${mac1_byte3}${mac1_byte2}

 

echo MAC0 = $MAC0
echo -n $MAC0 > /sys/fsl_otp/HW_OCOTP_MAC0
echo MAC1 = $MAC1
echo -n $MAC1 > /sys/fsl_otp/HW_OCOTP_MAC1
echo MAC2 = $MAC2
echo -n $MAC2 > /sys/fsl_otp/HW_OCOTP_MAC2

exit 0

Outcomes