diff --git a/ChangeLog b/ChangeLog index 21619c14..0042e47f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-11-27 Joerg Wunsch + + Submitted by Lars Ollén: + * linux_spi.c (linuxspi_open): ensure correct SPI mode is + set (submitted in the audit trail of patch #9816). + 2021-11-27 Joerg Wunsch * linuxspi.c: Use -B rather than -b diff --git a/linuxspi.c b/linuxspi.c index 998bf9b6..d539773e 100644 --- a/linuxspi.c +++ b/linuxspi.c @@ -166,6 +166,13 @@ static int linuxspi_open(PROGRAMMER *pgm, char *port) return -1; } + 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; + } fd_gpiochip = open(gpiochip, 0); if (fd_gpiochip < 0) { avrdude_message(MSG_INFO, "\n%s error: Unable to open the gpiochip %s", progname, gpiochip);