@@ -922,37 +922,27 @@ def compile(): # NOQA
922
922
sys .exit (ret_code )
923
923
924
924
if 'To flash, run:' in output :
925
- output = output .split ('To flash, run:' )[- 1 ].strip ()
925
+ output = output .rsplit ('To flash, run:' )[- 1 ].strip ()
926
926
927
927
espressif_path = "~/.espressif"
928
928
python_path = f'{ espressif_path } /python_env/idf5.2_py3.10_env/bin'
929
- esp_tool_path = f'{ python_path } /esptool.py'
929
+ esptool_path = f'{ python_path } /esptool.py'
930
+ python_path += '/python'
930
931
931
932
output = output .split ('python ' , 1 )[- 1 ]
932
933
output = output .split ('\n ' , 1 )[0 ]
933
- output = f'{ python_path } /python { output } '
934
- output = output .replace ('esptool.py' , esp_tool_path )
935
934
936
- out_cmd = []
935
+ build_name = f'build- { board } '
937
936
938
- for file in (
939
- 'bootloader.bin' ,
940
- 'partition-table.bin' ,
941
- 'micropython.bin'
942
- ):
943
- arg , output = output .split ('build-' , 1 )
944
- output = 'build-' + output
945
- path , output = output .split (file , 1 )
946
- output = output .strip ()
947
- path += file
948
- out_cmd .append (arg .strip ())
949
- out_cmd .append (
950
- os .path .abspath ('lib/micropython/ports/esp32/' + path )
951
- )
937
+ if board_variant :
938
+ build_name += f'-{ board_variant } '
952
939
953
- out_cmd = ' ' .join (out_cmd )
940
+ full_file_path = f'{ SCRIPT_DIR } /lib/micropython/ports/esp32/{ build_name } '
941
+ bin_files = ['0x' + item .replace (build_name , full_file_path ).strip () for item in output .split ('0x' )[1 :]]
942
+ bin_files = ' ' .join (bin_files )
954
943
955
- build_name = f'build-{ board } '
944
+ old_bin_files = ['0x' + item .strip () for item in output .split ('0x' )[1 :]]
945
+ old_bin_files = ' ' .join (old_bin_files )
956
946
957
947
os .remove ('build/lvgl_header.h' )
958
948
@@ -972,8 +962,10 @@ def compile(): # NOQA
972
962
build_bin_file += '.bin'
973
963
build_bin_file = os .path .abspath (build_bin_file )
974
964
975
- cmd = f'{ python_path } /python { esp_tool_path } { out_cmd } '
976
- cmd = cmd .replace ('write_flash' , f'merge_bin -o { build_bin_file } ' )
965
+ cmd = f'{ python_path } -m { esptool_path } merge_bin -o { build_bin_file } { bin_files } '
966
+
967
+ cmd = cmd .replace ('esptool.py' , esptool_path )
968
+ cmd = cmd .replace ('write_flash' , f'' )
977
969
cmd = cmd .replace ('--flash_freq 80m ' , '' )
978
970
cmd = cmd .replace ('-p (PORT) ' , '' )
979
971
cmd = cmd .replace ('-b 460800 ' , '' )
@@ -995,9 +987,9 @@ def compile(): # NOQA
995
987
if result :
996
988
sys .exit (result )
997
989
998
- cmd = f' { python_path } /python { esp_tool_path } { out_cmd } '
999
- cmd = cmd . split ( 'write_flash ' , 1 )[ 0 ]
1000
- cmd += f'write_flash 0x0 { build_bin_file } '
990
+ output = output . replace ( old_bin_files , f'0x0 { build_bin_file } ' )
991
+ output = output . replace ( 'esptool.py ' , esptool_path )
992
+ output = python_path + output
1001
993
1002
994
if deploy :
1003
995
python_env_path = os .path .split (os .path .split (python_path )[0 ])[0 ]
@@ -1089,11 +1081,11 @@ def find_esp32(chip):
1089
1081
print ()
1090
1082
1091
1083
print (
1092
- python_path , esp_tool_path , '-p (PORT) -b 460800 erase_flash'
1084
+ python_path , esptool_path , '-p (PORT) -b 460800 erase_flash'
1093
1085
)
1094
1086
1095
1087
print ()
1096
- print (cmd .replace ('-b 460800' , '-b 921600' ))
1088
+ print (output .replace ('-b 460800' , '-b 921600' ))
1097
1089
print ()
1098
1090
1099
1091
0 commit comments