Skip to content

Commit

Permalink
Added STM32U59x/5Ax in known devices
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofpayne committed Oct 10, 2023
1 parent d080db9 commit eb37567
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
10 changes: 9 additions & 1 deletion api/scaffold/stm32.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ class STM32:
'system': MemorySection(0x1fff0000, 0x1fff7000),
'flash': MemorySection(0x08000000, 0x08040000)}

# Memory layout for STM32U5A9
map_u5 = {
'otp': MemorySection(0x0bfa0000, 0x0bfa0200),
'system': MemorySection(0x0bf90000, 0x0bf98000),
'flash': MemorySection(0x08000000, 0x08080000)
}

# See AN2606 for PID values
PIDS = [
STM32Device('STM32F05xxx', 0x440, {}),
Expand All @@ -117,7 +124,8 @@ class STM32:
STM32Device('STM32L45xxx/46xxx', 0x462, {}),
STM32Device('STM32L47xxx/48xxx', 0x415, {}),
STM32Device('STM32L496xx/4A6xx', 0x461, {}),
STM32Device('STM32L4Rxx/4Sxx', 0x470, {})]
STM32Device('STM32L4Rxx/4Sxx', 0x470, {}),
STM32Device('STM32U59x/5Ax', 0x481, map_u5)]

def __init__(self, scaffold):
"""
Expand Down
33 changes: 18 additions & 15 deletions examples/stm32.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,24 @@
print(f'Bootloader version: {version[0]}.{version[1]}')

if stm.device is not None:
try:
data = stm.read_option_bytes()
print(f'Option bytes: {hexlify(data).decode()}')
rdp = data[stm.device.offset_rdp]
if rdp == 0xaa:
rdp_str = 'no protection'
elif rdp == 0xcc:
# If the chip is really protected, we should not be able to know it
# by reading the option bytes... So this may be useless.
rdp_str = 'chip protection'
else:
rdp_str = 'read protection'
print(f'RDP: {rdp_str}')
except NACKError:
print('Failed to read protection bytes, device probably in RDP1.')
if 'option_bytes' in stm.device.memory_mapping:
try:
data = stm.read_option_bytes()
print(f'Option bytes: {hexlify(data).decode()}')
rdp = data[stm.device.offset_rdp]
if rdp == 0xaa:
rdp_str = 'no protection'
elif rdp == 0xcc:
# If the chip is really protected, we should not be able to know it
# by reading the option bytes... So this may be useless.
rdp_str = 'chip protection'
else:
rdp_str = 'read protection'
print(f'RDP: {rdp_str}')
except NACKError:
print('Failed to read protection bytes, device probably in RDP1.')
else:
print('Unknown option bytes memory location')

if args.erase or ((args.load is not None) and (args.ram is None)):
# Erase Flash memory before writing it. This may be very long.
Expand Down

0 comments on commit eb37567

Please sign in to comment.