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 <sean@xobs.io>
This commit is contained in:
Sean Cross 2019-02-11 10:27:37 +08:00
parent 987ae9071a
commit 13464db5de

View File

@ -21,7 +21,7 @@
#define S_D1 S_MISO #define S_D1 S_MISO
#define S_D2 S_WP #define S_D2 S_WP
#define S_D3 S_HOLD #define S_D3 S_HOLD
#define F_RESET 27 static unsigned int F_RESET = 27;
#define F_DONE 17 #define F_DONE 17
static inline int isprint(int c) static inline int isprint(int c)
@ -170,6 +170,17 @@ int main(int argc, char **argv) {
enum op op = OP_UNKNOWN; enum op op = OP_UNKNOWN;
enum spi_type spi_type = ST_SINGLE; 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(); spi = spiAlloc();
fpga = fpgaAlloc(); fpga = fpgaAlloc();
@ -188,11 +199,6 @@ int main(int argc, char **argv) {
fpgaSetPin(fpga, FP_DONE, F_DONE); fpgaSetPin(fpga, FP_DONE, F_DONE);
fpgaSetPin(fpga, FP_CS, S_CE0); 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) { while ((opt = getopt(argc, argv, "hip:rf:b:w:s:2:3:v:g:t:k:")) != -1) {
switch (opt) { switch (opt) {