Skip to content

Commit 46454c9

Browse files
PackChk: enhancement - add check for <board> element <mountedDevice> (#1131)
* PackChk: enhancement - add check for <board> element <mountedDevice>
1 parent c56c2cf commit 46454c9

File tree

6 files changed

+379
-32
lines changed

6 files changed

+379
-32
lines changed

tools/packchk/include/ValidateSyntax.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ValidateSyntax : public Validate
8888
std::map<std::string, std::list<RteDeviceItem*> > m_allItems;
8989
std::map<std::string, std::list<RteDeviceItem*> > m_allDevices;
9090
std::string m_pdscFullpath;
91-
std::map<std::string, RteBoard*> boardsFound;
91+
std::map<std::string, RteBoard*> m_boardsFound;
9292

9393
FEATURE_TABLE m_featureTableDevice;
9494
FEATURE_TABLE m_featureTableBoard;

tools/packchk/src/PackChk_Msgs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ const MsgTable PackChk::msgTable = {
131131
{ "M315", { MsgLevel::LEVEL_ERROR, CRLF_B, "Invalid URL / Paths to Drives are not allowed in Package URL: '%URL%'" } },
132132
{ "M316", { MsgLevel::LEVEL_WARNING, CRLF_B, "URL must end with slash '/': '%URL%'" } },
133133
{ "M317", { MsgLevel::LEVEL_WARNING, CRLF_B, "Condition '%NAME%': No component found for '%NAME2%'" } },
134-
{ "M318", { MsgLevel::LEVEL_ERROR, CRLF_B, "" } },
135-
{ "M319", { MsgLevel::LEVEL_ERROR, CRLF_B, "" } },
134+
{ "M318", { MsgLevel::LEVEL_WARNING, CRLF_B, "Attribute '%TAG%' must not have '%TAG2%'" } },
135+
{ "M319", { MsgLevel::LEVEL_ERROR, CRLF_B, "'%TAG%' already defined for '%TAG2%'" } },
136136
{ "M320", { MsgLevel::LEVEL_ERROR, CRLF_B, "" } },
137137
{ "M321", { MsgLevel::LEVEL_ERROR, CRLF_B, "DS5 project requires '.project' file." } },
138138
{ "M322", { MsgLevel::LEVEL_ERROR, CRLF_B, "Associated File/Path not found: '%PATH%'" } },
@@ -184,7 +184,7 @@ const MsgTable PackChk::msgTable = {
184184
{ "M365", { MsgLevel::LEVEL_ERROR, CRLF_B, "Redefined %DEVTYPE% '%MCU%' found, see Line %LINE%" } },
185185
{ "M366", { MsgLevel::LEVEL_ERROR, CRLF_B, "Redefined %DEVTYPEEXIST% as %DEVTYPE% '%MCU%' found, see Line %LINE%" } },
186186
{ "M367", { MsgLevel::LEVEL_ERROR, CRLF_B, "Redefined %TYPE% '%NAME%' found, see Line %LINE%" } },
187-
{ "M368", { MsgLevel::LEVEL_ERROR, CRLF_B, "" } },
187+
{ "M368", { MsgLevel::LEVEL_ERROR, CRLF_B, "Cannot check '%NAME%'%MSG%" } },
188188
{ "M369", { MsgLevel::LEVEL_WARNING3, CRLF_B, "Feature is already defined for '%MCU%' and will be added, see Line %LINE%: '%PROP%'" } },
189189
{ "M370", { MsgLevel::LEVEL_WARNING, CRLF_B, "URL is not conformant: '%URL%':\n Backslashes are not allowed in URL, use forward slashes." } },
190190
{ "M371", { MsgLevel::LEVEL_ERROR, CRLF_B, "%SECTION% Feature for '%MCU%': '%FEATURE%' unknown." } },

tools/packchk/src/ValidateSyntax.cpp

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,8 +1496,8 @@ bool ValidateSyntax::CheckAddBoard(RteBoard* board)
14961496
const string& name = board->GetID();
14971497

14981498
bool ok = false;
1499-
auto it = boardsFound.find(name);
1500-
if(it != boardsFound.end()) { // board already exists
1499+
auto it = m_boardsFound.find(name);
1500+
if(it != m_boardsFound.end()) { // board already exists
15011501
RteBoard* board2 = it->second;
15021502
int lineNo2 = board2->GetLineNumber();
15031503
const string& path = board2->GetPackage()->GetPackageFileName();
@@ -1506,7 +1506,7 @@ bool ValidateSyntax::CheckAddBoard(RteBoard* board)
15061506
ok = false;
15071507
}
15081508
else {
1509-
boardsFound[name] = board;
1509+
m_boardsFound[name] = board;
15101510
}
15111511

15121512
return ok;
@@ -1602,32 +1602,43 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
16021602
LogMsg("M375", VAL("BOARD", boardName));
16031603
}
16041604

1605-
for(auto mountItem : mountedDevices) {
1606-
RteItem* dev = dynamic_cast<RteItem*>(mountItem);
1607-
if(!dev) {
1605+
map<string, RteItem*> mountedDeviceIndex;
1606+
for(auto mountedDevice : mountedDevices) {
1607+
if(!mountedDevice) {
16081608
continue;
16091609
}
1610+
lineNo = mountedDevice->GetLineNumber();
16101611

1611-
const string& dvendor = dev->GetAttribute("Dvendor");
1612-
string dname = dev->GetAttribute("Dname");
1613-
lineNo = dev->GetLineNumber();
1614-
if(dname.empty()) {
1615-
dname = dev->GetAttribute("DsubFamily");
1612+
const auto& devIdx = mountedDevice->GetAttribute("deviceIndex");
1613+
auto foundDevIdxIt = mountedDeviceIndex.find(devIdx);
1614+
if(foundDevIdxIt != mountedDeviceIndex.end()) {
1615+
const RteItem* foundDev = foundDevIdxIt->second;
1616+
LogMsg("M319", TAG("deviceIndex"), TAG2(foundDev->GetDeviceName()));
1617+
}
1618+
else {
1619+
mountedDeviceIndex[devIdx] = mountedDevice;
1620+
}
16161621

1617-
if(dname.empty()) {
1618-
dname = dev->GetAttribute("Dfamily");
1619-
}
1622+
const string& dvendor = mountedDevice->GetAttribute("Dvendor");
1623+
if(dvendor.empty()) {
1624+
LogMsg("M308", TAG("Dvendor"), TAG2(mountedDevice->GetTag()), lineNo);
1625+
}
16201626

1621-
if(dname.empty()) {
1622-
continue;
1623-
}
1627+
string dname = mountedDevice->GetAttribute("Dname");
1628+
if(dname.empty()) {
1629+
LogMsg("M308", TAG("Dname"), TAG2(mountedDevice->GetTag()), lineNo);
16241630
}
16251631

16261632
LogMsg("M060", VAL("BOARD", boardName), VAL("DEVICE", dname));
16271633

1634+
if(dname.empty() || dname.empty()) {
1635+
continue;
1636+
}
1637+
16281638
list<RteDevice*> devices;
16291639
GetModel().GetDevices(devices, dname, dvendor);
16301640
if(devices.empty()) {
1641+
LogMsg("M346", VAL("BOARD", boardName), VAL("DEVICE", dname), lineNo);
16311642
continue;
16321643
}
16331644

@@ -1653,14 +1664,26 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
16531664
Collection<RteItem*> compatibleDevices;
16541665
board->GetCompatibleDevices(compatibleDevices);
16551666

1656-
for(auto device : compatibleDevices) {
1657-
if(!device) {
1667+
for(auto compatibleDevice : compatibleDevices) {
1668+
if(!compatibleDevice) {
16581669
continue;
16591670
}
16601671

1661-
const string& dvendor = device->GetAttribute("Dvendor");
1662-
string dname = device->GetAttribute("Dname");
1672+
const auto& dfamily = compatibleDevice->GetAttribute("Dfamily");
1673+
if(!dfamily.empty()) {
1674+
LogMsg("M318", TAG(compatibleDevice->GetTag()), TAG2("Dfamily"), compatibleDevice->GetLineNumber());
1675+
}
1676+
1677+
const auto& dsubfamily = compatibleDevice->GetAttribute("DsubFamily");
1678+
if(!dsubfamily.empty()) {
1679+
LogMsg("M318", TAG(compatibleDevice->GetTag()), TAG2("DsubFamily"), compatibleDevice->GetLineNumber());
1680+
}
1681+
1682+
const auto& dvendor = compatibleDevice->GetAttribute("Dvendor");
1683+
1684+
const auto& dname = compatibleDevice->GetAttribute("Dname");
16631685
if(dname.empty()) {
1686+
LogMsg("M368", NAME(compatibleDevice->GetTag()), MSG(", no 'Dname' could be calculated"), compatibleDevice->GetLineNumber());
16641687
continue;
16651688
}
16661689

@@ -1669,7 +1692,7 @@ bool ValidateSyntax::CheckBoards(RtePackage* pKg)
16691692
list<RteDevice*> devices;
16701693
GetModel().GetDevices(devices, dname, dvendor);
16711694
if(devices.empty()) {
1672-
LogMsg("M346", VAL("BOARD", boardName), VAL("DEVICE", dname), device->GetLineNumber());
1695+
LogMsg("M346", VAL("BOARD", boardName), VAL("DEVICE", dname), compatibleDevice->GetLineNumber());
16731696
continue;
16741697
}
16751698

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<package schemaVersion="1.2" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="PACK.xsd">
4+
<vendor>Keil</vendor>
5+
<name>BulbBoard_BSP</name>
6+
<description>Glyn Bulb Board Development Board Support Package</description>
7+
<url>http://www.keil.com/pack</url>
8+
9+
<releases>
10+
<release version="1.1.0" date="2019-05-28">
11+
Updated Device Vendor: changed from Spansion to Cypress.
12+
Updated PDSC file: backward slashes changed to forward slashes in file references.
13+
</release>
14+
<release version="1.0.0" date="2014-09-04">
15+
First Release version of Bulb Board Board Support Pack.
16+
</release>
17+
</releases>
18+
19+
<keywords>
20+
<!-- keywords for indexing -->
21+
<keyword>Glyn</keyword>
22+
<keyword>Cypress</keyword>
23+
<keyword>Board Support</keyword>
24+
<keyword>S6E1A12B0AGP2</keyword>
25+
<keyword>FM0+</keyword>
26+
</keywords>
27+
28+
<boards>
29+
<board vendor="Glyn" name="Bulb Board" revision="v1.1" salesContact="[email protected]" orderForm="http://www.glyn.de/ideen-board">
30+
<description>Glyn Bulb Board Support</description>
31+
<image small="Images/BulbBoard_rot_small.jpg" large="Images/BulbBoard_rot_165px.jpg"/>
32+
<book category="overview" name="http://www.glyn.de/ideen-board" title="Bulb Board Web Page"/>
33+
<book category="schematic" name="Documents/schematic_BULB-BOARD-MINI_V11.pdf" title="Schematics"/>
34+
<book category="setup" name="Documents/readme_cmsisdap.pdf" title="How to use CMSIS-DAP debugger"/>
35+
<book category="setup" name="Documents/readme_keil.pdf" title="How to use Keil uVision with Cypress templates"/>
36+
<book category="other" name="Resources/driverinstaller.exe" title="Driver for CMSIS-DAP and programming"/>
37+
<book category="other" name="Resources/PCWFM3-V01L14.zip" title="Serial Flash programming Tool"/>
38+
<book category="other" name="Resources/serialportviewerandterminalv56.exe" title="Serial Port Viewer and Terminal installer"/>
39+
<mountedDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A12B0A"/>
40+
<mountedDevice deviceIndex="2" Dname="S6E1A12B0A"/>
41+
<mountedDevice deviceIndex="3" Dvendor="Cypress:19"/>
42+
<mountedDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A12B0B"/>
43+
<mountedDevice deviceIndex="2" Dvendor="Cypress:19" Dname="S6E1A12B0C"/>
44+
<compatibleDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A12C0A" Dfamily="Foo" DsubFamily="Bar"/>
45+
<compatibleDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A11B0A"/>
46+
<compatibleDevice deviceIndex="0" Dvendor="Cypress:19" Dname="S6E1A11C0A"/>
47+
<feature type="XTAL" n="4000000"/>
48+
<feature type="PWR" n="5" name="USB Powered: 5V of 3.3V Jumper selectable"/>
49+
<feature type="LED" n="2" name="LEDs: 2x User: green, red"/>
50+
<feature type="USB" n="1" name="USB Type A Plug for CMSIS-DAP and Virtual COM Port"/>
51+
<feature type="DIO" n="25" name="2 x 14-Pin Header"/>
52+
<feature type="ConnOther" n="1" name="Multicon: stackable solution for adding concept boards connected via SPI, I2C or UART"/>
53+
<feature type="CustomFF" n="35" m="65"/>
54+
<feature type="Curr" n="15" m="20"/>
55+
<debugInterface adapter="CMSIS-DAP" connector="USB Type A Plug"/>
56+
</board>
57+
</boards>
58+
59+
<conditions>
60+
<condition id="Cypress FM0+ CMSIS Device">
61+
<!-- conditions selecting Devices -->
62+
<description>Cypress FM0+ Series devices and CMSIS-CORE</description>
63+
<require Cclass="CMSIS" Cgroup="CORE"/>
64+
<require Dvendor="Cypress:19" Dname="S6E1A1*"/>
65+
</condition>
66+
</conditions>
67+
68+
<components>
69+
<bundle Cbundle="Bulb Board" Cclass="Board Support" Cversion="1.0.0">
70+
<description>Glyn Bulb Development Board</description>
71+
<doc>http://www.glyn.de/ideen-board</doc>
72+
<component Cgroup="LED" Capiversion="1.00" condition="Cypress FM0+ CMSIS Device">
73+
<description>LED driver for Glyn Bulb Development Board</description>
74+
<files>
75+
<file category="sourceC" name="Common/LED_BulbBoard.c"/>
76+
</files>
77+
</component>
78+
</bundle>
79+
</components>
80+
81+
<examples>
82+
<example name="Blinky" doc="Abstract.txt" folder="Examples/Blinky">
83+
<description>Blinky example</description>
84+
<board name="Bulb Board" vendor="Glyn"/>
85+
<project>
86+
<environment name="uv" load="Blinky.uvprojx"/>
87+
</project>
88+
<attributes>
89+
<component Cclass="CMSIS" Cgroup="CORE"/>
90+
<component Cclass="Device" Cgroup="Startup"/>
91+
<category>Getting Started</category>
92+
</attributes>
93+
</example>
94+
<example name="CMSIS-RTOS Blinky" doc="Abstract.txt" folder="Examples/RTX_Blinky">
95+
<description>CMSIS-RTOS based Blinky example</description>
96+
<board name="Bulb Board" vendor="Glyn"/>
97+
<project>
98+
<environment name="uv" load="RTX_Blinky.uvprojx"/>
99+
</project>
100+
<attributes>
101+
<component Cclass="CMSIS" Cgroup="CORE"/>
102+
<component Cclass="Device" Cgroup="Startup"/>
103+
<component Cclass="CMSIS" Cgroup="RTOS"/>
104+
<category>Getting Started</category>
105+
<category>CMSIS-RTX</category>
106+
</attributes>
107+
</example>
108+
<example name="Demo" doc="Readme.txt" folder="Examples/s6e1a1_bulb-board-mini-demo_v10">
109+
<description>Cypress Demo project</description>
110+
<board name="Bulb Board" vendor="Glyn"/>
111+
<project>
112+
<environment name="uv" load="Demo.uvprojx"/>
113+
</project>
114+
<attributes>
115+
<component Cclass="CMSIS" Cgroup="CORE"/>
116+
<component Cclass="Device" Cgroup="Startup"/>
117+
<category>Getting Started</category>
118+
</attributes>
119+
</example>
120+
</examples>
121+
122+
</package>

0 commit comments

Comments
 (0)