From c9a140554753318f049c0432b5a96144bc3ee8b6 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sat, 27 Nov 2021 20:18:44 +0000 Subject: [PATCH] =?UTF-8?q?*=20linux=5Fspi.c=20(linuxspi=5Fopen):=20ensure?= =?UTF-8?q?=20correct=20SPI=20mode=20is=20Submitted=20by=20Lars=20Oll?= =?UTF-8?q?=C3=A9n:=20set=20(submitted=20in=20the=20audit=20trail=20of=20p?= =?UTF-8?q?atch=20#9816).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1498 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 6 ++++++ linuxspi.c | 7 +++++++ 2 files changed, 13 insertions(+) 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);