OK. So the Pi v2 I have had older firmware and it wasn't quite

the same as everyone elses.

This is an interim version which will work on both Pi v1 and v2
boards until I have a bit more time to implement the correct
stuff for v2.
This commit is contained in:
Gordon Henderson 2015-02-03 14:53:32 +00:00
parent 7cb817498e
commit 72b2af231b
6 changed files with 91 additions and 52 deletions

View File

@ -1 +1 @@
2.24 2.25

28
build
View File

@ -102,20 +102,20 @@ fi
hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'` hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
if [ x$hardware != "xBCM2708" ]; then # if [ x$hardware != "xBCM2708" ]; then
echo "" # echo ""
echo " +------------------------------------------------------------+" # echo " +------------------------------------------------------------+"
echo " | wiringPi is designed to run on the Raspberry Pi only. |" # echo " | wiringPi is designed to run on the Raspberry Pi only. |"
echo " | This processor does not appear to be a Raspberry Pi. |" # echo " | This processor does not appear to be a Raspberry Pi. |"
echo " +------------------------------------------------------------+" # echo " +------------------------------------------------------------+"
echo " | In the unlikely event that you think it is a Raspberry Pi, |" # echo " | In the unlikely event that you think it is a Raspberry Pi, |"
echo " | then please accept my apologies and email the contents of |" # echo " | then please accept my apologies and email the contents of |"
echo " | /proc/cpuinfo to projects@drogon.net. |" # echo " | /proc/cpuinfo to projects@drogon.net. |"
echo " | - Thanks, Gordon |" # echo " | - Thanks, Gordon |"
echo " +------------------------------------------------------------+" # echo " +------------------------------------------------------------+"
echo "" # echo ""
exit 1 # exit 1
fi # fi
echo echo

View File

@ -185,9 +185,11 @@ Print a list (if any) of all the exported GPIO pins and their current values.
.TP .TP
.B export .B export
Export a GPIO pin in the \fI/sys/class/gpio\fR directory. Use like the Export a GPIO pin in the \fI/sys/class/gpio\fR directory. Use like the
mode command above however only \fIin\fR and \fIout\fR are supported at mode command above however only \fIin\fR, \fIout\fR, \fIhigh\fR and
this time. Note that the pin number is the \fBBCM_GPIO\fR number and \fRlow\fR are supported at this time. Note that the pin number is the
not the wiringPi number. \fBBCM_GPIO\fR number and not the wiringPi number. The \fIhigh\fR and
\fIlow\fR commands pre-set the output value at the same time as the
export to output mode.
Once a GPIO pin has been exported, the \fBgpio\fR program changes the Once a GPIO pin has been exported, the \fBgpio\fR program changes the
ownership of the \fI/sys/class/gpio/gpioX/value\fR and if present in ownership of the \fI/sys/class/gpio/gpioX/value\fR and if present in

View File

@ -438,15 +438,19 @@ void doExport (int argc, char *argv [])
fprintf (fd, "in\n") ; fprintf (fd, "in\n") ;
else if ((strcasecmp (mode, "out") == 0) || (strcasecmp (mode, "output") == 0)) else if ((strcasecmp (mode, "out") == 0) || (strcasecmp (mode, "output") == 0))
fprintf (fd, "out\n") ; fprintf (fd, "out\n") ;
else if ((strcasecmp (mode, "high") == 0) || (strcasecmp (mode, "up") == 0))
fprintf (fd, "high\n") ;
else if ((strcasecmp (mode, "low") == 0) || (strcasecmp (mode, "down") == 0))
fprintf (fd, "low\n") ;
else else
{ {
fprintf (stderr, "%s: Invalid mode: %s. Should be in or out\n", argv [1], mode) ; fprintf (stderr, "%s: Invalid mode: %s. Should be in, out, high or low\n", argv [1], mode) ;
exit (1) ; exit (1) ;
} }
fclose (fd) ; fclose (fd) ;
// Change ownership so the current user can actually use it! // Change ownership so the current user can actually use it
sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ; sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ;
changeOwner (argv [0], fName) ; changeOwner (argv [0], fName) ;

View File

@ -1 +1 @@
#define VERSION "2.24" #define VERSION "2.25"

View File

@ -667,19 +667,25 @@ int piBoardRev (void)
// Start by looking for the Architecture, then we can look for a B2 revision.... // Start by looking for the Architecture, then we can look for a B2 revision....
while (fgets (line, 120, cpuFd) != NULL) while (fgets (line, 120, cpuFd) != NULL)
if (strncmp (line, "model name", 10) == 0) if (strncmp (line, "Hardware", 8) == 0)
break ; break ;
if (strncmp (line, "model name", 10) != 0) if (strncmp (line, "Hardware", 8) != 0)
piBoardRevOops ("No \"model name\" line") ; piBoardRevOops ("No \"Hardware\" line") ;
if (wiringPiDebug) if (wiringPiDebug)
printf ("piboardRev: Model name: %s\n", line) ; printf ("piboardRev: Hardware: %s\n", line) ;
// See if it's v7 // See if it's BCM2708 or BCM2709
if (strstr (line, "ARMv7") != NULL) if (strstr (line, "BCM2709") != NULL)
piModel2 = TRUE ; piModel2 = TRUE ;
else if (strstr (line, "BCM2708") == NULL)
{
fprintf (stderr, "Unable to determine hardware version. I see: %s,\n", line) ;
fprintf (stderr, " - expecting BCM2708 or BCM2709. Please report this to projects@drogon.net\n") ;
exit (EXIT_FAILURE) ;
}
// Now do the rest of it as before // Now do the rest of it as before
@ -750,6 +756,15 @@ int piBoardRev (void)
* as much details as we can. * as much details as we can.
* This is undocumented and really only intended for the GPIO command. * This is undocumented and really only intended for the GPIO command.
* Use at your own risk! * Use at your own risk!
*
* for Pi v2:
* [USER:8] [NEW:1] [MEMSIZE:3] [MANUFACTURER:4] [PROCESSOR:4] [TYPE:8] [REV:4]
* NEW 23: will be 1 for the new scheme, 0 for the old scheme
* MEMSIZE 20: 0=256M 1=512M 2=1G
* MANUFACTURER 16: 0=SONY 1=EGOMAN 2=EMBEST
* PROCESSOR 12: 0=2835 1=2836
* TYPE 04: 0=MODELA 1=MODELB 2=MODELA+ 3=MODELB+ 4=Pi2 MODEL B 5=ALPHA 6=CM
* REV 00: 0=REV0 1=REV1 2=REV2
********************************************************************************* *********************************************************************************
*/ */
@ -759,6 +774,9 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted)
char line [120] ; char line [120] ;
char *c ; char *c ;
// Will deal with the properly later on - for now, lets just get it going...
// unsigned int modelNum ;
(void)piBoardRev () ; // Call this first to make sure all's OK. Don't care about the result. (void)piBoardRev () ; // Call this first to make sure all's OK. Don't care about the result.
if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL) if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
@ -781,6 +799,28 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted)
if (wiringPiDebug) if (wiringPiDebug)
printf ("piboardId: Revision string: %s\n", line) ; printf ("piboardId: Revision string: %s\n", line) ;
if (piModel2)
{
// Scan to the colon
for (c = line ; *c ; ++c)
if (*c == ':')
break ;
if (*c != ':')
piBoardRevOops ("Bogus \"Revision\" line") ;
// modelNum = (unsigned int)strtol (++c, NULL, 16) ; // Hex number with no leading 0x
*model = PI_MODEL_2 ;
*rev = PI_VERSION_1_1 ;
*mem = 1024 ;
*maker = PI_MAKER_SONY ;
}
else
{
// Scan to first digit // Scan to first digit
for (c = line ; *c ; ++c) for (c = line ; *c ; ++c)
@ -802,13 +842,6 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted)
// Fill out the replys as appropriate // Fill out the replys as appropriate
if (piModel2)
{
/**/ if (strcmp (c, "0010") == 0) { *model = PI_MODEL_2 ; *rev = PI_VERSION_1_1 ; *mem = 1024 ; *maker = PI_MAKER_SONY ; }
else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; }
}
else
{
/**/ if (strcmp (c, "0002") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; } /**/ if (strcmp (c, "0002") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0003") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; } else if (strcmp (c, "0003") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_1_1 ; *mem = 256 ; *maker = PI_MAKER_EGOMAN ; }
else if (strcmp (c, "0004") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_SONY ; } else if (strcmp (c, "0004") == 0) { *model = PI_MODEL_B ; *rev = PI_VERSION_2 ; *mem = 256 ; *maker = PI_MAKER_SONY ; }