mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
partition_table: Support same fallback logic as bootloader for default boot partition
Generates correct "make flash" command even when partition table has no factory partition. Also adds unit tests for parttool.py Closes https://github.com/espressif/esp-idf/issues/2086
This commit is contained in:

committed by
Angus Gratton

parent
9d1cc00e54
commit
077469c823
@@ -356,5 +356,53 @@ app,app, factory, 32K, 1M
|
||||
t.verify()
|
||||
|
||||
|
||||
class PartToolTests(unittest.TestCase):
|
||||
|
||||
def _run_parttool(self, csvcontents, args):
|
||||
csvpath = tempfile.mktemp()
|
||||
with open(csvpath, "w") as f:
|
||||
f.write(csvcontents)
|
||||
try:
|
||||
return subprocess.check_output([sys.executable, "../parttool.py"] + args.split(" ") + [ csvpath ]).strip()
|
||||
finally:
|
||||
os.remove(csvpath)
|
||||
|
||||
def test_find_basic(self):
|
||||
csv = """
|
||||
nvs, data, nvs, 0x9000, 0x4000
|
||||
otadata, data, ota, 0xd000, 0x2000
|
||||
phy_init, data, phy, 0xf000, 0x1000
|
||||
factory, app, factory, 0x10000, 1M
|
||||
"""
|
||||
rpt = lambda args: self._run_parttool(csv, args)
|
||||
|
||||
self.assertEqual(
|
||||
rpt("--type data --subtype nvs --offset"), "0x9000")
|
||||
self.assertEqual(
|
||||
rpt("--type data --subtype nvs --size"), "0x4000")
|
||||
self.assertEqual(
|
||||
rpt("--partition-name otadata --offset"), "0xd000")
|
||||
self.assertEqual(
|
||||
rpt("--default-boot-partition --offset"), "0x10000")
|
||||
|
||||
def test_fallback(self):
|
||||
csv = """
|
||||
nvs, data, nvs, 0x9000, 0x4000
|
||||
otadata, data, ota, 0xd000, 0x2000
|
||||
phy_init, data, phy, 0xf000, 0x1000
|
||||
ota_0, app, ota_0, 0x30000, 1M
|
||||
ota_1, app, ota_1, , 1M
|
||||
"""
|
||||
rpt = lambda args: self._run_parttool(csv, args)
|
||||
|
||||
self.assertEqual(
|
||||
rpt("--type app --subtype ota_1 --offset"), "0x130000")
|
||||
self.assertEqual(
|
||||
rpt("--default-boot-partition --offset"), "0x30000") # ota_0
|
||||
csv_mod = csv.replace("ota_0", "ota_2")
|
||||
self.assertEqual(
|
||||
self._run_parttool(csv_mod, "--default-boot-partition --offset"),
|
||||
"0x130000") # now default is ota_1
|
||||
|
||||
if __name__ =="__main__":
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user