Skip to content

Commit f18fab4

Browse files
committed
[fw-check | roc-list-cards] Publish firmware checker & print fw tag in roc-list-cards
1 parent 33f9703 commit f18fab4

File tree

5 files changed

+81
-15
lines changed

5 files changed

+81
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ add_library(ReadoutCard SHARED
9696
src/Dummy/DummyDmaChannel.cxx
9797
src/Dummy/DummyBar.cxx
9898
src/ExceptionInternal.cxx
99+
src/FirmwareChecker.cxx
99100
src/MemoryMappedFile.cxx
100101
src/Parameters.cxx
101102
src/ParameterTypes/Clock.cxx
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file FirmwareChecker.h
12+
/// \brief Helper functions to check a card's firmware compatibilty
13+
///
14+
/// \author Kostas Alexopoulos ([email protected])
15+
16+
#ifndef ALICEO2_INCLUDE_READOUTCARD_FIRMWARECHECKER_H_
17+
#define ALICEO2_INCLUDE_READOUTCARD_FIRMWARECHECKER_H_
18+
19+
#include "unordered_map"
20+
#include "ReadoutCard/ChannelFactory.h"
21+
#include "ReadoutCard/Parameters.h"
22+
23+
namespace AliceO2
24+
{
25+
namespace roc
26+
{
27+
28+
class FirmwareChecker
29+
{
30+
public:
31+
FirmwareChecker();
32+
~FirmwareChecker();
33+
34+
std::string resolveFirmwareTag(std::string firmware);
35+
void checkFirmwareCompatibility(Parameters params);
36+
void checkFirmwareCompatibility(Parameters::CardIdType cardId);
37+
38+
private:
39+
void checkFirmwareCompatibilityWrapped(std::shared_ptr<BarInterface> bar2);
40+
std::string getFirmwareCompatibilityList();
41+
std::unordered_map<std::string, std::string> mCompatibleFirmwareList;
42+
};
43+
44+
} // namespace roc
45+
} // namespace AliceO2
46+
47+
#endif // ALICEO2_INCLUDE_READOUTCARD_FIRMWARECHECKER_H_

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#include "CommandLineUtilities/Options.h"
1818
#include "CommandLineUtilities/Program.h"
1919
#include "Cru/CruBar.h"
20-
#include "FirmwareChecker.h"
2120
#include "ReadoutCard/CardConfigurator.h"
2221
#include "ReadoutCard/ChannelFactory.h"
2322
#include "ReadoutCard/Exception.h"
23+
#include "ReadoutCard/FirmwareChecker.h"
2424
#include "RocPciDevice.h"
2525

2626
using namespace AliceO2::roc::CommandLineUtilities;
@@ -106,7 +106,7 @@ class ProgramConfig : public Program
106106
auto params = Parameters::makeParameters(card.pciAddress, 2);
107107
if (!mOptions.bypassFirmwareCheck) {
108108
try {
109-
checkFirmwareCompatibility(params);
109+
FirmwareChecker().checkFirmwareCompatibility(params);
110110
CardConfigurator(card.pciAddress, mOptions.configFile, mOptions.forceConfig);
111111
} catch (const Exception& e) {
112112
std::cout << boost::diagnostic_information(e) << std::endl;
@@ -120,7 +120,7 @@ class ProgramConfig : public Program
120120
auto cardId = Options::getOptionCardId(map);
121121
if (!mOptions.bypassFirmwareCheck) {
122122
try {
123-
checkFirmwareCompatibility(cardId);
123+
FirmwareChecker().checkFirmwareCompatibility(cardId);
124124
} catch (const Exception& e) {
125125
std::cout << boost::diagnostic_information(e) << std::endl;
126126
return;

src/CommandLineUtilities/ProgramListCards.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "CommandLineUtilities/Program.h"
2121
#include "RocPciDevice.h"
2222
#include "ReadoutCard/ChannelFactory.h"
23+
#include "ReadoutCard/FirmwareChecker.h"
2324
#include "ReadoutCard/MemoryMappedFile.h"
2425
#include <boost/format.hpp>
2526

@@ -69,6 +70,8 @@ class ProgramListCards : public Program
6970
Parameters params2 = Parameters::makeParameters(card.pciAddress, 2);
7071
auto bar2 = ChannelFactory().getBar(params2);
7172
firmware = bar2->getFirmwareInfo().value_or(na);
73+
// Check if the firmware is tagged
74+
firmware = FirmwareChecker().resolveFirmwareTag(firmware);
7275
cardId = bar2->getCardId().value_or(na);
7376
endpointNumber = bar0->getEndpointNumber();
7477
} catch (const Exception& e) {
Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,48 @@
1313
///
1414
/// \author Kostas Alexopoulos ([email protected])
1515

16-
#include "unordered_map"
17-
#include "ReadoutCard/ChannelFactory.h"
18-
#include "ReadoutCard/Parameters.h"
16+
#include "ReadoutCard/FirmwareChecker.h"
17+
#include "ExceptionInternal.h"
1918

2019
namespace AliceO2
2120
{
2221
namespace roc
2322
{
2423

25-
inline std::unordered_map<std::string, std::string> compatibleFirmwareList({ { "20190911-150139-3f5e11b3", "CRU v3.3.0" },
26-
{ "20190718-120712-4c8e6c48", "CRU v3.2.0" },
27-
{ "0.0:2000-0-0", "CRORC alpha" } });
24+
FirmwareChecker::FirmwareChecker() : mCompatibleFirmwareList({ { "20191014-115705-51882687", "v3.4.0" },
25+
{ "20190911-150139-3f5e11b3", "v3.3.0" },
26+
{ "20190718-120712-4c8e6c48", "v3.2.0" },
27+
{ "0.0:2000-0-0", "alpha" } })
28+
{
29+
}
30+
31+
FirmwareChecker::~FirmwareChecker()
32+
{
33+
}
34+
35+
std::string FirmwareChecker::resolveFirmwareTag(std::string firmware)
36+
{
37+
if (mCompatibleFirmwareList.find(firmware) != mCompatibleFirmwareList.end()) {
38+
return mCompatibleFirmwareList.at(firmware);
39+
} else {
40+
return firmware;
41+
}
42+
}
2843

29-
inline std::string getFirmwareCompatibilityList()
44+
std::string FirmwareChecker::getFirmwareCompatibilityList()
3045
{
3146
std::string fwStrings;
32-
for (auto fwString : compatibleFirmwareList) {
47+
for (auto fwString : mCompatibleFirmwareList) {
3348
fwStrings += "\n" + fwString.second + " - " + fwString.first;
3449
}
3550
return fwStrings;
3651
}
3752

38-
inline void checkFirmwareCompatibilityWrapped(std::shared_ptr<BarInterface> bar2)
53+
void FirmwareChecker::checkFirmwareCompatibilityWrapped(std::shared_ptr<BarInterface> bar2)
3954
{
4055
auto firmware = bar2->getFirmwareInfo().value_or("");
4156
auto serial = bar2->getSerial().value_or(-1);
42-
if (compatibleFirmwareList.find(firmware) == compatibleFirmwareList.end()) {
57+
if (mCompatibleFirmwareList.find(firmware) == mCompatibleFirmwareList.end()) {
4358
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(
4459
std::string("Firmware compatibility check failed.\n") +
4560
std::string("Serial: " + std::to_string(serial) + "\n") +
@@ -49,13 +64,13 @@ inline void checkFirmwareCompatibilityWrapped(std::shared_ptr<BarInterface> bar2
4964
}
5065
}
5166

52-
inline void checkFirmwareCompatibility(Parameters params)
67+
void FirmwareChecker::checkFirmwareCompatibility(Parameters params)
5368
{
5469
auto bar2 = ChannelFactory().getBar(params);
5570
checkFirmwareCompatibilityWrapped(bar2);
5671
}
5772

58-
inline void checkFirmwareCompatibility(Parameters::CardIdType cardId)
73+
void FirmwareChecker::checkFirmwareCompatibility(Parameters::CardIdType cardId)
5974
{
6075
auto params = Parameters::makeParameters(cardId, 2); // access bar2 to check the firmware release
6176
auto bar2 = ChannelFactory().getBar(params);

0 commit comments

Comments
 (0)