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);
if (!pipe) {
printf("Unable to parse the /proc/cpuinfo. Are you running as root?");
spdlog::error(
"Unable to parse the /proc/cpuinfo. Are you running as root?");
SetValid(false);
} else {
spdlog::debug("Found cpuinfo. Parsing...");
SetValid(true);
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe.get()) !=
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.");
SetValid(false);
}
spdlog::debug("cpuinfo data: <" + result + ">");
rpi_revcode = strtol(result.c_str(), NULL, 16);
if (rpi_revcode == 0xFFFFFFFF) {
@ -88,13 +90,51 @@ Rpi_Revision_Code::Rpi_Revision_Code(const string &cpuinfo_path) {
}
if (!IsValid()) {
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());
}
else{
spdlog::info("Detected " + TypeStr() + " " + RevisionStr() + " " + MemorySizeStr() + " (" + ProcessorStr() + ")");
}
}
}
uint32_t Rpi_Revision_Code::extract_bits(int start_bit, int size) {
unsigned mask = ((1 << size) - 1) << 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 <string>
#include <type_traits>
#include <vector>
using namespace std;
@ -31,9 +32,11 @@ using namespace std;
//
//===========================================================================
class Rpi_Revision_Code {
class Rpi_Revision_Code
{
public:
enum class memory_size_type : uint8_t {
enum class memory_size_type : uint8_t
{
MEM_256MB = 0,
MEM_512MB = 1,
MEM_1GB = 2,
@ -42,11 +45,25 @@ public:
MEM_8GB = 5,
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 &&
value <= memory_size_type::MEM_8GB);
}
enum class manufacturer_type : uint8_t {
public:
enum class manufacturer_type : uint8_t
{
SonyUK = 0,
Egoman = 1,
Embest2 = 2,
@ -56,12 +73,19 @@ public:
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 &&
value <= manufacturer_type::Stadium);
}
enum class cpu_type : uint8_t {
public:
enum class cpu_type : uint8_t
{
BCM2835 = 0,
BCM2836 = 1,
BCM2837 = 2,
@ -69,21 +93,30 @@ public:
BCM2712 = 4,
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);
}
enum class rpi_version_type : uint8_t {
rpi_version_A = 0,
rpi_version_B = 1,
rpi_version_Aplus = 2,
rpi_version_Bplus = 3,
rpi_version_2B = 4,
rpi_version_Alpha = 5, // (early prototype)
rpi_version_CM1 = 6,
rpi_version_3B = 8,
rpi_version_Zero = 9,
public:
enum class rpi_version_type : uint8_t
{
rpi_version_A = 0x0,
rpi_version_B = 0x1,
rpi_version_Aplus = 0x2,
rpi_version_Bplus = 0x3,
rpi_version_2B = 0x4,
rpi_version_Alpha = 0x5, // (early prototype)
rpi_version_CM1 = 0x6,
unused_7 = 0x7,
rpi_version_3B = 0x8,
rpi_version_Zero = 0x9,
rpi_version_CM3 = 0xa,
unused_B = 0xb,
rpi_version_ZeroW = 0xc,
rpi_version_3Bplus = 0xd,
rpi_version_3Aplus = 0xe,
@ -98,7 +131,39 @@ public:
rpi_version_5 = 0x17,
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 &&
value <= rpi_version_type::rpi_version_5);
}
@ -112,17 +177,21 @@ private:
uint32_t extract_bits(int start_bit, int size);
public:
uint8_t Revision() {
uint8_t Revision()
{
return (uint8_t)extract_bits(0, 4);
} //: 4; // (bits 0-3)
rpi_version_type Type() {
rpi_version_type Type()
{
return (rpi_version_type)extract_bits(4, 8);
} //: // (bits 4-11)
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);
} // (bits 16-19)
memory_size_type MemorySize() {
memory_size_type MemorySize()
{
return (memory_size_type)extract_bits(20, 3);
} // (bits 20-22)
// 1: new-style revision
@ -144,6 +213,12 @@ public:
bool IsValid() { return is_valid; }
void SetValid(bool val) { is_valid = val; }
std::string RevisionStr();
std::string TypeStr();
std::string ProcessorStr();
std::string ManufacturerStr();
std::string MemorySizeStr();
private:
uint32_t rpi_revcode;
bool is_valid = true;

View File

@ -10,6 +10,7 @@
//---------------------------------------------------------------------------
#include "sbc_version.h"
#include "rpi_revision_code.h"
#include <spdlog/spdlog.h>
#include <fstream>
#include <iostream>
@ -17,31 +18,12 @@
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_2_3 = "Raspberry Pi 2/3";
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_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";
//---------------------------------------------------------------------------
@ -71,6 +53,41 @@ SBC_Version::sbc_version_type SBC_Version::GetSbcVersion()
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
@ -79,37 +96,24 @@ SBC_Version::sbc_version_type SBC_Version::GetSbcVersion()
//---------------------------------------------------------------------------
void SBC_Version::Init()
{
ifstream input_stream(SBC_Version::m_device_tree_model_path);
if (input_stream.fail())
spdlog::error("Checking rpi version...");
auto rpi_version = Rpi_Revision_Code();
if (rpi_version.IsValid())
{
#if defined(__x86_64__) || defined(__X86__)
// We expect this to fail on x86
spdlog::warn("Detected " + GetAsString());
sbc_version = sbc_version_type::sbc_unknown;
return;
#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
spdlog::debug("Detected valid raspberry pi version");
}
else
{
spdlog::error("Invalid rpi version defined");
}
stringstream str_buffer;
str_buffer << input_stream.rdbuf();
const string device_tree_model = str_buffer.str();
sbc_version = rpi_rev_to_sbc_version(rpi_version.Type());
for (const auto &[key, value] : proc_device_tree_mapping)
{
if (device_tree_model.starts_with(key))
{
sbc_version = value;
spdlog::info("Detected " + GetAsString());
return;
}
if (sbc_version == sbc_version_type::sbc_unknown){
sbc_version = sbc_version_type::sbc_raspberry_pi_4;
spdlog::error("Unable to determine single board computer type. Defaulting to Raspberry Pi 4");
}
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()

View File

@ -14,6 +14,7 @@
#include <cstdint>
#include <map>
#include <string>
#include "hal/rpi_revision_code.h"
using namespace std;
@ -61,5 +62,7 @@ private:
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);
};

View File

@ -42,6 +42,10 @@ typedef struct
bool otpprogram;
bool overvoltage;
bool isvalid;
std::string type_str;
std::string processor_str;
std::string manufacturer_str;
std::string memorysize_str;
} rpi_revision_test_case;
std::list<rpi_revision_test_case> test_cases =
@ -60,6 +64,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_Zero",
.processor_str = "BCM2835",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_512MB",
},
{
.rev_code = 0x9000c1,
.revision = 1,
@ -119,6 +140,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_Zero",
.processor_str = "BCM2835",
.manufacturer_str = "Embest2",
.memorysize_str = "MEM_512MB",
},
{
.rev_code = 0x900061,
.revision = 1,
@ -193,6 +235,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_2B",
.processor_str = "BCM2836",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
},
{
.rev_code = 0xa02082,
.revision = 2,
@ -237,7 +292,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_3B",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
},
{
.rev_code = 0xa020a0,
.revision = 0,
@ -251,7 +311,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_CM3",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
},
{
.rev_code = 0xa020d3,
.revision = 3,
@ -265,7 +330,12 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_3Bplus",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
},
{
.rev_code = 0xa020d4,
.revision = 4,
@ -279,6 +349,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_2B",
.processor_str = "BCM2837",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_1GB",
},
{
.rev_code = 0xa21041,
.revision = 1,
@ -308,6 +387,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_2GB",
},
{
.rev_code = 0xb03114,
@ -474,6 +598,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_2GB",
},
{
.rev_code = 0xc03111,
.revision = 1,
.type = Rpi_Revision_Code::rpi_version_type::rpi_version_4B,
.processor = Rpi_Revision_Code::cpu_type::BCM2711,
@ -506,6 +637,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_4B",
.processor_str = "BCM2711",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_8GB",
},
{
.rev_code = 0xd03115,
.revision = 5,
.type = Rpi_Revision_Code::rpi_version_type::rpi_version_4B,
.processor = Rpi_Revision_Code::cpu_type::BCM2711,
@ -585,6 +735,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.isvalid = true,
.type_str = "rpi_version_5",
.processor_str = "BCM2712",
.manufacturer_str = "SonyUK",
.memorysize_str = "MEM_4GB",
},
{
.rev_code = 0xd04170,
.revision = 0,
@ -710,6 +893,10 @@ std::list<rpi_revision_test_case> test_cases =
.otpprogram = false,
.overvoltage = false,
.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,
.overvoltage = 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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = false,
.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,
.overvoltage = true,
.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->Overvoltage(), tc.overvoltage);
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);
}
}