Skip to content

Commit 13dc507

Browse files
grasci-armbrondani
andauthored
[projmgr] Handle processor name for user specified image
Co-authored-by: Daniel Brondani <[email protected]>
1 parent 56da53b commit 13dc507

File tree

7 files changed

+49
-5
lines changed

7 files changed

+49
-5
lines changed

tools/projmgr/include/ProjMgrParser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ struct DebuggerItem {
166166
* type specifies an explicit file type
167167
* load mode
168168
* load offset
169+
* processor name associated with specified image
169170
*/
170171
struct ImageItem {
171172
std::string context;
@@ -174,6 +175,7 @@ struct ImageItem {
174175
std::string type;
175176
std::string load;
176177
std::string offset;
178+
std::string pname;
177179
};
178180

179181
/**

tools/projmgr/schemas/common.schema.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@
222222
"title": "device:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#device",
223223
"type": "string",
224224
"pattern": "^(([ -9;-~]+::)?[ -9;-~]+)?(:[ -9;-~]+)?$",
225-
"description": "Unique device name. Overrules default board device setting.\nA unique processor ID is reqiured for devices with multiple processors.\nExample: STMicroelectronics::STM32H735IGK"
225+
"description": "Unique device name. Overrules default board device setting.\nA unique processor ID is required for devices with multiple processors.\nExample: STMicroelectronics::STM32H735IGK"
226+
},
227+
"ProcessorNameType": {
228+
"title": "device:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#device",
229+
"type": "string",
230+
"pattern": "^:[ -9;-~]+$",
231+
"description": "Unique processor ID.\nFormat :pname (see device name convention).\nExample: :cm0plus"
226232
},
227233
"BoardType": {
228234
"title": "board:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#board",
@@ -2367,11 +2373,12 @@
23672373
"info": { "type": "string", "description": "Brief description of the image file." },
23682374
"type": { "enum": [ "elf", "hex", "bin", "lib" ], "description": "Specifies an explicit image type." },
23692375
"load": { "$ref": "#/definitions/TargetSetLoadType" },
2370-
"load-offset": { "type": "number", "description": "Offset applied to the binary content when loading the image file." }
2376+
"load-offset": { "type": "number", "description": "Offset applied to the binary content when loading the image file." },
2377+
"device": { "$ref": "#/definitions/ProcessorNameType" }
23712378
},
23722379
"additionalProperties": false,
23732380
"oneOf": [
2374-
{ "required": ["project-context"], "not": {"required": ["image", "type"]} },
2381+
{ "required": ["project-context"], "not": {"required": ["image", "type", "device"]} },
23752382
{ "required": ["image"], "not": {"required": ["project-context"]} }
23762383
]
23772384
},

tools/projmgr/src/ProjMgrRunDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts, cons
242242
item.load = item.type == RteConstants::OUTPUT_TYPE_ELF ? LOAD_IMAGE_SYMBOLS :
243243
item.type == RteConstants::OUTPUT_TYPE_LIB ? LOAD_NONE : LOAD_IMAGE;
244244
}
245-
m_runDebug.outputs.push_back({ item.image, item.info, item.type, item.load, item.offset });
245+
m_runDebug.outputs.push_back({ item.image, item.info, item.type, item.load, item.offset, item.pname });
246246
}
247247

248248
// debug vars

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ bool ProjMgrWorker::ProcessDevice(ContextItem& context, BoardOrDevice process) {
14131413
if (!deviceItem.pname.empty()) {
14141414
ProjMgrLogger::Get().Error("processor name '" + deviceItem.pname + "' was not found", context.name);
14151415
return false;
1416-
} else if (!HasVarDefineError() && process != BoardOrDevice::SkipProcessor) {
1416+
} else if (!HasVarDefineError() && process != BoardOrDevice::SkipProcessor && !context.imageOnly) {
14171417
string msg = "one of the following processors must be specified:";
14181418
const auto& processors = matchedDevice->GetProcessors();
14191419
for (const auto& p : processors) {

tools/projmgr/src/ProjMgrYamlParser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,8 @@ void ProjMgrYamlParser::ParseImages(const YAML::Node& parent, const string& file
10651065
ParseString(imagesEntry, YAML_INFO, imageItem.info);
10661066
ParseString(imagesEntry, YAML_TYPE, imageItem.type);
10671067
ParseString(imagesEntry, YAML_LOAD, imageItem.load);
1068+
ParseString(imagesEntry, YAML_DEVICE, imageItem.pname);
1069+
imageItem.pname = RteUtils::ExtractSuffix(imageItem.pname);
10681070
ParseNumber(imagesEntry, file, YAML_LOAD_OFFSET, imageItem.offset);
10691071
images.push_back(imageItem);
10701072
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
5+
packs:
6+
- pack: ARM::RteTest_DFP
7+
8+
target-types:
9+
- type: CM0
10+
device: RteTest_ARMCM0_Dual
11+
target-set:
12+
- set:
13+
debugger:
14+
name: CMSIS-DAP
15+
images:
16+
- image: ./images/image1.elf
17+
device: :cm0_core0
18+
- image: ./images/image2.elf
19+
device: :cm0_core1

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7093,6 +7093,20 @@ TEST_F(ProjMgrUnitTests, ImageOnly) {
70937093
testinput_folder + "/ImageOnly/ref/image-only+CM0.cbuild-run.yml");
70947094
}
70957095

7096+
TEST_F(ProjMgrUnitTests, ImageOnlyMulticore) {
7097+
char* argv[5];
7098+
const string& csolution = testinput_folder + "/ImageOnly/image-only-multicore.csolution.yml";
7099+
argv[1] = (char*)"convert";
7100+
argv[2] = (char*)csolution.c_str();
7101+
argv[3] = (char*)"--active";
7102+
argv[4] = (char*)"CM0";
7103+
EXPECT_EQ(0, RunProjMgr(5, argv, m_envp));
7104+
7105+
const YAML::Node& cbuildRun = YAML::LoadFile(testinput_folder + "/ImageOnly/out/image-only-multicore+CM0.cbuild-run.yml");
7106+
EXPECT_EQ("cm0_core0", cbuildRun["cbuild-run"]["output"][0]["pname"].as<string>());
7107+
EXPECT_EQ("cm0_core1", cbuildRun["cbuild-run"]["output"][1]["pname"].as<string>());
7108+
}
7109+
70967110
TEST_F(ProjMgrUnitTests, ListDebuggers) {
70977111
char* argv[6];
70987112
StdStreamRedirect streamRedirect;

0 commit comments

Comments
 (0)