Skip to content

Commit 1ed15db

Browse files
grasci-armthorstendb-ARMedriouk
authored
[packchk] Validate <mountedDevice> specifying an existing device #1079 (#1994)
* [packchk] issue warning for explicit include paths in *.pdsc to config files #1644 Co-authored-by: Thorsten de Buhr <[email protected]> Co-authored-by: Evgueni Driouk <[email protected]>
1 parent 5fc2808 commit 1ed15db

File tree

7 files changed

+107
-12
lines changed

7 files changed

+107
-12
lines changed

tools/packchk/src/PackChk_Msgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const MsgTable PackChk::msgTable = {
243243
{ "M608", { MsgLevel::LEVEL_WARNING, CRLF_B, "Memory '%NAME%' with '%ATTR%'='%VALUE%' must have '%ATTR2%'='%VALUE2%'" } },
244244
{ "M609", { MsgLevel::LEVEL_WARNING, CRLF_B, "Processor '%NAME%': Exact one memory with attribute \"startup=1\" must be configured, but found %NUM%" } },
245245
{ "M610", { MsgLevel::LEVEL_WARNING, CRLF_B, "File category '%CAT%': '%NAME%' redefined in component '%NAME2%', see Line %LINE%" } },
246-
246+
{ "M611", { MsgLevel::LEVEL_WARNING, CRLF_B, "Multiple devices or variants defined by '[%VENDOR%] %MCU%'" } },
247247
};
248248

249249
const MsgTableStrict PackChk::msgStrictTable = {

tools/packchk/src/ValidateSyntax.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,11 +1697,7 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
16971697

16981698
map<string, RteItem*> mountedDeviceIndex;
16991699
for(auto mountedDevice : mountedDevices) {
1700-
if(!mountedDevice) {
1701-
continue;
1702-
}
17031700
lineNo = mountedDevice->GetLineNumber();
1704-
17051701
const auto& devIdx = mountedDevice->GetAttribute("deviceIndex");
17061702
auto foundDevIdxIt = mountedDeviceIndex.find(devIdx);
17071703
if(foundDevIdxIt != mountedDeviceIndex.end()) {
@@ -1740,6 +1736,16 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
17401736
continue;
17411737
}
17421738

1739+
if(devices.size() > 1) {
1740+
LogMsg("M100", lineNo);
1741+
}
1742+
1743+
for(const auto device : devices) {
1744+
if(device->GetDeviceItemCount() > 0) {
1745+
LogMsg("M611", VENDOR(dvendor), MCU(dname), lineNo);
1746+
}
1747+
}
1748+
17431749
RteDevice* foundDevice = *devices.begin();
17441750
const string foundDName = foundDevice->GetName();
17451751
const string foundDVendor = foundDevice->GetVendorString();
@@ -1750,12 +1756,7 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
17501756
LogMsg("M381", VENDOR(dvendor), MCU(dname), VENDOR2(foundDVendor), MCU2(foundDName), LINE(lNo), board->GetLineNumber());
17511757
}
17521758

1753-
if(devices.empty()) {
1754-
LogMsg("M346", VAL("BOARD", boardName), VAL("DEVICE", dname), lineNo);
1755-
}
1756-
else {
1757-
LogMsg("M010");
1758-
}
1759+
LogMsg("M010");
17591760
}
17601761

17611762
// ------------ compatible devices ------------------
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<package schemaVersion="1.3" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="PACK.xsd">
4+
<name>RteTestBoard</name>
5+
<description>Testing packages listing</description>
6+
<vendor>ARM</vendor>
7+
8+
<releases>
9+
<release version="0.1.0" date="2022-03-11">
10+
Initial version
11+
</release>
12+
</releases>
13+
14+
<requirements>
15+
<packages>
16+
<package vendor="ARM" name="RteTest_DFP" version="0.1.1:0.2.0"/>
17+
</packages>
18+
</requirements>
19+
20+
<boards>
21+
<board name="RteTest board listing" vendor="Keil" revision="Rev.C">
22+
<description>uVision Simulator</description>
23+
<mountedDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM0"/>
24+
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM3"/>
25+
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM4_NOFP"/>
26+
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM4_FP"/>
27+
<algorithm name="Board/Flash/BoargAlgo1.FLM" start="0x00000000" size="0x00040000" default="1"/>
28+
<algorithm name="Board/Flash/BoargAlgo2.FLM" start="0x00000000" size="0x00020000" default="0"/>
29+
<memory name="BoardFLASH" access="rx" start="0x30000000" size="0x00040000" startup="1" default="1"/>
30+
<memory name="BoardRAM" access="rwx" start="0x40000000" size="0x00020000" uninit="1" default="1"/>
31+
</board>
32+
<board name="RteTest NoMCU board" vendor="Keil">
33+
<description>No device board</description>
34+
<mountedDevice Dvendor="NO_VENDOR:0" Dname="NO_MCU"/>
35+
<memory name="BoardFLASH" access="rx" start="0x30000000" size="0x00040000" startup="1" default="1"/>
36+
<memory name="BoardRAM" access="rwx" start="0x40000000" size="0x00020000" uninit="1" default="1"/>
37+
</board>
38+
<board name="RteTest CM4 board" vendor="Keil" revision="Rev.C">
39+
<description>uVision Simulator</description>
40+
<book category="overview" name="https://www.keil.arm.com/boards/" title="Development boards for application prototyping"/>
41+
<book category="other" name="Documents/README.md" title="Guide" public="true"/>
42+
<mountedDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM4"/>
43+
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM4_NOFP"/>
44+
<algorithm name="Board/Flash/BoargAlgo1.FLM" start="0x00000000" size="0x00040000" default="1"/>
45+
<algorithm name="Board/Flash/BoargAlgo2.FLM" start="0x00000000" size="0x00020000" default="0"/>
46+
<memory name="BoardFLASH" access="rx" start="0x30000000" size="0x00040000" startup="1" default="1"/>
47+
<memory name="BoardRAM" access="rwx" start="0x40000000" size="0x00020000" default="1"/>
48+
</board>
49+
</boards>
50+
51+
</package>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CortexM4Device.FLM : not real flash algorithm
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CortexM4SubFamily.FLM : not real flash algorithm
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Board documentation

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ TEST_F(PackChkIntegTests, CheckSchemaValidation) {
942942
}
943943
}
944944

945-
// Validate invalid file path (file is directory)
945+
// Validate mounted and compatible board devices
946946
TEST_F(PackChkIntegTests, CheckBoardMountedCompatibleDevices) {
947947
const char* argv[5];
948948

@@ -992,6 +992,46 @@ TEST_F(PackChkIntegTests, CheckBoardMountedCompatibleDevices) {
992992
}
993993
}
994994

995+
TEST_F(PackChkIntegTests, CheckBoardMountedCompatibleDevices2) {
996+
const char* argv[9];
997+
998+
const string& pdscFile = PackChkIntegTestEnv::localtestdata_dir +
999+
"/RteTestBoard/ARM.RteTestBoard.pdsc";
1000+
const string& pdscFileAdd1 = PackChkIntegTestEnv::globaltestdata_dir +
1001+
"/packs/ARM/RteTest/0.1.0/ARM.RteTest.pdsc";
1002+
const string& pdscFileAdd2 = PackChkIntegTestEnv::globaltestdata_dir +
1003+
"/packs/ARM/RteTest_DFP/0.2.0/ARM.RteTest_DFP.pdsc";
1004+
ASSERT_TRUE(RteFsUtils::Exists(pdscFile));
1005+
ASSERT_TRUE(RteFsUtils::Exists(pdscFileAdd1));
1006+
ASSERT_TRUE(RteFsUtils::Exists(pdscFileAdd1));
1007+
1008+
argv[0] = (char*)"";
1009+
argv[1] = (char*)pdscFile.c_str();
1010+
argv[2] = (char*)"-i";
1011+
argv[3] = (char*)pdscFileAdd1.c_str();
1012+
argv[4] = (char*)"-i";
1013+
argv[5] = (char*)pdscFileAdd2.c_str();
1014+
argv[6] = (char*)"--disable-validation";
1015+
argv[7] = (char*)"-x";
1016+
argv[8] = (char*)"!M611";
1017+
1018+
PackChk packChk;
1019+
EXPECT_EQ(0, packChk.Check(9, argv, nullptr));
1020+
1021+
auto errMsgs = ErrLog::Get()->GetLogMessages();
1022+
int M611_foundCnt = 0;
1023+
for (const string& msg : errMsgs) {
1024+
size_t s;
1025+
if ((s = msg.find("M611")) != string::npos) {
1026+
M611_foundCnt++;
1027+
}
1028+
}
1029+
1030+
if (M611_foundCnt != 1) {
1031+
FAIL() << "error: missing message(s) on check mounted devices: multiple devices found";
1032+
}
1033+
}
1034+
9951035
TEST_F(PackChkIntegTests, CheckSupportCcFiles) {
9961036
const char* argv[3];
9971037

0 commit comments

Comments
 (0)