[patch #9816] Implement new programmer type: linuxspi

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

[patch #9816] Implement new programmer type: linuxspi

Kevin Cuzner-2
URL:
  <https://savannah.nongnu.org/patch/?9816>

                 Summary: Implement new programmer type: linuxspi
                 Project: AVR Downloader/UploaDEr
            Submitted by: rralf
            Submitted on: Fri 14 Jun 2019 06:30:19 PM UTC
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

This adds a new linuxspi programmer type. Analogously to linuxgpio, this
programmer uses the Linux-specific spidev device.

For accessing the reset pin, this programmer uses an additional GPIO pin
using
the linux/gpio.h API. In contrast to the stateless and deprecated sysfs
interface, linux/gpio.h uses proper file descriptors for every pin, and
performs housekeeping when the device is closed. That saves some lines of
code.

The programmer can be used as follows:
  avrdude -c linuxspi -P /dev/spidev:/dev/gpiochip[:resetpin] [...]

Separated by colons, the first part of the port (-P) argument denotes the
spidev device, the second one is the gpiochip that contains the reset pin, and

the optional third argument contains the pin number of the reset pin.

If not specified, the pin number defaults to the reset pin number defined in
avrdude.conf. Currently, this defaults to 25, which is connected to Pin 22 on
a
Raspberry Pi.

Additionally, add some documentation.

Credits go to Kevin Cuzner, who started this fork ~5 years ago. I picked it
up,
rebased it to the current mainline, massaged some parts of the code here and
there, fixed some minor bugs and switched to the linux/gpio.h GPIO accessors.

Signed-off-by: Ralf Ramsauer <[hidden email]>




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 14 Jun 2019 06:30:19 PM UTC  Name: avrdude-linuxspi-V1.patch  Size:
15KiB   By: rralf

<http://savannah.nongnu.org/patch/download.php?file_id=47099>

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9816>

_______________________________________________
  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
|

[patch #9816] Implement new programmer type: linuxspi

Kevin Cuzner-2
Follow-up Comment #1, patch #9816 (project avrdude):

Just wanted to leave a comment to say, that I am using this to flash an
atmega328p via SPI from the raspberry pi and it works quite well. Did not
have any issues with it, yet :)

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9816>

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


Reply | Threaded
Open this post in threaded view
|

[patch #9816] Implement new programmer type: linuxspi

Kevin Cuzner-2
Follow-up Comment #2, patch #9816 (project avrdude):

Fabian,

thank you very much for your comment and for testing my/our patch. I'd really
wish that it would be integrated, but, to be honest, there was almost no
reaction at all and avrdude seems to unfortunately be dead from a maintainer
perspective. Sigh...

  Ralf

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9816>

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


Reply | Threaded
Open this post in threaded view
|

[patch #9816] Implement new programmer type: linuxspi

Kevin Cuzner-2
Update of patch #9816 (project avrdude):

                  Status:                    None => Done                  
             Assigned to:                    None => joerg_wunsch          
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #3:

Applied in r1447, thanks! (Without own tests, don't have an RPi readily
available where I could compile and use it.)

Thanks in particular for also providing documentation for it.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9816>

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


Reply | Threaded
Open this post in threaded view
|

Re: [patch #9816] Implement new programmer type: linuxspi

Ralf Ramsauer-2
Hi,

On 9/19/20 11:34 PM, Joerg Wunsch wrote:

> Update of patch #9816 (project avrdude):
>
>                   Status:                    None => Done                  
>              Assigned to:                    None => joerg_wunsch          
>              Open/Closed:                    Open => Closed                
>
>     _______________________________________________________
>
> Follow-up Comment #3:
>
> Applied in r1447, thanks! (Without own tests, don't have an RPi readily
> available where I could compile and use it.)

oh cool, thanks. Though it's been a while, I'm happy to see this
integrated. And btw, besides the RPi, this programmer type will run on
any machine that comes with an SPI interface.

If someone has an issue with this driver, don't hesitate to forward them
to me.

  Ralf

>
> Thanks in particular for also providing documentation for it.
>
>     _______________________________________________________
>
> Reply to this item at:
>
>   <https://savannah.nongnu.org/patch/?9816>
>
> _______________________________________________
>   Message sent via Savannah
>   https://savannah.nongnu.org/
>


--
Ralf Ramsauer
GPG: 73F94D11C85252CC

Reply | Threaded
Open this post in threaded view
|

[patch #9816] Implement new programmer type: linuxspi

Kevin Cuzner-2
In reply to this post by Kevin Cuzner-2
Follow-up Comment #4, patch #9816 (project avrdude):

I've used this patch for a while now, had some initial issues which I tracked
down to this patch not setting the SPI mode, and if you are using SPI to
communicate with as well, setting a incompatible SPI mode will cause this
programmer being unable to communicate with the chip.

I fixed it by adding:
    uint32_t mode = SPI_MODE_0 | SPI_NO_CS;
    ret = ioctl(fd_spidev, SPI_IOC_WR_MODE32, &mode);
    if (ret == -1) {
        avrdude_message(MSG_INFO, "%s: error: Unable to set SPI mode %0X on
%s\n", progname, mode, spidev);
        goto close_spidev;
    }


Before:
    fd_gpiochip = open(gpiochip, 0);

in linuxspi.c

Ya I know that's the worst patch ever :( I applied this to the 6.3 source and
added a shit load of debug messages to figure out where the issue was, so my
local source is a mess ;)

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9816>

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


Reply | Threaded
Open this post in threaded view
|

[patch #9816] Implement new programmer type: linuxspi

Kevin Cuzner-2
Update of patch #9816 (project avrdude):

                  Status:                    Done => Ready For Test        
             Open/Closed:                  Closed => Open                  


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?9816>

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


Reply | Threaded
Open this post in threaded view
|

Re: [patch #9816] Implement new programmer type: linuxspi

Ralf Ramsauer-2
In reply to this post by Kevin Cuzner-2
Hi Lars,

On 9/22/20 10:20 PM, Lars Ollén wrote:

> Follow-up Comment #4, patch #9816 (project avrdude):
>
> I've used this patch for a while now, had some initial issues which I tracked
> down to this patch not setting the SPI mode, and if you are using SPI to
> communicate with as well, setting a incompatible SPI mode will cause this
> programmer being unable to communicate with the chip.
>
> I fixed it by adding:
>     uint32_t mode = SPI_MODE_0 | SPI_NO_CS;
>     ret = ioctl(fd_spidev, SPI_IOC_WR_MODE32, &mode);
>     if (ret == -1) {
>         avrdude_message(MSG_INFO, "%s: error: Unable to set SPI mode %0X on
> %s\n", progname, mode, spidev);
>         goto close_spidev;
>     }
>
>
> Before:
>     fd_gpiochip = open(gpiochip, 0);
>
> in linuxspi.c

Could you attach a proper patch? Then I'll test this change on my
Raspberry Pi. I wonder why I didn't notice that on the Rpi, probably it
has those parameters set by default.

>
> Ya I know that's the worst patch ever :( I applied this to the 6.3 source and
> added a shit load of debug messages to figure out where the issue was, so my
> local source is a mess ;)

:-)

Thanks
  Ralf

>
>     _______________________________________________________
>
> Reply to this item at:
>
>   <https://savannah.nongnu.org/patch/?9816>
>
> _______________________________________________
>   Message sent via Savannah
>   https://savannah.nongnu.org/
>


--
Ralf Ramsauer
GPG: 73F94D11C85252CC