diff --git a/recipes-app/fofb-init/files/fofb-init.sh b/recipes-app/fofb-init/files/fofb-init.sh index f69fadc6179056c81335012e4eea4601fa006a30..2ee908587033c4f8837cdfe3dd7d03edddf0830e 100644 --- a/recipes-app/fofb-init/files/fofb-init.sh +++ b/recipes-app/fofb-init/files/fofb-init.sh @@ -1,34 +1,69 @@ #!/bin/bash +. /etc/init.d/functions + PATH_CONF="/opt/fofb/cfg/configuration" logger -t "fofb-fpgainit" "Reading configuration file ${PATH_CONF}" -if [ ! -f ${PATH_CONF} ]; then - logger -s -t "fofb-fpgainit" "Configuration file not found: ${PATH_CONF}" - exit 1 -fi -source ${PATH_CONF} +start() { + if [ ! -f ${PATH_CONF} ]; then + echo "Configuration file not found: ${PATH_CONF}" + exit 1 + fi + + source ${PATH_CONF} + + case $FOFB_APP in + cellnode|centralnode) + echo "Found configuration ${FOFB_APP}" + ;; + *) + echo "Could not establish FOFB application" + exit 1 + ;; + esac + + # Taking the last binary file in the sorted list (higher tag) + PATH_FPGABIN=$(ls -S /lib/firmware/base/${FOFB_APP}/*.bin | tail -n 1) + echo "Loading FPGA image ${PATH_FPGABIN}" + fpgautil -b ${PATH_FPGABIN} + + + # Linking the correct MAP file + PATH_MAP="/opt/fofb/map/app_${FOFB_APP}.mapt" + echo "Linking map file ${PATH_MAP}" + ln -sf ${PATH_MAP} /opt/fofb/map/app.mapt + +} -case $FOFB_APP in - cellnode|centralnode) - logger -t "fofb-fpgainit" "Found configuration ${FOFB_APP}" +stop() { + echo "Nothing to be done" +} + + + +### main logic ### +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + echo "Cannot give any status" + ;; + restart|reload|condrestart) + stop + start ;; *) - logger -s -t "fofb-fpgainit" "Could not establish FOFB application" + echo $"Usage: $0 {start|stop|restart|reload|status}" exit 1 - ;; esac -# Taking the last binary file in the sorted list (higher tag) -PATH_FPGABIN=$(ls -S /lib/firmware/base/${FOFB_APP}/*.bin | tail -n 1) -logger -t "fofb-fpgainit" "Loading FPGA image ${PATH_FPGABIN}" -fpgautil -b ${PATH_FPGABIN} - -# Linking the correct MAP file -PATH_MAP="/opt/fofb/map/app_{FOFB_APP}.mapt" -logger -t "fofb-fpgainit" "Linking map file ${PATH_MAP}" -ln -s ${PATH_MAP} /opt/fofb/map/app.mapt +exit 0 diff --git a/recipes-app/fofb-init/fofb-init_1.0.bb b/recipes-app/fofb-init/fofb-init_1.0.bb index c29e6457172a6e2d25bc6669e7c07ec90e248635..30ca7efdbf4d2a9a2e756e3fdbdeaa7a35073488 100644 --- a/recipes-app/fofb-init/fofb-init_1.0.bb +++ b/recipes-app/fofb-init/fofb-init_1.0.bb @@ -3,18 +3,21 @@ SECTION = "opt" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" -# RC script +# This will add startup scripts INITSCRIPT_NAME = "fofb-init.sh" -INITSCRIPT_PARAMS = "start 50 2" +INITSCRIPT_PARAMS = "defaults 50 2" inherit update-rc.d SRC_URI = " file://fofb-init.sh" -SRC_URI += " file://configuration +SRC_URI += " file://configuration" SRC_URI += " file://fpgaversion.sh" RDEPENDS_${PN}=" fpga-manager-script bash" FILES_${PN}+="/etc/init.d/fofb-init.sh" +FILES_${PN}+="/usr/bin/fpgaversion" +FILES_${PN}+="/opt/fofb/cfg/configuration" + do_install() { install -d ${D}/etc/init.d/