integrated with rpi5

This commit is contained in:
Tony Kuker 2024-06-04 21:41:15 -05:00
parent a46957c573
commit 7679f80e3a
5 changed files with 409 additions and 72 deletions

View File

@ -33,11 +33,11 @@ Rpi_Revision_Code::Rpi_Revision_Code(const string &cpuinfo_path) {
pclose); pclose);
if (!pipe) { if (!pipe) {
printf("Unable to parse the /proc/cpuinfo. Are you running as root?");
spdlog::error( spdlog::error(
"Unable to parse the /proc/cpuinfo. Are you running as root?"); "Unable to parse the /proc/cpuinfo. Are you running as root?");
SetValid(false); SetValid(false);
} else { } else {
spdlog::debug("Found cpuinfo. Parsing...");
SetValid(true); SetValid(true);
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe.get()) != while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe.get()) !=
nullptr) { nullptr) {
@ -58,6 +58,8 @@ Rpi_Revision_Code::Rpi_Revision_Code(const string &cpuinfo_path) {
spdlog::warn("The revision code is too short. It may be padded."); spdlog::warn("The revision code is too short. It may be padded.");
SetValid(false); SetValid(false);
} }
spdlog::debug("cpuinfo data: <" + result + ">");
rpi_revcode = strtol(result.c_str(), NULL, 16); rpi_revcode = strtol(result.c_str(), NULL, 16);
if (rpi_revcode == 0xFFFFFFFF) { if (rpi_revcode == 0xFFFFFFFF) {
@ -88,13 +90,51 @@ Rpi_Revision_Code::Rpi_Revision_Code(const string &cpuinfo_path) {
} }
if (!IsValid()) { if (!IsValid()) {
string hex_rev_code = fmt::format("{:08X}", rpi_revcode); string hex_rev_code = fmt::format("{:08X}", rpi_revcode);
spdlog::warn("Raspberry Pi Revision code is: {} result code: {}", spdlog::error("Invalid cpuinfo detected!! Raspberry Pi Revision code is: {} result code: {}",
hex_rev_code.c_str(), result.c_str()); hex_rev_code.c_str(), result.c_str());
} }
else{
spdlog::info("Detected " + TypeStr() + " " + RevisionStr() + " " + MemorySizeStr() + " (" + ProcessorStr() + ")");
}
} }
} }
uint32_t Rpi_Revision_Code::extract_bits(int start_bit, int size) { uint32_t Rpi_Revision_Code::extract_bits(int start_bit, int size) {
unsigned mask = ((1 << size) - 1) << start_bit; unsigned mask = ((1 << size) - 1) << start_bit;
return (rpi_revcode & mask) >> start_bit; return (rpi_revcode & mask) >> start_bit;
} }
std::string Rpi_Revision_Code::RevisionStr(){
return "1." + std::to_string(Revision());
}
std::string Rpi_Revision_Code::TypeStr(){
if (valid_rpi_version_type(Type())){
return rpi_version_type_string[(uint32_t)Type()];
}
else{
return "<<Invalid Rpi Version>>";
}
}
std::string Rpi_Revision_Code::ProcessorStr(){
if(valid_cpu_type(Processor())){
return cpu_type_string[(int)Processor()];
}else{
return "<<Invalid CPU Type>>";
}
}
std::string Rpi_Revision_Code::ManufacturerStr(){
if(valid_manufacturer_type(Manufacturer())){
return manufacturer_type_string[(int)Manufacturer()];
}else{
return "<<Invalid Manufacturer>>";
}
}
std::string Rpi_Revision_Code::MemorySizeStr(){
if(valid_memory_size_type(MemorySize())){
return memory_size_type_string[(int)MemorySize()];
}else{
return "<<Invalid Memory Size>>";
}
}

View File

@ -18,6 +18,7 @@
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <vector>
using namespace std; using namespace std;
@ -31,9 +32,11 @@ using namespace std;
// //
//=========================================================================== //===========================================================================
class Rpi_Revision_Code { class Rpi_Revision_Code
{
public: public:
enum class memory_size_type : uint8_t { enum class memory_size_type : uint8_t
{
MEM_256MB = 0, MEM_256MB = 0,
MEM_512MB = 1, MEM_512MB = 1,
MEM_1GB = 2, MEM_1GB = 2,
@ -42,11 +45,25 @@ public:
MEM_8GB = 5, MEM_8GB = 5,
MEM_INVALID = 0x7, MEM_INVALID = 0x7,
}; };
bool valid_memory_size_type(memory_size_type value) {
private:
const vector<std::string> memory_size_type_string = {
"MEM_256MB",
"MEM_512MB",
"MEM_1GB",
"MEM_2GB",
"MEM_4GB",
"MEM_8GB",
};
bool valid_memory_size_type(memory_size_type value)
{
return (value >= memory_size_type::MEM_256MB && return (value >= memory_size_type::MEM_256MB &&
value <= memory_size_type::MEM_8GB); value <= memory_size_type::MEM_8GB);
} }
enum class manufacturer_type : uint8_t {
public:
enum class manufacturer_type : uint8_t
{
SonyUK = 0, SonyUK = 0,
Egoman = 1, Egoman = 1,
Embest2 = 2, Embest2 = 2,
@ -56,12 +73,19 @@ public:
MANUFACTURER_INVALID = 0xF, MANUFACTURER_INVALID = 0xF,
}; };
bool valid_manufacturer_type(manufacturer_type value) { private:
const vector<std::string> manufacturer_type_string = {
"SonyUK", "Egoman", "Embest2", "SonyJapan", "Embest4", "Stadium"};
bool valid_manufacturer_type(manufacturer_type value)
{
return (value >= manufacturer_type::SonyUK && return (value >= manufacturer_type::SonyUK &&
value <= manufacturer_type::Stadium); value <= manufacturer_type::Stadium);
} }
enum class cpu_type : uint8_t { public:
enum class cpu_type : uint8_t
{
BCM2835 = 0, BCM2835 = 0,
BCM2836 = 1, BCM2836 = 1,
BCM2837 = 2, BCM2837 = 2,
@ -69,21 +93,30 @@ public:
BCM2712 = 4, BCM2712 = 4,
CPU_TYPE_INVALID = 0xF, CPU_TYPE_INVALID = 0xF,
}; };
bool valid_cpu_type(cpu_type value) {
private:
const vector<std::string> cpu_type_string = {
"BCM2835", "BCM2836", "BCM2837", "BCM2711", "BCM2712"};
bool valid_cpu_type(cpu_type value)
{
return (value >= cpu_type::BCM2835 && value <= cpu_type::BCM2712); return (value >= cpu_type::BCM2835 && value <= cpu_type::BCM2712);
} }
enum class rpi_version_type : uint8_t { public:
rpi_version_A = 0, enum class rpi_version_type : uint8_t
rpi_version_B = 1, {
rpi_version_Aplus = 2, rpi_version_A = 0x0,
rpi_version_Bplus = 3, rpi_version_B = 0x1,
rpi_version_2B = 4, rpi_version_Aplus = 0x2,
rpi_version_Alpha = 5, // (early prototype) rpi_version_Bplus = 0x3,
rpi_version_CM1 = 6, rpi_version_2B = 0x4,
rpi_version_3B = 8, rpi_version_Alpha = 0x5, // (early prototype)
rpi_version_Zero = 9, rpi_version_CM1 = 0x6,
unused_7 = 0x7,
rpi_version_3B = 0x8,
rpi_version_Zero = 0x9,
rpi_version_CM3 = 0xa, rpi_version_CM3 = 0xa,
unused_B = 0xb,
rpi_version_ZeroW = 0xc, rpi_version_ZeroW = 0xc,
rpi_version_3Bplus = 0xd, rpi_version_3Bplus = 0xd,
rpi_version_3Aplus = 0xe, rpi_version_3Aplus = 0xe,
@ -98,7 +131,39 @@ public:
rpi_version_5 = 0x17, rpi_version_5 = 0x17,
rpi_version_invalid = 0xFF rpi_version_invalid = 0xFF
}; };
bool valid_rpi_version_type(rpi_version_type value) {
private:
const vector<std::string> rpi_version_type_string = {
"rpi_version_A",
"rpi_version_B",
"rpi_version_Aplus",
"rpi_version_Bplus",
"rpi_version_2B",
"rpi_version_Alpha",
"rpi_version_CM1",
"unused_7",
"rpi_version_3B",
"rpi_version_Zero",
"rpi_version_CM3",
"unused_B",
"rpi_version_ZeroW",
"rpi_version_3Bplus",
"rpi_version_3Aplus",
"rpi_version_InternalUseOnly1",
"rpi_version_CM3plus",
"rpi_version_4B",
"rpi_version_Zero2W",
"rpi_version_400",
"rpi_version_CM4",
"rpi_version_CM4S",
"rpi_version_InternalUseOnly2",
"rpi_version_5",
"unknown_24",
"unknown_25",
};
bool valid_rpi_version_type(rpi_version_type value)
{
return (value >= rpi_version_type::rpi_version_A && return (value >= rpi_version_type::rpi_version_A &&
value <= rpi_version_type::rpi_version_5); value <= rpi_version_type::rpi_version_5);
} }
@ -112,17 +177,21 @@ private:
uint32_t extract_bits(int start_bit, int size); uint32_t extract_bits(int start_bit, int size);
public: public:
uint8_t Revision() { uint8_t Revision()
{
return (uint8_t)extract_bits(0, 4); return (uint8_t)extract_bits(0, 4);
} //: 4; // (bits 0-3) } //: 4; // (bits 0-3)
rpi_version_type Type() { rpi_version_type Type()
{
return (rpi_version_type)extract_bits(4, 8); return (rpi_version_type)extract_bits(4, 8);
} //: // (bits 4-11) } //: // (bits 4-11)
cpu_type Processor() { return (cpu_type)extract_bits(12, 4); } // (bits 12-15) cpu_type Processor() { return (cpu_type)extract_bits(12, 4); } // (bits 12-15)
manufacturer_type Manufacturer() { manufacturer_type Manufacturer()
{
return (manufacturer_type)extract_bits(16, 4); return (manufacturer_type)extract_bits(16, 4);
} // (bits 16-19) } // (bits 16-19)
memory_size_type MemorySize() { memory_size_type MemorySize()
{
return (memory_size_type)extract_bits(20, 3); return (memory_size_type)extract_bits(20, 3);
} // (bits 20-22) } // (bits 20-22)
// 1: new-style revision // 1: new-style revision
@ -144,6 +213,12 @@ public:
bool IsValid() { return is_valid; } bool IsValid() { return is_valid; }
void SetValid(bool val) { is_valid = val; } void SetValid(bool val) { is_valid = val; }
std::string RevisionStr();
std::string TypeStr();
std::string ProcessorStr();
std::string ManufacturerStr();
std::string MemorySizeStr();
private: private:
uint32_t rpi_revcode; uint32_t rpi_revcode;
bool is_valid = true; bool is_valid = true;

View File

@ -10,6 +10,7 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include "sbc_version.h" #include "sbc_version.h"
#include "rpi_revision_code.h"
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -17,31 +18,12 @@
SBC_Version::sbc_version_type SBC_Version::sbc_version = sbc_version_type::sbc_unknown; SBC_Version::sbc_version_type SBC_Version::sbc_version = sbc_version_type::sbc_unknown;
// TODO: THESE NEED TO BE VALIDATED!!!!
const string SBC_Version::str_raspberry_pi_1 = "Raspberry Pi 1"; const string SBC_Version::str_raspberry_pi_1 = "Raspberry Pi 1";
const string SBC_Version::str_raspberry_pi_2_3 = "Raspberry Pi 2/3"; const string SBC_Version::str_raspberry_pi_2_3 = "Raspberry Pi 2/3";
const string SBC_Version::str_raspberry_pi_4 = "Raspberry Pi 4"; const string SBC_Version::str_raspberry_pi_4 = "Raspberry Pi 4";
const string SBC_Version::str_raspberry_pi_5 = "Raspberry Pi 5"; const string SBC_Version::str_raspberry_pi_5 = "Raspberry Pi 5";
const string SBC_Version::str_unknown_sbc = "Unknown SBC"; const string SBC_Version::str_unknown_sbc = "Unknown SBC";
// The strings in this table should align with the 'model' embedded
// in the device tree. This can be aquired by running:
// cat /proc/device-tree/model
// Only the first part of the string is checked. Anything following
// will be ignored. For example:
// "Raspberry Pi 4 Model B" will match with both of the following:
// - Raspberry Pi 4 Model B Rev 1.4
// - Raspberry Pi 4 Model B Rev 1.3
// TODO Is there a better way to detect the Pi type than relying on strings?
const map<string, SBC_Version::sbc_version_type, less<>> SBC_Version::proc_device_tree_mapping = {
{"Raspberry Pi 1 Model ", sbc_version_type::sbc_raspberry_pi_1},
{"Raspberry Pi 2 Model ", sbc_version_type::sbc_raspberry_pi_2_3},
{"Raspberry Pi 3 Model ", sbc_version_type::sbc_raspberry_pi_2_3},
{"Raspberry Pi 4 Model ", sbc_version_type::sbc_raspberry_pi_4},
{"Raspberry Pi 400 ", sbc_version_type::sbc_raspberry_pi_4},
{"Raspberry Pi Zero W", sbc_version_type::sbc_raspberry_pi_1},
{"Raspberry Pi Zero", sbc_version_type::sbc_raspberry_pi_1}};
const string SBC_Version::m_device_tree_model_path = "/proc/device-tree/model"; const string SBC_Version::m_device_tree_model_path = "/proc/device-tree/model";
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -71,6 +53,41 @@ SBC_Version::sbc_version_type SBC_Version::GetSbcVersion()
return sbc_version; return sbc_version;
} }
SBC_Version::sbc_version_type SBC_Version::rpi_rev_to_sbc_version(Rpi_Revision_Code::rpi_version_type rpi_code)
{
switch (rpi_code)
{
case Rpi_Revision_Code::rpi_version_type::rpi_version_A:
case Rpi_Revision_Code::rpi_version_type::rpi_version_B:
case Rpi_Revision_Code::rpi_version_type::rpi_version_Aplus:
case Rpi_Revision_Code::rpi_version_type::rpi_version_Bplus:
case Rpi_Revision_Code::rpi_version_type::rpi_version_Alpha: // (early prototype)
case Rpi_Revision_Code::rpi_version_type::rpi_version_Zero:
case Rpi_Revision_Code::rpi_version_type::rpi_version_ZeroW:
return sbc_version_type::sbc_raspberry_pi_1;
case Rpi_Revision_Code::rpi_version_type::rpi_version_2B:
case Rpi_Revision_Code::rpi_version_type::rpi_version_CM1:
case Rpi_Revision_Code::rpi_version_type::rpi_version_3B:
case Rpi_Revision_Code::rpi_version_type::rpi_version_CM3:
case Rpi_Revision_Code::rpi_version_type::rpi_version_Zero2W:
case Rpi_Revision_Code::rpi_version_type::rpi_version_3Bplus:
case Rpi_Revision_Code::rpi_version_type::rpi_version_3Aplus:
case Rpi_Revision_Code::rpi_version_type::rpi_version_CM3plus:
return sbc_version_type::sbc_raspberry_pi_2_3;
case Rpi_Revision_Code::rpi_version_type::rpi_version_4B:
case Rpi_Revision_Code::rpi_version_type::rpi_version_400:
case Rpi_Revision_Code::rpi_version_type::rpi_version_CM4:
case Rpi_Revision_Code::rpi_version_type::rpi_version_CM4S:
return sbc_version_type::sbc_raspberry_pi_4;
case Rpi_Revision_Code::rpi_version_type::rpi_version_5:
return sbc_version_type::sbc_raspberry_pi_5;
default:
return sbc_version_type::sbc_unknown;
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// Determine which version of single board computer (Pi) is being used // Determine which version of single board computer (Pi) is being used
@ -79,37 +96,24 @@ SBC_Version::sbc_version_type SBC_Version::GetSbcVersion()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void SBC_Version::Init() void SBC_Version::Init()
{ {
ifstream input_stream(SBC_Version::m_device_tree_model_path); spdlog::error("Checking rpi version...");
auto rpi_version = Rpi_Revision_Code();
if (input_stream.fail()) if (rpi_version.IsValid())
{ {
#if defined(__x86_64__) || defined(__X86__) spdlog::debug("Detected valid raspberry pi version");
// We expect this to fail on x86 }
spdlog::warn("Detected " + GetAsString()); else
sbc_version = sbc_version_type::sbc_unknown; {
return; spdlog::error("Invalid rpi version defined");
#else
spdlog::error("Failed to open " + SBC_Version::m_device_tree_model_path + ". Are you running as root?");
throw invalid_argument("Failed to open /proc/device-tree/model");
#endif
} }
stringstream str_buffer; sbc_version = rpi_rev_to_sbc_version(rpi_version.Type());
str_buffer << input_stream.rdbuf();
const string device_tree_model = str_buffer.str();
for (const auto &[key, value] : proc_device_tree_mapping) if (sbc_version == sbc_version_type::sbc_unknown){
{ sbc_version = sbc_version_type::sbc_raspberry_pi_4;
if (device_tree_model.starts_with(key)) spdlog::error("Unable to determine single board computer type. Defaulting to Raspberry Pi 4");
{
sbc_version = value;
spdlog::info("Detected " + GetAsString());
return;
}
} }
sbc_version = sbc_version_type::sbc_raspberry_pi_4;
spdlog::error("Unable to determine single board computer type. Defaulting to Raspberry Pi 4");
} }
bool SBC_Version::IsRaspberryPi() bool SBC_Version::IsRaspberryPi()

View File

@ -14,6 +14,7 @@
#include <cstdint> #include <cstdint>
#include <map> #include <map>
#include <string> #include <string>
#include "hal/rpi_revision_code.h"
using namespace std; using namespace std;
@ -61,5 +62,7 @@ private:
static const string m_device_tree_model_path; static const string m_device_tree_model_path;
static sbc_version_type rpi_rev_to_sbc_version(Rpi_Revision_Code::Rpi_Revision_Code::rpi_version_type rpi_code);
static uint32_t GetDeviceTreeRanges(const char *filename, uint32_t offset); static uint32_t GetDeviceTreeRanges(const char *filename, uint32_t offset);
}; };

View File

@ -42,6 +42,10 @@ typedef struct
bool otpprogram; bool otpprogram;
bool overvoltage; bool overvoltage;
bool isvalid; bool isvalid;
std::string type_str;
std::string processor_str;
std::string manufacturer_str;
std::string memorysize_str;
} rpi_revision_test_case; } rpi_revision_test_case;
std::list<rpi_revision_test_case> test_cases = std::list<rpi_revision_test_case> test_cases =
@ -60,6 +64,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_Aplus",
.processor_str = "BCM2835",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -75,6 +83,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_Bplus",
.processor_str = "BCM2835",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -90,6 +102,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_Zero",
.processor_str = "BCM2835",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -105,7 +121,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_Zero",
.processor_str = "BCM2835",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
.rev_code = 0x9000c1, .rev_code = 0x9000c1,
.revision = 1, .revision = 1,
@ -119,6 +140,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_ZeroW",
.processor_str = "BCM2835",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -134,6 +159,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3Aplus",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -149,6 +178,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3Aplus",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -164,6 +197,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_Zero",
.processor_str = "BCM2835",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -179,7 +216,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_Zero",
.processor_str = "BCM2835",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_512MB",
}, },
{ {
.rev_code = 0x900061, .rev_code = 0x900061,
.revision = 1, .revision = 1,
@ -193,6 +235,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM1",
.processor_str = "BCM2835",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -208,6 +254,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_2B",
.processor_str = "BCM2836",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -223,7 +273,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_2B",
.processor_str = "BCM2836",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
.rev_code = 0xa02082, .rev_code = 0xa02082,
.revision = 2, .revision = 2,
@ -237,7 +292,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3B",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
.rev_code = 0xa020a0, .rev_code = 0xa020a0,
.revision = 0, .revision = 0,
@ -251,7 +311,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM3",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
.rev_code = 0xa020d3, .rev_code = 0xa020d3,
.revision = 3, .revision = 3,
@ -265,7 +330,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3Bplus",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
.rev_code = 0xa020d4, .rev_code = 0xa020d4,
.revision = 4, .revision = 4,
@ -279,6 +349,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3Bplus",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -294,7 +368,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_2B",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
.rev_code = 0xa21041, .rev_code = 0xa21041,
.revision = 1, .revision = 1,
@ -308,6 +387,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_2B",
.processor_str = "BCM2836",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -323,6 +406,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_2B",
.processor_str = "BCM2837",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -338,6 +425,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3B",
.processor_str = "BCM2837",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -353,6 +444,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM3",
.processor_str = "BCM2837",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -368,6 +463,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3B",
.processor_str = "BCM2837",
.manufacturer_str = "SonyJapan",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -383,6 +482,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3B",
.processor_str = "BCM2837",
.manufacturer_str = "Stadium",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -398,6 +501,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_3B",
.processor_str = "BCM2837",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -413,6 +520,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM3plus",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -428,6 +539,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -444,6 +559,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_2GB",
}, },
{ {
@ -459,7 +578,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_2GB",
}, },
{ {
.rev_code = 0xb03114, .rev_code = 0xb03114,
@ -474,6 +598,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_2GB",
}, },
{ {
@ -490,11 +618,14 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_2GB",
}, },
{ {
.rev_code = 0xc03111, .rev_code = 0xc03111,
.revision = 1, .revision = 1,
.type = Rpi_Revision_Code::rpi_version_type::rpi_version_4B, .type = Rpi_Revision_Code::rpi_version_type::rpi_version_4B,
.processor = Rpi_Revision_Code::cpu_type::BCM2711, .processor = Rpi_Revision_Code::cpu_type::BCM2711,
@ -506,6 +637,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
}, },
{ {
@ -522,6 +657,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
}, },
{ {
@ -537,6 +676,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
}, },
{ {
@ -553,6 +696,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
}, },
{ {
@ -569,11 +716,14 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
.rev_code = 0xd03115, .rev_code = 0xd03115,
.revision = 5, .revision = 5,
.type = Rpi_Revision_Code::rpi_version_type::rpi_version_4B, .type = Rpi_Revision_Code::rpi_version_type::rpi_version_4B,
.processor = Rpi_Revision_Code::cpu_type::BCM2711, .processor = Rpi_Revision_Code::cpu_type::BCM2711,
@ -585,6 +735,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -601,6 +755,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_400",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
}, },
{ {
@ -617,6 +775,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM4",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
}, },
{ {
@ -632,6 +794,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM4",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_2GB",
}, },
{ {
@ -648,6 +814,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM4",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
}, },
{ {
@ -664,6 +834,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_CM4",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -680,6 +854,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_Zero2W",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
}, },
{ {
@ -696,7 +874,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
}, },
{ {
.rev_code = 0xd04170, .rev_code = 0xd04170,
.revision = 0, .revision = 0,
@ -710,6 +893,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -726,6 +913,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = true, .overvoltage = true,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -742,6 +933,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = true, .otpprogram = true,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -758,6 +953,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -774,6 +973,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -790,6 +993,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false, .otpprogram = false,
.overvoltage = false, .overvoltage = false,
.isvalid = true, .isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
}, },
{ {
@ -806,6 +1013,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = true, .otpprogram = true,
.overvoltage = true, .overvoltage = true,
.isvalid = false, .isvalid = false,
.type_str = "<<Invalid Rpi Version>>",
.processor_str = "<<Invalid CPU Type>>",
.manufacturer_str = "<<Invalid Manufacturer>>",
.memorysize_str = "<<Invalid Memory Size>>",
}, },
}; };
@ -831,6 +1042,10 @@ TEST(RpiRevisionCode, Initialization)
EXPECT_EQ(rpi_info->OtpProgram(), tc.otpprogram); EXPECT_EQ(rpi_info->OtpProgram(), tc.otpprogram);
EXPECT_EQ(rpi_info->Overvoltage(), tc.overvoltage); EXPECT_EQ(rpi_info->Overvoltage(), tc.overvoltage);
EXPECT_EQ(rpi_info->IsValid(), tc.isvalid); EXPECT_EQ(rpi_info->IsValid(), tc.isvalid);
EXPECT_EQ(rpi_info->TypeStr(), tc.type_str);
EXPECT_EQ(rpi_info->ProcessorStr(), tc.processor_str);
EXPECT_EQ(rpi_info->ManufacturerStr(), tc.manufacturer_str);
EXPECT_EQ(rpi_info->MemorySizeStr(), tc.memorysize_str);
DeleteTempFile(cpuinfo_file); DeleteTempFile(cpuinfo_file);
} }
} }