mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 08:17:13 +02:00
fix to ensure updatekernel does not work with Amd blackfin flash and a kernel older than the current one
This commit is contained in:
@ -14,6 +14,7 @@ int FPGATouchFlash(char *mess);
|
|||||||
int resetFPGA(char *mess);
|
int resetFPGA(char *mess);
|
||||||
|
|
||||||
int emptyTempFolder(char *mess);
|
int emptyTempFolder(char *mess);
|
||||||
|
int allowKernelUpdate(char *mess);
|
||||||
/**
|
/**
|
||||||
* deletes old file
|
* deletes old file
|
||||||
* verify memory available to copy
|
* verify memory available to copy
|
||||||
|
@ -403,7 +403,8 @@ int verifyChecksum(char *mess, char *functionType, char *clientChecksum,
|
|||||||
if (strcmp(clientChecksum, checksum)) {
|
if (strcmp(clientChecksum, checksum)) {
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not %s. Checksum of %s does not match. Client "
|
"Could not %s. Checksum of %s does not match. Client "
|
||||||
"checksum:%s, copied checksum:%s\n",
|
"checksum:%s, copied checksum:%. Please try again before "
|
||||||
|
"rebooting.\n",
|
||||||
functionType, msg, clientChecksum, checksum);
|
functionType, msg, clientChecksum, checksum);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
#define CMD_GET_FPGA_FLASH_DRIVE "awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd"
|
#define CMD_GET_FPGA_FLASH_DRIVE "awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd"
|
||||||
#define CMD_GET_KERNEL_FLASH_DRIVE "awk \'$4== \"\\\"linux\" {print $1}\' /proc/mtd"
|
#define CMD_GET_KERNEL_FLASH_DRIVE "awk \'$4== \"\\\"linux\" {print $1}\' /proc/mtd"
|
||||||
|
|
||||||
|
|
||||||
|
#define CMD_GET_AMD_FLASH "dmesg | grep Amd"
|
||||||
|
|
||||||
#define FLASH_BUFFER_MEMORY_SIZE (128 * 1024) // 500 KB
|
#define FLASH_BUFFER_MEMORY_SIZE (128 * 1024) // 500 KB
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
@ -245,6 +248,41 @@ int emptyTempFolder(char *mess) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int allowKernelUpdate(char *mess) {
|
||||||
|
LOG(logINFO, ("\tVerifying kernel update allowed...\n"));
|
||||||
|
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
|
char retvals[MAX_STR_LENGTH] = {0};
|
||||||
|
if (executeCommand(CMD_GET_AMD_FLASH, retvals, logDEBUG1) == FAIL) {
|
||||||
|
snprintf(
|
||||||
|
mess, MAX_STR_LENGTH,
|
||||||
|
"Could not update %s. (Could not figure out if Amd flash: %s)\n",
|
||||||
|
messageType, retvals);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
// amd flash found
|
||||||
|
if (strlen(retvals) > 1) {
|
||||||
|
LOG(logINFO, ("\tAmd Flash found\n"));
|
||||||
|
// only current kernel works with amd flash
|
||||||
|
if (validateKernelVersion(KERNEL_DATE_VRSN_3GPIO) == FAIL) {
|
||||||
|
getKernelVersion(retvals);
|
||||||
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
|
"Could not update %s. Kernel version %s is too old to "
|
||||||
|
"update the Amd flash\n",
|
||||||
|
messageType, retvals);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG(logINFO, ("\tNot Amd Flash\n"));
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("\tKernel and flash ok for updating kernel\n"));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
int preparetoCopyProgram(char *mess, char *functionType, FILE **fd,
|
int preparetoCopyProgram(char *mess, char *functionType, FILE **fd,
|
||||||
uint64_t fsize) {
|
uint64_t fsize) {
|
||||||
|
|
||||||
|
@ -9255,9 +9255,10 @@ int get_kernel_version(int file_des) {
|
|||||||
ret = getKernelVersion(retvals);
|
ret = getKernelVersion(retvals);
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
if (snprintf(mess, MAX_STR_LENGTH, "Could not get kernel version. %s\n",
|
if (snprintf(mess, MAX_STR_LENGTH, "Could not get kernel version. %s\n",
|
||||||
retvals) >= MAX_STR_LENGTH) {
|
retvals) >= MAX_STR_LENGTH) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
strcpy(mess, "Could not get kernel version. Reason too long to copy\n");
|
strcpy(mess,
|
||||||
|
"Could not get kernel version. Reason too long to copy\n");
|
||||||
}
|
}
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
} else {
|
} else {
|
||||||
@ -9372,6 +9373,13 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
|||||||
functionType);
|
functionType);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
#else
|
#else
|
||||||
|
// check kernel update is allowed (Non Amd OR AMD + current kernel)
|
||||||
|
ret = allowKernelUpdate(mess);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// open file and allocate memory for part program
|
// open file and allocate memory for part program
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
ret = preparetoCopyProgram(mess, functionType, &fd, filesize);
|
ret = preparetoCopyProgram(mess, functionType, &fd, filesize);
|
||||||
|
Reference in New Issue
Block a user