[patch #8228] Added linux spi programmer type based on spidev userspace drivers

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

[patch #8228] Added linux spi programmer type based on spidev userspace drivers

Kevin Cuzner-2
URL:
  <http://savannah.nongnu.org/patch/?8228>

                 Summary: Added linux spi programmer type based on spidev
userspace drivers
                 Project: AVR Downloader/UploaDEr
            Submitted by: kcuzner
            Submitted on: Thu 31 Oct 2013 04:10:19 PM GMT
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I've been sitting on this a little while, but I just discovered how to submit
a patch. I apologize if this isn't what is supposed to go in the "Original
Submission" field. I have attached my patch as an attachment.

As documented at
http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/ and
https://github.com/kcuzner/avrdude, I have created a linuxspi programmer type
and added it to avrdude. I had talked about it a bit on the mailing list back
in May, but now I have finally gotten around to sending the patch.

The linuxspi programmer type allows avrdude to use the built-in spidev
userspace SPI drivers on linux to communicate to an attached AVR. While this
doesn't have much application for desktop or laptop computers, for
single-board linux computers such as the Raspberry Pi or Beaglebone, it allows
the single-board computer to be used as a stand-alone AVR programmer with
little to no extra hardware. I think this is useful on many levels, including
being able to embed an AVR onto a computer with spidev support and have it be
in-system programmable by executing a userspace program.

The port switch is used to direct the linuxspi programmer to which SPI bus to
use. The baud rate switch can be used to change the frequency at which the SPI
bus operates.

The comments on my blog post show that most people using it have been able to
get it to work and in many cases, using a lower frequency on the SPI bus via
the baud rate switch solved communication issues.

The patch was created by git, so it probably has to be applied with the -p1
flag to strip off the a/ and b/ that git likes to prepend to path names.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 31 Oct 2013 04:10:19 PM GMT  Name:
0001-Added-linuxspi-programmer-type-using-spidev.patch  Size: 17kB   By:
kcuzner

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

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?8228>

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

[patch #8228] Added linux spi programmer type based on spidev userspace drivers

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

This should definitely be included in the standard AVRDUDE.

Consider how many people have Raspberry PI's and how many people use
microcontrollers such as Arduino with the Pi. It must be better to have one
version of AVRDude rather than different forks of it. I've used the KCUZNER
version and it works well.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?8228>

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

[patch #8228] Added linux spi programmer type based on spidev userspace drivers

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

                  Status:                    None => In Progress            

    _______________________________________________________

Follow-up Comment #2:

Curious: shouldn't HAVE_SPIDEV default to NO for standard desktop-type Linux
systems? I don't think linuxspi would make much sense on those systems, so
just enabling it based on the presence of a header file is IMHO not a good
decision.

What I don't like is the trailing whitespace on many lines of your new files
(but I could fix that myself).

Otherwise, looks good.

    _______________________________________________________

Reply to this item at:

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

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


Reply | Threaded
Open this post in threaded view
|

[patch #8228] Added linux spi programmer type based on spidev userspace drivers

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

Finally, there's a one warning remaining:


linuxspi.c: In function ‘linuxspi_gpio_op_wr’:
linuxspi.c:170:5: warning: format not a string literal and no format arguments
[-Wformat-security]
     if (fprintf(f, val) < 0)


If I get it correctly, it would not even be necessary to use fprintf here, as
"val" is always a fixed string when being passed to linuxspi_gpio_op_wr(),
correct?

Thus, replacing "fprintf(f, val) < 0" by "fputs(val, f) != EOF" ought to be a
better solution (and avoids the overhead of fprintf trying to interpret a
format string that is known to not have format conversions at all).

    _______________________________________________________

Reply to this item at:

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

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


Reply | Threaded
Open this post in threaded view
|

[patch #8228] Added linux spi programmer type based on spidev userspace drivers

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

I just logged into my email after many months and saw movement on this patch!!
I'm surprised! I apologize for the roughness of the code in this patch. If
you're working on this patch, I would recommend instead looking at #9816. Ralf
Ramsauer put a bunch of effort in to get things up to speed with how avrdude
has morphed over the past 8 years. Any work I would do to clean this up has
already been done by Ralf in that patch.

    _______________________________________________________

Reply to this item at:

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

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