Compare commits
2 commits
remove-win
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
676a63d241 | ||
|
|
934769e0cc |
21 changed files with 175 additions and 76 deletions
2
Makefile
2
Makefile
|
|
@ -30,7 +30,7 @@ OPT = -O0
|
|||
|
||||
#DEBUG = -g -pedantic -Wall -Wextra
|
||||
#DEBUG = -g -Wall -Wextra
|
||||
DEBUG = -g
|
||||
DEBUG = -g -Werror=missing-prototypes -Werror=strict-prototypes -Werror=implicit-function-declaration
|
||||
|
||||
ifeq ($(TARGET),linux)
|
||||
INCLUDE = -I/usr/include
|
||||
|
|
|
|||
3
anyio.c
3
anyio.c
|
|
@ -334,6 +334,7 @@ void anyio_dev_print_sserial_info(board_t *board) {
|
|||
void anyio_bitfile_print_info(char *bitfile_name, int verbose_flag) {
|
||||
FILE *fp;
|
||||
char part_name[32];
|
||||
char board_name[5];
|
||||
|
||||
if (bitfile_name == NULL) {
|
||||
return;
|
||||
|
|
@ -343,6 +344,6 @@ void anyio_bitfile_print_info(char *bitfile_name, int verbose_flag) {
|
|||
printf("Can't open file %s: %s\n", bitfile_name, strerror(errno));
|
||||
return;
|
||||
}
|
||||
print_bitfile_header(fp, (char*) &part_name, verbose_flag);
|
||||
print_bitfile_header(fp, (char*) &part_name, (char*) &board_name, verbose_flag);
|
||||
fclose(fp);
|
||||
}
|
||||
|
|
|
|||
56
bitfile.c
56
bitfile.c
|
|
@ -22,12 +22,15 @@
|
|||
#include "bitfile.h"
|
||||
|
||||
// prints info about bitfile and returns header length or -1 when error
|
||||
int print_bitfile_header(FILE *fp, char *part_name, int verbose_flag) {
|
||||
int print_bitfile_header(FILE *fp, char *part_name, char *board_id, int verbose_flag) {
|
||||
u8 buff[256];
|
||||
int sleng;
|
||||
int bytesread, conflength;
|
||||
int ret = 0;
|
||||
|
||||
if(board_id)
|
||||
strcpy(board_id, "");
|
||||
|
||||
printf("Checking file... ");
|
||||
bytesread = fread(&buff, 1, 14, fp);
|
||||
ret += bytesread;
|
||||
|
|
@ -49,6 +52,20 @@ int print_bitfile_header(FILE *fp, char *part_name, int verbose_flag) {
|
|||
if (verbose_flag == 1) {
|
||||
printf(" Design name: %s\n", buff);
|
||||
}
|
||||
char *id = strstr(buff, "UserID=");
|
||||
if(id && board_id) {
|
||||
int id_hex = -1;
|
||||
sscanf(id+7, "%x", &id_hex);
|
||||
if(id_hex != 0xffffffff)
|
||||
{
|
||||
board_id[0] = (id_hex >> 24) & 0xff;
|
||||
board_id[1] = (id_hex >> 16) & 0xff;
|
||||
board_id[2] = (id_hex >> 8) & 0xff;
|
||||
board_id[3] = id_hex & 0xff;
|
||||
board_id[4] = 0;
|
||||
}
|
||||
fprintf(stderr, "note: board_id = %s\n", board_id);
|
||||
}
|
||||
|
||||
bytesread = fread(&buff, 1, 3, fp);
|
||||
ret += bytesread;
|
||||
|
|
@ -125,3 +142,40 @@ u8 bitfile_reverse_bits(u8 data) {
|
|||
};
|
||||
return swaptab[data];
|
||||
}
|
||||
|
||||
static const char *bitfile_basename(const char *filename) {
|
||||
const char *s = strrchr(filename, '/');
|
||||
if(!s) s = filename;
|
||||
else s = s + 1;
|
||||
#ifdef _WIN32
|
||||
s = strrchr(filename, '\\');
|
||||
if(!s) s = filename;
|
||||
else s = s + 1;
|
||||
#endif
|
||||
return s;
|
||||
}
|
||||
|
||||
int check_board_name(char *llio_board_name, const char *bitfile_board_name, const char *filename)
|
||||
{
|
||||
fprintf(stderr, "check_board_name %s %s %s\n",
|
||||
llio_board_name, filename, bitfile_board_name);
|
||||
|
||||
if(!llio_board_name) {
|
||||
fprintf(stderr, "LLIO: no boardname, cannot check that bitfile matches\n");
|
||||
return 1;
|
||||
}
|
||||
if(bitfile_board_name && *bitfile_board_name) {
|
||||
fprintf(stderr, "NOTE: comparing llio board name '%s' with bitfile board name '%s'\n", llio_board_name, bitfile_board_name);
|
||||
int result = !strncasecmp(llio_board_name, bitfile_board_name, 4);
|
||||
if(!result)
|
||||
fprintf(stderr, "Error: wrong bitfile destination card: Detected %s, bitfile ID is %s\n", llio_board_name, bitfile_board_name);
|
||||
return result;
|
||||
}
|
||||
if(filename) {
|
||||
filename = bitfile_basename(filename);
|
||||
int result = !strncasecmp(llio_board_name, filename, 4);
|
||||
if(!result)
|
||||
fprintf(stderr, "Error: wrong bitfile destination card: Detected %s, filename is %.4s\n", llio_board_name, filename);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
#include <stdio.h>
|
||||
#include "types.h"
|
||||
|
||||
int print_bitfile_header(FILE *fp, char *part_name, int verbose_flag);
|
||||
int print_bitfile_header(FILE *fp, char *part_name, char *board_id, int verbose_flag);
|
||||
int check_board_name(char *llio_board_name, const char *filename, const char *bitfile_board_name);
|
||||
u8 bitfile_reverse_bits(u8 data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
15
eeprom.c
15
eeprom.c
|
|
@ -22,6 +22,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include "types.h"
|
||||
#include "bitfile.h"
|
||||
#include "eeprom.h"
|
||||
#include "eeprom_local.h"
|
||||
#include "eeprom_remote.h"
|
||||
|
|
@ -154,6 +155,7 @@ int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address, int fix_bo
|
|||
int bytesread, i;
|
||||
u32 eeprom_addr;
|
||||
char part_name[32];
|
||||
char board_name[32];
|
||||
struct stat file_stat;
|
||||
FILE *fp;
|
||||
struct timeval tv1, tv2;
|
||||
|
|
@ -168,7 +170,7 @@ int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address, int fix_bo
|
|||
printf("Can't open file %s: %s\n", bitfile_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (print_bitfile_header(fp, (char*) &part_name, board->llio.verbose) == -1) {
|
||||
if (print_bitfile_header(fp, (char*) &part_name, (char*) &board_name, board->llio.verbose) == -1) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -180,6 +182,10 @@ int eeprom_write(llio_t *self, char *bitfile_name, u32 start_address, int fix_bo
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
if (!check_board_name(self->board_name, board_name, bitfile_name)) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// if board doesn't support fallback there is no boot block
|
||||
if (board->fallback_support == 1) {
|
||||
|
|
@ -238,6 +244,7 @@ int eeprom_verify(llio_t *self, char *bitfile_name, u32 start_address) {
|
|||
int bytesread, i, bindex;
|
||||
u32 eeprom_addr;
|
||||
char part_name[32];
|
||||
char board_name[32];
|
||||
struct stat file_stat;
|
||||
FILE *fp;
|
||||
struct timeval tv1, tv2;
|
||||
|
|
@ -252,7 +259,7 @@ int eeprom_verify(llio_t *self, char *bitfile_name, u32 start_address) {
|
|||
printf("Can't open file %s: %s\n", bitfile_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (print_bitfile_header(fp, (char*) &part_name, board->llio.verbose) == -1) {
|
||||
if (print_bitfile_header(fp, (char*) &part_name, (char*) &board_name, board->llio.verbose) == -1) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -263,6 +270,10 @@ int eeprom_verify(llio_t *self, char *bitfile_name, u32 start_address) {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
if (!check_board_name(self->board_name, board_name, bitfile_name)) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
// if board doesn't support fallback there is no boot block
|
||||
if (board->fallback_support == 1) {
|
||||
if (check_boot(self) == -1) {
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ static u8 recv_byte_io(llio_t *self) {
|
|||
|
||||
// spi access via epp on board 7i43 with EPPIO firmware
|
||||
|
||||
void wait_for_data_epp(llio_t *self) {
|
||||
static void wait_for_data_epp(llio_t *self) {
|
||||
board_t *board = self->board;
|
||||
u32 i = 0;
|
||||
u8 data = 0;
|
||||
|
|
|
|||
15
epp_boards.c
15
epp_boards.c
|
|
@ -136,7 +136,7 @@ static inline void epp_write32(board_t *board, u32 data) {
|
|||
}
|
||||
}
|
||||
|
||||
int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
int bytes_remaining = size;
|
||||
board_t *board = self->board;
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ int epp_read(llio_t *self, u32 addr, void *buffer, int size) {
|
|||
return 1; // success
|
||||
}
|
||||
|
||||
int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
int bytes_remaining = size;
|
||||
board_t *board = self->board;
|
||||
|
||||
|
|
@ -188,10 +188,11 @@ int epp_write(llio_t *self, u32 addr, void *buffer, int size) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int epp_program_fpga(llio_t *self, char *bitfile_name) {
|
||||
static int epp_program_fpga(llio_t *self, char *bitfile_name) {
|
||||
board_t *board = self->board;
|
||||
int bindex, bytesread;
|
||||
char part_name[32];
|
||||
char board_name[32];
|
||||
struct stat file_stat;
|
||||
FILE *fp;
|
||||
|
||||
|
|
@ -204,7 +205,11 @@ int epp_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
printf("Can't open file %s: %s\n", bitfile_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (print_bitfile_header(fp, (char*) &part_name, board->llio.verbose) == -1) {
|
||||
if (print_bitfile_header(fp, (char*) &part_name, (char*) &board_name, board->llio.verbose) == -1) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
if (!check_board_name(self->board_name, board_name, bitfile_name)) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -244,7 +249,7 @@ int epp_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
}
|
||||
|
||||
// return 0 if the board has been reset, -errno if not
|
||||
int epp_reset(llio_t *self) {
|
||||
static int epp_reset(llio_t *self) {
|
||||
board_t *board = self->board;
|
||||
u8 byte;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ inline int eth_recv_packet(void *buffer, int size) {
|
|||
return recvfrom(sd, (char*) buffer, size, 0, (struct sockaddr *) &src_addr, &len);
|
||||
}
|
||||
|
||||
static void eth_socket_nonblocking() {
|
||||
static void eth_socket_nonblocking(void) {
|
||||
#ifdef __linux__
|
||||
int val = fcntl(sd, F_GETFL);
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ static void eth_socket_nonblocking() {
|
|||
#endif
|
||||
}
|
||||
|
||||
static void eth_socket_blocking() {
|
||||
static void eth_socket_blocking(void) {
|
||||
#ifdef __linux__
|
||||
int val = fcntl(sd, F_GETFL);
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ void eth_socket_set_dest_ip(char *addr_name) {
|
|||
dst_addr.sin_addr.s_addr = inet_addr(addr_name);
|
||||
}
|
||||
|
||||
static char *eth_socket_get_src_ip() {
|
||||
static char *eth_socket_get_src_ip(void) {
|
||||
return inet_ntoa(src_addr.sin_addr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "../anyio.h"
|
||||
#include "../sserial_module.h"
|
||||
#ifdef __linux__
|
||||
|
|
@ -38,7 +39,7 @@ static int instance = 0;
|
|||
static int delay_flag;
|
||||
static int delay = 50;
|
||||
static int verbose_flag;
|
||||
static board_access_t access;
|
||||
static board_access_t board_access;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"device", required_argument, 0, 'd'},
|
||||
|
|
@ -48,7 +49,7 @@ static struct option long_options[] = {
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void print_short_usage() {
|
||||
static void print_short_usage(void) {
|
||||
printf("Example program for writing analog output on pci boards\n");
|
||||
printf("Syntax:\n");
|
||||
printf(" pci_analog_write --device str [--instance i] [--delay d] [--verbose]\n");
|
||||
|
|
@ -58,7 +59,7 @@ void print_short_usage() {
|
|||
printf(" --verbose printf additional info during execution\n");
|
||||
}
|
||||
|
||||
int process_cmd_line(int argc, char *argv[]) {
|
||||
static int process_cmd_line(int argc, char *argv[]) {
|
||||
int c;
|
||||
|
||||
while (1) {
|
||||
|
|
@ -87,9 +88,9 @@ int process_cmd_line(int argc, char *argv[]) {
|
|||
printf("Error: multiply --device option\n");
|
||||
exit(-1);
|
||||
}
|
||||
access.device_name = optarg;
|
||||
board_access.device_name = optarg;
|
||||
for (i = 0; optarg[i] != '\0'; i++)
|
||||
access.device_name[i] = toupper(access.device_name[i]);
|
||||
board_access.device_name[i] = toupper(board_access.device_name[i]);
|
||||
|
||||
device_flag++;
|
||||
}
|
||||
|
|
@ -143,18 +144,18 @@ int main(int argc, char *argv[]) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
access.verbose = verbose_flag;
|
||||
board_access.verbose = verbose_flag;
|
||||
|
||||
if (anyio_init(&access) != 0) { // init library
|
||||
if (anyio_init(&board_access) != 0) { // init library
|
||||
return -1;
|
||||
}
|
||||
ret = anyio_find_dev(&access); // find board
|
||||
ret = anyio_find_dev(&board_access); // find board
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
board = anyio_get_dev(&access, 1); // if found the get board handle
|
||||
board = anyio_get_dev(&board_access, 1); // if found the get board handle
|
||||
if (board == NULL) {
|
||||
printf("No %s board found\n", access.device_name);
|
||||
printf("No %s board found\n", board_access.device_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +185,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
board->close(board); // close board communication
|
||||
|
||||
anyio_cleanup(&access); // close library
|
||||
anyio_cleanup(&board_access); // close library
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "../anyio.h"
|
||||
#include "../encoder_module.h"
|
||||
#ifdef __linux__
|
||||
|
|
@ -38,7 +39,7 @@ static int instance = 0;
|
|||
static int delay_flag;
|
||||
static int delay = 50;
|
||||
static int verbose_flag;
|
||||
static board_access_t access;
|
||||
static board_access_t board_access;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"device", required_argument, 0, 'd'},
|
||||
|
|
@ -48,7 +49,7 @@ static struct option long_options[] = {
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void print_short_usage() {
|
||||
static void print_short_usage(void) {
|
||||
printf("Example program forreading encoder on pci boards\n");
|
||||
printf("Syntax:\n");
|
||||
printf(" pci_encoder_read --device str [--instance i] [--delay d] [--verbose]\n");
|
||||
|
|
@ -58,7 +59,7 @@ void print_short_usage() {
|
|||
printf(" --verbose printf additional info during execution\n");
|
||||
}
|
||||
|
||||
int process_cmd_line(int argc, char *argv[]) {
|
||||
static int process_cmd_line(int argc, char *argv[]) {
|
||||
int c;
|
||||
|
||||
while (1) {
|
||||
|
|
@ -87,9 +88,9 @@ int process_cmd_line(int argc, char *argv[]) {
|
|||
printf("Error: multiply --device option\n");
|
||||
exit(-1);
|
||||
}
|
||||
access.device_name = optarg;
|
||||
board_access.device_name = optarg;
|
||||
for (i = 0; optarg[i] != '\0'; i++)
|
||||
access.device_name[i] = toupper(access.device_name[i]);
|
||||
board_access.device_name[i] = toupper(board_access.device_name[i]);
|
||||
|
||||
device_flag++;
|
||||
}
|
||||
|
|
@ -141,18 +142,18 @@ int main(int argc, char *argv[]) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
access.verbose = verbose_flag;
|
||||
board_access.verbose = verbose_flag;
|
||||
|
||||
if (anyio_init(&access) != 0) { // init library
|
||||
if (anyio_init(&board_access) != 0) { // init library
|
||||
return -1;
|
||||
}
|
||||
ret = anyio_find_dev(&access); // find board
|
||||
ret = anyio_find_dev(&board_access); // find board
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
board = anyio_get_dev(&access, 1); // if found the get board handle
|
||||
board = anyio_get_dev(&board_access, 1); // if found the get board handle
|
||||
if (board == NULL) {
|
||||
printf("No %s board found\n", access.device_name);
|
||||
printf("No %s board found\n", board_access.device_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +177,7 @@ int main(int argc, char *argv[]) {
|
|||
fail0:
|
||||
board->close(board); // close board communication
|
||||
|
||||
anyio_cleanup(&access); // close library
|
||||
anyio_cleanup(&board_access); // close library
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void hm2_read_idrom(hostmot2_t *hm2) {
|
|||
}
|
||||
}
|
||||
|
||||
const char *hm2_hz_to_mhz(u32 freq_hz) {
|
||||
static const char *hm2_hz_to_mhz(u32 freq_hz) {
|
||||
static char mhz_str[20];
|
||||
int r;
|
||||
int freq_mhz, freq_mhz_fractional;
|
||||
|
|
@ -62,7 +62,7 @@ const char *hm2_hz_to_mhz(u32 freq_hz) {
|
|||
return mhz_str;
|
||||
}
|
||||
|
||||
const char *hm2_get_general_function_name(int gtag) {
|
||||
static const char *hm2_get_general_function_name(int gtag) {
|
||||
switch (gtag) {
|
||||
case HM2_GTAG_IRQ_LOGIC: return "IRQ logic";
|
||||
case HM2_GTAG_WATCHDOG: return "Watchdog";
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ void hm2_print_pin_file(llio_t *llio, int xml_flag);
|
|||
void hm2_set_pin_source(hostmot2_t *hm2, int pin_number, u8 source);
|
||||
void hm2_set_pin_direction(hostmot2_t *hm2, int pin_number, u8 direction);
|
||||
void sserial_module_init(llio_t *llio);
|
||||
void hm2_set_pin_source(hostmot2_t *hm2, int pin_number, u8 source);
|
||||
void hm2_set_pin_direction(hostmot2_t *hm2, int pin_number, u8 direction);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
4
lbp.c
4
lbp.c
|
|
@ -99,7 +99,7 @@ int lbp_write(u16 addr, void *buffer) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void lbp_print_info() {
|
||||
void lbp_print_info(void) {
|
||||
u8 data;
|
||||
|
||||
data = lbp_read_ctrl(LBP_CMD_READ_VERSION);
|
||||
|
|
@ -122,7 +122,7 @@ void lbp_init(board_access_t *access) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void lbp_release() {
|
||||
void lbp_release(void) {
|
||||
#ifdef __linux__
|
||||
close(sd);
|
||||
#endif
|
||||
|
|
|
|||
4
lbp.h
4
lbp.h
|
|
@ -85,9 +85,9 @@ int lbp_recv(void *packet, int size);
|
|||
u8 lbp_read_ctrl(u8 cmd);
|
||||
int lbp_read(u16 addr, void *buffer);
|
||||
int lbp_write(u16 addr, void *buffer);
|
||||
void lbp_print_info();
|
||||
void lbp_print_info(void);
|
||||
void lbp_init(board_access_t *access);
|
||||
void lbp_release();
|
||||
void lbp_release(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
2
lbp16.c
2
lbp16.c
|
|
@ -142,5 +142,5 @@ void lbp16_init(int board_type) {
|
|||
}
|
||||
}
|
||||
|
||||
void lbp_cleanup(int board_type) {
|
||||
void lbp16_cleanup(int board_type) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ static struct option long_options[] = {
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
void print_short_usage() {
|
||||
static void print_short_usage(void) {
|
||||
printf("\nMesaflash version 3.3.0~pre (built on %s %s with libpci %s)\n", __DATE__, __TIME__, PCILIB_VERSION);
|
||||
printf("Configuration and diagnostic tool for Mesa Electronics PCI(E)/ETH/EPP/USB boards\n");
|
||||
printf("(C) 2013-2015 Michael Geszkiewicz (contact: micges@wp.pl)\n");
|
||||
|
|
@ -97,7 +97,7 @@ void print_short_usage() {
|
|||
printf("Try 'mesaflash --help' for more information\n");
|
||||
}
|
||||
|
||||
void print_usage() {
|
||||
static void print_usage(void) {
|
||||
printf("Syntax:\n");
|
||||
printf(" mesaflash --device device_name [options]\n");
|
||||
printf(" mesaflash --device device_name [options] --write filename\n");
|
||||
|
|
@ -141,7 +141,7 @@ void print_usage() {
|
|||
printf(" --help print this help message\n");
|
||||
}
|
||||
|
||||
int process_cmd_line(int argc, char *argv[]) {
|
||||
static int process_cmd_line(int argc, char *argv[]) {
|
||||
int c;
|
||||
|
||||
while (1) {
|
||||
|
|
|
|||
27
pci_boards.c
27
pci_boards.c
|
|
@ -20,6 +20,7 @@
|
|||
#include <sys/mman.h>
|
||||
#include <sys/io.h>
|
||||
#include <pci/pci.h>
|
||||
#include <sys/time.h>
|
||||
#elif _WIN32
|
||||
#include <windows.h>
|
||||
#include "libpci/pci.h"
|
||||
|
|
@ -46,6 +47,9 @@ static int memfd = -1;
|
|||
struct pci_access *pacc;
|
||||
static u8 file_buffer[SECTOR_SIZE];
|
||||
|
||||
static int pci_read(llio_t *self, u32 addr, void *buffer, int size);
|
||||
static int pci_write(llio_t *self, u32 addr, void *buffer, int size);
|
||||
|
||||
u16 setup_eeprom_5i20[256] = {
|
||||
0x9030, // DEVICE ID
|
||||
0x10B5, // VENDOR ID
|
||||
|
|
@ -383,7 +387,7 @@ static u16 plx9030_read_eeprom_word(board_t *board, u8 reg) {
|
|||
return tdata;
|
||||
}
|
||||
|
||||
void pci_plx9030_bridge_eeprom_setup_read(board_t *board) {
|
||||
static void pci_plx9030_bridge_eeprom_setup_read(board_t *board) {
|
||||
int i;
|
||||
char *bridge_name = "Unknown";
|
||||
|
||||
|
|
@ -410,6 +414,7 @@ static int plx9030_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
int bindex, bytesread;
|
||||
u32 status, control;
|
||||
char part_name[32];
|
||||
char board_name[32];
|
||||
struct stat file_stat;
|
||||
FILE *fp;
|
||||
struct timeval tv1, tv2;
|
||||
|
|
@ -423,10 +428,15 @@ static int plx9030_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
printf("Can't open file %s: %s\n", bitfile_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (print_bitfile_header(fp, (char*) &part_name, board->llio.verbose) == -1) {
|
||||
if (print_bitfile_header(fp, (char*) &part_name, (char*) &board_name, board->llio.verbose) == -1) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
if (!check_board_name(self->board_name, board_name, bitfile_name)) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set /WRITE low for data transfer, and turn on LED
|
||||
status = inl(board->ctrl_base_addr + PLX9030_CTRL_STAT_OFFSET);
|
||||
control = status & ~PLX9030_WRITE_MASK & ~PLX9030_LED_MASK;
|
||||
|
|
@ -566,6 +576,7 @@ static int plx905x_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
int bindex, bytesread, i;
|
||||
u32 status;
|
||||
char part_name[32];
|
||||
char board_name[32];
|
||||
struct stat file_stat;
|
||||
FILE *fp;
|
||||
struct timeval tv1, tv2;
|
||||
|
|
@ -579,7 +590,11 @@ static int plx905x_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
printf("Can't open file %s: %s\n", bitfile_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (print_bitfile_header(fp, (char*) &part_name, board->llio.verbose) == -1) {
|
||||
if (print_bitfile_header(fp, (char*) &part_name, (char*) &board_name, board->llio.verbose) == -1) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
if (!check_board_name(self->board_name, board_name, bitfile_name)) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -663,7 +678,7 @@ static int plx905x_reset(llio_t *self) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void memcpy32(void *vdest, void *vsrc, int size) {
|
||||
static void memcpy32(void *vdest, void *vsrc, int size) {
|
||||
volatile u32 *dest = (volatile u32*)vdest;
|
||||
volatile u32 *src = (volatile u32*)vsrc;
|
||||
while(size) {
|
||||
|
|
@ -674,14 +689,14 @@ void memcpy32(void *vdest, void *vsrc, int size) {
|
|||
}
|
||||
}
|
||||
|
||||
int pci_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int pci_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
board_t *board = self->board;
|
||||
assert(size % 4 == 0);
|
||||
memcpy32(buffer, board->base + addr, size/4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pci_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int pci_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
board_t *board = self->board;
|
||||
assert(size % 4 == 0);
|
||||
memcpy32(board->base + addr, buffer, size/4);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <poll.h>
|
||||
#include <sys/poll.h>
|
||||
#include <unistd.h>
|
||||
#include "types.h"
|
||||
#include "anyio.h"
|
||||
#include "serial_boards.h"
|
||||
|
|
|
|||
10
spi_boards.c
10
spi_boards.c
|
|
@ -16,6 +16,7 @@
|
|||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/spi/spidev.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -28,11 +29,12 @@
|
|||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "types.h"
|
||||
#include "eeprom.h"
|
||||
#include "eeprom_local.h"
|
||||
#include "spi_boards.h"
|
||||
#include "common.h"
|
||||
|
||||
extern board_t boards[MAX_BOARDS];
|
||||
extern int boards_count;
|
||||
|
||||
|
|
@ -110,7 +112,7 @@ void spi_boards_cleanup(board_access_t *access) {
|
|||
if(sd != -1) close(sd);
|
||||
}
|
||||
|
||||
void reorderBuffer(char *pBuf, int numInts)
|
||||
static void reorderBuffer(char *pBuf, int numInts)
|
||||
{
|
||||
int lcv;
|
||||
for (lcv = 0; lcv < numInts; lcv++)
|
||||
|
|
@ -125,7 +127,7 @@ void reorderBuffer(char *pBuf, int numInts)
|
|||
}
|
||||
}
|
||||
|
||||
int spi_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int spi_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
if(size % 4 != 0) return -1;
|
||||
int numInts = 1+size/4;
|
||||
u32 trxbuf[numInts];
|
||||
|
|
@ -154,7 +156,7 @@ int spi_read(llio_t *self, u32 addr, void *buffer, int size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int spi_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int spi_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
if(size % 4 != 0) return -1;
|
||||
int numInts = 1+size/4;
|
||||
u32 txbuf[numInts];
|
||||
|
|
|
|||
|
|
@ -68,40 +68,40 @@ static void disable_sserial_pins(llio_t *llio) {
|
|||
}
|
||||
}
|
||||
|
||||
void sslbp_send_local_cmd(sserial_module_t *ssmod, int interface, u32 cmd) {
|
||||
static void sslbp_send_local_cmd(sserial_module_t *ssmod, int interface, u32 cmd) {
|
||||
ssmod->board->llio.write(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_CMD + interface*0x40, &(cmd), sizeof(u32));
|
||||
}
|
||||
|
||||
u32 sslbp_read_local_cmd(sserial_module_t *ssmod, int interface) {
|
||||
static u32 sslbp_read_local_cmd(sserial_module_t *ssmod, int interface) {
|
||||
u32 data;
|
||||
|
||||
ssmod->board->llio.read(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_CMD + interface*0x40, &(data), sizeof(u32));
|
||||
return data;
|
||||
}
|
||||
|
||||
u8 sslbp_read_data(sserial_module_t *ssmod, int interface) {
|
||||
static u8 sslbp_read_data(sserial_module_t *ssmod, int interface) {
|
||||
u32 data;
|
||||
|
||||
ssmod->board->llio.read(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_DATA + interface*0x40, &(data), sizeof(u32));
|
||||
return data & 0xFF;
|
||||
}
|
||||
|
||||
void sslbp_wait_complete(sserial_module_t *ssmod, int interface) {
|
||||
static void sslbp_wait_complete(sserial_module_t *ssmod, int interface) {
|
||||
while (sslbp_read_local_cmd(ssmod, interface) != 0) {}
|
||||
}
|
||||
|
||||
void sslbp_send_remote_cmd(sserial_module_t *ssmod, int interface, int channel, u32 cmd) {
|
||||
static void sslbp_send_remote_cmd(sserial_module_t *ssmod, int interface, int channel, u32 cmd) {
|
||||
ssmod->board->llio.write(&(ssmod->board->llio), ssmod->base_address + HM2_MOD_OFFS_SSERIAL_CS + interface*0x40 + channel*4, &(cmd), sizeof(u32));
|
||||
}
|
||||
|
||||
u8 sslbp_read_local8(sserial_module_t *ssmod, int interface, u32 addr) {
|
||||
static u8 sslbp_read_local8(sserial_module_t *ssmod, int interface, u32 addr) {
|
||||
|
||||
sslbp_send_local_cmd(ssmod, interface, SSLBP_CMD_READ(addr));
|
||||
sslbp_wait_complete(ssmod, interface);
|
||||
return sslbp_read_data(ssmod, interface);
|
||||
}
|
||||
|
||||
u32 sslbp_read_local32(sserial_module_t *ssmod, int interface, u32 addr) {
|
||||
static u32 sslbp_read_local32(sserial_module_t *ssmod, int interface, u32 addr) {
|
||||
int byte = 4;
|
||||
u32 ret = 0;
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ u32 sslbp_read_local32(sserial_module_t *ssmod, int interface, u32 addr) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
u8 sslbp_read_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
static u8 sslbp_read_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
u32 data;
|
||||
|
||||
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_READ | LBP_ADDR_AUTO_INC) << 24) | addr);
|
||||
|
|
@ -120,7 +120,7 @@ u8 sslbp_read_remote8(sserial_module_t *ssmod, int interface, int channel, u32 a
|
|||
return data & 0xFF;
|
||||
}
|
||||
|
||||
u16 sslbp_read_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
static u16 sslbp_read_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
int byte;
|
||||
u16 ret = 0;
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ u16 sslbp_read_remote16(sserial_module_t *ssmod, int interface, int channel, u32
|
|||
return ret;
|
||||
}
|
||||
|
||||
u32 sslbp_read_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
static u32 sslbp_read_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
int byte;
|
||||
u32 ret = 0;
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ u32 sslbp_read_remote32(sserial_module_t *ssmod, int interface, int channel, u32
|
|||
return ret;
|
||||
}
|
||||
|
||||
void sslbp_write_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr, u8 data) {
|
||||
static void sslbp_write_remote8(sserial_module_t *ssmod, int interface, int channel, u32 addr, u8 data) {
|
||||
u32 d = data;
|
||||
|
||||
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_WRITE | LBP_ARGS_8BIT | LBP_ADDR_AUTO_INC) << 24) | addr);
|
||||
|
|
@ -147,7 +147,7 @@ void sslbp_write_remote8(sserial_module_t *ssmod, int interface, int channel, u3
|
|||
sslbp_wait_complete(ssmod, interface);
|
||||
}
|
||||
|
||||
void sslbp_write_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr, u16 data) {
|
||||
static void sslbp_write_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr, u16 data) {
|
||||
u32 d = data;
|
||||
|
||||
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_WRITE | LBP_ARGS_16BIT | LBP_ADDR_AUTO_INC) << 24) | addr);
|
||||
|
|
@ -156,7 +156,7 @@ void sslbp_write_remote16(sserial_module_t *ssmod, int interface, int channel, u
|
|||
sslbp_wait_complete(ssmod, interface);
|
||||
}
|
||||
|
||||
void sslbp_write_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr, u32 data) {
|
||||
static void sslbp_write_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr, u32 data) {
|
||||
u32 d = data;
|
||||
|
||||
sslbp_send_remote_cmd(ssmod, interface, channel, ((LBP_CMD_WRITE | LBP_ARGS_32BIT | LBP_ADDR_AUTO_INC) << 24) | addr);
|
||||
|
|
@ -165,7 +165,7 @@ void sslbp_write_remote32(sserial_module_t *ssmod, int interface, int channel, u
|
|||
sslbp_wait_complete(ssmod, interface);
|
||||
}
|
||||
|
||||
u16 sslbp_read_nv_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
static u16 sslbp_read_nv_remote16(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
u16 data;
|
||||
u32 cmd = LBP_CMD_READ_NV << 24;
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ u16 sslbp_read_nv_remote16(sserial_module_t *ssmod, int interface, int channel,
|
|||
return data;
|
||||
}
|
||||
|
||||
u32 sslbp_read_nv_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
static u32 sslbp_read_nv_remote32(sserial_module_t *ssmod, int interface, int channel, u32 addr) {
|
||||
u32 data;
|
||||
u32 cmd = LBP_CMD_READ_NV << 24;
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ u32 sslbp_read_nv_remote32(sserial_module_t *ssmod, int interface, int channel,
|
|||
return data;
|
||||
}
|
||||
|
||||
void sslbp_read_remote_bytes(sserial_module_t *ssmod, int interface, int channel, u32 addr, void *buffer, int size) {
|
||||
static void sslbp_read_remote_bytes(sserial_module_t *ssmod, int interface, int channel, u32 addr, void *buffer, int size) {
|
||||
char *ptr = (char *) buffer;
|
||||
|
||||
while (size != 0) {
|
||||
|
|
|
|||
10
usb_boards.c
10
usb_boards.c
|
|
@ -33,7 +33,7 @@ extern board_t boards[MAX_BOARDS];
|
|||
extern int boards_count;
|
||||
static u8 file_buffer[SECTOR_SIZE];
|
||||
|
||||
int usb_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int usb_read(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
while (size > 0) {
|
||||
lbp_read(addr & 0xFFFF, buffer);
|
||||
addr += 4;
|
||||
|
|
@ -43,7 +43,7 @@ int usb_read(llio_t *self, u32 addr, void *buffer, int size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int usb_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
static int usb_write(llio_t *self, u32 addr, void *buffer, int size) {
|
||||
while (size > 0) {
|
||||
lbp_write(addr & 0xFFFF, buffer);
|
||||
addr += 4;
|
||||
|
|
@ -57,6 +57,7 @@ static int usb_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
board_t *board = self->board;
|
||||
int bindex, bytesread;
|
||||
char part_name[32];
|
||||
char board_name[32];
|
||||
struct stat file_stat;
|
||||
FILE *fp;
|
||||
u8 cmd = '0';
|
||||
|
|
@ -70,10 +71,13 @@ static int usb_program_fpga(llio_t *self, char *bitfile_name) {
|
|||
printf("Can't open file %s: %s\n", bitfile_name, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (print_bitfile_header(fp, (char*) &part_name, board->llio.verbose) == -1) {
|
||||
if (print_bitfile_header(fp, (char*) &part_name, (char*) &board_name, board->llio.verbose) == -1) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
if (!check_board_name(self->board_name, board_name, bitfile_name)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Programming FPGA...\n");
|
||||
printf(" |");
|
||||
|
|
|
|||
Loading…
Reference in a new issue