fomu-flash: make DEBUG_ICE40_PATCH work better
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
4156a37d72
commit
f4297532d0
23
fomu-flash.c
23
fomu-flash.c
@ -187,6 +187,7 @@ int main(int argc, char **argv) {
|
|||||||
enum spi_type spi_type = ST_SINGLE;
|
enum spi_type spi_type = ST_SINGLE;
|
||||||
struct irw_file *replacement_rom = NULL;
|
struct irw_file *replacement_rom = NULL;
|
||||||
|
|
||||||
|
#ifndef DEBUG_ICE40_PATCH
|
||||||
if (gpioInitialise() < 0) {
|
if (gpioInitialise() < 0) {
|
||||||
fprintf(stderr, "Unable to initialize GPIO\n");
|
fprintf(stderr, "Unable to initialize GPIO\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -197,8 +198,9 @@ int main(int argc, char **argv) {
|
|||||||
// original had it as BCM 21.
|
// original had it as BCM 21.
|
||||||
if ((gpioHardwareRevision() == 2) || (gpioHardwareRevision() == 3))
|
if ((gpioHardwareRevision() == 2) || (gpioHardwareRevision() == 3))
|
||||||
F_RESET = 21;
|
F_RESET = 21;
|
||||||
|
#endif
|
||||||
|
|
||||||
spi = spiAlloc();
|
spi = spiAlloc();
|
||||||
fpga = fpgaAlloc();
|
fpga = fpgaAlloc();
|
||||||
|
|
||||||
spiSetPin(spi, SP_CLK, S_CLK);
|
spiSetPin(spi, SP_CLK, S_CLK);
|
||||||
@ -363,6 +365,7 @@ int main(int argc, char **argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DEBUG_ICE40_PATCH
|
||||||
spiInit(spi);
|
spiInit(spi);
|
||||||
fpgaInit(fpga);
|
fpgaInit(fpga);
|
||||||
|
|
||||||
@ -371,6 +374,16 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (spi_flash_bytes != -1)
|
if (spi_flash_bytes != -1)
|
||||||
spiOverrideSize(spi, spi_flash_bytes);
|
spiOverrideSize(spi, spi_flash_bytes);
|
||||||
|
#else
|
||||||
|
if (op != OP_FPGA_BOOT) {
|
||||||
|
printf("DEBUG_ICE40_PATCH requires you load a bitstream with '-f'\n");
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
if (!replacement_rom) {
|
||||||
|
printf("DEBUG_ICE40_PATCH requires you load a replacement rom with '-l'\n");
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case OP_SPI_ID: {
|
case OP_SPI_ID: {
|
||||||
@ -504,14 +517,13 @@ offset, file_src[offset], spi_src[offset]);
|
|||||||
|
|
||||||
case OP_FPGA_BOOT: {
|
case OP_FPGA_BOOT: {
|
||||||
int count;
|
int count;
|
||||||
|
#ifndef DEBUG_ICE40_PATCH
|
||||||
spiHold(spi);
|
spiHold(spi);
|
||||||
spiSwapTxRx(spi);
|
spiSwapTxRx(spi);
|
||||||
fpgaResetSlave(fpga);
|
fpgaResetSlave(fpga);
|
||||||
|
|
||||||
fprintf(stderr, "FPGA Done? %d\n", fpgaDone(fpga));
|
fprintf(stderr, "FPGA Done? %d\n", fpgaDone(fpga));
|
||||||
|
|
||||||
spiBegin(spi);
|
spiBegin(spi);
|
||||||
|
#endif
|
||||||
if (replacement_rom) {
|
if (replacement_rom) {
|
||||||
IRW_FILE *bitstream = irw_open(op_filename, "r");
|
IRW_FILE *bitstream = irw_open(op_filename, "r");
|
||||||
if (!bitstream) {
|
if (!bitstream) {
|
||||||
@ -519,7 +531,8 @@ offset, file_src[offset], spi_src[offset]);
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_ICE40_PATCH
|
#ifdef DEBUG_ICE40_PATCH
|
||||||
IRW_FILE *spidev = irw_open("foboot-patched-broken.bin", "w");
|
IRW_FILE *spidev = irw_open("foboot-patched.bin", "w");
|
||||||
|
return ice40_patch(bitstream, replacement_rom, spidev, 8192);
|
||||||
#else
|
#else
|
||||||
IRW_FILE *spidev = irw_open_fake(spi, spi_irw_readb, spi_irw_writeb);
|
IRW_FILE *spidev = irw_open_fake(spi, spi_irw_readb, spi_irw_writeb);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user