mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 09:13:52 +08:00
erase log flash sectors in DFU recovery (#1661)
* erase log flash sectors in DFU recovery * always erase by sector * erase all * fix
This commit is contained in:
@@ -53,14 +53,9 @@ class BaseSTBootloaderHandle(ABC):
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def erase_app(self) -> None:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def erase_bootstub(self) -> None:
|
||||
def erase_sector(self, sector: int) -> None:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
def jump(self, address: int) -> None:
|
||||
...
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ class McuConfig(NamedTuple):
|
||||
bootstub_address: int
|
||||
bootstub_fn: str
|
||||
|
||||
def sector_address(self, i):
|
||||
# assume bootstub is in sector 0
|
||||
return self.bootstub_address + sum(self.sector_sizes[:i])
|
||||
|
||||
Fx = (
|
||||
0x1FFF7A10,
|
||||
0x800,
|
||||
|
||||
@@ -121,8 +121,11 @@ class PandaDFU:
|
||||
|
||||
def program_bootstub(self, code_bootstub):
|
||||
self._handle.clear_status()
|
||||
self._handle.erase_bootstub()
|
||||
self._handle.erase_app()
|
||||
|
||||
# erase all sectors
|
||||
for i in range(len(self._mcu_type.config.sector_sizes)):
|
||||
self._handle.erase_sector(i)
|
||||
|
||||
self._handle.program(self._mcu_type.config.bootstub_address, code_bootstub)
|
||||
|
||||
def recover(self):
|
||||
|
||||
@@ -403,12 +403,6 @@ class STBootloaderSPIHandle(BaseSTBootloaderHandle):
|
||||
|
||||
# *** PandaDFU API ***
|
||||
|
||||
def erase_app(self):
|
||||
self.erase_sector(1)
|
||||
|
||||
def erase_bootstub(self):
|
||||
self.erase_sector(0)
|
||||
|
||||
def get_mcu_type(self):
|
||||
return self._mcu_type
|
||||
|
||||
|
||||
@@ -51,11 +51,8 @@ class STBootloaderUSBHandle(BaseSTBootloaderHandle):
|
||||
def get_mcu_type(self):
|
||||
return self._mcu_type
|
||||
|
||||
def erase_app(self):
|
||||
self._erase_page_address(self._mcu_type.config.app_address)
|
||||
|
||||
def erase_bootstub(self):
|
||||
self._erase_page_address(self._mcu_type.config.bootstub_address)
|
||||
def erase_sector(self, sector: int):
|
||||
self._erase_page_address(self._mcu_type.config.sector_address(sector))
|
||||
|
||||
def clear_status(self):
|
||||
# Clear status
|
||||
|
||||
Reference in New Issue
Block a user