Skip to content

Commit 7cdea30

Browse files
[packchk] Does it check for incomplete <processors>? #1535 (#1151) (#1978)
Co-authored-by: Thorsten de Buhr <[email protected]>
1 parent 536537a commit 7cdea30

File tree

6 files changed

+215
-4
lines changed

6 files changed

+215
-4
lines changed

tools/packchk/include/ValidateSemantic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class ValidateSemantic : public Validate
4545
bool CheckDeviceDependencies(RteDeviceItem* device, RteProject* rteProject);
4646
bool HasExternalGenerator(RteComponentAggregate* aggregate);
4747
bool FileIsHeader(const std::string& name);
48-
48+
bool CheckDeviceAttributes(RteDeviceItem *device);
49+
4950
const std::map<std::string, compiler_s>& GetCompilers() {
5051
return m_compilers;
5152
}

tools/packchk/src/PackChk.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ int PackChk::Check(int argc, const char* argv[], const char* envp[])
189189
return 1;
190190
}
191191

192-
LogMsg("M001", TXT(header));
192+
if(m_packOptions.GetLogPath() != "") {
193+
LogMsg("M001", TXT(header));
194+
}
195+
193196
bool bOk = CheckPackage();
194197

195198
if(ErrLog::Get()->GetErrCnt() || !bOk) {

tools/packchk/src/PackChk_Msgs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ const MsgTable PackChk::msgTable = {
236236
{ "M601", { MsgLevel::LEVEL_WARNING, CRLF_B, "'%TAG%' missing on '%TAG2%'" } },
237237
{ "M602", { MsgLevel::LEVEL_WARNING, CRLF_B, "Attribute '%ATTR%' already set, see Line %LINE%" } },
238238
{ "M603", { MsgLevel::LEVEL_WARNING, CRLF_B, "No license information found" } },
239-
{ "M604", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
240-
{ "M605", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
239+
{ "M604", { MsgLevel::LEVEL_WARNING, CRLF_B, "Currently no Dcore feature check for '%NAME%'" } },
240+
{ "M605", { MsgLevel::LEVEL_WARNING, CRLF_B, "Required Dcore '%NAME%' feature '%NAME2%' not defined" } },
241241
{ "M606", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
242242
{ "M607", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },
243243
{ "M608", { MsgLevel::LEVEL_WARNING, CRLF_B, "" } },

tools/packchk/src/ValidateSemantic.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,94 @@ bool ValidateSemantic::FileIsHeader(const std::string& name)
455455
return RteFsUtils::FileCategoryFromExtension(name) == "header";
456456
}
457457

458+
/**
459+
* @brief Check device attributes. Tests if all attributes like Dtz, Ddsp, ... are set
460+
* @param device RteDeviceItem to run on
461+
* @return passed / failed
462+
*/
463+
464+
const map<string, list<string>> processorFeaturesMap = {
465+
//{ "ARMV81MML" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
466+
{ "Cortex-M0" , { "Dfpu", "Dmpu", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
467+
{ "Cortex-M0+" , { "Dfpu", "Dmpu", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
468+
{ "Cortex-M1" , { "Dfpu", "Dmpu", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
469+
{ "Cortex-M3" , { "Dfpu", "Dmpu", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
470+
{ "Cortex-M4" , { "Dfpu", "Dmpu", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
471+
{ "Cortex-M7" , { "Dfpu", "Dmpu", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
472+
{ "Cortex-M23" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
473+
{ "Cortex-M33" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
474+
{ "Cortex-M35P" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dendian", "Dclock","DcoreVersion" } },
475+
{ "Cortex-M52" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dendian", "Dclock","DcoreVersion" } },
476+
{ "Cortex-M55" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dendian", "Dclock","DcoreVersion" } },
477+
{ "Cortex-M85" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dendian", "Dclock","DcoreVersion" } },
478+
{ "Star-MC1" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dendian", "Dclock","DcoreVersion" } },
479+
{ "SC000" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
480+
{ "SC300" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
481+
{ "ARMV8MBL" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
482+
{ "ARMV8MML" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dendian", "Dclock","DcoreVersion" } },
483+
{ "ARMV81MML" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dendian", "Dclock","DcoreVersion" } },
484+
/* Currently unchecked
485+
{ "Cortex-R4" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
486+
{ "Cortex-R5" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
487+
{ "Cortex-R7" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
488+
{ "Cortex-R8" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
489+
{ "Cortex-A5" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
490+
{ "Cortex-A7" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
491+
{ "Cortex-A8" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
492+
{ "Cortex-A9" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
493+
{ "Cortex-A15" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
494+
{ "Cortex-A17" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
495+
{ "Cortex-A32" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
496+
{ "Cortex-A35" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
497+
{ "Cortex-A53" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
498+
{ "Cortex-A57" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
499+
{ "Cortex-A72" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
500+
{ "Cortex-A73" , { "Dfpu", "Dmpu", "Dtz", "Ddsp", "Dmve", "Dcdecp", "Dpacbti", "Dendian", "Dclock","DcoreVersion" } },
501+
*/
502+
};
503+
504+
const list<string> processorMulticoreFeaturesList = {
505+
"Pname",
506+
};
507+
508+
bool ValidateSemantic::CheckDeviceAttributes(RteDeviceItem *device)
509+
{
510+
if(!device) {
511+
return true;
512+
}
513+
514+
bool bOk = false;
515+
int lineNo = device->GetLineNumber();
516+
const auto processors = device->GetProcessors();
517+
for(const auto& [core, processor] : processors) {
518+
const auto& Dcore = processor->GetAttribute("Dcore");
519+
const auto& processorFeatures = processorFeaturesMap.find(Dcore);
520+
if(processorFeatures == processorFeaturesMap.end()) {
521+
LogMsg("M604", NAME(Dcore), lineNo); // Dcore not found in list for feature check
522+
return true;
523+
}
524+
525+
const auto& features = processorFeatures->second;
526+
for(const auto& feature : features) {
527+
if(processor->GetEffectiveAttribute(feature) == "") {
528+
LogMsg("M605", NAME(Dcore), NAME2(feature), lineNo); // Required processor feature '%NAME%' not found.
529+
bOk = false;
530+
}
531+
}
532+
533+
// Test dependant features (if one is found, all the others must be present as well)
534+
if(processors.size() > 1) {
535+
for(const auto& requiredMulticoreFeature : processorMulticoreFeaturesList) {
536+
if(processor->GetEffectiveAttribute(requiredMulticoreFeature) == "") {
537+
LogMsg("M605", NAME(Dcore), NAME2(requiredMulticoreFeature), lineNo); // Required processor feature '%NAME%' not found.
538+
bOk = false;
539+
}
540+
}
541+
}
542+
}
543+
544+
return bOk;
545+
}
458546

459547
/**
460548
* @brief Check device dependencies. Tests if all dependencies are solved and a minimum
@@ -737,6 +825,7 @@ bool ValidateSemantic::TestMcuDependencies(RtePackage* pKg)
737825
pKg->GetEffectiveDeviceItems(devices);
738826
for(auto device : devices) {
739827
CheckDeviceDependencies(device, rteProject);
828+
CheckDeviceAttributes(device);
740829
}
741830

742831
model.DeleteProject(1);
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<package schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="PACK.xsd">
4+
<vendor>TestVendor</vendor>
5+
<url>http://www.keil.com/pack/</url>
6+
<name>ProcessorFeatures</name>
7+
<description>Test Processor Features</description>
8+
9+
<releases>
10+
<release version="1.0.0" date="2025-02-18">
11+
First Release version of ProcessorFeatures.
12+
</release>
13+
</releases>
14+
15+
<keywords>
16+
<!-- keywords for indexing -->
17+
<keyword>ARM</keyword>
18+
</keywords>
19+
20+
<conditions>
21+
<condition id="TestDevices">
22+
<description>Test devices</description>
23+
<require Dvendor="ARM:82" Dname="Test*"/>
24+
</condition>
25+
<condition id="Test ARMCC">
26+
<description>Filter for Test Device and the ARM compiler</description>
27+
<require condition="TestDevices"/>
28+
<require Tcompiler="ARMCC"/>
29+
</condition>
30+
</conditions>
31+
32+
33+
<devices>
34+
<family Dfamily="TestFamily" Dvendor="ARM:82">
35+
<algorithm name="Flash/ARMCMx_512.FLM" start="0x00000000" size="0x00040000" default="1"/>
36+
37+
<!-- ****************************** TestSubFamily ****************************** -->
38+
<subFamily DsubFamily="TestSubFamily">
39+
<compile header="Files/TestDevices.h" define="TESTDEVICES"/>
40+
41+
<description>The TestSubFamily</description>
42+
43+
<!-- ****************************** TestDevice1 ***************************** -->
44+
<device Dname="TestDevice1">
45+
<processor Dcore="Cortex-M4" Pname="Cortex-M4" DcoreVersion="r0p1" Dfpu="SP_FPU" Dmpu="MPU" Ddsp="NO_DSP" Dendian="Little-endian" Dclock="1000000" />
46+
47+
<processor Dcore="Cortex-M0" Pname="Cortex-M0" />
48+
<processor Dcore="Cortex-M0+" Pname="Cortex-M0+" />
49+
<processor Dcore="Cortex-M1" Pname="Cortex-M1" />
50+
<processor Dcore="Cortex-M3" Pname="Cortex-M3" />
51+
<processor Dcore="Cortex-M4" Pname="Cortex-M4" />
52+
<processor Dcore="Cortex-M7" Pname="Cortex-M7" />
53+
<processor Dcore="Cortex-M23" Pname="Cortex-M23" />
54+
<processor Dcore="Cortex-M33" Pname="Cortex-M33" />
55+
<processor Dcore="Cortex-M35P" Pname="Cortex-M35P" />
56+
<processor Dcore="Cortex-M52" Pname="Cortex-M52" />
57+
<processor Dcore="Cortex-M55" Pname="Cortex-M55" />
58+
<processor Dcore="Cortex-M85" Pname="Cortex-M85" />
59+
<processor Dcore="Star-MC1" Pname="Star-MC1" />
60+
<processor Dcore="SC000" Pname="SC000" />
61+
<processor Dcore="SC300" Pname="SC300" />
62+
<processor Dcore="ARMV8MBL" Pname="ARMV8MBL" />
63+
<processor Dcore="ARMV8MML" Pname="ARMV8MML" />
64+
<processor Dcore="ARMV81MML" Pname="ARMV81MML" />
65+
<processor Dcore="Cortex-R4" Pname="Cortex-R4" />
66+
67+
<memory id="IROM1" start="0x00000000" size="0x00040000" default="1" startup="1"/>
68+
<memory id="IRAM1" start="0x10000000" size="0x00010000" default="1" init ="0"/>
69+
<memory id="IRAM2" start="0x20000000" size="0x00010000" default="0" init ="0"/>
70+
</device>
71+
72+
</subFamily>
73+
</family>
74+
</devices>
75+
76+
<components>
77+
<component Cclass="Device" Cgroup="Startup" Cversion="1.0.0" condition="TestDevices">
78+
<description>System Startup for Test device series</description>
79+
<files>
80+
<file category="include" name="Files/"/>
81+
<file category="source" name="Files/startup_Test.s" attr="config" version="1.0.0" condition="Test ARMCC"/>
82+
<file category="source" name="Files/system_Test.c" attr="config" version="1.0.0" />
83+
</files>
84+
</component>
85+
</components>
86+
87+
</package>

tools/packchk/test/integtests/src/PackChkIntegTests.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,37 @@ TEST_F(PackChkIntegTests, CheckConditionComponentDependency_Pos) {
10771077
}
10781078
}
10791079

1080+
TEST_F(PackChkIntegTests, CheckProcessorFeatures) {
1081+
const char* argv[3];
1082+
1083+
string pdscFile = PackChkIntegTestEnv::localtestdata_dir +
1084+
"/ProcessorFeatures/TestVendor.ProcessorFeatures.pdsc";
1085+
ASSERT_TRUE(RteFsUtils::Exists(pdscFile));
1086+
1087+
argv[0] = (char*)"";
1088+
argv[1] = (char*)pdscFile.c_str();
1089+
argv[2] = (char*)"--disable-validation";
1090+
1091+
PackChk packChk;
1092+
EXPECT_EQ(1, packChk.Check(3, argv, nullptr));
1093+
1094+
auto errMsgs = ErrLog::Get()->GetLogMessages();
1095+
int M604_foundCnt = 0;
1096+
int M605_foundCnt = 0;
1097+
for (const string& msg : errMsgs) {
1098+
if (msg.find("M604", 0) != string::npos) {
1099+
M604_foundCnt++;
1100+
}
1101+
if (msg.find("M605", 0) != string::npos) {
1102+
M605_foundCnt++;
1103+
}
1104+
}
1105+
1106+
if(M604_foundCnt != 1 || M605_foundCnt != 98) {
1107+
FAIL() << "error: Missing message M604, M605: processor features";
1108+
}
1109+
}
1110+
10801111
TEST_F(PackChkIntegTests, CheckConditionComponentDependency_Neg) {
10811112
const char* argv[5];
10821113

0 commit comments

Comments
 (0)