BertoldVdb / ms-tools

Program, library and reference designs to develop for MacroSilicon MS2106/MS2109/MS2130 chips.
MIT License
117 stars 10 forks source link

Read EEPROM fails with "Allocated 0 bytes for patch" then "index out of range [5] with length 0" #2

Closed exikyut closed 1 year ago

exikyut commented 2 years ago

Was idly poking around after learning my USB capture dongle is MS2109-based and found this repo. Unfortunately didn't get very far :( and thought you might like to know. I had to remove _ "embed" from a couple of places so perhaps the problem below (see end of code block) is a "newer Go version" niggle as well.

(I'm also incidentally curious about the firmware you wrote for the MS2106, and what the 8051's role is.)

$ sudo ./cli --no-firmware --log-level 3 read EEPROM 0 --filename=eeprom.bin
HAL(3): ROMOut:   00b5f8000000000000
HAL(3): ROMIn:    00b5f800a700000000
HAL(1): Detected MS2109
HAL(3): ROMOut:   00b5cbd00000000000
HAL(3): ROMIn:    00b5cbd0a500000000
HAL(3): ROMOut:   00b5cbd10000000000
HAL(3): ROMIn:    00b5cbd15a00000000
HAL(3): ROMOut:   00b5cbd20000000000
HAL(3): ROMIn:    00b5cbd20200000000
HAL(3): ROMOut:   00b5cbd30000000000
HAL(3): ROMIn:    00b5cbd31500000000
HAL(2): Allocated 12 bytes for patch at ce15
HAL(3): ROMOut:   00b5ce150000000000
HAL(3): ROMIn:    00b5ce152600000000
HAL(3): ROMOut:   00b5ce160000000000
HAL(3): ROMIn:    00b5ce162b00000000
HAL(3): ROMOut:   00b5ce170000000000
HAL(3): ROMIn:    00b5ce17d400000000
HAL(3): ROMOut:   00b5ce180000000000
HAL(3): ROMIn:    00b5ce185300000000
HAL(3): ROMOut:   00b5ce190000000000
HAL(3): ROMIn:    00b5ce195d00000000
HAL(3): ROMOut:   00b5ce1a0000000000
HAL(3): ROMIn:    00b5ce1a5500000000
HAL(3): ROMOut:   00b5ce1b0000000000
HAL(3): ROMIn:    00b5ce1bc200000000
HAL(3): ROMOut:   00b5ce1c0000000000
HAL(3): ROMIn:    00b5ce1cfa00000000
HAL(3): ROMOut:   00b5ce1d0000000000
HAL(3): ROMIn:    00b5ce1de900000000
HAL(3): ROMOut:   00b5ce1e0000000000
HAL(3): ROMIn:    00b5ce1e8e00000000
HAL(3): ROMOut:   00b5ce1f0000000000
HAL(3): ROMIn:    00b5ce1f4700000000
HAL(3): ROMOut:   00b5ce200000000000
HAL(3): ROMIn:    00b5ce20e600000000
HAL(1): Unloading EEPROM code
HAL(3): ROMOut:   00b6cbd0ff00000000
HAL(3): ROMIn:    00b6cbd0ff00000000
HAL(3): ROMOut:   00b6cbd1ff00000000
HAL(3): ROMIn:    00b6cbd1ff00000000
HAL(3): ROMOut:   00b6cbd2ff00000000
HAL(3): ROMIn:    00b6cbd2ff00000000
HAL(3): ROMOut:   00b6cbd3ff00000000
HAL(3): ROMIn:    00b6cbd3ff00000000
HAL(3): ROMOut:   00b6cbd40000000000
HAL(3): ROMIn:    00b6cbd40000000000
HAL(3): ROMOut:   00b6cbd50000000000
HAL(3): ROMIn:    00b6cbd50000000000
HAL(3): ROMOut:   00b6cbd6ff00000000
HAL(3): ROMIn:    00b6cbd6ff00000000
HAL(3): ROMOut:   00b6cbd7ff00000000
HAL(3): ROMIn:    00b6cbd7ff00000000
HAL(3): ROMOut:   00b6cbd8ff00000000
HAL(3): ROMIn:    00b6cbd8ff00000000
HAL(3): ROMOut:   00b6cbd9ff00000000
HAL(3): ROMIn:    00b6cbd9ff00000000
HAL(3): ROMOut:   00b6cbdaff00000000
HAL(3): ROMIn:    00b6cbdaff00000000
HAL(3): ROMOut:   00b6cbdbff00000000
HAL(3): ROMIn:    00b6cbdbff00000000
HAL(3): ROMOut:   00b6cbdcff00000000
HAL(3): ROMIn:    00b6cbdcff00000000
HAL(3): ROMOut:   00b6cbddff00000000
HAL(3): ROMIn:    00b6cbddff00000000
HAL(3): ROMOut:   00b6cbdeff00000000
HAL(3): ROMIn:    00b6cbdeff00000000
HAL(3): ROMOut:   00b6cbdfff00000000
HAL(3): ROMIn:    00b6cbdfff00000000
HAL(3): ROMOut:   00b6cbe0ff00000000
HAL(3): ROMIn:    00b6cbe0ff00000000
HAL(3): ROMOut:   00b6cbe1ff00000000
HAL(3): ROMIn:    00b6cbe1ff00000000
HAL(3): ROMOut:   00b6cbe2ff00000000
HAL(3): ROMIn:    00b6cbe2ff00000000
HAL(3): ROMOut:   00b6cbe3ff00000000
HAL(3): ROMIn:    00b6cbe3ff00000000
HAL(3): ROMOut:   00b6cbe4ff00000000
HAL(3): ROMIn:    00b6cbe4ff00000000
HAL(3): ROMOut:   00b6cbe5ff00000000
HAL(3): ROMIn:    00b6cbe5ff00000000
HAL(3): ROMOut:   00b6cbe6ff00000000
HAL(3): ROMIn:    00b6cbe6ff00000000
HAL(3): ROMOut:   00b6cbe7ff00000000
HAL(3): ROMIn:    00b6cbe7ff00000000
HAL(3): ROMOut:   00b6cbe8ff00000000
HAL(3): ROMIn:    00b6cbe8ff00000000
HAL(3): ROMOut:   00b6cbe9ff00000000
HAL(3): ROMIn:    00b6cbe9ff00000000
HAL(3): ROMOut:   00b6cbeaff00000000
HAL(3): ROMIn:    00b6cbeaff00000000
HAL(3): ROMOut:   00b6cbebff00000000
HAL(3): ROMIn:    00b6cbebff00000000
HAL(3): ROMOut:   00b6cbecff00000000
HAL(3): ROMIn:    00b6cbecff00000000
HAL(3): ROMOut:   00b6cbedff00000000
HAL(3): ROMIn:    00b6cbedff00000000
HAL(3): ROMOut:   00b6cbeeff00000000
HAL(3): ROMIn:    00b6cbeeff00000000
HAL(3): ROMOut:   00b6cbefff00000000
HAL(3): ROMIn:    00b6cbefff00000000
HAL(3): ROMOut:   00b6cbf0ff00000000
HAL(3): ROMIn:    00b6cbf0ff00000000
HAL(3): ROMOut:   00b6cbf1ff00000000
HAL(3): ROMIn:    00b6cbf1ff00000000
HAL(3): ROMOut:   00b6cbf2ff00000000
HAL(3): ROMIn:    00b6cbf2ff00000000
HAL(3): ROMOut:   00b6cbf3ff00000000
HAL(3): ROMIn:    00b6cbf3ff00000000
HAL(3): ROMOut:   00b6cbf4ff00000000
HAL(3): ROMIn:    00b6cbf4ff00000000
HAL(3): ROMOut:   00b6cbf5ff00000000
HAL(3): ROMIn:    00b6cbf5ff00000000
HAL(3): ROMOut:   00b6cbf6ff00000000
HAL(3): ROMIn:    00b6cbf6ff00000000
HAL(3): ROMOut:   00b6cbf7ff00000000
HAL(3): ROMIn:    00b6cbf7ff00000000
HAL(3): ROMOut:   00b6cbf8ff00000000
HAL(3): ROMIn:    00b6cbf8ff00000000
HAL(3): ROMOut:   00b6cbf9ff00000000
HAL(3): ROMIn:    00b6cbf9ff00000000
HAL(3): ROMOut:   00b6cbfaff00000000
HAL(3): ROMIn:    00b6cbfaff00000000
HAL(3): ROMOut:   00b6cbfbff00000000
HAL(3): ROMIn:    00b6cbfbff00000000
HAL(3): ROMOut:   00b6cbfcff00000000
HAL(3): ROMIn:    00b6cbfcff00000000
HAL(3): ROMOut:   00b6cbfdff00000000
HAL(3): ROMIn:    00b6cbfdff00000000
HAL(3): ROMOut:   00b6cbfeff00000000
HAL(3): ROMIn:    00b6cbfeff00000000
HAL(3): ROMOut:   00b6cbffff00000000
HAL(3): ROMIn:    00b6cbffff00000000
HAL(3): ROMOut:   00b5cbd00000000000
HAL(3): ROMIn:    00b5cbd0ff00000000
HAL(3): ROMOut:   00b5cbd10000000000
HAL(3): ROMIn:    00b5cbd1ff00000000
HAL(3): ROMOut:   00b5cbd20000000000
HAL(3): ROMIn:    00b5cbd2ff00000000
HAL(3): ROMOut:   00b5cbd30000000000
HAL(3): ROMIn:    00b5cbd3ff00000000
HAL(2): Allocated 12 bytes for patch at cd00
HAL(2): Allocated 0 bytes for patch at cd0c
panic: runtime error: index out of range [5] with length 0

goroutine 1 [running]:
github.com/BertoldVdb/ms-tools/mshal.relocateCallgate(0x720118, 0x0, 0x0, 0xcd0c, 0x0, 0x0, 0xc, 0x0)
        /archive/ms-tools/mshal/hal_patch_install.go:123 +0xa7
github.com/BertoldVdb/ms-tools/mshal.(*HAL).patchInstall(0xc00011c5a0, 0x5c9c09, 0xb, 0xc0000435c0)
        /archive/ms-tools/mshal/hal_patch_install.go:389 +0xddf
github.com/BertoldVdb/ms-tools/mshal.New(0x600000, 0xc00014ecf0, 0x0, 0x10101, 0x0, 0x0, 0x0, 0x5d4018, 0x516a0b, 0x5d2f94, ...)
        /archive/ms-tools/mshal/hal.go:67 +0x44c
main.main()
        /archive/ms-tools/cli/main.go:89 +0x478
BertoldVdb commented 2 years ago

Hello,

If you remove the "embed" package the pre-assembled 8051 code won't be loaded into the arrays. Embed is used to read the files from this directory and add them tot he program: https://github.com/BertoldVdb/ms-tools/tree/main/mshal/asm

Just update your go version and it should work. Go is provided as a standalone package so you can just download it and use the included go binary: https://go.dev/dl/

The 8051 core handles the USB control endpoint and implements UVC controls. It is also responsible for acquisition of the TV signal. This is all done by the ROM, the user firmware can extend the functionality.

Sincerely, Bertold

BertoldVdb commented 2 years ago

PS: If you run the command with --no-patch it does not need embed. Depending on what you want to do it can be enough.