mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
wip
This commit is contained in:
parent
b8086dcd70
commit
5b3e5e8d16
@ -4,8 +4,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#define TEMP_PROG_FILE_NAME "/var/tmp/tmp.pof"
|
#define TEMP_PROG_FILE_NAME "/var/tmp/tmp.rawbin"
|
||||||
|
|
||||||
|
|
||||||
void defineGPIOpins();
|
void defineGPIOpins();
|
||||||
void FPGAdontTouchFlash();
|
void FPGAdontTouchFlash();
|
||||||
@ -17,6 +16,7 @@ void resetFPGA();
|
|||||||
* verify memory available to copy
|
* verify memory available to copy
|
||||||
* open file to copy
|
* open file to copy
|
||||||
*/
|
*/
|
||||||
|
int deleteOldFile(char *mess);
|
||||||
int preparetoCopyFPGAProgram(FILE **fd, uint64_t fsize, char *mess);
|
int preparetoCopyFPGAProgram(FILE **fd, uint64_t fsize, char *mess);
|
||||||
int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess);
|
int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess);
|
||||||
int getDrive(char *mess);
|
int getDrive(char *mess);
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h> // readlink
|
#include <unistd.h> // readlink
|
||||||
|
|
||||||
|
#define FLASH_READ_FNAME "/var/tmp/flash.rawbin"
|
||||||
|
|
||||||
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||||
int outputMax, int inputValue, int *outputValue) {
|
int outputMax, int inputValue, int *outputValue) {
|
||||||
LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
|
LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
|
||||||
@ -251,6 +253,14 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE *flashfp = fopen(FLASH_READ_FNAME, "w");
|
||||||
|
if (fp == NULL) {
|
||||||
|
sprintf(mess, "Unable to open %s in write mode to get from flash\n",
|
||||||
|
FLASH_READ_FNAME);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(logINFO, ("\tReading from flash\n"));
|
LOG(logINFO, ("\tReading from flash\n"));
|
||||||
int oldProgress = 0;
|
int oldProgress = 0;
|
||||||
ssize_t bytes = 0;
|
ssize_t bytes = 0;
|
||||||
@ -268,6 +278,7 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++bytes;
|
++bytes;
|
||||||
|
write(flashfp, &s, 1);
|
||||||
// swap bits
|
// swap bits
|
||||||
int d = 0;
|
int d = 0;
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
@ -283,6 +294,7 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname,
|
|||||||
}
|
}
|
||||||
LOG(logINFO, ("\tRead %lu bytes to calculate checksum\n", (long int)bytes));
|
LOG(logINFO, ("\tRead %lu bytes to calculate checksum\n", (long int)bytes));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
fclose(flashfp);
|
||||||
return verifyChecksum(mess, clientChecksum, &c);
|
return verifyChecksum(mess, clientChecksum, &c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,10 +66,7 @@ void resetFPGA() {
|
|||||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
int preparetoCopyFPGAProgram(FILE **fd, uint64_t fsize, char *mess) {
|
int deleteOldFile(char *mess) {
|
||||||
|
|
||||||
// delete old /var/tmp/file
|
|
||||||
{
|
|
||||||
char cmd[MAX_STR_LENGTH] = {0};
|
char cmd[MAX_STR_LENGTH] = {0};
|
||||||
char retvals[MAX_STR_LENGTH] = {0};
|
char retvals[MAX_STR_LENGTH] = {0};
|
||||||
sprintf(cmd, "rm -fr %s", TEMP_PROG_FILE_NAME);
|
sprintf(cmd, "rm -fr %s", TEMP_PROG_FILE_NAME);
|
||||||
@ -81,6 +78,13 @@ int preparetoCopyFPGAProgram(FILE **fd, uint64_t fsize, char *mess) {
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int preparetoCopyFPGAProgram(FILE **fd, uint64_t fsize, char *mess) {
|
||||||
|
|
||||||
|
if (deleteOldFile(mess) == FAIL) {
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check available memory to copy program
|
// check available memory to copy program
|
||||||
@ -131,6 +135,10 @@ int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess) {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deleteOldFile(mess) == FAIL) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize) ==
|
if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize) ==
|
||||||
FAIL) {
|
FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user