From 13464db5de199d8aa81612c0d241ccfd27933e6d Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 11 Feb 2019 10:27:37 +0800 Subject: [PATCH] fomu-flash: map F_RESET differently for original Pi Pin 13, which we use as F_RESET, was originally routed to BCM Pin 21. All other revisions of the board map it to BCM Pin 27. Check for the original version of the board, and re-assign F_RESET as necessary. Signed-off-by: Sean Cross --- fomu-flash.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fomu-flash.c b/fomu-flash.c index 9a4a9ec..2e414c5 100755 --- a/fomu-flash.c +++ b/fomu-flash.c @@ -21,7 +21,7 @@ #define S_D1 S_MISO #define S_D2 S_WP #define S_D3 S_HOLD -#define F_RESET 27 +static unsigned int F_RESET = 27; #define F_DONE 17 static inline int isprint(int c) @@ -170,6 +170,17 @@ int main(int argc, char **argv) { enum op op = OP_UNKNOWN; enum spi_type spi_type = ST_SINGLE; + if (gpioInitialise() < 0) { + fprintf(stderr, "Unable to initialize GPIO\n"); + return 1; + } + + // The original Raspberry Pi boards had a different assignment + // of pin 13. All other boards assign it to BCM 27, but the + // original had it as BCM 21. + if ((gpioHardwareRevision() == 2) || (gpioHardwareRevision() == 3)) + F_RESET = 21; + spi = spiAlloc(); fpga = fpgaAlloc(); @@ -188,11 +199,6 @@ int main(int argc, char **argv) { fpgaSetPin(fpga, FP_DONE, F_DONE); fpgaSetPin(fpga, FP_CS, S_CE0); - if (gpioInitialise() < 0) { - fprintf(stderr, "Unable to initialize GPIO\n"); - return 1; - } - while ((opt = getopt(argc, argv, "hip:rf:b:w:s:2:3:v:g:t:k:")) != -1) { switch (opt) {