@@ -64,10 +64,15 @@ def get_app_size(self) -> int:
64
64
return self .factory
65
65
66
66
def set_app_size (self , size ):
67
- if int ((self .factory + size ) / 0x1000 ) * 0x1000 == self .factory + size :
68
- self .factory += size
69
- else :
70
- self .factory = (int ((self .factory + size ) / 0x1000 ) + 1 ) * 0x1000
67
+ if int (size / 0x1000 ) * 0x1000 != size :
68
+ size = (int (size / 0x1000 ) + 1 ) * 0x1000
69
+
70
+ if self .factory == size :
71
+ return False
72
+
73
+ self .factory = size
74
+
75
+ return True
71
76
72
77
def save (self ):
73
78
offset = self .first_offset
@@ -937,16 +942,17 @@ def compile(*args): # NOQA
937
942
sys .exit (ret_code )
938
943
939
944
if not skip_partition_resize and partition_size == - 1 :
940
- if 'partition is too small ' in output :
945
+ if 'Error: app partition is too small' in output :
941
946
sys .stdout .write (
942
947
'\n \033 [31;1m***** Resizing Partition *****\033 [0m\n '
943
948
)
944
949
sys .stdout .flush ()
945
950
946
- end = output .split ('(overflow ' , 1 )[- 1 ]
947
- overflow_amount = int (end .split (')' , 1 )[0 ], 16 )
951
+ app_size = output .rsplit ('Error: app partition is too small' , 1 )[1 ]
952
+ app_size = app_size .split ('micropython.bin size' , 1 )[1 ]
953
+ app_size = int (app_size .split (':' , 1 )[0 ].strip (), 16 )
948
954
949
- partition .set_app_size (overflow_amount )
955
+ partition .set_app_size (app_size )
950
956
partition .save ()
951
957
952
958
sys .stdout .write (
@@ -960,26 +966,22 @@ def compile(*args): # NOQA
960
966
if ret_code != 0 :
961
967
sys .exit (ret_code )
962
968
963
- elif 'Project build complete.' in output :
964
- app_size = output .rsplit ('micropython.bin binary size ' , 1 )[1 ]
969
+ if 'Project build complete.' in output :
970
+ app_size = output .rsplit ('Project build complete.' , 1 )[0 ]
971
+
972
+ app_size = app_size .rsplit ('micropython.bin binary size' , 1 )[1 ]
965
973
app_size = int (
966
- app_size .split (' bytes' , 1 )[0 ].strip (),
974
+ app_size .split ('bytes' , 1 )[0 ].strip (),
967
975
16
968
976
)
969
977
970
- remaining = app_size - partition .get_app_size ()
971
-
972
- app_size
978
+ if partition .set_app_size (app_size ):
979
+ partition .save ()
973
980
974
- if abs (remaining ) > 0x1000 :
975
981
sys .stdout .write (
976
982
'\n \033 [31;1m***** Resizing Partition *****\033 [0m\n '
977
983
)
978
984
sys .stdout .flush ()
979
-
980
- partition .set_app_size (- remaining )
981
- partition .save ()
982
-
983
985
sys .stdout .write (
984
986
'\n \033 [31;1m***** Running build again *****\033 [0m\n \n '
985
987
)
0 commit comments