Introduce, use new commandline flag --fix-boot-block

Don't automatically try to rewrite the boot block.  Instead, require the
--fix-boot-block flag to be given in order to do so.

Closes #13
This commit is contained in:
Jeff Epler 2016-07-02 08:13:10 -05:00
parent bd82bc54ba
commit ac70cc2c29
10 changed files with 28 additions and 19 deletions

View file

@ -205,7 +205,7 @@ board_t *anyio_get_dev(board_access_t *access, int board_number) {
return NULL;
}
int anyio_dev_write_flash(board_t *board, char *bitfile_name, int fallback_flag) {
int anyio_dev_write_flash(board_t *board, char *bitfile_name, int fallback_flag, int fix_boot_flag) {
int ret;
if (board == NULL) {
@ -217,7 +217,7 @@ int anyio_dev_write_flash(board_t *board, char *bitfile_name, int fallback_flag)
if (fallback_flag == 1) {
addr = FALLBACK_ADDRESS;
}
ret = board->llio.write_flash(&(board->llio), bitfile_name, addr);
ret = board->llio.write_flash(&(board->llio), bitfile_name, addr, fix_boot_flag);
} else {
printf("ERROR: Board %s doesn't support flash writing.\n", board->llio.board_name);
return -EINVAL;

View file

@ -29,7 +29,7 @@ int anyio_init(board_access_t *access);
void anyio_cleanup(board_access_t *access);
int anyio_find_dev(board_access_t *access);
board_t *anyio_get_dev(board_access_t *access, int board_number);
int anyio_dev_write_flash(board_t *board, char *bitfile_name, int fallback_flag);
int anyio_dev_write_flash(board_t *board, char *bitfile_name, int fallback_flag, int fix_boot_flag);
int anyio_dev_verify_flash(board_t *board, char *bitfile_name, int fallback_flag);
int anyio_dev_program_fpga(board_t *board, char *bitfile_name);
int anyio_dev_set_remote_ip(board_t *board, char *lbp16_set_ip_addr);

View file

@ -149,7 +149,7 @@ int start_programming(llio_t *self, u32 start_address, int fsize) {
return 0;
}
int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address) {
int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address, int fix_boot_flag) {
board_t *board = self->board;
int bytesread, i;
u32 eeprom_addr;
@ -184,15 +184,21 @@ int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address) {
// if board doesn't support fallback there is no boot block
if (board->fallback_support == 1) {
if (check_boot(self) == -1) {
write_boot(self);
if (fix_boot_flag) {
write_boot(self);
if (check_boot(self) == -1) {
printf("Failed to write valid boot sector\n");
fclose(fp);
return -1;
}
} else {
printf("Error: BootSector is invalid\n");
fclose(fp);
return -1;
}
} else {
printf("Boot sector OK\n");
}
if (check_boot(self) == -1) {
printf("Failed to write valid boot sector\n");
fclose(fp);
return -1;
}
}
if (eeprom_access.start_programming(self, start_address, file_stat.st_size) == -1) {

View file

@ -55,7 +55,7 @@ char *eeprom_get_flash_type(u8 flash_id);
u32 eeprom_calc_user_space(u8 flash_id);
void eeprom_prepare_boot_block(u8 flash_id);
int start_programming(llio_t *self, u32 start_address, int fsize);
int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address);
int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address, int fix_boot_flag);
int eeprom_verify(llio_t *self, char *bitfile_name, u32 start_address);
void eeprom_init(llio_t *self);
void eeprom_cleanup(llio_t *self);

View file

@ -419,10 +419,10 @@ static void done_programming(llio_t *self) {
// global functions
int local_write_flash(llio_t *self, char *bitfile_name, u32 start_address) {
int local_write_flash(llio_t *self, char *bitfile_name, u32 start_address, int fix_boot_flag) {
int ret;
ret = eeprom_write(self, bitfile_name, start_address);
ret = eeprom_write(self, bitfile_name, start_address, fix_boot_flag);
done_programming(self);
return ret;
}

View file

@ -44,7 +44,7 @@
#define EPP_SPI_SREG_REG 0x7E
u8 read_flash_id(llio_t *self);
int local_write_flash(llio_t *self, char *bitfile_name, u32 start_address);
int local_write_flash(llio_t *self, char *bitfile_name, u32 start_address, int fix_boot_flag);
int local_verify_flash(llio_t *self, char *bitfile_name, u32 start_address);
void open_spi_access_local(llio_t *self);
void close_spi_access_local(llio_t *self);

View file

@ -91,8 +91,8 @@ static int remote_start_programming(llio_t *self, u32 start_address, int fsize)
// global functions
int remote_write_flash(llio_t *self, char *bitfile_name, u32 start_address) {
return eeprom_write(self, bitfile_name, start_address);
int remote_write_flash(llio_t *self, char *bitfile_name, u32 start_address, int fix_boot_flag) {
return eeprom_write(self, bitfile_name, start_address, fix_boot_flag);
}
int remote_verify_flash(llio_t *self, char *bitfile_name, u32 start_address) {

View file

@ -21,7 +21,7 @@
#include "hostmot2.h"
int remote_write_flash(llio_t *self, char *bitfile_name, u32 start_address);
int remote_write_flash(llio_t *self, char *bitfile_name, u32 start_address, int fix_boot_flag);
int remote_verify_flash(llio_t *self, char *bitfile_name, u32 start_address);
void open_spi_access_remote(llio_t *self);
void close_spi_access_remote(llio_t *self);

View file

@ -52,7 +52,7 @@ typedef struct {
struct llio_struct {
int (*read)(llio_t *self, u32 addr, void *buffer, int size);
int (*write)(llio_t *self, u32 addr, void *buffer, int size);
int (*write_flash)(llio_t *self, char *bitfile_name, u32 start_address);
int (*write_flash)(llio_t *self, char *bitfile_name, u32 start_address, int fix_boot_flag);
int (*verify_flash)(llio_t *self, char *bitfile_name, u32 start_address);
int (*program_fpga)(llio_t *self, char *bitfile_name);
int (*reset)(llio_t *self);

View file

@ -33,6 +33,7 @@ static int device_flag;
static int addr_flag;
static int addr_hi_flag;
static int write_flag;
static int fix_boot_flag;
static int verify_flag;
static int fallback_flag;
static int recover_flag;
@ -63,6 +64,7 @@ static struct option long_options[] = {
{"addr", required_argument, 0, 'a'},
{"addr_hi", required_argument, 0, 'b'},
{"write", required_argument, 0, 'w'},
{"fix-boot-block", no_argument, &fix_boot_flag, 1},
{"verify", required_argument, 0, 'v'},
{"fallback", no_argument, &fallback_flag, 1},
{"recover", no_argument, &recover_flag, 1},
@ -122,6 +124,7 @@ void print_usage() {
printf(" --verbose print detailed information while running commands\n");
printf("\nCommands:\n");
printf(" --write writes a standard bitfile 'filename' configuration to the userarea of the EEPROM (IMPORTANT! 'filename' must be VALID FPGA configuration file)\n");
printf(" --fix-boot-block If a write operation does not detect a valid boot block, write one\n");
printf(" --verify verifies the EEPROM configuration against the bitfile 'filename'\n");
printf(" --program writes a standard bitfile 'filename' configuration to the FPGA (IMPORTANT! 'filename' must be VALID FPGA configuration file)\n");
printf(" --readhmid print hostmot2 configuration in PIN file format\n");
@ -373,7 +376,7 @@ int main(int argc, char *argv[]) {
} else if (set_flag == 1) {
ret = anyio_dev_set_remote_ip(board, lbp16_set_ip_addr);
} else if (write_flag == 1) {
ret = anyio_dev_write_flash(board, bitfile_name, fallback_flag);
ret = anyio_dev_write_flash(board, bitfile_name, fallback_flag, fix_boot_flag);
if (ret == 0)
{
if (reload_flag == 1) {