Skip to content

Commit 1e471a3

Browse files
committed
still messing with the partition resizing
1 parent 46ab4a7 commit 1e471a3

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

builder/esp32.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -930,46 +930,44 @@ def compile(*args): # NOQA
930930

931931
ret_code, output = spawn(cmd_, env=env, cmpl=True)
932932
if ret_code != 0:
933-
if (
934-
'partition is too small ' not in output or
935-
skip_partition_resize
936-
):
933+
if skip_partition_resize:
937934
sys.exit(ret_code)
938935

939936
if partition_size != -1:
940937
sys.exit(ret_code)
941938

942-
sys.stdout.write('\n\033[31;1m***** Resizing Partition *****\033[0m\n')
943-
sys.stdout.flush()
939+
if not skip_partition_resize and partition_size == -1:
940+
if 'partition is too small ' in output:
941+
sys.stdout.write('\n\033[31;1m***** Resizing Partition *****\033[0m\n')
942+
sys.stdout.flush()
944943

945-
end = output.split('(overflow ', 1)[-1]
946-
overflow_amount = int(end.split(')', 1)[0], 16)
944+
end = output.split('(overflow ', 1)[-1]
945+
overflow_amount = int(end.split(')', 1)[0], 16)
947946

948-
partition.set_app_size(overflow_amount)
949-
partition.save()
947+
partition.set_app_size(overflow_amount)
948+
partition.save()
950949

951-
sys.stdout.write(
952-
'\n\033[31;1m***** Running build again *****\033[0m\n\n'
953-
)
954-
sys.stdout.flush()
950+
sys.stdout.write(
951+
'\n\033[31;1m***** Running build again *****\033[0m\n\n'
952+
)
953+
sys.stdout.flush()
955954

956-
cmd_[4] = 'SECOND_BUILD=1'
957-
ret_code, output = spawn(cmd_, env=env, cmpl=True)
955+
cmd_[4] = 'SECOND_BUILD=1'
956+
ret_code, output = spawn(cmd_, env=env, cmpl=True)
958957

959-
if ret_code != 0:
960-
sys.exit(ret_code)
958+
if ret_code != 0:
959+
sys.exit(ret_code)
961960

962-
if not skip_partition_resize:
963-
if partition_size == -1 and 'build complete' in output:
964-
app_size = output.rsplit('micropython.bin binary size ')[-1]
961+
elif 'Project build complete.' in output:
962+
app_size = output.rsplit('micropython.bin binary size ', 1)[1]
965963
app_size = int(
966-
app_size.split(' bytes')[0].strip(),
964+
app_size.split(' bytes', 1)[0].strip(),
967965
16
968966
)
969967

970968
remaining = app_size - partition.get_app_size()
971969

972-
if remaining > 0x1000:
970+
if abs(remaining) > 0x1000:
973971
sys.stdout.write(
974972
'\n\033[31;1m***** Resizing Partition *****\033[0m\n'
975973
)
@@ -983,14 +981,14 @@ def compile(*args): # NOQA
983981
)
984982
sys.stdout.flush()
985983

986-
compile_cmd[4] = 'SECOND_BUILD=1'
984+
cmd_[4] = 'SECOND_BUILD=1'
987985

988-
ret_code, output = spawn(cmds, env=env, cmpl=True)
986+
ret_code, output = spawn(cmd_, env=env, cmpl=True)
989987

990988
if ret_code != 0:
991989
sys.exit(ret_code)
992990

993-
if 'To flash, run:' in output:
991+
if 'Project build complete.' in output:
994992
output = output.rsplit('To flash, run:')[-1].strip()
995993

996994
espressif_path = os.path.expanduser('~/.espressif')

0 commit comments

Comments
 (0)