ODROID-C5: Use wiringpi in sudo

Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
Change-Id: I42bf4afda5a5cb6fc3996c12cb1cb192e58157d6
This commit is contained in:
2025-04-16 17:15:59 +09:00
parent a79270835f
commit 423e0bbcd4

View File

@@ -922,23 +922,15 @@ static void init_gpio_mmap (void)
int fd = -1; int fd = -1;
void *mapped; void *mapped;
/* GPIO mmap setup */ if (access("/dev/gpiomem",0) == 0) {
if (!getuid()) { if ((fd = open ("/dev/gpiomem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0)
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0)
msg (MSG_ERR, msg (MSG_ERR,
"wiringPiSetup: Unable to open /dev/mem: %s\n", "wiringPiSetup: Unable to open /dev/gpiomem: %s\n",
strerror (errno)); strerror (errno));
} else { setUsingGpiomem(TRUE);
if (access("/dev/gpiomem",0) == 0) { } else
if ((fd = open ("/dev/gpiomem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0) msg (MSG_ERR,
msg (MSG_ERR, "wiringPiSetup: /dev/gpiomem doesn't exist. Please try again with sudo.\n");
"wiringPiSetup: Unable to open /dev/gpiomem: %s\n",
strerror (errno));
setUsingGpiomem(TRUE);
} else
msg (MSG_ERR,
"wiringPiSetup: /dev/gpiomem doesn't exist. Please try again with sudo.\n");
}
if (fd < 0) { if (fd < 0) {
msg(MSG_ERR, "wiringPiSetup: Cannot open memory area for GPIO use. \n"); msg(MSG_ERR, "wiringPiSetup: Cannot open memory area for GPIO use. \n");