@@ -1349,7 +1349,7 @@ def get_partition_info(pt_path, pt_offset, pt_params):
1349
1349
"offset" ,
1350
1350
]
1351
1351
1352
- if pt_params [ "name" ] == "boot" :
1352
+ if pt_params . get ( "name" ) == "boot" :
1353
1353
cmd .append ("--partition-boot-default" )
1354
1354
else :
1355
1355
cmd .extend (
@@ -1380,8 +1380,11 @@ def get_partition_info(pt_path, pt_offset, pt_params):
1380
1380
1381
1381
def get_app_partition_offset (pt_table , pt_offset ):
1382
1382
# Get the default boot partition offset
1383
- app_params = get_partition_info (pt_table , pt_offset , {"name" : "boot" })
1384
- return app_params .get ("offset" , "0x10000" )
1383
+ ota_app_params = get_partition_info (pt_table , pt_offset , {"type" : "app" , "subtype" : "ota_0" })
1384
+ if ota_app_params .get ("offset" ):
1385
+ return ota_app_params ["offset" ]
1386
+ factory_app_params = get_partition_info (pt_table , pt_offset , {"type" : "app" , "subtype" : "factory" })
1387
+ return factory_app_params .get ("offset" , "0x10000" )
1385
1388
1386
1389
1387
1390
def preprocess_linker_file (src_ld_script , target_ld_script ):
@@ -2234,33 +2237,12 @@ def _parse_size(value):
2234
2237
# Configure application partition offset
2235
2238
#
2236
2239
2237
- partitions_csv = env .subst ("$PARTITIONS_TABLE_CSV" )
2238
- result = []
2239
- next_offset = 0
2240
- bound = 0x10000
2241
- with open (partitions_csv ) as fp :
2242
- for line in fp .readlines ():
2243
- line = line .strip ()
2244
- if not line or line .startswith ("#" ):
2245
- continue
2246
- tokens = [t .strip () for t in line .split ("," )]
2247
- if len (tokens ) < 5 :
2248
- continue
2249
- partition = {
2250
- "name" : tokens [0 ],
2251
- "type" : tokens [1 ],
2252
- "subtype" : tokens [2 ],
2253
- "offset" : tokens [3 ] or next_offset ,
2254
- "size" : tokens [4 ],
2255
- "flags" : tokens [5 ] if len (tokens ) > 5 else None
2256
- }
2257
- result .append (partition )
2258
- next_offset = _parse_size (partition ["offset" ])
2259
- if (partition ["subtype" ] == "ota_0" ):
2260
- bound = next_offset
2261
- next_offset = (next_offset + bound - 1 ) & ~ (bound - 1 )
2262
-
2263
- env .Replace (ESP32_APP_OFFSET = str (hex (bound )))
2240
+ app_offset = get_app_partition_offset (
2241
+ env .subst ("$PARTITIONS_TABLE_CSV" ),
2242
+ partition_table_offset
2243
+ )
2244
+
2245
+ env .Replace (ESP32_APP_OFFSET = app_offset )
2264
2246
2265
2247
#
2266
2248
# Propagate application offset to debug configurations
0 commit comments