File tree Expand file tree Collapse file tree 2 files changed +22
-13
lines changed Expand file tree Collapse file tree 2 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 1
1
from sys import exit
2
2
from stm32_flash import *
3
- from stm32_flash import _STM32_readMode , _STM32_sendAddress , _STM32_readPage
4
3
5
4
ans = STM32_startCommunication ()
6
5
if ans == STM32_NACK :
9
8
10
9
print ('\n STM32 FOUND' )
11
10
12
- print ('\n READING MEMORY' )
13
-
14
- _STM32_readMode ()
15
- print ('\n READ MODE' )
16
-
17
- _STM32_sendAddress (STM32_ADDRESS )
18
- print ('\n ADDRESS SENT' )
19
-
20
- page = _STM32_readPage ()
21
- print (page )
11
+ print ("\n READING 10 MEM PAGES" )
12
+ STM32_readMEM (10 )
Original file line number Diff line number Diff line change 1
1
from time import sleep_ms
2
- from machine import Pin , UART
2
+ from machine import UART
3
3
4
4
STM32_INIT = b'\x7F '
5
5
STM32_NACK = b'\x1F '
@@ -167,7 +167,7 @@ def _STM32_sendAddress(address: bytes) -> bytes:
167
167
168
168
def _incrementAddress (address : bytearray ):
169
169
"""
170
- Incremets address by one page (256 bytes)
170
+ Increments address by one page (256 bytes)
171
171
:param address:
172
172
:return:
173
173
"""
@@ -220,3 +220,21 @@ def _STM32_flashPage(data: bytearray) -> bytes:
220
220
uart .write (bytes ([checksum ]))
221
221
222
222
return _STM32_waitForAnswer ()
223
+
224
+
225
+ def STM32_readMEM (pages : int ):
226
+ """
227
+ Reads n 256-bytes pages from memory
228
+ :param pages: number of pages to read
229
+ :return:
230
+ """
231
+
232
+ for i in range (0 , pages ):
233
+ _STM32_readMode ()
234
+ _STM32_sendAddress (readAddress )
235
+
236
+ page = _STM32_readPage ()
237
+ print (f"Page { i + 1 } content:\n " )
238
+ print (page .hex ())
239
+
240
+ _incrementAddress (readAddress )
You can’t perform that action at this time.
0 commit comments