Skip to content

Commit

Permalink
openwrt: Raspberry PI gpiomem fix
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Feb 5, 2024
1 parent 4e4cd8e commit 29f1adc
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions hcxdumptool.c
Original file line number Diff line number Diff line change
Expand Up @@ -4530,7 +4530,7 @@ if((modinfo = fopen("/proc/device-tree/model", "r")) == NULL)
len = fgetline(modinfo, RASPBERRY_INFO, linein);
fclose(modinfo);
if(len < RPINAME_SIZE) return false;
if(memcmp(&rpiname, &linein, RPINAME_SIZE) != 0) return false;
if(memcmp(rpiname, linein, RPINAME_SIZE) != 0) return false;
if((procinfo = fopen("/proc/cpuinfo", "r")) != NULL)
{
while(1)
Expand All @@ -4546,37 +4546,37 @@ if((procinfo = fopen("/proc/cpuinfo", "r")) != NULL)
}
fclose(procinfo);
}
if((procinfo = fopen("/proc/iomem", "r")) != NULL)
if((fd_devinfo = open("/dev/gpiomem", O_RDWR | O_SYNC)) > 0)
{
while(1)
gpio_map = mmap(NULL, RPI_BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd_devinfo, gpioperibase);
close(fd_devinfo);
}
else
{
if((procinfo = fopen("/proc/iomem", "r")) != NULL)
{
if((len = fgetline(procinfo, RASPBERRY_INFO, linein)) == -1) break;
if(strstr(linein, ".gpio") != NULL)
while(1)
{
if(linein[8] != '-') break;
if((len = fgetline(procinfo, RASPBERRY_INFO, linein)) == -1) break;
if(strstr(linein, ".gpio") != NULL)
{
linein[8] = 0;
gpioperibase = strtoul(linein, NULL, 16);
break;
if(linein[8] != '-') break;
{
linein[8] = 0;
gpioperibase = strtoul(linein, NULL, 16);
if(gpioperibase != 0)
{
if((fd_devinfo = open("/dev/mem", O_RDWR | O_SYNC)) > 0)
{
gpio_map = mmap(NULL, RPI_BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd_devinfo, gpioperibase);
close(fd_devinfo);
}
}
break;
}
}
}
}
fclose(procinfo);
}
if(gpioperibase != 0)
{
if((fd_devinfo = open("/dev/mem", O_RDWR | O_SYNC)) > 0)
{
gpio_map = mmap(NULL, RPI_BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd_devinfo, gpioperibase);
close(fd_devinfo);
}
}
else
{
if((fd_devinfo = open("/dev/gpiomem", O_RDWR | O_SYNC)) > 0)
{
gpio_map = mmap(NULL, RPI_BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd_devinfo, gpioperibase);
close(fd_devinfo);
fclose(procinfo);
}
}
if(gpio_map == MAP_FAILED)
Expand Down

0 comments on commit 29f1adc

Please sign in to comment.