[bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Georg-Johann Lay-3
URL:
  <http://savannah.nongnu.org/bugs/?40748>

                 Summary: linuxgpio doesn't work on Raspberry PI rev. 2.
                 Project: AVR Downloader/UploaDEr
            Submitted by: None
            Submitted on: Fri 29 Nov 2013 12:19:14 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: Joakim Lubeck
        Originator Email: [hidden email]
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I just wanted to test linuxgpio on a Raspberry PI rev. 2. I used the following
configuration entry:

---
programmer
  id    = "linuxgpio";
  desc  = "Use the Linux sysfs interface to bitbang GPIO lines";
  type  = "linuxgpio";
  reset = 17;
  sck   = 2;
  mosi  = 3;
  miso  = 4;
;
---

And used this command:

---
sudo ./avrdude -c linuxgpio -p t1634
Can't export GPIO 0, already exported/busy?: Device or resource busy
---

I don't really know why, but it may be because GPIO 0 isn't available on the
RPi rev. 2. and because of the "special handling" of GPIO 0 in linuxgpio.c.

I don't have a solution but got it to work with this as a workaround:

---
svn diff linuxgpio.c  
Index: linuxgpio.c
===================================================================
--- linuxgpio.c (revision 1250)
+++ linuxgpio.c (working copy)
@@ -257,7 +257,7 @@
   //that unwanted toggling of GPIO0 can occur and that other optional pins
   //mostry LED status, can't be set to GPIO0. It can be fixed when a better
   //solution exists.
-  for (i=0; i<N_PINS; i++) {
+  for (i=2; i<N_PINS; i++) {
     if ( pgm->pinno[i] != 0 ||
          i == PIN_AVR_RESET ||
          i == PIN_AVR_SCK   ||
---

/Joakim




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?40748>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

René Liebscher
Hi,

I'm sure how you can get the error you observe. In the loop pin should
never set to 0 for open the gpio file. (value  = 0 is filtered and all
exceptions of this are set to non-0 values.)
Could print out the relevant values in the loop so I can understand what
going on.

Just insert the following line in the for loop:

         fprintf(stderr, "linuxgpio: i=%d, pin=%d, mask=%08x,
inverse=%08x\n", i, pgm->pinno[i], pgm->pin[i].mask[0],
pgm->pin[i].inverse[0]);


René



On 29.11.2013 13:19, anonymous wrote:

> URL:
>    <http://savannah.nongnu.org/bugs/?40748>
>
>                   Summary: linuxgpio doesn't work on Raspberry PI rev. 2.
>                   Project: AVR Downloader/UploaDEr
>              Submitted by: None
>              Submitted on: Fri 29 Nov 2013 12:19:14 PM UTC
>                  Category: None
>                  Severity: 3 - Normal
>                  Priority: 5 - Normal
>                Item Group: None
>                    Status: None
>                   Privacy: Public
>               Assigned to: None
>           Originator Name: Joakim Lubeck
>          Originator Email: [hidden email]
>               Open/Closed: Open
>           Discussion Lock: Any
>
>      _______________________________________________________
>
> Details:
>
> I just wanted to test linuxgpio on a Raspberry PI rev. 2. I used the following
> configuration entry:
>
> ---
> programmer
>    id    = "linuxgpio";
>    desc  = "Use the Linux sysfs interface to bitbang GPIO lines";
>    type  = "linuxgpio";
>    reset = 17;
>    sck   = 2;
>    mosi  = 3;
>    miso  = 4;
> ;
> ---
>
> And used this command:
>
> ---
> sudo ./avrdude -c linuxgpio -p t1634
> Can't export GPIO 0, already exported/busy?: Device or resource busy
> ---
>
> I don't really know why, but it may be because GPIO 0 isn't available on the
> RPi rev. 2. and because of the "special handling" of GPIO 0 in linuxgpio.c.
>
> I don't have a solution but got it to work with this as a workaround:
>
> ---
> svn diff linuxgpio.c
> Index: linuxgpio.c
> ===================================================================
> --- linuxgpio.c (revision 1250)
> +++ linuxgpio.c (working copy)
> @@ -257,7 +257,7 @@
>     //that unwanted toggling of GPIO0 can occur and that other optional pins
>     //mostry LED status, can't be set to GPIO0. It can be fixed when a better
>     //solution exists.
> -  for (i=0; i<N_PINS; i++) {
> +  for (i=2; i<N_PINS; i++) {
>       if ( pgm->pinno[i] != 0 ||
>            i == PIN_AVR_RESET ||
>            i == PIN_AVR_SCK   ||
> ---
>
> /Joakim
>
>

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Joakim Lubeck
On Fri, November 29, 2013 11:42 pm, René Liebscher wrote:

> Hi,
>
> I'm sure how you can get the error you observe. In the loop pin should
> never set to 0 for open the gpio file. (value  = 0 is filtered and all
> exceptions of this are set to non-0 values.)
> Could print out the relevant values in the loop so I can understand what
> going on.
>
> Just insert the following line in the for loop:
>
>          fprintf(stderr, "linuxgpio: i=%d, pin=%d, mask=%08x,
> inverse=%08x\n", i, pgm->pinno[i], pgm->pin[i].mask[0],
> pgm->pin[i].inverse[0]);

Hello,

With that printf as the first statement in the for loop I get,

Loop starts with i = 0
---
sudo ./avrdude -c linuxgpio -p t1634
linuxgpio: i=0, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=1, pin=-2147483648, mask=00000000, inverse=00000000
linuxgpio: i=2, pin=-2147483648, mask=00000000, inverse=00000000
Can't export GPIO 0, already exported/busy?: Device or resource busy
avrdude done.  Thank you.
---


Loop starts with i = 2
---
sudo ./avrdude -c linuxgpio -p t1634
linuxgpio: i=2, pin=-2147483648, mask=00000000, inverse=00000000
linuxgpio: i=3, pin=17, mask=00020000, inverse=00000000
linuxgpio: i=4, pin=2, mask=00000004, inverse=00000000
linuxgpio: i=5, pin=3, mask=00000008, inverse=00000000
linuxgpio: i=6, pin=4, mask=00000010, inverse=00000000
linuxgpio: i=7, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=8, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=9, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=10, pin=0, mask=00000000, inverse=00000000

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9412

avrdude: safemode: Fuses OK (E:1F, H:DF, L:E2)

avrdude done.  Thank you.
---

/Joakim


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Joakim Lubeck
In reply to this post by René Liebscher
On Fri, November 29, 2013 11:42 pm, René Liebscher wrote:
> Hi,
>
> (value  = 0 is filtered and all exceptions of this are set to non-0
values.)

Now I don't know the details here, but should there be only || in that if
statement? I tested with

---

    if ( pgm->pinno[i] != 0 && (
         i == PIN_AVR_RESET ||
         i == PIN_AVR_SCK   ||
         i == PIN_AVR_MOSI  ||
         i == PIN_AVR_MISO) ) {
---

Just guessing here, but do that make sense?
It seems to work with the loop starting with i = 0. Output with with your
printf's

---
sudo ./avrdude -c linuxgpio -p t1634
linuxgpio: i=0, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=1, pin=-2147483648, mask=00000000, inverse=00000000
linuxgpio: i=2, pin=-2147483648, mask=00000000, inverse=00000000
linuxgpio: i=3, pin=17, mask=00020000, inverse=00000000
linuxgpio: i=4, pin=2, mask=00000004, inverse=00000000
linuxgpio: i=5, pin=3, mask=00000008, inverse=00000000
linuxgpio: i=6, pin=4, mask=00000010, inverse=00000000
linuxgpio: i=7, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=8, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=9, pin=0, mask=00000000, inverse=00000000
linuxgpio: i=10, pin=0, mask=00000000, inverse=00000000

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9412

avrdude: safemode: Fuses OK (E:1F, H:DF, L:E2)

avrdude done.  Thank you.
---

/Joakim


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Radoslav Kolev-3
On Sat, Nov 30, 2013 at 10:15 AM, Joakim Lubeck <[hidden email]> wrote:
> On Fri, November 29, 2013 11:42 pm, René Liebscher wrote:
> Now I don't know the details here, but should there be only || in that if
> statement? I tested with

No, this check is a kludge, to allow 0 based pin numbers, before René
submitted the proper changes for that. The best solution would be to
convert linuxgpio programmer to use this new infrastructure. I haven't
had time to do this unfortunately.

>     if ( pgm->pinno[i] != 0

Before if a pin was not configured, is was assured that is will be set
to 0, and this check relies on this. After the changes for 0 based
pins this is no longer so. As a quick fix you can try this patch to
the pin_fill_old_pinno() funtcion below, which replicates this
behavior for not configured pins. This is not even compile tested, so
try at your own risk :). René can probably say if it's a good idea to
do this and if it can have some bad side effects.

diff --git a/avrdude/pindefs.c b/avrdude/pindefs.c
index 8842649..00ae753 100644
--- a/avrdude/pindefs.c
+++ b/avrdude/pindefs.c
@@ -73,6 +73,11 @@ static void pin_fill_old_pinno(const struct
pindef_t * const pindef, unsigned in
       }
     }
   }
+
+  if (!found) {
+    *pinno = 0;
+  }
+
 }

 /**


Regards,
Rado

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

[bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Georg-Johann Lay-3
In reply to this post by Georg-Johann Lay-3
Update of bug #40748 (project avrdude):

                  Status:                    None => Ready For Test        
             Assigned to:                    None => rliebscher            

    _______________________________________________________

Follow-up Comment #1:

fixed in revision 1251

There were two problems:

- linuxgpio: did not mask out the inverse flag at the check for pin == 0 (so
it tried to open gpio for vcc and buff functions)
- pindefs.c: fill_old_pinlist did create an entry (O | inverse_flag) for
unused pin lists (buff and vcc)

Please test it now again.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?40748>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Joakim Lubeck
On Sat, November 30, 2013 1:16 pm, Rene Liebscher wrote:

> fixed in revision 1251
>
> There were two problems:
>
> - linuxgpio: did not mask out the inverse flag at the check for pin == 0
> (so
> it tried to open gpio for vcc and buff functions)
> - pindefs.c: fill_old_pinlist did create an entry (O | inverse_flag) for
> unused pin lists (buff and vcc)
>
> Please test it now again.

That seems to work fine! Thanks!

Regards
/Joakim


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

René Liebscher
In reply to this post by Radoslav Kolev-3
On 30.11.2013 11:57, Radoslav Kolev wrote:
> On Sat, Nov 30, 2013 at 10:15 AM, Joakim Lubeck <[hidden email]> wrote:
>> On Fri, November 29, 2013 11:42 pm, René Liebscher wrote:
>> Now I don't know the details here, but should there be only || in that if
>> statement? I tested with
> No, this check is a kludge, to allow 0 based pin numbers, before René
> submitted the proper changes for that. The best solution would be to
> convert linuxgpio programmer to use this new infrastructure. I haven't
> had time to do this unfortunately.
This should be now a little bit easier to realize as I changed the
interface of setpin, getpin, and highpulsepin, so you have the choice to
use the new pindefs here.
Linuxgpio needs to be tested that my changes did not break anything.
(The same is true for serial bitbanging devices. Parport and
buspirate_bb is already tested by me.)


Kind regards,

René

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

[bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Georg-Johann Lay-3
In reply to this post by Georg-Johann Lay-3
Follow-up Comment #2, bug #40748 (project avrdude):

This bug is present in 6.3.
6.2 works.

Thanks for this awesome software!

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?40748>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Mike Brandon
What error are you getting?

In 6.3 you need to compile with rev 1388 for linuxgpio.c which fixes %ud
snprintf.

Mike

On Thu, Nov 15, 2018, 11:22 AM Gaspar Karm <[hidden email] wrote:

> Follow-up Comment #2, bug #40748 (project avrdude):
>
> This bug is present in 6.3.
> 6.2 works.
>
> Thanks for this awesome software!
>
>     _______________________________________________________
>
> Reply to this item at:
>
>   <https://savannah.nongnu.org/bugs/?40748>
>
> _______________________________________________
>   Message sent via Savannah
>   https://savannah.nongnu.org/
>
>
> _______________________________________________
> avrdude-dev mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/avrdude-dev
>
_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Gaspar Karm
Error is the same as reported in first post:

'Can't export GPIO X, already exported/busy?: Device or resource busy'


Gaspar




________________________________
From: Mike Brandon <[hidden email]>
Sent: Thursday, November 15, 2018 4:43 PM
To: Gaspar Karm
Cc: Rene Liebscher; Gaspar Karm; Joakim Lubeck; [hidden email]
Subject: Re: [avrdude-dev] [bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

What error are you getting?

In 6.3 you need to compile with rev 1388 for linuxgpio.c which fixes %ud snprintf.

Mike

On Thu, Nov 15, 2018, 11:22 AM Gaspar Karm <[hidden email]<mailto:[hidden email]> wrote:
Follow-up Comment #2, bug #40748 (project avrdude):

This bug is present in 6.3.
6.2 works.

Thanks for this awesome software!

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?40748>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]<mailto:[hidden email]>
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

[bug #40748] linuxgpio doesn't work on Raspberry PI rev. 2.

Georg-Johann Lay-3
In reply to this post by Georg-Johann Lay-3
Update of bug #40748 (project avrdude):

                  Status:          Ready For Test => Fixed                  
             Open/Closed:                    Open => Closed                
                 Release:                    None => 6.1                    

    _______________________________________________________

Follow-up Comment #3:

> This bug is present in 6.3.

Nope. What you're reporting is actually bug #47550 which has already been
fixed in the sources, but is unrelated to this (original) bug.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?40748>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev