Skip to content

Instantly share code, notes, and snippets.

@neggles
Last active December 9, 2022 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neggles/bf8b2353a8d521c03ed3a78404ac57ea to your computer and use it in GitHub Desktop.
Save neggles/bf8b2353a8d521c03ed3a78404ac57ea to your computer and use it in GitHub Desktop.
SX6012 FRU EEPROM patch
# bash functions for converting FRU EEPROMs
emc_to_6012() {
dd if=/dev/zero bs=16 count=256 of="$2" 2> /dev/null
dd if="$1" bs=16 count=12 of="$2" conv=notrunc 2> /dev/null
dd if="$1" bs=16 count=5 of="$2" skip=12 seek=14 conv=notrunc 2> /dev/null
printf "\x20" | dd of="$2" bs=1 seek=1 count=1 conv=notrunc 2> /dev/null
printf "\x00" | dd of="$2" bs=1 seek=5 count=1 conv=notrunc 2> /dev/null
printf "\x05\x0E\x02\x14\x06\x16\x07" | dd of="$2" bs=1 seek=15 count=7 conv=notrunc 2> /dev/null
printf "\x00\x1A\x00\x03\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" | dd of="$2" bs=1 seek=192 count=32 conv=notrunc 2> /dev/null
printf "\x00\x12\x00\x01\x06\x00\x00\x00\x00\x01\x00\x00\x02\x88\x04\x04\x02\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0A\x00\x01\x07\x00\x00\x00\x00\x02\x10\x00\x00\x00\x00\x00" | dd of="$2" bs=1 seek=320 count=48 conv=notrunc 2> /dev/null
printf "\x4D\x53\x58\x36\x30\x31\x32\x46\x2D\x32\x42\x46\x53\x00" | dd of="$2" bs=1 seek=64 count=14 conv=notrunc 2> /dev/null
}
6012_to_1012() {
if [ "$1" != "$2" ]; then
dd if="$1" bs=16 count=256 of="$2" 2> /dev/null
fi
printf "\x4D\x53\x58\x31\x30\x31\x32\x42\x2D\x32\x42\x46\x53\x00" | dd of="$2" bs=1 seek=64 count=14 conv=notrunc 2> /dev/null
printf "\x03\xF4" | dd of="$2" bs=1 seek=162 count=2 conv=notrunc 2> /dev/null
printf "\x31" | dd of="$2" bs=1 seek=166 count=1 conv=notrunc 2> /dev/null
printf "\x06" | dd of="$2" bs=1 seek=329 count=1 conv=notrunc 2> /dev/null
}
1012_to_6012() {
if [ "$1" != "$2" ]; then
dd if="$1" bs=16 count=256 of="$2" 2> /dev/null
fi
printf "\x4D\x53\x58\x36\x30\x31\x32\x46\x2D\x32\x42\x46\x53\x00" | dd of="$2" bs=1 seek=64 count=14 conv=notrunc 2> /dev/null
printf "\x17\x7C" | dd of="$2" bs=1 seek=162 count=2 conv=notrunc 2> /dev/null
printf "\x36" | dd of="$2" bs=1 seek=166 count=1 conv=notrunc 2> /dev/null
printf "\x01" | dd of="$2" bs=1 seek=329 count=1 conv=notrunc 2> /dev/null
}
# usage:
# /opt/tms/bin/mellaggra _read_fru 8 0x51 1000 fru_backplate.bin
# emc_to_6012 "fru_backplate.bin" "fru_bp_patched.bin"
# /opt/tms/bin/mellaggra _write_fru 8 0x51 1000 fru_bp_patched.bin
# update bootstrap details
mlxi2c update_bootstrap166 (86 82 96 1a d9 80 0 e0 c0 8 23 50 d 5 0 0) # my unit already had this set
mlxi2c update_bootstrap200 (86 82 96 19 b9 80 0 e0 c0 8 23 50 d 5 0 0)
 
# dump bootstrap rom
/opt/tms/bin/mellaggra _read 0 0x52 0 1 16 # this will dump the bootstrap ROM
 
# back up the backplate and CPU FRUs
/opt/tms/bin/mellaggra _read_fru 8 0x51 1000 fru_backplate.bin
/opt/tms/bin/mellaggra _read_fru 0 0x50 1000 fru_cpu.bin
 
# run emc_to_6012 from fru-eeprom-funcs.sh on the eeprom dump
emc_to_6012 "fru_backplate.bin" "fru_bp_patched.bin"
# flash the modified file back
/opt/tms/bin/mellaggra _write_fru 8 0x51 1000 fru_bp_patched.bin
# manual mfg boot over tftp
run mfg_load;if test 0${filesize} -gt 0; then echo Booting mfg ; run mfg_args mfg_common_args;bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} ; else ; echo Failed mfg load ; fi
 
# apply image over ftp from manufacturing environment without rebooting and with progress
manufacture.sh -v -v -t -a -m ppc -u ftp://ftp-user:ftp@host/image-PPC_M460EX-3.6.8012.img
 
# mount system from mfg and chroot
mkdir -p /mnt/root2 && \
mount -t jffs2 /dev/mtdblock7 /mnt/root2 && \
mount -t jffs2 /dev/mtdblock8 /mnt/root2/config && \
mount -t proc /proc /mnt/root2/proc && \
mount -o bind /sys /mnt/root2/sys && \
mount -o bind /dev /mnt/root2/dev && \
chroot /mnt/root2 /bin/bash
 
# now we clear the bootloader password
# default val = $1$yCoib8pn$vSaWSssw2k17iOJRIdmcw/
mddbreq /config/mfg/mfincdb set modify - /system/bootmgr/password string ''
mddbreq /config/mfg/mfincdb.bak set modify - /system/bootmgr/password string ''
# check they're empty now
mddbreq /config/mfg/mfincdb query get - /system/bootmgr/password
mddbreq /config/mfg/mfincdb.bak query get - /system/bootmgr/password
# set the hwname
mddbreq /config/mfg/mfdb set modify - /mfg/mfdb/system/hwname string M460EX
 
# exit chroot then do this to reboot and run firstboot
umount /mnt/root2/dev && umount /mnt/root2/sys && umount /mnt/root2/proc && umount /mnt/root2/config && umount /mnt/root2 && reboot
 
# get modded binaries if need
wget ftp://ftp-user:ftp@10.61.1.220/disk1/ftp/3.6.8012.tar
 
# set root pw
mddbreq /config/db/initial set modify - /auth/passwd/user/root/password string 'hashed-password-string-using-sha512' # starts with $6$
# or set admincli shell
mddbreq /config/db/initial set modify - /auth/passwd/user/admincli/shell string '/bin/bash'
 
mddbreq /config/mfg/mfdb query get - /auth/passwd/user/admincli/shell
 
chroot /mnt/root2 /bin/bash
 
# licenses!
# the license secret is 'm2l0n%0x9'
 
# need these lics for all the fun stuff:
# RESTRICTED_CMDS_GEN2
genlicense 2 RESTRICTED_CMDS_GEN2 'm2l0n%0x9'
 
key: LK2-RESTRICTED_CMDS_GEN2-88A1-NEWD-BPNB-1
 
Activation option IDs:
1 (start_date): Start date: license not active before this date
2 (end_date): End date: license not active after this date
3 (tied_primary_mac): Tie to this MAC address on primary interface
4 (tied_host_id): Tie to this host ID
5 (tied_host_id_hex): Tie to this host ID (lowercase hexadecimal)
6 (tied_serialno): Tie to this serial number
7 (tied_uuid): Tie to this UUID (must be RFC 4122 compliant)
49 (efm_sx_serial_num): Chassis serial number for license verification
 
Informational option IDs:
48 (efm_sx_max_num_hca_ports): Maximum number of HCA ports supported by this MLNX-OS SwitchX license
50 (efm_sx_active_ports): Active ports number supported by this MLNX-OS SwitchX license
51 (efm_sx_l2_enabled): Eth L2 enabled by this MLNX-OS SwitchX license
52 (efm_sx_ib_enabled): IB enabled by this MLNX-OS SwitchX license
53 (efm_sx_eth_enabled): Eth enabled by this MLNX-OS SwitchX license
54 (efm_sx_gw_ports): GW ports number supported by this MLNX-OS SwitchX license
55 (efm_sx_max_ufm_ports): Maximum number of UFM ports supported by this MLNX-OS SwitchX license
56 (efm_sx_ib_speed_sw_limit): IB port SW speed limit enabled by this MLNX-OS SwitchX license
57 (efm_sx_eth_speed_sw_limit): Eth port SW speed limit enabled by this MLNX-OS SwitchX license
58 (efm_sx_l3_enabled): Eth L3 enabled by this MLNX-OS SwitchX license
59 (efm_sx_fcf_enabled): FCF enabled by this MLNX-OS SwitchX license
60 (oem_lic_10gbps_enable): 10 Gbps ports licensed by OEM license
61 (oem_lic_25gbps_enable): 25 Gbps ports licensed by OEM license
62 (oem_lic_100gbps_enable): 100 Gbps ports licensed by OEM license
 
# EFM_SX with the following options set:
48 (efm_sx_max_num_hca_ports): Maximum number of HCA ports supported by this EFM SX license
50 (efm_sx_active_ports): Active ports number supported by this EFM SX license
51 (efm_sx_full_l2_enabled): Full Eth L2 enabled by this EFM SX license
52 (efm_sx_ib_enabled): IB enabled by this EFM SX license
53 (efm_sx_eth_enabled): Eth enabled by this EFM SX license
54 (efm_sx_gw_ports): GW ports number supported by this EFM SX license
55 (efm_sx_max_ufm_ports): Maximum number of UFM ports supported by this EFM SX license
56 (efm_sx_ib_speed_sw_limit): IB port SW speed limit enabled by this EFM SX license
57 (efm_sx_eth_speed_sw_limit): Eth port SW speed limit enabled by this EFM SX license
58 (efm_sx_l3_enabled): Eth L3 enabled by this EFM SX license
 
./genlicense 2 EFM_SX 'm2l0n%0x9' -o efm_sx_ib_enabled true -o efm_sx_eth_enabled true -o efm_sx_l2_enabled true -o efm_sx_l3_enabled true -o efm_sx_fcf_enabled true -o efm_sx_max_num_hca_ports 64 -o efm_sx_active_ports 64 -o efm_sx_gw_ports 64 -o efm_sx_max_ufm_ports 64
LK2-EFM_SX-5L11-5M11-5K11-5T11-5U11-5G22-05J2-205N-2205-P220-88A2-L5T5-3MYW-9
 
key: LK2-EFM_SX-5L11-5M11-5T11-5G1C-5J1C-5N1C-5P1C-5Q21-85R2-1888-A4N2-VF2J-8VV
 
# known good key for eth+l2+l3:
LK2-EFM_SX-5M11-5K11-5T11-88A1-BBD0-JP82-X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment