Improve defaults and documentation of linuxspi

* avrdude.conf.in: use @HAVE_LINUXGPIO_BEGIN/END@ and
@HAVE_LINUXSPI_BEGIN/END@ brackets around respective config
snippets; values were already set in configure.ac.
* linuxspi.c (linuxspi_open): Provide a reasonable (for the
Raspberry Pi) default for the -P option
* avrdude.1: Extend linuxspi documentation
* doc/avrdude.texi: (Dito.)



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1496 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2021-11-27 17:33:49 +00:00
parent 18fe8ef834
commit dd1255b0c8
6 changed files with 59 additions and 31 deletions

View File

@ -1,3 +1,14 @@
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Improve defaults and documentation of linuxspi
* avrdude.conf.in: use @HAVE_LINUXGPIO_BEGIN/END@ and
@HAVE_LINUXSPI_BEGIN/END@ brackets around respective config
snippets; values were already set in configure.ac.
* linuxspi.c (linuxspi_open): Provide a reasonable (for the
Raspberry Pi) default for the -P option
* avrdude.1: Extend linuxspi documentation
* doc/avrdude.texi: (Dito.)
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Alex Sverdlin: Submitted by Alex Sverdlin:

2
NEWS
View File

@ -20,6 +20,7 @@ Current:
- New configure option: -disable-libusb_1_0 - New configure option: -disable-libusb_1_0
- extended UPDI device context (> 64 Ki flash) - extended UPDI device context (> 64 Ki flash)
- major overhaul of ft245r driver (patch #9327/#9328) - major overhaul of ft245r driver (patch #9327/#9328)
- some improvements in linuxspi driver
* New devices supported: * New devices supported:
@ -122,6 +123,7 @@ Current:
patch #10029: linuxspi: Report GPIO_GET_LINEHANDLE_IOCTL errors patch #10029: linuxspi: Report GPIO_GET_LINEHANDLE_IOCTL errors
patch #10030: linuxspi: Support inverted GPIO pin patch #10030: linuxspi: Support inverted GPIO pin
patch #10031: linuxspi: Support GPIO uAPI v2 patch #10031: linuxspi: Support GPIO uAPI v2
(no-id): Improve documentation of linuxspi driver, provide portname default
* Internals: * Internals:
- New avrdude.conf keyword "family_id", used to verify SIB attributes - New avrdude.conf keyword "family_id", used to verify SIB attributes

View File

@ -129,13 +129,10 @@ should be connected between the AVR's reset pin and Vcc. If Vcc is not
the same as the SPI voltage, this should be done on the AVR side of the same as the SPI voltage, this should be done on the AVR side of
the level translator to protect the hardware from damage. the level translator to protect the hardware from damage.
.Pp .Pp
A commented-out template for this programmer is provided in the The
avrdude configuration file. To use it, clone that entry into the .Fl P Ar portname
per-user configuration file, and configure the option for this programmer defaults to
.Li reset .Li /dev/spidev0.0:/dev/gpiochip0 .
GPIO
number accordingly. Linuxspi can be used as follows:
.Dl avrdude -c linuxspi -P /dev/spidev:/dev/gpiochip[:resetpin]
.Pp .Pp
Atmel's STK500 programmer is also supported and connects to a serial Atmel's STK500 programmer is also supported and connects to a serial
port. port.

View File

@ -1519,6 +1519,7 @@ programmer
@HAVE_PARPORT_END@ @HAVE_PARPORT_END@
@HAVE_LINUXGPIO_BEGIN@
#This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface #This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface
# #
#To enable it set the configuration below to match the GPIO lines connected to the #To enable it set the configuration below to match the GPIO lines connected to the
@ -1540,23 +1541,22 @@ programmer
# mosi = ?; # mosi = ?;
# miso = ?; # miso = ?;
#; #;
@HAVE_LINUXGPIO_END@
@HAVE_LINUXSPI_BEGIN@
# This programmer uses the built in linux SPI bus devices to program an # This programmer uses the built in linux SPI bus devices to program an
# attached AVR. A GPIO accessed through the sysfs GPIO interface needs to # attached AVR. The reset pin must be attached to a GPIO pin that
# be specified for a reset pin since the linux SPI userspace functions do # is otherwise unused (see gpioinfo(1)); the SPI bus CE pins are not
# not allow for control over the slave select/chip select signal. # suitable since they would release /RESET too early.
# #
# To use it, copy this snippet into your ~/.avrduderc, make sure the programmer
# 'reset' entry is configured correctly. id = "linuxspi";
# desc = "Use Linux SPI device in /dev/spidev*";
# programmer type = "linuxspi";
# id = "linuxspi"; reset = 25; # Pi GPIO number - this is J8:22
# desc = "Use Linux SPI device in /dev/spidev*"; ;
# type = "linuxspi"; @HAVE_LINUXSPI_END@
# reset = 25;
# baudrate=400000;
# ;
# some ultra cheap programmers use bitbanging on the # some ultra cheap programmers use bitbanging on the
# serialport. # serialport.

View File

@ -198,14 +198,30 @@ should be connected between the AVR's reset pin and Vcc. If Vcc is not
the same as the SPI voltage, this should be done on the AVR side of the same as the SPI voltage, this should be done on the AVR side of
the level translator to protect the hardware from damage. the level translator to protect the hardware from damage.
A commented-out template for this programmer is provided in the On a Raspberry Pi, header J8 provides access to the SPI and GPIO
avrdude configuration file. To use it, clone that entry into the lines.
per-user configuration file, and configure the @code{reset} GPIO
number accordingly. Linuxspi can be used as follows:
@smallexample Typically, pins 19, 21, and 23 are SPI MOSI, MISO, and SCK, while
avrdude -c linuxspi -P /dev/spidev:/dev/gpiochip[:resetpin] pins 24 and 26 would serve as CE outputs. So, close to these pins
@end smallexample is pin 22 as GPIO25 which can be used as /RESET, and pin 25 can
be used as GND.
A typical programming cable would then look like:
@multitable @columnfractions .15 .15 .3
@item @code{J8 pin} @tab @code{ISP pin} @tab @code{Name}
@item @code{21} @tab @code{1} @tab @code{MISO}
@item @code{-} @tab @code{2} @tab @code{Vcc - leave open}
@item @code{23} @tab @code{3} @tab @code{SCK}
@item @code{19} @tab @code{4} @tab @code{MOSI}
@item @code{22} @tab @code{5} @tab @code{/RESET}
@item @code{25} @tab @code{6} @tab @code{GND}
@end multitable
(Mind the 3.3 V voltage level of the Raspberry Pi!)
The @code{-P @var{portname}} option defaults to
@code{/dev/spidev0.0:/dev/gpiochip0} for this programmer.
The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC. The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC.
The STK600, JTAG ICE mkII/3, AVRISP mkII, USBasp, avrftdi (and derivatives), and USBtinyISP The STK600, JTAG ICE mkII/3, AVRISP mkII, USBasp, avrftdi (and derivatives), and USBtinyISP

View File

@ -131,14 +131,16 @@ static int linuxspi_reset_mcu(PROGRAMMER *pgm, bool active)
static int linuxspi_open(PROGRAMMER *pgm, char *port) static int linuxspi_open(PROGRAMMER *pgm, char *port)
{ {
const char *port_error = "%s: error: Unknown port specification. Please use the format /dev/spidev:/dev/gpiochip[:resetno]\n"; const char *port_error =
"%s: error: Unknown port specification. "
"Please use the format /dev/spidev:/dev/gpiochip[:resetno]\n";
char port_default[] = "/dev/spidev0.0:/dev/gpiochip0";
char *spidev, *gpiochip, *reset_pin; char *spidev, *gpiochip, *reset_pin;
struct gpiohandle_request req; struct gpiohandle_request req;
int ret; int ret;
if (!port || !strcmp(port, "unknown")) { if (!strcmp(port, "unknown")) {
avrdude_message(MSG_INFO, "%s: error: No port specified. Port should point to an spidev device.\n", progname); port = port_default;
return -1;
} }
spidev = strtok(port, ":"); spidev = strtok(port, ":");