Skip to content

Commit f569883

Browse files
committed
still fixing the build.
1 parent e12b838 commit f569883

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ for the binding.
1717
___________________________
1818

1919
ESP32-ALL
20+
21+
22+
If you are having an issue with getting the firmware to fit into your esp32
23+
or if space is more of a concern than speed you can set the
24+
`--optimize-size` command line option. This will tell the compiler that the
25+
firmware size is more important than performance and the compiled binary will
26+
be smaller as a result.
27+
28+
2029
Flash sizes that are able to be used are 4, 8, 16, 32, 64 and 128 across all
2130
variants of the ESP32. It is up to the user to know what their board is using.
2231

builder/esp32.py

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -922,37 +922,27 @@ def compile(): # NOQA
922922
sys.exit(ret_code)
923923

924924
if 'To flash, run:' in output:
925-
output = output.split('To flash, run:')[-1].strip()
925+
output = output.rsplit('To flash, run:')[-1].strip()
926926

927927
espressif_path = "~/.espressif"
928928
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'
930931

931932
output = output.split('python ', 1)[-1]
932933
output = output.split('\n', 1)[0]
933-
output = f'{python_path}/python {output}'
934-
output = output.replace('esptool.py', esp_tool_path)
935934

936-
out_cmd = []
935+
build_name = f'build-{board}'
937936

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}'
952939

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)
954943

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)
956946

957947
os.remove('build/lvgl_header.h')
958948

@@ -972,8 +962,10 @@ def compile(): # NOQA
972962
build_bin_file += '.bin'
973963
build_bin_file = os.path.abspath(build_bin_file)
974964

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'')
977969
cmd = cmd.replace('--flash_freq 80m ', '')
978970
cmd = cmd.replace('-p (PORT) ', '')
979971
cmd = cmd.replace('-b 460800 ', '')
@@ -995,9 +987,9 @@ def compile(): # NOQA
995987
if result:
996988
sys.exit(result)
997989

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
1001993

1002994
if deploy:
1003995
python_env_path = os.path.split(os.path.split(python_path)[0])[0]
@@ -1089,11 +1081,11 @@ def find_esp32(chip):
10891081
print()
10901082

10911083
print(
1092-
python_path, esp_tool_path, '-p (PORT) -b 460800 erase_flash'
1084+
python_path, esptool_path, '-p (PORT) -b 460800 erase_flash'
10931085
)
10941086

10951087
print()
1096-
print(cmd.replace('-b 460800', '-b 921600'))
1088+
print(output.replace('-b 460800', '-b 921600'))
10971089
print()
10981090

10991091

0 commit comments

Comments
 (0)