From c76a8f23181b83d2ad048448d91734a0627c90be Mon Sep 17 00:00:00 2001 From: mikee47 Date: Tue, 26 Oct 2021 07:27:09 +0100 Subject: [PATCH] Allow partition build config to be embedded Avoids need for separate file with simple FWFS definitions --- Sming/Components/IFS | 2 +- Sming/Components/Storage/Tools/hwconfig/hwconfig.py | 5 ++++- samples/Basic_Templates/app/CsvTemplate.h | 4 ++++ samples/Basic_Templates/basic_templates.hw | 7 ++++++- samples/Basic_Templates/fsimage.fwfs | 6 ------ 5 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 samples/Basic_Templates/fsimage.fwfs diff --git a/Sming/Components/IFS b/Sming/Components/IFS index ec34e44660..9485c2d1fc 160000 --- a/Sming/Components/IFS +++ b/Sming/Components/IFS @@ -1 +1 @@ -Subproject commit ec34e44660e650ab0de4229807c36fca2f206750 +Subproject commit 9485c2d1fc6ba529293089a62fec8f8d11de7a8f diff --git a/Sming/Components/Storage/Tools/hwconfig/hwconfig.py b/Sming/Components/Storage/Tools/hwconfig/hwconfig.py index 5f195737a4..854b197683 100644 --- a/Sming/Components/Storage/Tools/hwconfig/hwconfig.py +++ b/Sming/Components/Storage/Tools/hwconfig/hwconfig.py @@ -64,7 +64,10 @@ def handle_partgen(args, config, part): def handle_expr(args, config, part): # Evaluate expression against configuration data - return str(eval(args.expr)).encode() + res = eval(args.expr) + if isinstance(res, dict): + return json.dumps(res).encode() + return str(res).encode() def main(): diff --git a/samples/Basic_Templates/app/CsvTemplate.h b/samples/Basic_Templates/app/CsvTemplate.h index f5f608451d..b29b4ae349 100644 --- a/samples/Basic_Templates/app/CsvTemplate.h +++ b/samples/Basic_Templates/app/CsvTemplate.h @@ -14,12 +14,16 @@ class CsvTemplate : public SectionTemplate { } + // Return true if we have a new valid record, false if not bool nextRecord() override { + // Content section we fetch the next data record, if there is one if(sectionIndex() == 1) { return csv.next(); } + // This code emits the header and footer sections exactly once + // `recordIndex` starts at -1 (before first record) return recordIndex() < 0; } diff --git a/samples/Basic_Templates/basic_templates.hw b/samples/Basic_Templates/basic_templates.hw index bdaab43522..82d2938aef 100644 --- a/samples/Basic_Templates/basic_templates.hw +++ b/samples/Basic_Templates/basic_templates.hw @@ -13,7 +13,12 @@ "filename": "out/fwfs1.bin", "build": { "target": "fwfs-build", - "config": "fsimage.fwfs" + "config": { + "name": "Basic Templates demo volume", + "source": { + "/": "files" + } + } }, "readonly": true, "encrypted": false diff --git a/samples/Basic_Templates/fsimage.fwfs b/samples/Basic_Templates/fsimage.fwfs deleted file mode 100644 index 415fafb78f..0000000000 --- a/samples/Basic_Templates/fsimage.fwfs +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Basic Templates demo volume", - "source": { - "/": "files" - } -} \ No newline at end of file