forked from nxp-mcuxpresso/rblhost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_read_memory.py
More file actions
26 lines (22 loc) · 791 Bytes
/
Copy pathwrite_read_memory.py
File metadata and controls
26 lines (22 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright 2025 NXP
#
# SPDX-License-Identifier: BSD-3-Clause
"""Erase flash, write some bytes and read them back from UART device specified as the first argument to the script."""
import sys
from pymboot import McuBoot
if len(sys.argv) < 2:
print("specify a UART device as the first argument")
exit(1)
device = sys.argv[1]
memory_bytes = [0x12, 0x34, 0x56]
with McuBoot(device) as boot:
print("erasing flash")
boot.flash_erase_all()
print(f"writing memory bytes: {list(map(hex, memory_bytes))}")
boot.write_memory(0, memory_bytes)
print("reading memory bytes")
response = boot.read_memory(0, len(memory_bytes))
if response is not None:
print(f"read memory bytes: {list(map(hex, response))}")
else:
print("could not read memory")