← Back to team overview

linaro-pm-wg team mailing list archive

[Bug 1229658] Re: Information is unavailable on "Gpio" page in powerdebug 0.7.1 with vexpress A9 Android.

 

Hello Sanjay/Botao,

It looks like there are some problems in the patch merged recently as
part of commit 1540b3c8a3ddfd0d2d592bfe47eae5024b3b9df3,
b21205477658e0ba9eb5af8ac2ee5f0877b1d380, and
96f6e050107da5d258280b785e5ed410d534a775.

After doing git clone powerdebug, I get the following build errors -

 make
cc -O1 -g -Wall -Wshadow   -c -o sensor.o sensor.c
sensor.c: In function ‘sensor_init’:
sensor.c:300:2: warning: implicit declaration of function ‘access’ [-Wimplicit-function-declaration]
  if (access(SYSFS_SENSOR, F_OK))
  ^
sensor.c:300:27: error: ‘F_OK’ undeclared (first use in this function)
  if (access(SYSFS_SENSOR, F_OK))
                           ^
sensor.c:300:27: note: each undeclared identifier is reported only once for each function it appears in
make: *** [sensor.o] Error 1

It looks like we need to include <unistd.h> header file.

However, after fixing the build error, I was getting segmentation fault
(core dumped) while running as root.

./powerdebug
Segmentation fault (core dumped)

I debugged it and found that getline() function used in export_gpios()
is causing segmentation fault. Should initialize char *line = NULL
(please refer to example in manpage of getline).


I have written a patch to fix the build problem and segmentation fault.  Some other minor changes to get rid of some warnings.


Please find the patch below (also attached) - 


diff --git a/gpio.c b/gpio.c
index ea97278..259904b 100644
--- a/gpio.c
+++ b/gpio.c
@@ -323,26 +323,25 @@ static struct display_ops gpio_ops = {
 void export_gpios(void)
 {
        FILE *fgpio, *fgpio_export;
-       int ret = 0, gpio[256], num = 0;
-       char *line;
-       ssize_t read, len;
+       int gpio[256], num = 0;
+       char *line = NULL;
+       ssize_t read;
+       size_t len;

        fgpio = fopen("/sys/kernel/debug/gpio", "r");
        if (!fgpio) {
                printf("failed to read debugfs gpio file\n");
-               ret = -1;
                goto out;
        }

        fgpio_export = fopen("/sys/class/gpio/export", "w");
        if (!fgpio_export) {
                printf("failed to write open gpio-export file\n");
-               ret = -1;
                goto out;
        }

        /* export the gpios */
-       while (read = getline(&line, &len, fgpio) != -1) {
+       while ((read = getline(&line, &len, fgpio)) != -1) {
                char *str;

                if (strstr(line, "gpio-")) {
diff --git a/regulator.c b/regulator.c
index 27d75b6..8cf9288 100644
--- a/regulator.c
+++ b/regulator.c
@@ -28,6 +28,8 @@
 #include <dirent.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
+
 #include "display.h"
 #include "powerdebug.h"
 #include "tree.h"
diff --git a/sensor.c b/sensor.c
index bf67277..e4174eb 100644
--- a/sensor.c
+++ b/sensor.c
@@ -21,6 +21,7 @@
 #include <dirent.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>

 #include "powerdebug.h"
 #include "display.h"


***** NOTE: gpio information is still missing even though /sys/class/gpio is present on my system. I will investigate further and update the bug report ******


--
Thanks,
- Mera





** Attachment added: "gpio_segmentation_fault_patch"
   https://bugs.launchpad.net/linaro-powerdebug/+bug/1229658/+attachment/4119633/+files/gpio_segmentation_fault_patch

-- 
You received this bug notification because you are a member of Linaro
Powerdebug Commits, which is subscribed to Linaro PMWG Powerdebug.
Matching subscriptions: powerdebug commits
https://bugs.launchpad.net/bugs/1229658

Title:
  Information is unavailable on "Gpio" page in powerdebug 0.7.1 with
  vexpress A9 Android.

Status in Linaro Android:
  New
Status in Powerdebug - a tool to help ARM developers:
  In Progress

Bug description:
  On ARM Versatile Express A9 board with Linaro Android image:

  https://android-build.linaro.org/builds/~linaro-android/vexpress-
  linaro-13.09-release/#build=6

  Information is unavailable on "Clocks" & "Gpio" after launched
  powerdebug version 0.7.1, error output shows as below:

  root@vexpress:/ # powerdebug
  failed to initialize clock details (check debugfs)
  error: unable to open directory /sys/class/gpio
  failed to initialize gpios
  root@vexpress:/ #

  Please refer to attachment to get snapshot pictures.

  Note:

  Please run powerdebug in ADB shell, which the output is well
  formatted, however the failure is same as run in serial console.

  Latest update for this bug is the behaviour shows as described in
  comment #9, only GPIO information is unavailable.

  For the bug on Samsung Arndale Android, please refer to:

  https://bugs.launchpad.net/linaro-powerdebug/+bug/1298171

  ###########################################
  This issue is observed on following images:
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-13.09-release/#build=6
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-13.11-release/#build=2
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-13.12-release/#build=1
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-14.01-release/#build=6
  ###########################################
  From build #247, only "Gpio" page is empty:
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=247
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-14.02-release/#build=11
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=271
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-14.03-release/#build=1
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=297
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-14.04-release/#build=1
  https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=331

To manage notifications about this bug go to:
https://bugs.launchpad.net/linaro-android/+bug/1229658/+subscriptions


References