@@ -113,11 +113,6 @@ def build_image(apps, device_type, img_format="esp32", fatsize=0):
113113 return image_file
114114
115115
116- def flash_image (image_file ):
117- print ("Flashing image file: %s\n " % image_file )
118- run ([ESPTOOL_PY , "write_flash" , "0x0" , image_file ], check = False )
119-
120-
121116def clean_app (app ):
122117 print ("Cleaning up app '%s'..." % app )
123118 try :
@@ -158,6 +153,14 @@ def flash_app(app, port, baudrate=1152000):
158153 run ([PARTTOOL_PY , "--partition-table-file" , "partitions.bin" , "write_partition" , "--partition-name" , app , "--input" , app_bin ])
159154
160155
156+ def flash_image (image_file , port , baudrate = 1152000 ):
157+ os .putenv ("ESPTOOL_CHIP" , os .getenv ("IDF_TARGET" , "auto" ))
158+ os .putenv ("ESPTOOL_BAUD" , baudrate )
159+ os .putenv ("ESPTOOL_PORT" , port )
160+ print (f"Flashing image file '{ image_file } ' to { port } " )
161+ run ([ESPTOOL_PY , "write_flash" , "--flash_size" , "detect" , "0x0" , image_file ])
162+
163+
161164def monitor_app (app , port , baudrate = 115200 ):
162165 print (f"Starting monitor for app { app } on port { port } " )
163166 elf_file = os .path .join (os .getcwd (), app , "build" , app + ".elf" )
@@ -229,7 +232,7 @@ def monitor_app(app, port, baudrate=115200):
229232 if command in ["install" ]:
230233 print ("=== Step: Flashing entire image to device ===\n " )
231234 # Should probably show a warning here and ask for confirmation...
232- flash_image (image_file )
235+ flash_image (image_file , args . port , args . baud )
233236
234237 if command in ["flash" , "run" , "profile" ]:
235238 print ("=== Step: Flashing ===\n " )
0 commit comments