diff --git a/VERSION b/VERSION index c8cfe39..e4fba21 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.10 +3.12 diff --git a/gpio/gpio.1 b/gpio/gpio.1 index bf5864a..4d76671 100644 --- a/gpio/gpio.1 +++ b/gpio/gpio.1 @@ -282,7 +282,7 @@ Please report bugs to https://github.com/WiringPi/WiringPi/issues .SH COPYRIGHT -Copyright (c) 2012-2024 Gordon Henderson and contributors +Copyright (c) 2012-2025 Gordon Henderson and contributors .br This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/gpio/gpio.c b/gpio/gpio.c index a563b24..3fc97a3 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -2,7 +2,7 @@ * gpio.c: * Swiss-Army-Knife, Set-UID command-line interface to the Raspberry * Pi's GPIO. - * Copyright (c) 2012-2024 Gordon Henderson and contributors + * Copyright (c) 2012-2025 Gordon Henderson and contributors *********************************************************************** * This file is part of wiringPi: * https://github.com/WiringPi/WiringPi/ @@ -842,7 +842,7 @@ static void doVersion (char *argv []) wiringPiVersion (&vMaj, &vMin) ; printf ("gpio version: %d.%d\n", vMaj, vMin) ; - printf ("Copyright (c) 2012-2024 Gordon Henderson and contributors\n") ; + printf ("Copyright (c) 2012-2025 Gordon Henderson and contributors\n") ; printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ; printf ("For details type: %s -warranty\n", argv [0]) ; printf ("\n") ; @@ -955,7 +955,7 @@ int main (int argc, char *argv []) if (strcasecmp (argv [1], "-warranty") == 0) { printf ("gpio version: %s\n", VERSION) ; - printf ("Copyright (c) 2012-2024 Gordon Henderson and contributors\n") ; + printf ("Copyright (c) 2012-2025 Gordon Henderson and contributors\n") ; printf ("\n") ; printf (" This program is free software; you can redistribute it and/or modify\n") ; printf (" it under the terms of the GNU Leser General Public License as published\n") ; diff --git a/version.h b/version.h index 8ef452a..225bee7 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ -#define VERSION "3.10" +#define VERSION "3.12" #define VERSION_MAJOR 3 -#define VERSION_MINOR 10 +#define VERSION_MINOR 12 diff --git a/wiringPi/test/Makefile b/wiringPi/test/Makefile index 7c379a7..bb87910 100644 --- a/wiringPi/test/Makefile +++ b/wiringPi/test/Makefile @@ -3,7 +3,7 @@ CFLAGS = -Wall LDFLAGS = # Need BCM19 <-> BCM26, +PWM: BCM12 <-> BCM13, BCM18 <-> BCM17 connected (1kOhm) -tests = wiringpi_test1_sysfs wiringpi_test2_sysfs wiringpi_test3_device_wpi wiringpi_test4_device_phys wiringpi_test5_default wiringpi_test6_isr wiringpi_test7_version wiringpi_test8_pwm wiringpi_test9_pwm +tests = wiringpi_test0_version wiringpi_test1_sysfs wiringpi_test2_sysfs wiringpi_test3_device_wpi wiringpi_test4_device_phys wiringpi_test5_default wiringpi_test6_isr wiringpi_test8_pwm wiringpi_test9_pwm # Need XO hardware xotests = wiringpi_xotest_test1_spi wiringpi_i2c_test1_pcf8574 wiringpi_test8_pwm wiringpi_test9_pwm @@ -31,8 +31,8 @@ wiringpi_test5_default: wiringpi_test6_isr: ${CC} ${CFLAGS} wiringpi_test6_isr.c -o wiringpi_test6_isr -lwiringPi -wiringpi_test7_version: - ${CC} ${CFLAGS} wiringpi_test7_version.c -o wiringpi_test7_version -lwiringPi +wiringpi_test0_version: + ${CC} ${CFLAGS} wiringpi_test0_version.c -o wiringpi_test0_version -lwiringPi wiringpi_test8_pwm: ${CC} ${CFLAGS} wiringpi_test8_pwm.c -o wiringpi_test8_pwm -lwiringPi diff --git a/wiringPi/test/wiringpi_test7_version.c b/wiringPi/test/wiringpi_test0_version.c similarity index 100% rename from wiringPi/test/wiringpi_test7_version.c rename to wiringPi/test/wiringpi_test0_version.c diff --git a/wiringPi/wiringPi.c b/wiringPi/wiringPi.c index bc00369..50d20fe 100644 --- a/wiringPi/wiringPi.c +++ b/wiringPi/wiringPi.c @@ -1,7 +1,7 @@ /* * wiringPi: * Arduino look-a-like Wiring library for the Raspberry Pi - * Copyright (c) 2012-2024 Gordon Henderson and contributors + * Copyright (c) 2012-2025 Gordon Henderson and contributors * Additional code for pwmSetClock by Chris Hall * * Thanks to code samples from Gert Jan van Loo and the @@ -73,6 +73,7 @@ #include #include #include +#include #include "softPwm.h" #include "softTone.h" @@ -222,13 +223,19 @@ const char* gpiomem_global = "/dev/mem"; const char* gpiomem_BCM = "/dev/gpiomem"; const char* gpiomem_RP1 = "/dev/gpiomem0"; const int gpiomem_RP1_Size = 0x00030000; -// PCIe Memory access, static define - maybe needed to detect in future +// PCIe memory access, need to detect path / PCIe address //dmesg: rp1 0000:01:00.0: bar1 len 0x400000, start 0x1f00000000, end 0x1f003fffff, flags, 0x40200 -const char* pciemem_RP1_path = "/sys/bus/pci/devices/0000:01:00.0"; -const char* pciemem_RP1 = "/sys/bus/pci/devices/0000:01:00.0/resource1"; +const char* pcie_path = "/sys/bus/pci/devices"; +//const char* pciemem_RP1_path = "/sys/bus/pci/devices/0000:01:00.0"; +//const char* pciemem_RP1 = "/sys/bus/pci/devices/0000:01:00.0/resource1"; +char pciemem_RP1[512] = { '\0' }; +const char* pciemem_RP1_bar = "resource1"; const int pciemem_RP1_Size = 0x00400000; -const unsigned short pciemem_RP1_Ventor= 0x1de4; -const unsigned short pciemem_RP1_Device= 0x0001; +//const unsigned short pciemem_RP1_Ventor= 0x1de4; +//const unsigned short pciemem_RP1_Device= 0x0001; +const char* pciemem_RP1_Ventor= "0x1de4"; +const char* pciemem_RP1_Device= "0x0001"; + static volatile unsigned int GPIO_PADS ; static volatile unsigned int GPIO_CLOCK_ADR ; @@ -2992,6 +2999,57 @@ int wiringPiUserLevelAccess(void) } +int CheckPCIeFileContent(const char* pcieaddress, const char* filename, const char* content) { + char file_path[512]; + int Found = 0; + + snprintf(file_path, sizeof(file_path), "%s/%s/%s", pcie_path, pcieaddress, filename); + if (wiringPiDebug) { printf("Open: %s ->", file_path); } + FILE *device_file = fopen(file_path, "r"); + if (device_file != NULL) { + char buffer[64]; + if (fgets(buffer, sizeof(buffer), device_file) != NULL) { + if (wiringPiDebug) { printf(" %s", buffer); } + if (strstr(buffer, content) != NULL) { + Found = 1; + if (wiringPiDebug) { printf(" >> correct\n"); } + } else { + if (wiringPiDebug) { printf(" >> wrong\n"); } + } + } + fclose(device_file); + } else { + if (wiringPiDebug) { perror("fopen"); }; + } + return Found; +} + + +void GetRP1Memory() { + + pciemem_RP1[0] = '\0'; + DIR *dir = opendir(pcie_path); + struct dirent *entry; + + if (dir == NULL) { + if (wiringPiDebug) { perror("opendir"); }; + return; + } + while ((entry = readdir(dir)) != NULL) { + if (entry->d_type == DT_LNK) { + if (CheckPCIeFileContent(entry->d_name, "device", pciemem_RP1_Device) && + CheckPCIeFileContent(entry->d_name, "vendor", pciemem_RP1_Ventor)) { + snprintf(pciemem_RP1, sizeof(pciemem_RP1), "%s/%s/%s", pcie_path, entry->d_name, pciemem_RP1_bar); + if (wiringPiDebug) { printf("RP1 device memory found at '%s'\n", pciemem_RP1); } + break; + } + } + } + + closedir(dir); +} + + int wiringPiGlobalMemoryAccess(void) { const char* gpiomemGlobal; @@ -3001,6 +3059,7 @@ int wiringPiGlobalMemoryAccess(void) piBoard(); if (PI_MODEL_5 == RaspberryPiModel) { + GetRP1Memory(pciemem_RP1, sizeof(pciemem_RP1)); gpiomemGlobal = pciemem_RP1; MMAP_size = pciemem_RP1_Size; BaseAddr = 0x00000000; @@ -3109,6 +3168,7 @@ int wiringPiSetup (void) const char* gpiomemModule = gpiomem_BCM; if (PI_MODEL_5 == model) { + GetRP1Memory(); gpiomemGlobal = pciemem_RP1; gpiomemModule = gpiomem_RP1;