Skip to content

Commit 30c0970

Browse files
committed
[fw-check] Firmware compatibility table may be overwritten by local file
1 parent 5331a71 commit 30c0970

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@ Both _PDA_ packages can also be installed from source as described on the next s
738738
739739
For the _CRU firmware_ see the [gitlab](https://gitlab.cern.ch/alice-cru/cru-fw) repo.
740740
741+
Note: The CRU firmware compatibility table has lower precedence to an (optionally present) firmware compatibility json file, which
742+
is always searched for in `/etc/o2.d/readoutcard/o2-roc-fw-list.json`. This is a flat json map, as seen in the example file
743+
[o2-roc-fw-list.json](o2-roc-fw-list.json).
744+
741745
### PDA
742746
The module depends on the PDA (Portable Driver Architecture) library and driver.
743747
If PDA is not detected on the system, only a dummy implementation of the interface will be compiled.

include/ReadoutCard/FirmwareChecker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class FirmwareChecker
4141
void checkFirmwareCompatibilityWrapped(Parameters::CardIdType cardId);
4242
std::string getFirmwareCompatibilityList();
4343
std::unordered_map<std::string, std::string> mCompatibleFirmwareList;
44+
static constexpr char kFirmwareListFile[] = "json:///etc/o2.d/readoutcard/o2-roc-fw-list.json";
4445
};
4546

4647
} // namespace roc

o2-roc-fw-list.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"14ccd414": "v3.14.1",
3+
"2058c933": "v3.14.0",
4+
"ed43b5d": "free string"
5+
}

src/CommandLineUtilities/ProgramListCards.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ProgramListCards : public Program
7070
pt::ptree root;
7171

7272
auto cardsFound = o2::roc::RocPciDevice::findSystemDevices();
73+
auto firmwareChecker = FirmwareChecker();
7374

7475
int i = 0;
7576
for (const auto& card : cardsFound) {
@@ -85,7 +86,7 @@ class ProgramListCards : public Program
8586
userLogicVersion = std::dynamic_pointer_cast<CruBar>(bar2)->getUserLogicVersion().value_or(na);
8687
}
8788
// Check if the firmware is tagged
88-
firmware = FirmwareChecker().resolveFirmwareTag(firmware);
89+
firmware = firmwareChecker.resolveFirmwareTag(firmware);
8990
} catch (const Exception& e) {
9091
std::cerr << "Error parsing card information through BAR\n"
9192
<< boost::diagnostic_information(e) << '\n';

src/FirmwareChecker.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "ReadoutCard/FirmwareChecker.h"
1818
#include "ExceptionInternal.h"
19+
#include <Configuration/ConfigurationFactory.h>
1920

2021
namespace o2
2122
{
@@ -49,6 +50,19 @@ FirmwareChecker::FirmwareChecker() : mCompatibleFirmwareList({
4950
{ "72cdb92", "v2.4.1" }*/
5051
})
5152
{
53+
std::unordered_map<std::string, std::string> parsedList;
54+
try {
55+
auto conf = configuration::ConfigurationFactory::getConfiguration(kFirmwareListFile);
56+
parsedList = conf->getRecursiveMap();
57+
} catch (const std::runtime_error& e) {
58+
/* on error bail out */
59+
return;
60+
}
61+
62+
// if the parsed list is not empty update the compatible fimrware list
63+
if (!parsedList.empty()) {
64+
mCompatibleFirmwareList = parsedList;
65+
}
5266
}
5367

5468
FirmwareChecker::~FirmwareChecker()

0 commit comments

Comments
 (0)