[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avrdude-dev] Fix linuxgpio bug and add TPI support
From: |
David Mosberger |
Subject: |
[avrdude-dev] Fix linuxgpio bug and add TPI support |
Date: |
Sat, 27 Feb 2016 03:24:07 -0700 |
With the attached patch (relative to GIT repository), I'm able to program
an ATtiny9 via TPI using a Raspberry PI.
Example command:
$ avrdude -i100 -C./avrdude.conf -pt9 -clinuxgpio
-i option is only needed if the data clock needs to be slowed down for
some reason (shouldn't be needed, normally).
The bugfix is to mask the pin number against PIN_MASK before checking it
against PIN_AVR_RESET etc. Without that,
I get errors because the code then tries to export GPIO 0 multiple times.
--david
--
eGauge Systems LLC, http://egauge.net/, 1.877-EGAUGE1, fax 720.545.9768
diff --git a/avrdude/linuxgpio.c b/avrdude/linuxgpio.c
index e6452e2..77abf60 100644
--- a/avrdude/linuxgpio.c
+++ b/avrdude/linuxgpio.c
@@ -258,12 +258,12 @@ static int linuxgpio_open(PROGRAMMER *pgm, char *port)
//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++) {
- if ( pgm->pinno[i] != 0 ||
+ pin = pgm->pinno[i] & PIN_MASK;
+ if ( pin != 0) ||
i == PIN_AVR_RESET ||
i == PIN_AVR_SCK ||
i == PIN_AVR_MOSI ||
i == PIN_AVR_MISO ) {
- pin = pgm->pinno[i] & PIN_MASK;
if ((r=linuxgpio_export(pin)) < 0) {
fprintf(stderr, "Can't export GPIO %d, already exported/busy?:
%s",
pin, strerror(errno));
@@ -327,6 +327,7 @@ void linuxgpio_initpgm(PROGRAMMER *pgm)
pgm->program_enable = bitbang_program_enable;
pgm->chip_erase = bitbang_chip_erase;
pgm->cmd = bitbang_cmd;
+ pgm->cmd_tpi = bitbang_cmd_tpi;
pgm->open = linuxgpio_open;
pgm->close = linuxgpio_close;
pgm->setpin = linuxgpio_setpin;
- [avrdude-dev] Fix linuxgpio bug and add TPI support,
David Mosberger <=