mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge pull request #330 from slsdetectorgroup/programfix
Program firmware for new kernel
This commit is contained in:
commit
2b1028d636
@ -28,6 +28,8 @@ This document describes the differences between vx.x.x and v6.0.0.
|
||||
|
||||
- setting rx_hostname to none threw an exception. fixed.
|
||||
- rx id in config file was not taken into account. fixed.
|
||||
- programming firmware failure for blackfin, fixed but requires new kernel.
|
||||
- nios kernel check updated (ensuring right kernel)
|
||||
|
||||
3. Known Issues
|
||||
===============
|
||||
|
Binary file not shown.
Binary file not shown.
@ -188,7 +188,9 @@ int checkKernelVersion() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
return Nios_checkKernelVersion(KERNEL_DATE_VRSN);
|
||||
char buf[255] = {0};
|
||||
strcpy(buf, KERNEL_DATE_VRSN);
|
||||
return validateKernelVersion(buf);
|
||||
}
|
||||
|
||||
int checkType() {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#define REQRD_FRMWRE_VRSN (0x210527)
|
||||
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
|
||||
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
|
||||
#define ID_FILE "detid_gotthard2.txt"
|
||||
|
||||
#define LINKED_SERVER_NAME "gotthard2DetectorServer"
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -181,7 +181,9 @@ int checkKernelVersion() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
return Nios_checkKernelVersion(KERNEL_DATE_VRSN);
|
||||
char buf[255] = {0};
|
||||
strcpy(buf, KERNEL_DATE_VRSN);
|
||||
return validateKernelVersion(buf);
|
||||
}
|
||||
|
||||
int checkType() {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#define REQRD_FRMWRE_VRSN (0x210910)
|
||||
#define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020"
|
||||
#define KERNEL_DATE_VRSN "Mon May 10 18:00:21 CEST 2021"
|
||||
#define ID_FILE "detid_mythen3.txt"
|
||||
|
||||
#define LINKED_SERVER_NAME "mythen3DetectorServer"
|
||||
|
@ -26,7 +26,9 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||
|
||||
int getAbsPath(char *buf, size_t bufSize, char *fname);
|
||||
|
||||
int GetTimeFromString(char *buf, time_t *result);
|
||||
int getTimeFromString(char *buf, time_t *result);
|
||||
|
||||
int validateKernelVersion(char *expectedVersion);
|
||||
|
||||
void validate(int *ret, char *mess, int arg, int retval, char *modename,
|
||||
enum numberMode nummode);
|
||||
|
@ -89,7 +89,3 @@ int mapCSP0(void);
|
||||
* Get Nios base address
|
||||
*/
|
||||
u_int32_t *Nios_getBaseAddress();
|
||||
|
||||
/** check kernel version against expected version string (complain if too old)
|
||||
* @returns OK or FAIL */
|
||||
int Nios_checkKernelVersion(char *expectedVersion);
|
@ -3,6 +3,7 @@
|
||||
#include "blackfin.h"
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sls/ansi.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
@ -126,4 +127,4 @@ int mapCSP0(void) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t *Blackfin_getBaseAddress() { return csp0base; }
|
||||
uint32_t *Blackfin_getBaseAddress() { return csp0base; }
|
||||
|
@ -7,7 +7,8 @@
|
||||
|
||||
#include <libgen.h> // dirname
|
||||
#include <string.h>
|
||||
#include <unistd.h> // readlink
|
||||
#include <sys/utsname.h> // uname
|
||||
#include <unistd.h> // readlink
|
||||
|
||||
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
|
||||
int outputMax, int inputValue, int *outputValue) {
|
||||
@ -64,15 +65,83 @@ int getAbsPath(char *buf, size_t bufSize, char *fname) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int GetTimeFromString(char *buf, time_t *result) {
|
||||
int getTimeFromString(char *buf, time_t *result) {
|
||||
// remove timezone as strptime cannot validate timezone despite
|
||||
// documentation (for blackfin)
|
||||
LOG(logDEBUG, ("buf for time %s\n", buf));
|
||||
const char *timezone = {"CEST"};
|
||||
char *res = strstr(buf, timezone);
|
||||
if (res != NULL) {
|
||||
size_t cestPos = res - buf;
|
||||
size_t pos = cestPos + strlen(timezone) + 1;
|
||||
while (pos != strlen(buf)) {
|
||||
buf[cestPos] = buf[pos];
|
||||
++cestPos;
|
||||
++pos;
|
||||
}
|
||||
buf[cestPos] = '\0';
|
||||
}
|
||||
LOG(logDEBUG, ("buf after removing CEST %s\n", buf));
|
||||
|
||||
// convert to time structure
|
||||
struct tm t;
|
||||
if (NULL == strptime(buf, "%a %b %d %H:%M:%S %Z %Y", &t)) {
|
||||
if (NULL == strptime(buf, "%a %b %d %H:%M:%S %Y", &t)) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// print time structure
|
||||
LOG(logDEBUG, ("%d %d %d %d:%d:%d %d (day date month H:M:S year)\n", t.tm_wday, t.tm_mday, t.tm_mon, t.tm_year +1900, t.tm_hour, t.tm_min, t.tm_sec));
|
||||
|
||||
*result = mktime(&t);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int validateKernelVersion(char *expectedVersion) {
|
||||
// extract kernel date string
|
||||
struct utsname buf = {0};
|
||||
if (uname(&buf) == -1) {
|
||||
LOG(logERROR, ("Could not get kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// remove first word (#version number)
|
||||
const char *ptr = strchr(buf.version, ' ');
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
char output[255];
|
||||
memset(output, 0, sizeof(output));
|
||||
strcpy(output, buf.version + (ptr - buf.version + 1));
|
||||
|
||||
// convert kernel date string into time
|
||||
time_t kernelDate;
|
||||
if (getTimeFromString(output, &kernelDate) == FAIL) {
|
||||
LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// convert expected date into time
|
||||
time_t expDate;
|
||||
if (getTimeFromString(expectedVersion, &expDate) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// compare if kernel time is older than expected time
|
||||
if (kernelDate < expDate) {
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
||||
"Got [%s]\n",
|
||||
expectedVersion, output));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output,
|
||||
expectedVersion));
|
||||
return OK;
|
||||
}
|
||||
|
||||
void validate(int *ret, char *mess, int arg, int retval, char *modename,
|
||||
enum numberMode nummode) {
|
||||
if (*ret == OK && arg != GET_FLAG && retval != arg) {
|
||||
|
@ -7,10 +7,8 @@
|
||||
#include "sls/ansi.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <fcntl.h> // open
|
||||
#include <string.h>
|
||||
#include <sys/mman.h> // mmap
|
||||
#include <sys/utsname.h> // uname
|
||||
#include <fcntl.h> // open
|
||||
#include <sys/mman.h> // mmap
|
||||
|
||||
/* global variables */
|
||||
u_int32_t *csp0base = 0;
|
||||
@ -132,49 +130,3 @@ int mapCSP0(void) {
|
||||
}
|
||||
|
||||
u_int32_t *Nios_getBaseAddress() { return csp0base; }
|
||||
|
||||
int Nios_checkKernelVersion(char *expectedVersion) {
|
||||
// extract kernel date string
|
||||
struct utsname buf;
|
||||
if (uname(&buf) == -1) {
|
||||
LOG(logERROR, ("Could not get kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// remove first word (#version number)
|
||||
const char *ptr = strchr(buf.version, ' ');
|
||||
if (ptr == NULL) {
|
||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||
return FAIL;
|
||||
}
|
||||
char output[256];
|
||||
memset(output, 0, 256);
|
||||
strcpy(output, buf.version + (ptr - buf.version + 1));
|
||||
|
||||
// convert kernel date string into time
|
||||
time_t kernelDate;
|
||||
if (GetTimeFromString(output, &kernelDate) == FAIL) {
|
||||
LOG(logERROR, ("Could not parse retrieved kernel date, %s\n", output));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// convert expected date into time
|
||||
time_t expDate;
|
||||
if (GetTimeFromString(expectedVersion, &expDate) == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// compare if kernel time is older than expected time
|
||||
if (kernelDate < expDate) {
|
||||
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
||||
"Got [%s]\n",
|
||||
expectedVersion, output));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE, ("Kernel Version Compatible: %s [min.: %s]\n", output,
|
||||
expectedVersion));
|
||||
return OK;
|
||||
}
|
@ -24,18 +24,37 @@ int gpioDefined = 0;
|
||||
|
||||
extern int executeCommand(char *command, char *result, enum TLogLevel level);
|
||||
|
||||
int latestKernelVerified = -1;
|
||||
#define KERNEL_DATE_VRSN_3GPIO "Fri Oct 29 00:00:00 2021"
|
||||
|
||||
void defineGPIOpins() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
if (latestKernelVerified == -1) {
|
||||
if (FAIL == validateKernelVersion(KERNEL_DATE_VRSN_3GPIO)) {
|
||||
latestKernelVerified = 0;
|
||||
LOG(logWARNING,
|
||||
("Kernel too old to use gpio 3 pins. Not the end "
|
||||
"of the world. Continuing with current kernel.\n"));
|
||||
} else {
|
||||
latestKernelVerified = 1;
|
||||
}
|
||||
}
|
||||
if (!gpioDefined) {
|
||||
// define the gpio pins
|
||||
system("echo 7 > /sys/class/gpio/export");
|
||||
system("echo 9 > /sys/class/gpio/export");
|
||||
// define their direction
|
||||
LOG(logINFO, ("\tgpio7: defined\n"));
|
||||
system("echo in > /sys/class/gpio/gpio7/direction");
|
||||
system("echo out > /sys/class/gpio/gpio9/direction");
|
||||
LOG(logINFO, ("gpio pins defined\n"));
|
||||
LOG(logINFO, ("\tgpio7: setting intput\n"));
|
||||
system("echo 9 > /sys/class/gpio/export");
|
||||
LOG(logINFO, ("\tgpio9: defined\n"));
|
||||
|
||||
if (latestKernelVerified == 1) {
|
||||
// gpio 3 = not chip enable
|
||||
system("echo 3 > /sys/class/gpio/export");
|
||||
LOG(logINFO, ("\tgpio3: defined\n"));
|
||||
}
|
||||
gpioDefined = 1;
|
||||
} else
|
||||
LOG(logDEBUG1, ("gpio pins already defined earlier\n"));
|
||||
@ -45,8 +64,22 @@ void FPGAdontTouchFlash() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
// define as output pins
|
||||
system("echo out > /sys/class/gpio/gpio9/direction");
|
||||
LOG(logINFO, ("\tgpio9: setting output\n"));
|
||||
if (latestKernelVerified == 1) {
|
||||
// gpio 3 = not chip enable
|
||||
system("echo out > /sys/class/gpio/gpio3/direction");
|
||||
LOG(logINFO, ("\tgpio3: setting output\n"));
|
||||
}
|
||||
|
||||
// tell FPGA to not touch flash
|
||||
system("echo 0 > /sys/class/gpio/gpio9/value");
|
||||
LOG(logINFO, ("\tgpio9: fpga dont touch flash\n"));
|
||||
if (latestKernelVerified == 1) {
|
||||
system("echo 1 > /sys/class/gpio/gpio3/value");
|
||||
LOG(logINFO, ("\tgpio3: fpga dont touch flash\n"));
|
||||
}
|
||||
// usleep(100*1000);
|
||||
}
|
||||
|
||||
@ -55,7 +88,12 @@ void FPGATouchFlash() {
|
||||
return;
|
||||
#endif
|
||||
// tell FPGA to touch flash to program itself
|
||||
system("echo 1 > /sys/class/gpio/gpio9/value");
|
||||
system("echo in > /sys/class/gpio/gpio9/direction");
|
||||
LOG(logINFO, ("\tgpio9: setting input\n"));
|
||||
if (latestKernelVerified == 1) {
|
||||
system("echo in > /sys/class/gpio/gpio3/direction");
|
||||
LOG(logINFO, ("\tgpio3: setting input\n"));
|
||||
}
|
||||
}
|
||||
|
||||
void resetFPGA() {
|
||||
@ -151,10 +189,9 @@ int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/* ignoring this until a consistent way to read from bfin flash
|
||||
if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize)
|
||||
== FAIL) { return FAIL;
|
||||
}
|
||||
/* ignoring this until flash fixed
|
||||
if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize) == FAIL) { return FAIL;
|
||||
}
|
||||
*/
|
||||
if (waitForFPGAtoTouchFlash(mess) == FAIL) {
|
||||
return FAIL;
|
||||
|
@ -6,10 +6,10 @@
|
||||
#define APILIB 0x211027
|
||||
#define APIRECEIVER 0x211020
|
||||
#define APIGUI 0x211021
|
||||
#define APICTB 0x211027
|
||||
#define APIGOTTHARD 0x211027
|
||||
#define APIGOTTHARD2 0x211027
|
||||
#define APIJUNGFRAU 0x211027
|
||||
#define APIMYTHEN3 0x211027
|
||||
#define APIMOENCH 0x211025
|
||||
#define APIEIGER 0x211027
|
||||
#define APICTB 0x211103
|
||||
#define APIGOTTHARD 0x211103
|
||||
#define APIGOTTHARD2 0x211103
|
||||
#define APIJUNGFRAU 0x211103
|
||||
#define APIMYTHEN3 0x211103
|
||||
#define APIMOENCH 0x211103
|
||||
|
Loading…
x
Reference in New Issue
Block a user