From 2671599b902afa55f9c21f0ee9db74889c6f9a67 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 7 Feb 2020 07:40:42 -0800 Subject: [PATCH] auto generate partition tables --- genpartitions.py | 41 +++++++++++++++++++++++++++++++++++++++++ partition-table.csv | 13 +++++++------ 2 files changed, 48 insertions(+), 6 deletions(-) create mode 100755 genpartitions.py diff --git a/genpartitions.py b/genpartitions.py new file mode 100755 index 00000000..a9f29753 --- /dev/null +++ b/genpartitions.py @@ -0,0 +1,41 @@ + + +# This is a layout for 4MB of flash +# Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x6000, +# otadata, data, ota, , 0x2000, +# app0, app, ota_0, , 0x1c0000, +# app1, app, ota_1, , 0x1c0000, +# spiffs, data, spiffs, , 0x06f000, + +start = 0x9000 +nvssys = 0x3000 +nvsuser = 0x3000 +nvs = nvssys + nvsuser +ota = 0x2000 +# app = 0x1c0000 +spi = 128 * 1024 + +# treat sys part sizes + spiffs size as reserved, then calculate what appsize can be +reserved = start + nvs + ota + spi +maxsize = 0x400000 # 4MB + +app = (maxsize - reserved) / 2 + +# total = start + nvs + ota + 2 * app + spi + +nvskb = nvsuser / 1024 +spikb = spi / 1024 +appkb = app / 1024 + +table = """ +# This is autogenerated by genpartions.py - change that tool instead! +# appsize={appkb} KB, spiffs={spikb} KB, usernvs={nvskb} KB +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x{start:x}, 0x{nvs:x}, +otadata, data, ota, , 0x{ota:x}, +app0, app, ota_0, , 0x{app:x}, +app1, app, ota_1, , 0x{app:x}, +spiffs, data, spiffs, , 0x{spi:x} """.format(**locals()) + +print table \ No newline at end of file diff --git a/partition-table.csv b/partition-table.csv index 80243db6..3d0c7ccc 100644 --- a/partition-table.csv +++ b/partition-table.csv @@ -1,7 +1,8 @@ -# This is a layout for 4MB of flash +# This is autogenerated by genpartions.py - change that tool instead! +# appsize=1950 KB, spiffs=128 KB, usernvs=12 KB # Name, Type, SubType, Offset, Size, Flags -nvs, data, nvs, 0x9000, 0x5000, -otadata, data, ota, 0xe000, 0x2000, -app0, app, ota_0, 0x10000, 0x1c0000, -app1, app, ota_1, 0x1d0000,0x1c0000, -spiffs, data, spiffs, 0x390000,0x070000, \ No newline at end of file +nvs, data, nvs, 0x9000, 0x6000, +otadata, data, ota, , 0x2000, +app0, app, ota_0, , 0x1e7800, +app1, app, ota_1, , 0x1e7800, +spiffs, data, spiffs, , 0x20000