SFPI2CSCRIPT

SFPのEEPROM情報をshell scriptで書き換える。

write password

checksumの更新

0x3fと0x5fがchecksum

link

https://github.com/ibreakifix/sfp-testing

power class : 0x01を0xceから0xccへ

distance : 0x0eを0x0aから0x02へ

checksum : 0x3fから9引く

type : 0x40を0x03から0x06へ

checksum : 0x5fに3足す

#! /bin/sh

# change EEPROM

i2cdump -y -f 2 0x50

cc1=`expr $(i2cget -y -f 2 0x50 0xbf) - 9`

cc2=`expr $(i2cget -y -f 2 0x50 0xcf) + 3`

#write password

i2cset -y -f 2 0x50 0x7b 0x00

i2cset -y -f 2 0x50 0x7c 0x00

i2cset -y -f 2 0x50 0x7d 0x00

i2cset -y -f 2 0x50 0x7e 0x00

#write power class 3.5W

i2cset -y -f 2 0x50 0x81 0xcc

#disntance 2km

i2cset -y -f 2 0x50 0x8e 0x02

#rev code 50 -> 51

i2cset -y -f 2 0x50 0xb9 0x31

# update checksum

i2scet -y -f 2 0x50 0xbf $cc1

# write type code CWDM4

i2cset -y -f 2 0x50 0xc0 0x06

# update checksum

i2cset -y -f 2 0x50 0xcf $cc2

# review new dump

i2cdump -y -f 2 0x50

echo done

# serial is 0xc4 16 bytes

sn=$(i2cget -y -f 2 0x50 0xc4)$(i2cget -y -f 2 0x50 0xc4)$(i2cget -y -f 2 0x50 0xc4)$(i2cget -y -f 2 0x50 0xc4)$(i2cget -y -f 2 0x50 0xc4)$(i2cget -y -f 2 0x50 0xc4)$(i2cget -y -f 2 0x50 0xc4)$(i2cget -y -f 2 0x50 0xcb)

i2cdump -y -f 2 0x50 > $sn

Cによるサンプル

https://raspberry-projects.com/pi/programming-in-c/i2c/using-the-i2c-interface

http://eoinpk.blogspot.com/2014/05/raspberry-pi-and-programming-eeproms-on.html