Skip to content

Commit

Permalink
brom-dump: spft-replay: add mt6582 SoC support
Browse files Browse the repository at this point in the history
  • Loading branch information
arzam16 committed Nov 24, 2023
1 parent 459d03d commit 939e81a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions brom-dump/spft-replay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Usually old Mediatek devices from the mt65xx family do not enforce digital signa
* mt6573
* mt6577 / mt8317
* mt6580
* mt6582 / mt8382
* mt6589 / mt8389

### License
Expand Down
4 changes: 3 additions & 1 deletion brom-dump/spft-replay/src/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

from src.common import as_hex, from_bytes, target_config_to_string
from src.platform import MT6573, MT6577, MT6580, MT6589
from src.platform import MT6573, MT6577, MT6580, MT6582, MT6589


class DeviceManager:
Expand Down Expand Up @@ -61,6 +61,8 @@ def replay(self, payload, simple_mode, skip_remaining_data):
)
elif hw_code == 0x6580:
self.platform = MT6580(self.dev)
elif hw_code == 0x6582:
self.platform = MT6582(self.dev)
elif hw_code == 0x6583: # The code is 0x6583 but the SoC is 6589
self.platform = MT6589(self.dev)
else:
Expand Down
47 changes: 47 additions & 0 deletions brom-dump/spft-replay/src/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,53 @@ def recv_remaining_data(self):
pass


class MT6582(AbstractPlatform):
def __init__(self, dev):
self.dev = dev

def identify_chip(self):
hw_dict = self.dev.get_hw_sw_ver()
logging.replay(f"HW subcode: {as_hex(hw_dict[0], 2)}")
logging.replay(f"HW version: {as_hex(hw_dict[1], 2)}")
logging.replay(f"SW version: {as_hex(hw_dict[2], 2)}")
# The 0x10206000~0x10207000 region is allocated to EFUSE controller.
# It is barely documented even in datasheets but the specified offset
# should contain some sort of additional SoC revision codes.
val = self.dev.read32(0x10206044)
logging.replay(f"0x10206044: {as_hex(val)}")

def init_pmic(self):
pass

def disable_watchdog(self):
self.dev.write32(
0x10007000, 0x22000064, expected_response=0x0001
) # TOPRGU_WDT_MOD

def init_rtc(self):
pass

def identify_software(self):
val = self.dev.get_preloader_version()
val = self.dev.get_me_id()
logging.replay(f"ME ID: {as_hex(val)}")
val = self.dev.get_preloader_version() # repeated twice
pass

def init_emi(self):
pass

def send_payload(self, payload):
val = self.dev.send_da(0x200000, len(payload), 0, payload)
logging.replay(f"Received DA checksum: {as_hex(val, 2)}")

def jump_to_payload(self):
self.dev.jump_da(0x200000)

def recv_remaining_data(self):
pass


class MT6589(AbstractPlatform):
def __init__(self, dev):
super().__init__(dev)
Expand Down

0 comments on commit 939e81a

Please sign in to comment.