Przeglądaj źródła

applied ubuntu patches

pull/185/head
Rafael Diniz 1 rok temu
rodzic
commit
b6d05d709f
5 zmienionych plików z 70 dodań i 35 usunięć
  1. +3
    -3
      devLib/Makefile
  2. +1
    -1
      gpio/Makefile
  3. +0
    -6
      gpio/gpio.c
  4. +1
    -0
      wiringPi/Makefile
  5. +65
    -25
      wiringPi/wiringPi.c

+ 3
- 3
devLib/Makefile Wyświetl plik

@@ -37,11 +37,11 @@ DYNAMIC=libwiringPiDev.so.$(VERSION)
#DEBUG = -g -O0
DEBUG = -O2
CC ?= gcc
INCLUDE = -I.
INCLUDE = -I. -I../wiringPi
DEFS = -D_GNU_SOURCE
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Winline $(INCLUDE) -pipe -fPIC $(EXTRA_CFLAGS)

LIBS =
LIBS = -lpthread -lwiringPi

###############################################################################

@@ -68,7 +68,7 @@ $(STATIC): $(OBJ)

$(DYNAMIC): $(OBJ)
$Q echo "[Link (Dynamic)]"
$Q $(CC) -shared -Wl,-soname,libwiringPiDev.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPiDev.so.$(VERSION) -lpthread $(OBJ)
$Q $(CC) -shared -Wl,-soname,libwiringPiDev.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPiDev.so.$(VERSION) -L ../wiringPi $(OBJ) $(LIBS)

.c.o:
$Q echo [Compile] $<


+ 1
- 1
gpio/Makefile Wyświetl plik

@@ -37,7 +37,7 @@ INCLUDE = -I$(DESTDIR)$(PREFIX)/include
CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe $(EXTRA_CFLAGS)

LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt
LIBS = -lwiringPi -lwiringPiDev -lpthread

# May not need to alter anything below this line
###############################################################################


+ 0
- 6
gpio/gpio.c Wyświetl plik

@@ -1371,12 +1371,6 @@ int main (int argc, char *argv [])
exit (EXIT_SUCCESS) ;
}

if (geteuid () != 0)
{
fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
exit (EXIT_FAILURE) ;
}

// Initial test for /sys/class/gpio operations:

/**/ if (strcasecmp (argv [1], "exports" ) == 0) { doExports (argc, argv) ; return 0 ; }


+ 1
- 0
wiringPi/Makefile Wyświetl plik

@@ -76,6 +76,7 @@ static:
$(DYNAMIC): $(OBJ)
$Q echo "[Link (Dynamic)]"
$Q $(CC) -shared -Wl,-soname,libwiringPi.so$(WIRINGPI_SONAME_SUFFIX) -o libwiringPi.so.$(VERSION) $(OBJ) $(LIBS)
$Q ln -sf libwiringPi.so.$(VERSION) libwiringPi.so

.c.o:
$Q echo [Compile] $<


+ 65
- 25
wiringPi/wiringPi.c Wyświetl plik

@@ -70,6 +70,7 @@
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <asm/ioctl.h>
#include <arpa/inet.h>

#include "softPwm.h"
#include "softTone.h"
@@ -737,7 +738,8 @@ static void usingGpioMemCheck (const char *what)

static void piGpioLayoutOops (const char *why)
{
fprintf (stderr, "Oops: Unable to determine board revision from /proc/cpuinfo\n") ;
fprintf (stderr, "Oops: Unable to determine board revision from /proc/device-tree/system/linux,revision\n");
fprintf (stderr, "or from /proc/cpuinfo\n") ;
fprintf (stderr, " -> %s\n", why) ;
fprintf (stderr, " -> You'd best google the error to find out why.\n") ;
//fprintf (stderr, " -> http://www.raspberrypi.org/phpBB3/viewtopic.php?p=184410#p184410\n") ;
@@ -754,8 +756,30 @@ int piGpioLayout (void)
if (gpioLayout != -1) // No point checking twice
return gpioLayout ;

// The "/proc/device-tree/compatible" file consists of a sequence of
// NUL-terminated strings. We expect to find brcm,bcm283[765] on pi platforms

if ((cpuFd = fopen ("/proc/device-tree/compatible", "r")) != NULL) {
size_t linelen;
linelen = fread(line, 1, sizeof(line), cpuFd);
fclose(cpuFd);
cpuFd = NULL;
line[linelen] = '\0';
c = line;
while ((size_t)(c - line) < linelen) {
if ((strncmp(c, "brcm,bcm2837", strlen(c)) == 0) ||
(strncmp(c, "brcm,bcm2836", strlen(c)) == 0)) {
gpioLayout = 2;
if (wiringPiDebug)
printf ("piGpioLayoutOops: Returning revision: %d\n", gpioLayout) ;
return gpioLayout;
}
c += strlen(c) + 1;
}
}

if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
piGpioLayoutOops ("Unable to open /proc/cpuinfo") ;
piGpioLayoutOops ("Unable to open /proc/device-tree/compatible or /proc/cpuinfo") ;

// Start by looking for the Architecture to make sure we're really running
// on a Pi. I'm getting fed-up with people whinging at me because
@@ -966,47 +990,63 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)

(void)piGpioLayout () ; // Call this first to make sure all's OK. Don't care about the result.

if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
piGpioLayoutOops ("Unable to open /proc/cpuinfo") ;
// The /proc/device-tree/system/linux,revision (on modern versions of Raspbian
// and a few other distros) stores the revision code as a big-endian 32-bit
// integer

while (fgets (line, 120, cpuFd) != NULL)
if (strncmp (line, "Revision", 8) == 0)
break ;
if ((cpuFd = fopen ("/proc/device-tree/system/linux,revision", "r")) != NULL) {
revision = 0;
fread(&revision, sizeof(revision), 1, cpuFd);
fclose(cpuFd);
if (revision)
revision = ntohl(revision);
else
piGpioLayoutOops ("No revision in /proc/device-tree/system/linux,revision");
}

fclose (cpuFd) ;
else if ((cpuFd = fopen ("/proc/cpuinfo", "r")) != NULL) {

if (strncmp (line, "Revision", 8) != 0)
piGpioLayoutOops ("No \"Revision\" line") ;
while (fgets (line, 120, cpuFd) != NULL)
if (strncmp (line, "Revision", 8) == 0)
break ;

fclose (cpuFd) ;

if (strncmp (line, "Revision", 8) != 0)
piGpioLayoutOops ("No \"Revision\" line") ;

// Chomp trailing CR/NL

for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
*c = 0 ;
for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
*c = 0 ;

if (wiringPiDebug)
printf ("piBoardId: Revision string: %s\n", line) ;
if (wiringPiDebug)
printf ("piBoardId: Revision string: %s\n", line) ;

// Need to work out if it's using the new or old encoding scheme:

// Scan to the first character of the revision number

for (c = line ; *c ; ++c)
if (*c == ':')
break ;
for (c = line ; *c ; ++c)
if (*c == ':')
break ;

if (*c != ':')
piGpioLayoutOops ("Bogus \"Revision\" line (no colon)") ;
if (*c != ':')
piGpioLayoutOops ("Bogus \"Revision\" line (no colon)") ;

// Chomp spaces

++c ;
while (isspace (*c))
++c ;
++c ;
while (isspace (*c))
++c ;

if (!isxdigit (*c))
piGpioLayoutOops ("Bogus \"Revision\" line (no hex digit at start of revision)") ;
if (!isxdigit (*c))
piGpioLayoutOops ("Bogus \"Revision\" line (no hex digit at start of revision)") ;

revision = (unsigned int)strtol (c, NULL, 16) ; // Hex number with no leading 0x
revision = (unsigned int)strtol (c, NULL, 16) ; // Hex number with no leading 0x
}
else
piGpioLayoutOops ("Unable to open /proc/device-tree/system/linux,revision or /proc/cpuinfo") ;

// Check for new way:



Ładowanie…
Anuluj
Zapisz