Commit 504cd753 authored by Federico Vaga's avatar Federico Vaga

tool: minor style fixes

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 060a0973
......@@ -292,7 +292,8 @@ int flash_program(uint32_t addr, const uint8_t * data, int size, uint32_t flash_
fprintf(stderr,
"Verification failed at offset 0x%06x (is: 0x%02x, should be: 0x%02x)\n.",
addr + n, d, *p);
ret = -EINVAL;
errno = EINVAL;
ret = -1;
goto flash_program_exit;
}
}
......@@ -310,8 +311,7 @@ static int program_flash(struct bitstream *bitstream,
printf("Programming the Application FPGA flash with bitstream %s.\n",
bitstream->path);
if (!spi_test_presence())
{
if (!spi_test_presence()) {
fprintf(stderr,
"SPI Master core not responding. You are probably be running an\nold version of the bootloader that doesn't support flash programming via VME.\n");
return -1;
......@@ -322,20 +322,19 @@ static int program_flash(struct bitstream *bitstream,
fprintf(stderr, "Flash memory ID invalid (0x%.8x). ", flash_id);
fprintf(stderr, "You are probably running an old version of the bootloader\n");
fprintf(stderr, "that doesn't support flash programming via VME.\n");
return -ENODEV;
errno = ENODEV;
return -1;
}
printf("Flash ID: 0x%.7x, OK\n", flash_id);
if(fpga_bootloader_flash)
{
if (fpga_bootloader_flash) {
char confirm[1024];
printf("\nWARNING! You're about to update the SVEC bootloader. \nIf this operation fails (due to incorrect bitstream or power loss), the card "
"can be only recovered through JTAG.\n\n");
printf("Type 'yes' to continue or Ctrl-C to exit the program: ");
fgets(confirm, 1024, stdin);
if(strncmp(confirm,"yes", 3))
{
if (strncmp(confirm,"yes", 3)) {
printf("Bootloader update aborted.\n");
return -1;
}
......@@ -365,8 +364,8 @@ static int program_afpga(struct bitstream *bitstream)
csr_writel(SXLDR_CSR_SWRST, SXLDR_REG_CSR);
csr_writel(SXLDR_CSR_START | SXLDR_CSR_MSBF, SXLDR_REG_CSR);
while(i < bitstream->size) {
if(! (csr_readl(SXLDR_REG_FIFO_CSR) & SXLDR_FIFO_CSR_FULL))
while (i < bitstream->size) {
if (! (csr_readl(SXLDR_REG_FIFO_CSR) & SXLDR_FIFO_CSR_FULL))
{
uint32_t word = *(uint32_t *) ( bitstream->buf + i );
......@@ -377,18 +376,17 @@ static int program_afpga(struct bitstream *bitstream)
}
}
while(1)
{
uint32_t rval = csr_readl(SXLDR_REG_CSR);
while (1) {
uint32_t rval = csr_readl(SXLDR_REG_CSR);
if(rval & SXLDR_CSR_DONE) {
printf("Bitstream loaded, status: %s\n", (rval & SXLDR_CSR_ERROR ? "ERROR" : "OK"));
if (rval & SXLDR_CSR_DONE) {
printf("Bitstream loaded, status: %s\n", (rval & SXLDR_CSR_ERROR ? "ERROR" : "OK"));
/* give the VME bus control to App FPGA */
csr_writel(SXLDR_CSR_EXIT, SXLDR_REG_CSR);
if ( rval & SXLDR_CSR_ERROR )
return -1;
return 0;
}
if ( rval & SXLDR_CSR_ERROR )
return -1;
return 0;
}
}
return 0;
......@@ -495,7 +493,7 @@ int main(int argc, char *argv[])
init_vme(slot);
enter_bootloader();
if(!fpga_configure)
if (!fpga_configure)
err = program_flash(&bitstream, fpga_bootloader_flash);
else
err = program_afpga(&bitstream);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment