Skip to content
Snippets Groups Projects
hostname.sh 984 B
Newer Older
  • Learn to ignore specific revisions
  • Mick Michalski's avatar
    Mick Michalski committed
    url="rigadogateway.com"
    
    
    get_fuse () {
        local name=$1
        local pad=$2
        # read the fuse and pad the left with zeros to the size of $pad
    
        local fuse="0000000000"$(cat /sys/fsl_otp/$name | cut -b 3-)
    
        len=$(( ${#fuse} - $pad ))
        echo ${fuse:$len}
    }
    
    get_sn () {
        local base=$1
        local arena=$(get_fuse HW_OCOTP_GP$base 7)
        if [[ ${arena:0:2} == "00" ]] ; then
        	# starts with "00", so doesn't start with ascii hex value
            arena=${arena:2}
        else
        	# doesn't start with "00", so starts with ascii hex value
            arena=$(printf "\x${arena:0:2}${arena:2}")
        fi
    
        local build=$(get_fuse HW_OCOTP_GP$(( $base + 1)) 4)
        local unit=$(get_fuse HW_OCOTP_GP$(( $base + 2)) 5)
    
        echo "$arena$build-$unit"
    }
    
    
    Mick Michalski's avatar
    Mick Michalski committed
    if [[ "$(cat /sys/fsl_otp/HW_OCOTP_GP37)" == "0x0" ]] ; then
        # No unit serial number set, use board serial number
    
    Mick Michalski's avatar
    Mick Michalski committed
    else
        # unit serial number set, use it