programmer: Add bitbanging programmer driver for Linux libgpiod
With this driver, any single board computer, old smartphone, etc. with
a few spare GPIOs can be used for flashrom.
Tested by reading of a 2048 kB flash chip on a Qualcomm MSM8916 SoC
@800 MHz, ran the following command:
time flashrom -p linux_gpiod:gpiochip=0,cs=18,sck=19,mosi=13,miso=56 -r test.bin
This command uses /dev/gpiochip0 with the specified GPIO numbers for the
SPI lines. All arguments are mandatory.
Output:
[...]
Found GigaDevice flash chip "GD25LQ16" (2048 kB, SPI) on linux_gpiod.
[...]
real 1m 33.96s
Change-Id: Icad3eb7764f28feaea51bda3a7893da724c86d06
Signed-off-by: Steve Markgraf <steve@steve-m.de>
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/73290
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/meson.build b/meson.build
index cd98e5b..3090808 100644
--- a/meson.build
+++ b/meson.build
@@ -109,6 +109,7 @@
group_i2c = get_option('programmer').contains('group_i2c')
group_serial = get_option('programmer').contains('group_serial')
group_jlink = get_option('programmer').contains('group_jlink')
+group_gpiod = get_option('programmer').contains('group_gpiod')
group_internal = get_option('programmer').contains('group_internal')
group_external = get_option('programmer').contains('group_external')
@@ -116,6 +117,7 @@
libusb1 = dependency('libusb-1.0', required : group_usb)
libftdi1 = dependency('libftdi1', required : group_ftdi)
libjaylink = dependency('libjaylink', required : group_jlink)
+libgpiod = dependency('libgpiod', required : group_gpiod)
subdir('platform')
@@ -284,6 +286,13 @@
'flags' : [ '-DCONFIG_JLINK_SPI=1' ],
'default' : false,
},
+ 'linux_gpio_spi' : {
+ 'systems' : [ 'linux' ],
+ 'deps' : [ libgpiod ],
+ 'groups' : [ group_gpiod, group_external ],
+ 'srcs' : files('linux_gpio_spi.c'),
+ 'flags' : [ '-DCONFIG_LINUX_GPIOD=1' ],
+ },
'linux_mtd' : {
'systems' : [ 'linux' ],
'deps' : [ linux_headers ],