Commit b379e439 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/snmpd: add wrsBootLoadFPGA to wrsBootStatusGroup

-- change script userspace/rootfs_override/wr/sbin/startup-mb.sh to save
   load result in file /tmp/load_fpga_status
-- update wrsBootStatusGroup.c and wrsBootStatusGroup.h
-- update MIB
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent dfc16041
#!/bin/ash
export WR_HOME="/wr"
LOAD_FPGA_STATUS_FILE="/tmp/load_fpga_status"
# Get parameter from kernel commandline
for arg in $(cat /proc/cmdline); do
......@@ -26,6 +27,7 @@ LM_FILE="$WR_HOME/lib/firmware/rt_cpu.elf"
if ! [ -f "$FP_FILE" ]; then
echo "Fatal: can't find \"$FP_FILE\"" >& 2
echo "load_file_not_found" > $LOAD_FPGA_STATUS_FILE
exit 1;
fi
if ! [ -f "$LM_FILE" ]; then
......@@ -34,6 +36,14 @@ if ! [ -f "$LM_FILE" ]; then
fi
$WR_HOME/bin/load-virtex $FP_FILE
if [ $? -eq 0 ];
then
echo "load_ok" > $LOAD_FPGA_STATUS_FILE
else
echo "Fatal: load FPGA failed" >& 2
echo "load_error" > $LOAD_FPGA_STATUS_FILE
fi
$WR_HOME/bin/load-lm32 $LM_FILE scb_ver=${scb_ver}
insmod $WR_HOME/lib/modules/at91_softpwm.ko
insmod $WR_HOME/lib/modules/wr_vic.ko
......
......@@ -335,6 +335,23 @@ wrsBootHwinfoReadout OBJECT-TYPE
warning - no hwinfo partition"
::= { wrsBootStatusGroup 10 }
wrsBootLoadFPGA OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
error(2),
errorMinor(3),
fileNotFound(4)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Result of loading FPGA
error - loading failed
errorMinor - cannot read status file, problem is probably somewhere else
fileNotFound - file to be loaded not found"
::= { wrsBootStatusGroup 11 }
-- wrsTemperatureGroup (.7.1.3)
wrsTemperatureGroup OBJECT IDENTIFIER ::= { wrsOperationStatus 3 }
......
......@@ -11,6 +11,8 @@
#define DOTCONFIG_DOWNLOAD "dot-config_status"
#define HWINFO_FILE "/tmp/hwinfo_read_status"
#define LOAD_FPGA_STATUS_FILE "/tmp/load_fpga_status"
/* Macros for fscanf function to read line with maximum of "x" characters
* without new line. Macro expands to something like: "%10[^\n]" */
#define LINE_READ_LEN_HELPER(x) "%"#x"[^\n]"
......@@ -31,6 +33,7 @@ static struct pickinfo wrsBootStatus_pickinfo[] = {
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsConfigSourceFilename),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootConfigStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootHwinfoReadout),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsBootLoadFPGA),
};
struct wrsBootStatus_s wrsBootStatus_s;
......@@ -194,6 +197,7 @@ static void get_dotconfig_source(void)
/* get status of execution of following scripts:
* /etc/init.d/S90hwinfo
* /wr/sbin/startup-mb.sh
* */
static void get_boot_scripts_status(void){
static int run_once = 0;
......@@ -227,6 +231,28 @@ static void get_boot_scripts_status(void){
wrsBootStatus_s.wrsBootHwinfoReadout =
WRS_BOOT_HWINFO_ERROR_MINOR;
}
/* result of loading FPGA */
f = fopen(LOAD_FPGA_STATUS_FILE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strncmp(buff, "load_ok", 20))
wrsBootStatus_s.wrsBootLoadFPGA =
WRS_BOOT_LOAD_FPGA_OK;
else if (!strncmp(buff, "load_file_not_found", 20))
wrsBootStatus_s.wrsBootLoadFPGA =
WRS_BOOT_LOAD_FPGA_FILE_NOT_FOUND;
else /* */
wrsBootStatus_s.wrsBootLoadFPGA =
WRS_BOOT_LOAD_FPGA_ERROR;
} else {
/* status file not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsBootLoadFPGA =
WRS_BOOT_LOAD_FPGA_ERROR_MINOR;
}
}
......
......@@ -27,6 +27,11 @@
#define WRS_BOOT_HWINFO_ERROR_MINOR 3 /* warning */
#define WRS_BOOT_HWINFO_WARNING 4 /* warning */
#define WRS_BOOT_LOAD_FPGA_OK 1 /* ok */
#define WRS_BOOT_LOAD_FPGA_ERROR 2 /* error */
#define WRS_BOOT_LOAD_FPGA_ERROR_MINOR 3 /* warning */
#define WRS_BOOT_LOAD_FPGA_FILE_NOT_FOUND 4 /* error */
struct wrsBootStatus_s {
uint32_t wrsBootCnt; /* boots since power-on must be != 0 */
uint32_t wrsRebootCnt; /* soft reboots since hard reboot
......@@ -39,6 +44,7 @@ struct wrsBootStatus_s {
char wrsConfigSourceFilename[WRS_CONFIG_SOURCE_FILENAME_LEN+1];
int32_t wrsBootConfigStatus;
int32_t wrsBootHwinfoReadout;
int32_t wrsBootLoadFPGA;
};
extern struct wrsBootStatus_s wrsBootStatus_s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment