Skip to content
Snippets Groups Projects
Select Git revision
  • cdbba845bf712e98dc02e8ecfb5d8066fc708c13
  • master default protected
  • compilation2022apr
  • ISEI_3_5_1
  • VERSION_3_9-alba
  • VERSION_3_9-Indus2
  • Jianfeng
  • VERSION-3_10
  • VERSION-3_9_1
  • VERSION-3_9_alba
  • VERSION-3_9_Indus2
  • VERSION-3_9
  • VERSION-3_8
  • VERSION-3_7
  • ISEI_3_5_1-PATCH_2
  • ISEI_3_5_1-PATCH_1
  • PROD_3_5_1
  • VERSION_3_6prerelease2
  • VERSION_3_6prerelease
  • VERSION-3_5
  • tracy
21 results

multipole_soleil.dat

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    fofb-init.sh 4.87 KiB
    #!/bin/bash
    
    . /etc/init.d/functions
    
    PATH_CFG="/opt/fofb/cfg/"
    PATH_MAP="/opt/fofb/map/"
    PATH_MAPT="/usr/share/deviceaccess/map/"
    PATH_FPGABIN=${PATH_CFG}/fpga_bitstream.bin
    LOCK_FILE=/var/lock/subsys/fofb-init
    
    
    shopt -s expand_aliases
    alias log="logger -t \"fofb-fpgainit\""
    
    # Reading the configuration file
    CFG_FILE=${PATH_CFG}/configuration
    log "Reading configuration file ${CFG_FILE}"
    if [ ! -f ${CFG_FILE} ]; then
        log -p user.error "Configuration file not found: ${CFG_FILE}"
        exit 1
    fi
    source ${CFG_FILE}
    
    ########################################################################
    # Look for UIO devices, make special symbolic link for axiapp and ddr4
    link_uio_dev() {
        for uio in /sys/class/uio/*
        do
            name=$(cat ${uio}/name)
            uiobn=$(basename $uio)
            case $name in
                axiapp)
                    log "Installing link /dev/$name -> /dev/$uiobn"
                    ln -sf /dev/$uiobn /dev/$name
                    ;;
                ddr4)
                    log "Installing link /dev/$name -> /dev/$uiobn"
                    ln -sf /dev/$uiobn /dev/$name
                    ;;
                *)
                    ;;
            esac
        done
    }
    
    ########################################################################
    # Link the proper FPGA bitstream depending on the configuration variable FOFB_APP
    link_fpga_bitstream() {
        if [ -z FOFB_APP ]; then
            log -p user.error "Variable FOFB_APP not set in configuration file ${CFG_FILE}"
            exit 1
        fi
    
        PATH_TARGET=/lib/firmware/base/${FOFB_APP}/pl-full.bit.bin
    
        if [ ! -e $PATH_TARGET ]; then
            log -p user.error "Could not establish FOFB application"
            exit 1
        fi
    
        log "Linking FPGA bitstream ${PATH_TARGET}"
        ln -sf ${PATH_TARGET} ${PATH_FPGABIN}
    }
    
    ########################################################################
    # Link the proper MAPT file depending on FOFB_APP
    # Generate the DMAP file with correct UIO dev
    # Add LNM device if specified in FOFB_LNM
    link_mapt() {
        if [ -z FOFB_APP ]; then
            log -p user.error "Variable FOFB_APP not set in configuration file ${CFG_FILE}"
            exit 1
        fi
    
        LINK_TARGET="${PATH_MAPT}/${FOFB_APP}/${FOFB_APP}_ch8.mapt"
        if [ ! -f ${LINK_TARGET} ]; then
            log -p user.error "MAPT file not found: ${LINK_TARGET}"
            exit 1
        fi
    
        log "Linking map file ${LINK_TARGET}"
        ln -sf ${LINK_TARGET} ${PATH_MAP}/app.mapt
    
        log "Create dmap file to axi app UIO ${PATH_MAP}/appuio.dmap"
        echo "APPUIO (uio:$(basename $(readlink /dev/axiapp))?map=${PATH_MAP}/app.mapt)"  > ${PATH_MAP}/appuio.dmap
    
    }
    
    
    ########################################################################
    # Link the proper configuration register
    link_configuration() {
        if [ -z FOFB_CFG ]; then
            log -p user.error "Variable FOFB_CFG not set in configuration file ${CFG_FILE}"
            exit 1
        fi
    
        LINK_TARGET="${PATH_CFG}/${FOFB_CFG}_config_register"
        if [ ! -f ${LINK_TARGET} ]; then
            log -p user.error "Register Configuration file not found: ${LINK_TARGET}"
            exit 1
        fi
    
        log "Linking config_register file ${LINK_TARGET}"
        ln -sf ${LINK_TARGET} ${PATH_CFG}/config_register
    }
    
    ########################################################################
    # Write Bitstream
    # Reset PS
    # Apply register configuration
    fpga_reconfig() {
        log "Loading FPGA image ${PATH_FPGABIN}"
        fpgautil -b ${PATH_FPGABIN} |& log
    
        log "Reset the FPGA"
        /etc/init.d/fw_plreset.sh |& log
    
        # Applying configuration
        fofb-configurator --config ${PATH_CFG}/config_register --dmap ${PATH_MAP}/appuio.dmap |& log
    }
    
    ########################################################################
    ########################################################################
    ########################################################################
    # Daemon style handling
    
    reload() {
        if [ ! -f $LOCK_FILE ]; then
            echo "FOFB application not started, cannot reload"
            exit 1
        fi
    
        log "FOFB application: loading application"
        fpga_reconfig
        echo "started" > $LOCK_FILE
    }
    
    start() {
        if [ -f $LOCK_FILE ]; then
            echo "FOFB application already started, status: $(cat $LOCK_FILE)"
            exit 1
        fi
    
        log "FOFB application: linking configuration"
    
        link_uio_dev
        link_fpga_bitstream
        link_mapt
        link_configuration
    
        echo "configured" > $LOCK_FILE
    
        reload
    }
    
    stop() {
        log "FOFB application: (not really) stopping"
        rm -f $LOCK_FILE
    }
    
    status() {
        if [ -f $LOCK_FILE ]; then
            echo "fofb-opcua server status: $(cat $LOCK_FILE)"
        else
            echo "fofb-opcua server status: stopped"
        fi
    }
    
    ### main logic ###
    case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        status)
            status
            ;;
        reload)
            reload
            ;;
        restart|condrestart)
            stop
            start
            ;;
        *)
            echo $"Usage: $0 {start|stop|restart|reload|status}"
            exit 1
    esac
    
    
    
    exit 0