binaries in. fixed

This commit is contained in:
maliakal_d 2022-03-24 12:33:19 +01:00
parent 5fe10c19a1
commit 1e564a1b33
11 changed files with 28 additions and 20 deletions

View File

@ -29,9 +29,9 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
ssize_t fsize, int forceDeleteNormalFile);
int getDrive(char *mess, enum PROGRAM_INDEX index);
/** Notify fpga not to touch flash, open src and flash drive to write */
int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd,
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
int forceDeleteNormalFile);
int checkNormalFile(char *mess, int forceDeleteNormalFile);
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile);
int eraseFlash(char *mess);
/* write from tmp file to flash */
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd);

View File

@ -335,7 +335,7 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
FILE *flashfd = NULL;
FILE *srcfd = NULL;
if (openFileForFlash(mess, &flashfd, &srcfd, forceDeleteNormalFile) ==
if (openFileForFlash(mess, index, &flashfd, &srcfd, forceDeleteNormalFile) ==
FAIL) {
return FAIL;
}
@ -440,7 +440,7 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
return OK;
}
int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd,
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
int forceDeleteNormalFile) {
// open src file
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
@ -454,8 +454,10 @@ int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd,
}
LOG(logDEBUG1, ("Temp file ready for reading\n"));
if (checkNormalFile(mess, forceDeleteNormalFile) == FAIL)
if (checkNormalFile(mess, index, forceDeleteNormalFile) == FAIL) {
fclose(*srcfd);
return FAIL;
}
// open flash drive for writing
*flashfd = fopen(flashDriveName, "w");
@ -472,7 +474,7 @@ int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd,
return OK;
}
int checkNormalFile(char *mess, int forceDeleteNormalFile) {
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile) {
#ifndef VIRTUAL
// check if its a normal file or special file
struct stat buf;
@ -484,7 +486,7 @@ int checkNormalFile(char *mess, int forceDeleteNormalFile) {
LOG(logERROR, (mess));
return FAIL;
}
// non zero = block special file
// zero = normal file (not block special file)
if (S_ISBLK(buf.st_mode)) {
// kernel memory is not permanent
if (index != PROGRAM_FPGA) {
@ -496,18 +498,21 @@ int checkNormalFile(char *mess, int forceDeleteNormalFile) {
LOG(logERROR, (mess));
return FAIL;
}
// fpga memory stays after a reboot, so fix it if user allows
sprintf(mess,
"Could not %s. The flash drive found is a normal file. To "
"delete this file, create the flash drive and proceed with "
"programming, re-run the programming command with parameter "
// user does not allow to fix it (default)
if (forceDeleteNormalFile == 0) {
sprintf(mess,
"Could not %s. The flash drive %s found for fpga programming is a normal file. To "
"fix this (by deleting this file, creating the flash drive and proceeding with "
"programming), re-run the programming command 'programfpga' with parameter "
"'--force-delete-normal-file'\n",
messageType);
LOG(logERROR, (mess));
// user does not allow (default)
if (!forceDeleteNormalFile) {
messageType, flashDriveName);
LOG(logERROR, (mess));
return FAIL;
}
// fpga memory stays after a reboot, user allowed to fix it
LOG(logWARNING, ("Flash drive invalidated (normal file). Fixing it...\n"));
// user allows to fix it, so force delete normal file
char cmd[MAX_STR_LENGTH] = {0};
@ -530,7 +535,7 @@ int checkNormalFile(char *mess, int forceDeleteNormalFile) {
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tDeleted Normal File(%s)\n", flashDriveName));
LOG(logINFO, ("\tDeleted Normal File (%s)\n", flashDriveName));
// create special drive
if (snprintf(cmd, MAX_STR_LENGTH, "%s %s %s",
@ -552,6 +557,8 @@ int checkNormalFile(char *mess, int forceDeleteNormalFile) {
return FAIL;
}
LOG(logINFO, ("\tSpecial File created (%s)\n", flashDriveName));
} else {
LOG(logINFO, ("\tValidated flash drive (not a normal file)\n"));
}
#endif
return OK;

View File

@ -158,7 +158,7 @@ int openFileForFlash(char *mess, FILE **flashfd) {
LOG(logERROR, (mess));
return FAIL;
}
// non zero = block special file
// zero = normal file (not block special file)
if (S_ISBLK(buf.st_mode)) {
// memory is not permanent
sprintf(mess,
@ -169,6 +169,7 @@ int openFileForFlash(char *mess, FILE **flashfd) {
LOG(logERROR, (mess));
return FAIL;
}
LOG(logINFO, ("\tValidated flash drive (not a normal file)\n"));
#endif
*flashfd = fopen(flashDriveName, "w");

View File

@ -9450,7 +9450,7 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
sizeof(forceDeleteNormalFile), INT32) < 0)
return printSocketReadError();
LOG(logINFO,
("\tForce Delete Normal File: %d\n", forceDeleteNormalFile));
("\tForce Delete Normal File flag? %s\n", (forceDeleteNormalFile ? "Y" : "N")));
#endif
// in same folder as current process (will also work for virtual then

View File

@ -6,10 +6,10 @@
#define APIRECEIVER 0x211124
#define APIGUI 0x211124
#define APIEIGER 0x220324
#define APICTB 0x220324
#define APIGOTTHARD 0x220324
#define APIGOTTHARD2 0x220324
#define APIJUNGFRAU 0x220324
#define APIMYTHEN3 0x220324
#define APIMOENCH 0x220324
#define APIEIGER 0x220324