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

Bug #1229658 reported by Botao
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro Android
Fix Released
Undecided
Unassigned
Linaro PMWG Powerdebug
Fix Released
High
sanjay singh rawat

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

For the bug on TI Panda Android, please refer to:
https://bugs.linaro.org/show_bug.cgi?id=65

###########################################
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
https://android-build.linaro.org/builds/~linaro-android-member-ti/panda-linaro-14.07-release/#1

###########################################
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
https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-14.05-release/#build=2

Revision history for this message
Botao (botao-sun) wrote :
Amit Kucheria (amitk)
Changed in linaro-powerdebug:
assignee: nobody → shaojie.sun (shaojie-sun)
importance: Undecided → High
Revision history for this message
Botao (botao-sun) wrote :

File structures 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

root@vexpress:/sys/kernel/debug # ls -la
drwxr-xr-x root root 1970-01-01 00:00 bdi
drwxr-xr-x root root 1970-01-01 00:00 binder
drwxr-xr-x root root 1970-01-01 00:00 extfrag
-r--r--r-- root root 0 1970-01-01 00:00 gpio
drwxr-xr-x root root 1970-01-01 00:00 hid
drwxr-xr-x root root 1970-01-01 00:00 memblock
drwxr-xr-x root root 1970-01-01 00:00 mmc0
drwxr-xr-x root root 1970-01-01 00:00 regulator
-rw-r--r-- root root 0 1970-01-01 00:00 sched_features
-rw-r--r-- root root 0 1970-01-01 00:00 shrinker
-r--r--r-- root root 0 1970-01-01 00:00 sleep_time
-r--r--r-- root root 0 1970-01-01 00:00 suspend_stats
drwxr-xr-x root root 1970-01-01 00:00 tracing
drwxr-xr-x root root 1970-01-01 00:00 usb
-r--r--r-- root root 0 1970-01-01 00:00 wakeup_sources
root@vexpress:/sys/kernel/debug #

Revision history for this message
shaojie.sun (shaojie-sun) wrote :

There are no clk or clock folder in /sys/kernel/debug. So clock couldn't be shown in powerdebug tool.

And please help me to /sys/class/gpio. Thanks.

Revision history for this message
Botao (botao-sun) wrote :

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

For files under path "/sys/class", it shows as:

root@vexpress:/sys/class # ls -la
drwxr-xr-x root root 2013-09-24 11:39 bdi
drwxr-xr-x root root 2013-09-24 11:39 block
drwxr-xr-x root root 2013-09-24 11:39 bsg
drwxr-xr-x root root 2013-09-24 11:39 firmware
drwxr-xr-x root root 2013-09-24 11:39 graphics
drwxr-xr-x root root 2013-09-24 11:39 hwmon
drwxr-xr-x root root 2013-09-24 11:39 input
drwxr-xr-x root root 2013-09-24 11:39 leds
drwxr-xr-x root root 2013-09-24 11:39 mdio_bus
drwxr-xr-x root root 2013-09-24 11:39 mem
drwxr-xr-x root root 2013-09-24 11:39 misc
drwxr-xr-x root root 2013-09-24 11:39 mmc_host
drwxr-xr-x root root 2013-09-24 11:39 mtd
drwxr-xr-x root root 2013-09-24 11:39 net
drwxr-xr-x root root 2013-09-24 11:39 power_supply
drwxr-xr-x root root 2013-09-24 11:39 regulator
drwxr-xr-x root root 2013-09-24 11:39 rtc
drwxr-xr-x root root 2013-09-24 11:39 scsi_device
drwxr-xr-x root root 2013-09-24 11:39 scsi_disk
drwxr-xr-x root root 2013-09-24 11:39 scsi_host
drwxr-xr-x root root 2013-09-24 11:39 sound
drwxr-xr-x root root 2013-09-24 11:39 switch
drwxr-xr-x root root 2013-09-24 11:39 timed_output
drwxr-xr-x root root 2013-09-24 11:39 tty
drwxr-xr-x root root 2013-09-24 11:39 vc
drwxr-xr-x root root 2013-09-24 11:39 vtconsole
root@vexpress:/sys/class #

There is no "gpio" directory there. However, I found file "gpio" under the path "/sys/kernel/debug"

/sys/kernel/debug/gpio

And the content of this file shows:

GPIOs 0-10, platform/10000000.sysreg, vexpress-sysreg:
 gpio-0 (mmci-pl18x (cd) ) in hi
 gpio-1 (mmci-pl18x (wp) ) in lo
 gpio-3 (v2m:green:user1 ) out lo
 gpio-4 (v2m:green:user2 ) out lo
 gpio-5 (v2m:green:user3 ) out lo
 gpio-6 (v2m:green:user4 ) out lo
 gpio-7 (v2m:green:user5 ) out lo
 gpio-8 (v2m:green:user6 ) out hi
 gpio-9 (v2m:green:user7 ) out lo
 gpio-10 (v2m:green:user8 ) out lo

Revision history for this message
shaojie.sun (shaojie-sun) wrote : Re: [Bug 1229658] Re: Information is unavailable on "Clocks" & "Gpio" pages in powerdebug 0.7.1
Download full text (3.8 KiB)

Thanks, I will check ARM Versatile Express codes. Why move the folder
to /sys/kernel/debug/.

On Tue, Sep 24, 2013 at 7:46 PM, Botao Sun <email address hidden> wrote:
> 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
>
> For files under path "/sys/class", it shows as:
>
> root@vexpress:/sys/class # ls -la
> drwxr-xr-x root root 2013-09-24 11:39 bdi
> drwxr-xr-x root root 2013-09-24 11:39 block
> drwxr-xr-x root root 2013-09-24 11:39 bsg
> drwxr-xr-x root root 2013-09-24 11:39 firmware
> drwxr-xr-x root root 2013-09-24 11:39 graphics
> drwxr-xr-x root root 2013-09-24 11:39 hwmon
> drwxr-xr-x root root 2013-09-24 11:39 input
> drwxr-xr-x root root 2013-09-24 11:39 leds
> drwxr-xr-x root root 2013-09-24 11:39 mdio_bus
> drwxr-xr-x root root 2013-09-24 11:39 mem
> drwxr-xr-x root root 2013-09-24 11:39 misc
> drwxr-xr-x root root 2013-09-24 11:39 mmc_host
> drwxr-xr-x root root 2013-09-24 11:39 mtd
> drwxr-xr-x root root 2013-09-24 11:39 net
> drwxr-xr-x root root 2013-09-24 11:39 power_supply
> drwxr-xr-x root root 2013-09-24 11:39 regulator
> drwxr-xr-x root root 2013-09-24 11:39 rtc
> drwxr-xr-x root root 2013-09-24 11:39 scsi_device
> drwxr-xr-x root root 2013-09-24 11:39 scsi_disk
> drwxr-xr-x root root 2013-09-24 11:39 scsi_host
> drwxr-xr-x root root 2013-09-24 11:39 sound
> drwxr-xr-x root root 2013-09-24 11:39 switch
> drwxr-xr-x root root 2013-09-24 11:39 timed_output
> drwxr-xr-x root root 2013-09-24 11:39 tty
> drwxr-xr-x root root 2013-09-24 11:39 vc
> drwxr-xr-x root root 2013-09-24 11:39 vtconsole
> root@vexpress:/sys/class #
>
> There is no "gpio" directory there. However, I found file "gpio" under
> the path "/sys/kernel/debug"
>
> /sys/kernel/debug/gpio
>
> And the content of this file shows:
>
> GPIOs 0-10, platform/10000000.sysreg, vexpress-sysreg:
> gpio-0 (mmci-pl18x (cd) ) in hi
> gpio-1 (mmci-pl18x (wp) ) in lo
> gpio-3 (v2m:green:user1 ) out lo
> gpio-4 (v2m:green:user2 ) out lo
> gpio-5 (v2m:green:user3 ) out lo
> gpio-6 (v2m:green:user4 ) out lo
> gpio-7 (v2m:green:user5 ) out lo
> gpio-8 (v2m:green:user6 ) out hi
> gpio-9 (v2m:green:user7 ) out lo
> gpio-10 (v2m:green:user8 ) out lo
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/1229658
>
> Title:
> Information is unavailable on "Clocks" & "Gpio" pages in powerdebug
> 0.7.1
>
> Status in Powerdebug - a tool to help ARM developers:
> New
>
> Bug description:
> On ARM Versatile Express A9 board with Linaro Android image:
>
> https://android-build.linaro.org/builds/~linaro-android/vexp...

Read more...

Revision history for this message
Soumya Basak (soumya-basak) wrote : Re: Information is unavailable on "Clocks" & "Gpio" pages in powerdebug 0.7.1

The same issue reproduced with Linaro Android Jellybean Arndale builds:

https://android-build.linaro.org/builds/~linaro-android/arndale-linaro-13.09-release/#build=11

Clocks, Sensors and GPIO data is not avilable.

Revision history for this message
Soumya Basak (soumya-basak) wrote :

observed with Linaro android jellybean TI-panda builds:

https://android-build.linaro.org/builds/~linaro-android-member-ti/panda-linaro-13.09-release/#build=10

 "gpio" directory there is under /sys/class

root@pandaboard:/ # ls /sys/class
android_usb
backlight
bdi
block
bluetooth
bsg
display
firmware
gpio
graphics
i2c-adapter
i2c-dev
ieee80211
input
lcd
lirc
mbox
mdio_bus
mem
misc
mmc_host
net
power_supply
pvr
rc
regulator
rfkill
rtc
scsi_device
scsi_disk
scsi_host
sound
spi_master
switch
thermal
tiler
timed_output
tty
udc
usb_device
usbmon
vc
video4linux
vtconsole
root@pandaboard:/ #

Revision history for this message
Amit Kucheria (amitk) wrote : Re: [Bug 1229658] Re: Information is unavailable on "Clocks" & "Gpio" pages in powerdebug 0.7.1

Let us not overload a single bug with reports from every board. This
information is very board-specific. Please file separate bugs for each
board.

On Thu, Sep 26, 2013 at 2:08 PM, Soumya Basak <email address hidden> wrote:
> observed with Linaro android jellybean TI-panda builds:
>
> https://android-build.linaro.org/builds/~linaro-android-member-ti/panda-
> linaro-13.09-release/#build=10
>
> "gpio" directory there is under /sys/class
>
> root@pandaboard:/ # ls /sys/class
> android_usb
> backlight
> bdi
> block
> bluetooth
> bsg
> display
> firmware
> gpio
> graphics
> i2c-adapter
> i2c-dev
> ieee80211
> input
> lcd
> lirc
> mbox
> mdio_bus
> mem
> misc
> mmc_host
> net
> power_supply
> pvr
> rc
> regulator
> rfkill
> rtc
> scsi_device
> scsi_disk
> scsi_host
> sound
> spi_master
> switch
> thermal
> tiler
> timed_output
> tty
> udc
> usb_device
> usbmon
> vc
> video4linux
> vtconsole
> root@pandaboard:/ #
>
> --
> 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 "Clocks" & "Gpio" pages in powerdebug
> 0.7.1
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linaro-powerdebug/+bug/1229658/+subscriptions

Botao (botao-sun)
description: updated
summary: Information is unavailable on "Clocks" & "Gpio" pages in powerdebug
- 0.7.1
+ 0.7.1 with vexpress A9 Android
Botao (botao-sun)
description: updated
Botao (botao-sun)
description: updated
Revision history for this message
Botao (botao-sun) wrote : Re: Information is unavailable on "Clocks" & "Gpio" pages in powerdebug 0.7.1 with vexpress A9. - Android KitKat

On ARM Versatile Express A9 board with Linaro Android build #247:

https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=247

Only "Gpio" is empty, other 3 columns work well.

summary: Information is unavailable on "Clocks" & "Gpio" pages in powerdebug
- 0.7.1 with vexpress A9 Android
+ 0.7.1 with vexpress A9. - Android KitKat
description: updated
Botao (botao-sun)
description: updated
Botao (botao-sun)
description: updated
Botao (botao-sun)
description: updated
Botao (botao-sun)
tags: added: android-kitkat
summary: Information is unavailable on "Clocks" & "Gpio" pages in powerdebug
- 0.7.1 with vexpress A9. - Android KitKat
+ 0.7.1 with vexpress A9 Android.
Botao (botao-sun)
description: updated
Amit Kucheria (amitk)
Changed in linaro-powerdebug:
assignee: shaojie.sun (shaojie-sun) → sanjay singh rawat (sanjay-rawat)
Botao (botao-sun)
description: updated
Botao (botao-sun)
summary: - Information is unavailable on "Clocks" & "Gpio" pages in powerdebug
- 0.7.1 with vexpress A9 Android.
+ Information is unavailable on "Gpio" page in powerdebug 0.7.1 with
+ vexpress A9 Android.
description: updated
Revision history for this message
sanjay singh rawat (sanjay-rawat) wrote :

Botao i checked image https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=247 , the issue is GPIO_SYSFS config support is not enabled. Its a prerequisite for powerdebug to work.

Changed in linaro-powerdebug:
status: New → Triaged
Revision history for this message
Soumya Basak (soumya-basak) wrote :

on image https://android-build.linaro.org/builds/~linaro-android-member-ti/panda-linaro-14.04-release/#build=1

Validate PowerDebug with TI-Panda 4430 & TI-Panda 4460 board,

 Sensors & Gpio info are not available.

Revision history for this message
Soumya Basak (soumya-basak) wrote :

with image https://android-build.linaro.org/builds/~linaro-android/arndale-linaro-14.04-release/#build=1
on Samsung Arndale board,

Powerdebug doesn't shows Clock, sensors and gpio info (only shows regulator info.)

Revision history for this message
Amit Kucheria (amitk) wrote :

Can you check the output after some gpios are exported using

"echo XX > /sys/class/gpio/export"

where XX is the gpio number.

Revision history for this message
Soumya Basak (soumya-basak) wrote :

for Samsung Arndale board, with build:

https://android-build.linaro.org/builds/~linaro-android/arndale-linaro-14.04-release/#build=1

gpio file is not present under /sys/class

file structure under /sys/class

root@arndale:/sys/class # ls
ata_device
ata_link
ata_port
bdi
block
dma
firmware
graphics
i2c-adapter
input
mdio_bus
mem
misc
mmc_host
net
regulator
scsi_device
scsi_disk
scsi_generic
scsi_host
thermal
timed_output
tty
udc
vc
video4linux
vtconsole

so for that reason gpio info page not display on Arndale.

Revision history for this message
Amit Kucheria (amitk) wrote : Re: [Bug 1229658] Re: Information is unavailable on "Gpio" page in powerdebug 0.7.1 with vexpress A9 Android.

So first we need them to compile in the GPIO_SYSFS option...

On Wed, Apr 30, 2014 at 5:06 PM, Soumya Basak <email address hidden> wrote:
> for Samsung Arndale board, with build:
>
> https://android-build.linaro.org/builds/~linaro-android/arndale-
> linaro-14.04-release/#build=1
>
> gpio file is not present under /sys/class
>
> file structure under /sys/class
>
> root@arndale:/sys/class # ls
> ata_device
> ata_link
> ata_port
> bdi
> block
> dma
> firmware
> graphics
> i2c-adapter
> input
> mdio_bus
> mem
> misc
> mmc_host
> net
> regulator
> scsi_device
> scsi_disk
> scsi_generic
> scsi_host
> thermal
> timed_output
> tty
> udc
> vc
> video4linux
> vtconsole
>
> so for that reason gpio info page not display on Arndale.
>
> --
> 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.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linaro-android/+bug/1229658/+subscriptions

Revision history for this message
sanjay singh rawat (sanjay-rawat) wrote :

submitted patch to export gpios. Please reopen if you see the issue again.

Changed in linaro-powerdebug:
status: Triaged → Fix Released
Revision history for this message
Botao (botao-sun) wrote :

Hi Sanjay, the issue still exists on vexpress Android build #331

https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=331

The GPIO column is empty there. The version of PowerDebug now shows 0.7.2, have your patch been merged?

description: updated
Changed in linaro-powerdebug:
status: Fix Released → In Progress
Revision history for this message
sanjay singh rawat (sanjay-rawat) wrote :

hello Botao,

Here change is needed from kernel side. The issue is, in the vexpress
kernel the GPIO_SYSFS directive is not enabled (checked in the 331 build
config file). Its one of the prerequisites for the feature to work.
Please create a new bug for that and close this one. thanks

On Thursday 22 May 2014 12:47 PM, Botao Sun wrote:
> Hi Sanjay, the issue still exists on vexpress Android build #331
>
> https://android-build.linaro.org/builds/~linaro-android/vexpress-
> linaro/#build=331
>
> The GPIO column is empty there. The version of PowerDebug now shows
> 0.7.2, have your patch been merged?
>
> ** Description changed:
>
> 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
>
> ** Changed in: linaro-powerdebug
> Status: Fix Released => In Progress
>

--
sanjay

Revision history for this message
Botao (botao-sun) wrote :

Yes, as we discussed before. But maybe a better idea is to involve Kernel team to this bug? This way we won't loose any history conversation.

Revision history for this message
Mohammad Merajul Islam Molla (meraj-enigma) wrote :

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

Revision history for this message
Mohammad Merajul Islam Molla (meraj-enigma) wrote :

Hello Sanjay/Botao,

It looks like there is a problem in the code portion below -

while (read = getline(&line, &len, fgpio) != -1) {
  char *str;

  if (strstr(line, "gpio-")) {
   str = strtok(line, " ");
   sscanf(str, "gpio-%d", &gpio[num]);
   fprintf(fgpio_export, "%d", gpio[num]);
   num++;
  }

/sys/kernel/debug/gpio will have lines as below only if those gpio pins have already been exported by writing to /sys/class/gpio/export file -

 gpio-1 (sysfs ) in hi
 gpio-2 (sysfs ) in lo
 gpio-3 (sysfs ) in hi
 gpio-4 (sysfs ) in lo
 gpio-5 (sysfs ) in lo
 gpio-6 (sysfs ) in hi
 gpio-7 (sysfs ) in hi

I have attached a patch which fixes the problem. Now it dynamically determines maximum number of gpios on the platform and exports those via /sys/class/gpio/export file.

Please review/comment/test the patch attached.

*** NOTE: The earlier patch (mentioned above) is no longer necessary. This patch contains all the other fixes too.

Thanks,
-Meraj

Revision history for this message
Fathi Boudra (fboudra) wrote :
Botao (botao-sun)
description: updated
Amit Khare (amit-khare)
description: updated
description: updated
Revision history for this message
sanjay singh rawat (sanjay-rawat) wrote :

Hi Meraj,

Your patch assumes the gpio numbers sequentially listed in the debug
file, which is a wrong assumption. It will export gpios which are not
listed.

e.g. below is the gpio debug info for panda

GPIOs 0-31, gpio:
  gpio-0 (tfp410 PD ) out lo
  gpio-1 (hsusb1_vbus ) out hi

GPIOs 32-63, gpio:
  gpio-41 (hdmi_ls_oe ) out lo
  gpio-43 (vwl1271 ) out hi
  gpio-60 (hdmi_ct_cp_hpd ) out hi
  gpio-62 (hsusb1_phy.8 ) out hi
  gpio-63 (hdmi_hpd ) in lo IRQ

GPIOs 64-95, gpio:

GPIOs 96-127, gpio:
  gpio-127 (audpwron ) out hi

GPIOs 128-159, gpio:

GPIOs 160-191, gpio:

On Monday 26 May 2014 02:43 PM, Mohammad Merajul Islam Molla wrote:
> Hello Sanjay/Botao,
>
> It looks like there is a problem in the code portion below -
>
> while (read = getline(&line, &len, fgpio) != -1) {
> char *str;
>
> if (strstr(line, "gpio-")) {
> str = strtok(line, " ");
> sscanf(str, "gpio-%d", &gpio[num]);
> fprintf(fgpio_export, "%d", gpio[num]);
> num++;
> }
>
> /sys/kernel/debug/gpio will have lines as below only if those gpio pins
> have already been exported by writing to /sys/class/gpio/export file -
>
> gpio-1 (sysfs ) in hi
> gpio-2 (sysfs ) in lo
> gpio-3 (sysfs ) in hi
> gpio-4 (sysfs ) in lo
> gpio-5 (sysfs ) in lo
> gpio-6 (sysfs ) in hi
> gpio-7 (sysfs ) in hi
>
>
> I have attached a patch which fixes the problem. Now it dynamically determines maximum number of gpios on the platform and exports those via /sys/class/gpio/export file.
>
> Please review/comment/test the patch attached.
>
> *** NOTE: The earlier patch (mentioned above) is no longer necessary.
> This patch contains all the other fixes too.
>
>
> Thanks,
> -Meraj
>
> ** Attachment added: "powerdebug_gpio_info_patch"
> https://bugs.launchpad.net/linaro-powerdebug/+bug/1229658/+attachment/4119672/+files/powerdebug_gpio_info_patch
>

--
sanjay

Revision history for this message
Mohammad Merajul Islam Molla (meraj-enigma) wrote :

Hi Sanjay,

In that case, I think users need to export GPIOs first via /sys/kernel/gpio/export. Otherwise, the below lines don't appear in /sys/kernel/debug/gpio file -

  gpio-0 (tfp410 PD ) out lo
  gpio-1 (hsusb1_vbus ) out hi

Atleast thats what I see on my Samsung Arndale Board with Linaro Saucy Server.

If that is the case, then patch mentioned in comment #21 is not necessary. Simply configuring kernel with SYSFS_GPIO won't do it (may be a warning message in gpio page of powerdebug will help - export gpios first by writing to /sys/kernel/gpio/export file?) Please correct me if I am wrong.

However, patch mentioned in comment #20 is still necessary to avoid build errors and segmentation fault.

Please suggest.

--
Thanks,
-Meraj

Revision history for this message
Botao (botao-sun) wrote :

On ARM Versatile Express A9 board with Linaro Android image:

https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro/#build=356

Segmentation fault occurred when run powerdebug:

root@vexpress:/ # powerdebug
Segmentation fault
139|root@vexpress:/ #

Revision history for this message
Botao (botao-sun) wrote :

On ARM Versatile Express A9 board with Linaro Android image:

https://android-build.linaro.org/builds/~linaro-android/vexpress-linaro-14.06-release/#build=1

This issue has gone, now all 4 columns have data shows.

Changed in linaro-powerdebug:
status: In Progress → Fix Released
Changed in linaro-android:
status: New → Fix Released
Botao (botao-sun)
description: updated
Amit Khare (amit-khare)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.