From 1214f99c2b5f19cd14da1a7abe86d272de452e03 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Fri, 3 Dec 2021 22:30:05 +0000 Subject: [PATCH] patch #10153: linuxspi: Support "-E reset" and "-E noreset" Submitted by Alex Sverdlin: * linuxspi.c (linuxspi_parseexitspecs): New function git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1506 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 6 ++++++ NEWS | 1 + linuxspi.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/ChangeLog b/ChangeLog index b8f2db27..75e65008 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-12-03 Joerg Wunsch + + Submitted by Alex Sverdlin: + patch #10153: linuxspi: Support "-E reset" and "-E noreset" + * linuxspi.c (linuxspi_parseexitspecs): New function + 2021-11-27 Joerg Wunsch bug #58440: linuxgpio PIN limit too low diff --git a/NEWS b/NEWS index 14b86938..a8dcca04 100644 --- a/NEWS +++ b/NEWS @@ -135,6 +135,7 @@ Current: patch #9304: [Bug #48767] Implemented WinSock variation of "ser_drain(...)" functionality patch #8996: Remove lock byte read mask (bug#21954, bug#46759) patch #8923: Enable TPI for linuxgpio + patch #10153: linuxspi: Support "-E reset" and "-E noreset" * Internals: - New avrdude.conf keyword "family_id", used to verify SIB attributes diff --git a/linuxspi.c b/linuxspi.c index d539773e..1ad6bcda 100644 --- a/linuxspi.c +++ b/linuxspi.c @@ -245,6 +245,19 @@ close_spidev: static void linuxspi_close(PROGRAMMER *pgm) { + switch (pgm->exit_reset) { + case EXIT_RESET_ENABLED: + linuxspi_reset_mcu(pgm, true); + break; + + case EXIT_RESET_DISABLED: + linuxspi_reset_mcu(pgm, false); + break; + + default: + break; + } + close(fd_linehandle); close(fd_spidev); close(fd_gpiochip); @@ -354,6 +367,26 @@ static int linuxspi_chip_erase(PROGRAMMER *pgm, AVRPART *p) return 0; } +static int linuxspi_parseexitspecs(PROGRAMMER *pgm, char *s) +{ + char *cp; + + while ((cp = strtok(s, ","))) { + s = 0; + if (!strcmp(cp, "reset")) { + pgm->exit_reset = EXIT_RESET_ENABLED; + continue; + } + if (!strcmp(cp, "noreset")) { + pgm->exit_reset = EXIT_RESET_DISABLED; + continue; + } + return -1; + } + + return 0; +} + void linuxspi_initpgm(PROGRAMMER *pgm) { strcpy(pgm->type, LINUXSPI); @@ -376,6 +409,7 @@ void linuxspi_initpgm(PROGRAMMER *pgm) /* optional functions */ pgm->setup = linuxspi_setup; pgm->teardown = linuxspi_teardown; + pgm->parseexitspecs = linuxspi_parseexitspecs; } const char linuxspi_desc[] = "SPI using Linux spidev driver";