Add code to detect if the system is in fact a raspberry pi.

This commit is contained in:
Peter Michael Green 2018-12-08 12:18:12 +00:00
parent 34b33c3bf3
commit a0c405ca6f
1 changed files with 19 additions and 0 deletions

View File

@ -1198,6 +1198,7 @@ typedef struct
/* initialise once then preserve */
static volatile uint32_t piCores = 0;
static volatile uint32_t pi_ispi = 0;
static volatile uint32_t pi_peri_phys = 0x20000000;
static volatile uint32_t pi_dram_bus = 0x40000000;
static volatile uint32_t pi_mem_flag = 0x0C;
@ -7198,6 +7199,17 @@ static int initCheckPermitted(void)
{
DBG(DBG_STARTUP, "");
if (!pi_ispi)
{
DBG(DBG_ALWAYS,
"\n" \
"+---------------------------------------------------------+\n" \
"|Sorry, this system does not appear to be a raspberry pi. |\n" \
"|aborting. |\n" \
"+---------------------------------------------------------+\n\n");
return -1;
}
if ((fdMem = open("/dev/mem", O_RDWR | O_SYNC) ) < 0)
{
DBG(DBG_ALWAYS,
@ -13327,6 +13339,13 @@ unsigned gpioHardwareRevision(void)
}
}
if (!strncasecmp("hardware\t: BCM", buf, 14)) {
int bcmno = atoi(buf+14);
if ((bcmno == 2708) || (bcmno == 2709) || (bcmno == 2710) || (bcmno == 2835) || (bcmno == 2836) || (bcmno == 2837)) {
pi_ispi = 1;
}
}
if (!strncasecmp("revision\t:", buf, 10))
{
if (sscanf(buf+10, "%x%c", &rev, &term) == 2)