board/eeprom.rb

69 lines
3.8 KiB
Ruby

eeprom = [
0x50, # VID LSB (OpenMoko)
0x1d, # VID MSB (OpenMoko)
0x7a, # PID LSB
0x61, # PID MSB
0x32, # DID_LSB board revision (BCD format)
0x01, # DID_MSB board version (BCD format)
0b10010011, # CONFIG_BYTE_1: SELF_BUS_PWR = 1 (indicate self-powered, superseeded by DYNAMIC), reserved, HS_DISABLE = 0 (allow high speed), MTT_ENABLE = 1 (one TT per port), EOP_DISABLE = normal, CURRENT_SNS = Individual port-by-port, PORT_PWR = Individual port-by-port switching
0b10000000, # CONFIG_BYTE_2: DYNAMIC = Dynamic Auto-switching capable, Reserved, OC_TIMER = 00 = 0.1ms, COMPOUND = No, Reserved
0b000000011, # CONFIG_BYTE_3: PRTMAP_EN = Standard Mode, LED_MODE = Speed Indication Mode, STRING_EN = String Support Enabled
0x00, # NR_DEVICE = no non-removable devices
0x00, # PORT_DIS_SP = no port disable
0x00, # PORT_DIS_BP = no bus powered port disable
1, # MAX_PWR_SP = 2 mA
50, # MAX_PWR_BP = 100 mA (neede to charge all capacitor)
1, # HC_MAX_C_SP = MAX_PWR_SP
50, # HC_MAX_C_BP = MAX_PWR_BP
10, # POWER_ON_TIME = 20 ms
0x04, # LANG_ID_H = US
0x09, # LANG_ID_L = english
0, # MFR_STR_LEN will be encoded below
0, # PRD_STR_LEN will be encoded below
0, # SER_STR_LEN will be encoded below
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # MFR_STR will be encoded below
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # PRD_STR will be encoded below
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # SER_STR will be encoded below
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,# reserved
0x00, # BOOST_IOUT = no boost
0x00, # Boost_7:5 = no boost
0x00, # Boost_4:0 = no boost+
0x00, # 0xf9 reserved (undocumented debug mode using LED pins)
0x00, # PRTSP = no port is swapped
0x00, # PRTR12 = no remap
0x00, # PRTR34 = no remap
0x00, # PRTR56 = no remap
0x00, # PRTR7 = no remap
0x00, # Status/Command (not used)
]
# encode manufacturer
MANUFACTURER = "CuVoodoo"
MFR_STR_LEN = 0x13
eeprom[MFR_STR_LEN] = MANUFACTURER.length
MFR_STR = 0x16
MANUFACTURER_BYTES = MANUFACTURER.encode("UTF-16LE").unpack("C*")
eeprom[MFR_STR, MANUFACTURER_BYTES.length] = MANUFACTURER_BYTES
# encode product
PRODUCT = "power USB hub"
PRD_STR_LEN = 0x14
eeprom[PRD_STR_LEN] = PRODUCT.length
PRD_STR = 0x54
PRODUCT_BYTES = PRODUCT.encode("UTF-16LE").unpack("C*")
eeprom[PRD_STR, PRODUCT_BYTES.length] = PRODUCT_BYTES
# encode serial
SERIAL = "2022061601"
SER_STR_LEN = 0x15
eeprom[SER_STR_LEN] = SERIAL.length
SER_STR = 0x92
SERIAL_BYTES = SERIAL.encode("UTF-16LE").unpack("C*")
eeprom[SER_STR, SERIAL_BYTES.length] = SERIAL_BYTES
# output epprom
raise "EEPROM length not 256" unless eeprom.length == 256
File.open("eeprom.bin", "wb") do |file|
file.write eeprom.pack("C*")
end