From 7e42d8df7a8c6a70ef1d36323565d043bd56295e Mon Sep 17 00:00:00 2001 From: Daniel Brondani Date: Mon, 27 Jul 2026 12:15:28 +0200 Subject: [PATCH] Support custom RAM settings for programming algorithms Parse and validate ram-start and ram-size on target memory entries, and use them instead of the default RAM settings in generated run/debug data. --- tools/projmgr/include/ProjMgrParser.h | 4 +++ tools/projmgr/include/ProjMgrRunDebug.h | 1 + tools/projmgr/schemas/common.schema.json | 4 ++- tools/projmgr/src/ProjMgrRunDebug.cpp | 24 ++++++++++++----- tools/projmgr/src/ProjMgrYamlParser.cpp | 2 ++ .../ref/run-debug+TestHW.cbuild-run.yml | 4 +-- .../data/TestRunDebug/run-debug.csolution.yml | 2 ++ .../test/src/ProjMgrWorkerUnitTests.cpp | 27 +++++++++++++++++++ 8 files changed, 58 insertions(+), 10 deletions(-) diff --git a/tools/projmgr/include/ProjMgrParser.h b/tools/projmgr/include/ProjMgrParser.h index 93853b1f0..7e1feaa7d 100644 --- a/tools/projmgr/include/ProjMgrParser.h +++ b/tools/projmgr/include/ProjMgrParser.h @@ -121,6 +121,8 @@ struct ProcessorItem { * size * algorithm * pname + * ram start + * ram size */ struct MemoryItem { std::string name; @@ -129,6 +131,8 @@ struct MemoryItem { std::string size; std::string algorithm; std::string pname; + std::string ramStart; + std::string ramSize; }; /** diff --git a/tools/projmgr/include/ProjMgrRunDebug.h b/tools/projmgr/include/ProjMgrRunDebug.h index 800559637..0d9250bce 100644 --- a/tools/projmgr/include/ProjMgrRunDebug.h +++ b/tools/projmgr/include/ProjMgrRunDebug.h @@ -274,6 +274,7 @@ class ProjMgrRunDebug { const RteItem* item, const std::string pname); void AddGeneratedImage(const ContextItem* context, const std::string& filename, const std::string& type, const std::string& load); void AddGeneratedImages(const ContextItem* context); + bool CheckDefaultRam(const RamType& defaultRam); void SetAccessPorts(std::vector& parent, const std::map>& childrenMap); void SetProtNodes(const RteDeviceProperty* item, AccessPortType& ap); diff --git a/tools/projmgr/schemas/common.schema.json b/tools/projmgr/schemas/common.schema.json index 5ef42b77c..123d81ef7 100644 --- a/tools/projmgr/schemas/common.schema.json +++ b/tools/projmgr/schemas/common.schema.json @@ -2109,7 +2109,9 @@ "start": { "title": "start:", "type": "number", "description": "Base address of the memory." }, "size": { "title": "size:", "type": "number", "description": "Size of the memory." }, "pname": { "title": "pname:", "type": "string", "description": "Only accessible by the specified processor." }, - "algorithm":{ "title": "algorithm:", "type": "string", "description": "Programming algorithm for download." } + "algorithm":{ "title": "algorithm:", "type": "string", "description": "Programming algorithm for download." }, + "ram-start":{ "title": "ram-start:", "type": "number", "description": "Start address of RAM where the algorithm will be executed from." }, + "ram-size": { "title": "ram-size:", "type": "number", "description": "Maximum size of RAM available for executing the programming algorithm." } }, "additionalProperties": false, "required": ["name", "access", "start", "size"] diff --git a/tools/projmgr/src/ProjMgrRunDebug.cpp b/tools/projmgr/src/ProjMgrRunDebug.cpp index 0f6f2a7be..35eddaeb3 100644 --- a/tools/projmgr/src/ProjMgrRunDebug.cpp +++ b/tools/projmgr/src/ProjMgrRunDebug.cpp @@ -150,10 +150,6 @@ bool ProjMgrRunDebug::CollectSettings(const vector& contexts, cons break; } } - if (defaultRam.size == 0) { - ProjMgrLogger::Get().Error("no default rwx memory nor algorithm with ramstart/size was found"); - return false; - } } // board collections @@ -199,6 +195,9 @@ bool ProjMgrRunDebug::CollectSettings(const vector& contexts, cons item.ram.size = algorithm->GetAttributeAsULL("RAMsize"); item.ram.pname = algorithm->GetProcessorName(); } else { + if (!CheckDefaultRam(defaultRam)) { + return false; + } item.ram.start = defaultRam.start; item.ram.size = defaultRam.size; item.ram.pname = defaultRam.pname; @@ -236,9 +235,12 @@ bool ProjMgrRunDebug::CollectSettings(const vector& contexts, cons algoItem.algorithm = memory.algorithm; algoItem.start = memItem.start; algoItem.size = memItem.size; - algoItem.ram.start = defaultRam.start; - algoItem.ram.size = defaultRam.size; - algoItem.ram.pname = defaultRam.pname; + if ((memory.ramStart.empty() || memory.ramSize.empty()) && !CheckDefaultRam(defaultRam)) { + return false; + } + algoItem.ram.start = memory.ramStart.empty() ? defaultRam.start : RteUtils::StringToULL(memory.ramStart); + algoItem.ram.size = memory.ramSize.empty() ? defaultRam.size : RteUtils::StringToULL(memory.ramSize); + algoItem.ram.pname = memory.pname.empty() ? defaultRam.pname : memory.pname; m_runDebug.algorithms.push_back(algoItem); } } @@ -380,6 +382,14 @@ bool ProjMgrRunDebug::CollectSettings(const vector& contexts, cons return true; } +bool ProjMgrRunDebug::CheckDefaultRam(const RamType& defaultRam) { + if (defaultRam.size != 0) { + return true; + } + ProjMgrLogger::Get().Error("no default rwx memory nor algorithm with ramstart/size was found"); + return false; +} + void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const DebugAdaptersItem& adapters, const std::map& pnames) { // default debugger parameters from DFP and BSP diff --git a/tools/projmgr/src/ProjMgrYamlParser.cpp b/tools/projmgr/src/ProjMgrYamlParser.cpp index 8220afd97..14237e430 100644 --- a/tools/projmgr/src/ProjMgrYamlParser.cpp +++ b/tools/projmgr/src/ProjMgrYamlParser.cpp @@ -1101,6 +1101,8 @@ bool ProjMgrYamlParser::ParseTargetType(const YAML::Node& parent, const string& ParseString(memoryEntry, YAML_ALGORITHM, memoryItem.algorithm); ParseNumber(memoryEntry, file, YAML_START, memoryItem.start); ParseNumber(memoryEntry, file, YAML_SIZE, memoryItem.size); + ParseNumber(memoryEntry, file, YAML_RAM_START, memoryItem.ramStart); + ParseNumber(memoryEntry, file, YAML_RAM_SIZE, memoryItem.ramSize); targetType.memory.push_back(memoryItem); } } diff --git a/tools/projmgr/test/data/TestRunDebug/ref/run-debug+TestHW.cbuild-run.yml b/tools/projmgr/test/data/TestRunDebug/ref/run-debug+TestHW.cbuild-run.yml index 8c140838b..4f9a805c0 100644 --- a/tools/projmgr/test/data/TestRunDebug/ref/run-debug+TestHW.cbuild-run.yml +++ b/tools/projmgr/test/data/TestRunDebug/ref/run-debug+TestHW.cbuild-run.yml @@ -161,8 +161,8 @@ cbuild-run: - algorithm: ../../data/TestRunDebug/CustomAlgo.flm start: 0x80000000 size: 0x00010000 - ram-start: 0x20000000 - ram-size: 0x00020000 + ram-start: 0x80000000 + ram-size: 0x00008000 flash-info: - name: Family Flash start: 0x80000000 diff --git a/tools/projmgr/test/data/TestRunDebug/run-debug.csolution.yml b/tools/projmgr/test/data/TestRunDebug/run-debug.csolution.yml index c567e051d..d0ee7e49e 100644 --- a/tools/projmgr/test/data/TestRunDebug/run-debug.csolution.yml +++ b/tools/projmgr/test/data/TestRunDebug/run-debug.csolution.yml @@ -14,6 +14,8 @@ solution: name: CustomMemory access: rwx algorithm: CustomAlgo.flm + ram-start: 0x80000000 + ram-size: 0x00008000 target-set: - set: info: Info target-set diff --git a/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp b/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp index 8dae828aa..1616e2f7f 100644 --- a/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp @@ -145,6 +145,33 @@ TEST_F(ProjMgrWorkerUnitTests, ProcessDevice) { EXPECT_TRUE(context.targetAttributes.find("Dendian") == context.targetAttributes.end()); } +TEST_F(ProjMgrWorkerUnitTests, CheckDefaultRam) { + ContextDesc descriptor; + const string& filename = testinput_folder + "/TestProject/test.cproject.yml"; + ASSERT_TRUE(parser.ParseCproject(filename, true)); + ASSERT_TRUE(AddContexts(parser, descriptor, filename)); + map* contextMap; + GetContexts(contextMap); + ContextItem context = contextMap->begin()->second; + ASSERT_TRUE(LoadPacks(context)); + ASSERT_TRUE(ProcessPrecedences(context)); + ASSERT_TRUE(ProcessDevice(context)); + + context.devicePack = nullptr; + context.boardPack = nullptr; + context.memory = {{ "CustomMemory", "rwx", "0x80000000", "0x00010000", + "CustomAlgo.flm", {}, "0x80000000", {} }}; + const vector contexts = { &context }; + ProjMgrRunDebug runDebug; + + ProjMgrLogger::Get().Clear(); + EXPECT_FALSE(runDebug.CollectSettings(contexts, parser.GetDebugAdaptersItem())); + const auto& errors = ProjMgrLogger::Get().GetErrorsForContext(); + ASSERT_EQ(1, errors.size()); + EXPECT_EQ("no default rwx memory nor algorithm with ramstart/size was found", errors.front()); + ProjMgrLogger::Get().Clear(); +} + TEST_F(ProjMgrWorkerUnitTests, ProcessDeviceUndefLayerVar) { ContextItem context; EXPECT_TRUE(LoadPacks(context));