Skip to content

Commit

Permalink
Fix sector size and RDP check on STM32H743 and H723
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Fritiofson committed Jun 13, 2024
1 parent 475bbd0 commit dc0d4ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pyocd/target/builtin/target_STM32H723xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class STM32H723xx(CoreSightTarget):
VENDOR = "STMicroelectronics"

MEMORY_MAP = MemoryMap(
FlashRegion( start=0x08000000, length=0x100000, sector_size=0x8000,
FlashRegion( start=0x08000000, length=0x100000, sector_size=0x20000,
page_size=0x400,
is_boot_memory=True,
algo=FLASH_ALGO),
Expand Down Expand Up @@ -232,9 +232,9 @@ def is_locked(self):
bank = FlashPeripheral()
optsr = self.read32(bank.flash_optsr_prg)
rdp = optsr & 0x0000_ff00
if rdp == 0xaa:
if rdp == 0xaa00:
return False;
if rdp == 0xcc:
if rdp == 0xcc00:
LOG.warning("MCU permanently locked. No unlock possible")
return True

Expand Down
10 changes: 5 additions & 5 deletions pyocd/target/builtin/target_STM32H743xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self, bank=0):
'flash_start': 0x8000000,
'flash_size': 0x200000,
'sector_sizes': (
(0x0, 0x2000),
(0x0, 0x20000),
)
}

Expand All @@ -152,12 +152,12 @@ class STM32H743xx(CoreSightTarget):
VENDOR = "STMicroelectronics"

MEMORY_MAP = MemoryMap(
FlashRegion( start=0x0800_0000, length=0x10_0000, sector_size=0x8000,
FlashRegion( start=0x0800_0000, length=0x10_0000, sector_size=0x2_0000,
page_size=0x400,
is_boot_memory=True,
algo=FLASH_ALGO),

FlashRegion( start=0x0810_0000, length=0x10_0000, sector_size=0x8000,
FlashRegion( start=0x0810_0000, length=0x10_0000, sector_size=0x2_0000,
page_size=0x400,
algo=FLASH_ALGO),
#ITCM
Expand Down Expand Up @@ -278,9 +278,9 @@ def is_locked(self, flash_banks=[0,1]):
for bank in banks:
optsr = self.read32(bank.flash_optsr_prg)
rdp = optsr & 0x0000_ff00
if rdp == 0xcc:
if rdp == 0xcc00:
LOG.warning(f"BANK {bank.bank} permanently locked. No unlock possible")
if rdp != 0xaa:
if rdp != 0xaa00:
return True
return False

Expand Down

0 comments on commit dc0d4ff

Please sign in to comment.