1212CMD_GET_LENGTH_V12 = const (20 ) # Length of the response data
1313CMD_GET_VERSION = const (0x01 ) # Gets the protocol version
1414CMD_GET_ID = const (0x02 ) # Get chip ID
15- CMD_ERASE = const (0x44 ) # Erase memory
15+ CMD_ERASE_NO_STRETCH = const (0x45 ) # Erase memory. Returns busy state while operation is ongoing
1616CMD_GO = const (0x21 ) # Jumps to user application code located in the internal flash memory
1717CMD_WRITE_NO_STRETCH = const (0x32 ) # Writes up to 256 bytes to the memory, starting from an address specified
18+
1819CHUNK_SIZE = const (128 ) # Size of the memory chunk to write
1920
2021# Define I2C pins and initialize I2C
@@ -132,7 +133,7 @@ def flash_firmware(firmware_path, verbose=False):
132133
133134 print ("🗑️ Erasing memory..." )
134135 erase_params = bytearray ([0xFF , 0xFF , 0x0 ]) # Mass erase flash
135- execute_command (CMD_ERASE , erase_params , 0 , verbose )
136+ execute_command (CMD_ERASE_NO_STRETCH , erase_params , 0 , verbose )
136137
137138 with open (firmware_path , 'rb' ) as file :
138139 firmware_data = file .read ()
@@ -156,7 +157,7 @@ def flash_firmware(firmware_path, verbose=False):
156157
157158 print ("🏃 Starting firmware" )
158159 go_params = bytearray ([0x8 , 0x00 , 0x00 , 0x00 , 0x8 ])
159- # execute_command(CMD_GO, go_params, 0, verbose) # Jump to the application
160+ execute_command (CMD_GO , go_params , 0 , verbose ) # Jump to the application
160161
161162 return True
162163
0 commit comments