@@ -570,7 +570,7 @@ def open_file_dialog(self) -> None:
570
570
None ,
571
571
"Select Firmware to Upload" ,
572
572
"" ,
573
- "Firmware Files (*.zip *.uf2 *.hex *.elf);;All Files (*)" ,
573
+ "Firmware Files (*.zip *.bin *. uf2 *.hex *.elf);;All Files (*)" ,
574
574
options = options )
575
575
if fileName :
576
576
# self.firmware_combobox.clear()
@@ -721,36 +721,39 @@ def on_upload_btn_pressed(self) -> None:
721
721
722
722
def do_upload_esp32 (self , fwFile = None ) -> None :
723
723
"""Upload the firmware to the ESP32."""
724
- # Unzip the file to the temp directory
725
- try :
726
- with zipfile .ZipFile (fwFile , 'r' ) as zip_ref :
727
- zip_ref .extractall (_TEMP_DIR )
728
- except zipfile .BadZipFile :
729
- self .end_upload_with_message ("Provided ESP32 firmware is of wrong type." )
730
- return
731
-
732
- # Make sure that we now have all three files we need:
733
- # - bootloader.bin
734
- # - partition-table.bin
735
- # - micropython.bin
736
- # Get the name of the fwFile provided by taking the last part of the path (do this in a cross-platform way with os)
737
-
738
- fname = os .path .split (fwFile )[1 ]
739
- unzipDir = os .path .join (_TEMP_DIR , fname .replace (".zip" ,"" ))
740
- if not os .path .exists (unzipDir ):
741
- unzipDir = os .path .join (_TEMP_DIR , os .listdir (_TEMP_DIR )[0 ])
724
+
725
+ isZipFileUpload = fwFile .endswith (".zip" )
742
726
743
- for file in ["bootloader.bin" , "partition-table.bin" , "micropython.bin" ]:
744
- if not os .path .exists (os .path .join (unzipDir , file )):
745
- self .end_upload_with_message (f"{ os .path .join (unzipDir , file )} not found when checking esp32 zip." )
727
+ if isZipFileUpload :
728
+ # Unzip the file to the temp directory
729
+ try :
730
+ with zipfile .ZipFile (fwFile , 'r' ) as zip_ref :
731
+ zip_ref .extractall (_TEMP_DIR )
732
+ except zipfile .BadZipFile :
733
+ self .end_upload_with_message ("Provided ESP32 firmware is of wrong type." )
746
734
return
735
+
736
+ # Make sure that we now have all three files we need:
737
+ # - bootloader.bin
738
+ # - partition-table.bin
739
+ # - micropython.bin
740
+ # Get the name of the fwFile provided by taking the last part of the path (do this in a cross-platform way with os)
741
+ fname = os .path .split (fwFile )[1 ]
742
+ unzipDir = os .path .join (_TEMP_DIR , fname .replace (".zip" ,"" ))
743
+ if not os .path .exists (unzipDir ):
744
+ unzipDir = os .path .join (_TEMP_DIR , os .listdir (_TEMP_DIR )[0 ])
745
+
746
+ for file in ["bootloader.bin" , "partition-table.bin" , "micropython.bin" ]:
747
+ if not os .path .exists (os .path .join (unzipDir , file )):
748
+ self .end_upload_with_message (f"{ os .path .join (unzipDir , file )} not found when checking esp32 zip." )
749
+ return
747
750
748
- # For now we will always assume that the partitions table is 4MB. If future ESP32 devices are released with different flash sizes, we will need to update this code
749
- # Ideally, we would also add a .txt file with all of the necessary flashing parameters by grepping it from the build output when releases are generated, but for now we'll assume default stuff...
750
- thePartitionFileName = os .path .join (unzipDir , "partition-table.bin" )
751
- self .flashSize = 4
752
- theBootloaderFileName = os .path .join (unzipDir , "bootloader.bin" )
753
- theFirmwareFileName = os .path .join (unzipDir , "micropython.bin" )
751
+ # For now we will always assume that the partitions table is 4MB. If future ESP32 devices are released with different flash sizes, we will need to update this code
752
+ # Ideally, we would also add a .txt file with all of the necessary flashing parameters by grepping it from the build output when releases are generated, but for now we'll assume default stuff...
753
+ thePartitionFileName = os .path .join (unzipDir , "partition-table.bin" )
754
+ self .flashSize = 4
755
+ theBootloaderFileName = os .path .join (unzipDir , "bootloader.bin" )
756
+ theFirmwareFileName = os .path .join (unzipDir , "micropython.bin" )
754
757
755
758
sleep (1.0 ) # Don't know why this was here, but hell hath no fury like a sleep removed...
756
759
self .writeMessage ("Uploading firmware\n " )
@@ -767,9 +770,14 @@ def do_upload_esp32(self, fwFile = None) -> None:
767
770
command .extend (["--port" ,self .port ])
768
771
command .extend (["--baud" ,baud ])
769
772
command .extend (["--before" ,"default_reset" ,"--after" ,"hard_reset" ,"write_flash" ,"--flash_mode" ,"dio" ,"--flash_freq" ,"40m" ,"--flash_size" ,"4MB" ])
770
- command .extend (["0x1000" ,theBootloaderFileName ])
771
- command .extend (["0x8000" ,thePartitionFileName ])
772
- command .extend (["0x10000" ,theFirmwareFileName ])
773
+
774
+ if isZipFileUpload :
775
+ command .extend (["0x1000" ,theBootloaderFileName ])
776
+ command .extend (["0x8000" ,thePartitionFileName ])
777
+ command .extend (["0x10000" ,theFirmwareFileName ])
778
+ else :
779
+ # If we are not uploading a zip file, we assume the user has supplied a valid .bin file to flash directly at 0x1000
780
+ command .extend (["0x1000" , fwFile ])
773
781
774
782
#print("python esptool.py %s\n\n" % " ".join(command)) # Useful for debugging - cut and paste into a command prompt
775
783
@@ -934,7 +942,7 @@ def is_esp32_upload(self) -> bool:
934
942
# Check the processor variable in the primary firmware file for the device
935
943
return self .githubFirmware .get_basic_firmware_for_device (self .device_button .text ()).processor == "ESP32"
936
944
except :
937
- return self .theFileName .endswith (".zip" )
945
+ return self .theFileName .endswith (".zip" ) or self . theFileName . endswith ( ".bin" )
938
946
939
947
def is_rp2_upload (self ) -> bool :
940
948
"""Check if the upload is for RP2."""
0 commit comments