From ed174f7617c14d6424bbf8799e57daace5494b33 Mon Sep 17 00:00:00 2001
From: "Hans P. Reiser"
Date: Sun, 28 Apr 2019 18:17:27 +0200
Subject: [PATCH] +skript for image generation
---
scripts/makeimage.py | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100755 scripts/makeimage.py
diff --git a/scripts/makeimage.py b/scripts/makeimage.py
new file mode 100755
index 0000000..b291d75
--- /dev/null
+++ b/scripts/makeimage.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+import sys
+
+OFFSET_BOOTLOADER = 0x1000
+OFFSET_PARTITIONS = 0x8000
+OFFSET_BOOTAPP0 = 0xE000
+OFFSET_APPLICATION = 0x10000
+OFFSET_SPIFFS = 0x291000
+
+esp32tools = sys.argv[1]
+file_in = sys.argv[2]
+file_out = sys.argv[3]
+
+files_in = [
+ ('bootloader', OFFSET_BOOTLOADER, esp32tools+"/sdk/bin/bootloader_dio_80m.bin"),
+ ('partitions', OFFSET_PARTITIONS, esp32tools+"/partitions/default.bin"),
+ ('bootapp0', OFFSET_BOOTAPP0, esp32tools+"/partitions/boot_app0.bin"),
+ ('application', OFFSET_APPLICATION, file_in),
+ ('spiffs', OFFSET_SPIFFS, "/dev/null"),
+]
+
+cur_offset = OFFSET_BOOTLOADER
+with open(file_out, 'wb') as fout:
+ for name, offset, file_in in files_in:
+ assert offset >= cur_offset
+ fout.write(b'\xff' * (offset - cur_offset))
+ cur_offset = offset
+ with open(file_in, 'rb') as fin:
+ data = fin.read()
+ fout.write(data)
+ cur_offset += len(data)
+ print('%-12s% 8d' % (name, len(data)))
+ print('%-12s% 8d' % ('total', cur_offset))