From c83a76065953e89ba9edcfbc593b4418eb6c9be2 Mon Sep 17 00:00:00 2001 From: acastellane Date: Tue, 9 Nov 2021 15:59:39 +0100 Subject: [PATCH 01/34] locking mechanism Signed-off-by: acastellane --- oc-reset.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/oc-reset.sh b/oc-reset.sh index 19ae2de..6805b9d 100755 --- a/oc-reset.sh +++ b/oc-reset.sh @@ -18,6 +18,7 @@ # get capi-utils root [ -h $0 ] && package_root=`ls -l "$0" |sed -e 's|.*-> ||'` || package_root="$0" package_root=$(dirname $package_root) +# echo "DEBUG : Package_root is : $package_root" source $package_root/oc-utils-common.sh program=`basename "$0"` @@ -139,27 +140,33 @@ if [ -n "$card" ]; then else select_cards - echo "card selected is : $c" + + # Convert the slot number into a 000x:00:00.0 slot number + card=$(printf '%.4x:00:00.0' "0x${c}") +fi + + + + echo "card selected is : $card" echo "Checking if card is locked" - LockDir="$LockDirPrefix$c" - # make LockDir if not presen +# echo "DEBUG : LockDirPrefix is $LockDirPrefix" + LockDir="$LockDirPrefix$card" +# echo "DEBUG : LockDir is $LockDir" + # make LockDir if not present # mutual exclusion if mkdir $LockDir 2>/dev/null; then echo "$LockDir created" - mylock=1 - else + trap 'rm -rf "$LockDir"' EXIT # This prepares a cleaning of the newly created dir + # when script will output + else echo printf "${bold}ERROR:${normal} $LockDir is already existing\n" printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" - exit 1 + exit 10 fi -trap 'if [ $mylock ]; then rm -rf "$LockDir" ;echo "$LockDir removed";fi' EXIT - # Convert the slot number into a 000x:00:00.0 slot number - card=$(printf '%.4x:00:00.0' "0x${c}") -fi reset_card $card factory "Resetting OpenCAPI Adapter $card" From 117d2e7cc2537f93f3e926f34dfeb7fd6d738ba0 Mon Sep 17 00:00:00 2001 From: acastellane Date: Fri, 12 Nov 2021 20:07:14 +0100 Subject: [PATCH 02/34] oc-flash lock mechanism Signed-off-by: acastellane --- oc-flash-script.sh | 86 ++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 829d449..984f53d 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -139,42 +139,6 @@ if [ $capi_check -eq 0 ]; then exit 1 fi -LockDir=/var/ocxl/oc-flash-script.lock - -# make cxl dir if not present -mkdir -p `dirname $LockDir` - -# mutual exclusion -if ! mkdir $LockDir 2>/dev/null; then - echo - printf "${bold}ERROR:${normal} Existing LOCK => Another instance of this script is maybe running\n" - - DateLastBoot=`who -b | awk '{print $3 " " $4}'` - EpochLastBoot=`date -d "$DateLastBoot" +%s` - - EpochLockDir=`stat --format=%Y $LockDir` - DateLockDir=`date --date @$EpochLockDir` - - echo - echo "Last BOOT: `date --date @$EpochLastBoot` ($EpochLastBoot)" - echo "Last LOCK modification: $DateLockDir ($EpochLockDir)" - - echo;echo "=======================================================" - if [ $EpochLockDir -lt $EpochLastBoot ]; then - echo "$LockDir modified BEFORE last boot" - echo "LOCK is not supposed to still be here" - echo " ==> Deleting and recreating $LockDir" - rmdir $LockDir - mkdir $LockDir - else - echo "$LockDir modified AFTER last boot" - printf "${bold}ERROR:${normal} Another instance of this script is running\n" - echo "Exiting..." - exit 1 - fi - -fi -trap 'rm -rf "$LockDir"' EXIT printf "\n" # get number of cards in system @@ -486,14 +450,61 @@ fi trap 'kill -TERM $PID; perst_factory $c' TERM INT # flash card with corresponding binary bdf=`echo ${allcards_array[$c]}` -#echo $bdf +echo "Entering card locking mechanism ..." + + +#LockDir=/var/ocxl/oc-flash-script.lock +LockDir="$LockDirPrefix$bdf" # taken from oc-utils-common.sh + +# make cxl dir if not present +# mkdir -p `dirname $LockDir` + +# mutual exclusion +if mkdir $LockDir 2>/dev/null; then + echo "$LockDir created" + trap 'rm -rf "$LockDir"' EXIT # This prepares a cleaning of the newly created dir + # when script will output + +else + printf "${bold}ERROR:${normal} Existing LOCK for card ${bdf} => Another instance of this script or oc-reset maybe running\n" + + DateLastBoot=`who -b | awk '{print $3 " " $4}'` + EpochLastBoot=`date -d "$DateLastBoot" +%s` + + EpochLockDir=`stat --format=%Y $LockDir` + DateLockDir=`date --date @$EpochLockDir` + + echo + echo "Last BOOT: `date --date @$EpochLastBoot` ($EpochLastBoot)" + echo "Last LOCK modification: $DateLockDir ($EpochLockDir)" + + echo;echo "=======================================================" + if [ $EpochLockDir -lt $EpochLastBoot ]; then + echo "$LockDir modified BEFORE last boot" + echo "LOCK is not supposed to still be here" + echo " ==> Deleting and recreating $LockDir" + rmdir $LockDir + mkdir $LockDir + else + echo "$LockDir modified AFTER last boot" + printf "${bold}ERROR:${normal} Another instance of this script or oc-reset is running\n" + echo "Exiting..." + exit 10 + fi + +fi + + + if [ $flash_type == "SPIx8" ]; then # SPIx8 needs two file inputs (primary/secondary) # $package_root/oc-flash --type $flash_type --file $1 --file2 $2 --card ${allcards_array[$c]} --address $flash_address --address2 $flash_address2 --blocksize $flash_block_size & # until multiboot is enabled, force writing to 0x0 $package_root/oc-flash --image_file1 $1 --image_file2 $2 --devicebdf $bdf --startaddr 0x0 + sleep 2 else $package_root/oc-flash --image_file1 $1 --devicebdf $bdf --startaddr 0x0 + sleep 2 fi PID=$! @@ -504,6 +515,7 @@ RC=$? if [ $RC -eq 0 ]; then if [ $PR_mode == 0 ]; then # reload code from Flash (oc-reload calls a oc_reset) + # As we call routines, not shells, we keep the current card LockDir printf "Auto reload the image from flash:\n" source $package_root/oc-reload.sh -C ${allcards_array[$c]} else From bff1abe04cc5519841ea3308689f4d0fd10ec376 Mon Sep 17 00:00:00 2001 From: acastellane Date: Fri, 12 Nov 2021 20:23:13 +0100 Subject: [PATCH 03/34] cosmetics Signed-off-by: acastellane --- oc-flash-script.sh | 2 -- oc-reset.sh | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 984f53d..8e5c94d 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -501,10 +501,8 @@ if [ $flash_type == "SPIx8" ]; then # $package_root/oc-flash --type $flash_type --file $1 --file2 $2 --card ${allcards_array[$c]} --address $flash_address --address2 $flash_address2 --blocksize $flash_block_size & # until multiboot is enabled, force writing to 0x0 $package_root/oc-flash --image_file1 $1 --image_file2 $2 --devicebdf $bdf --startaddr 0x0 - sleep 2 else $package_root/oc-flash --image_file1 $1 --devicebdf $bdf --startaddr 0x0 - sleep 2 fi PID=$! diff --git a/oc-reset.sh b/oc-reset.sh index 6805b9d..561c9b3 100755 --- a/oc-reset.sh +++ b/oc-reset.sh @@ -155,8 +155,8 @@ fi # make LockDir if not present # mutual exclusion if mkdir $LockDir 2>/dev/null; then - echo "$LockDir created" - trap 'rm -rf "$LockDir"' EXIT # This prepares a cleaning of the newly created dir + echo "$LockDir created during oc-reset" + trap 'rm -rf "$LockDir";echo "$LockDir removed"' EXIT # This prepares a cleaning of the newly created dir # when script will output else echo From 4bb104d270ee1628387feb8c241d767add415560 Mon Sep 17 00:00:00 2001 From: Alexandre CASTELLANE Date: Thu, 18 Nov 2021 11:36:40 +0100 Subject: [PATCH 04/34] Update oc-flash-script.sh --- oc-flash-script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 8e5c94d..5db6e92 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -462,8 +462,8 @@ LockDir="$LockDirPrefix$bdf" # taken from oc-utils-common.sh # mutual exclusion if mkdir $LockDir 2>/dev/null; then echo "$LockDir created" - trap 'rm -rf "$LockDir"' EXIT # This prepares a cleaning of the newly created dir - # when script will output + trap 'rm -rf "$LockDir";echo "$LockDir removed at the end of oc-flash-script"' EXIT # This prepares a cleaning of the newly created dir + # when script will output else printf "${bold}ERROR:${normal} Existing LOCK for card ${bdf} => Another instance of this script or oc-reset maybe running\n" From 285b3ab3e7d71f0de9062a27d895d82b7e4c619e Mon Sep 17 00:00:00 2001 From: Alexandre CASTELLANE Date: Thu, 18 Nov 2021 12:01:47 +0100 Subject: [PATCH 05/34] Updated oc-flash-script with lock mechanism --- oc-flash-script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 5db6e92..a2f26f3 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -16,7 +16,7 @@ # # Usage: sudo oc-flash-script.sh -tool_version=4.00 +tool_version=4.1 # Changes History # V2.0 code cleaning # V2.1 reduce lines printed to screen (elasped times) @@ -25,6 +25,7 @@ tool_version=4.00 # V2.31 repaired the 4 bytes mode for 9H3 # V3.00 reordering the slot numbering # V4.00 integrating the Partial reconfiguration +# V4.1 introducing a per card lock mechanism # get capi-utils root [ -h $0 ] && package_root=`ls -l "$0" |sed -e 's|.*-> ||'` || package_root="$0" From 128fb78d741499de6768c8b17f4d0392de9e92d5 Mon Sep 17 00:00:00 2001 From: Bruno Mesnet Date: Fri, 19 Nov 2021 15:50:21 +0100 Subject: [PATCH 06/34] adding colors + cleaning Signed-off-by: Bruno Mesnet --- oc-flash-script.sh | 125 ++++++++++++++++++++++++---------------- oc-reload.sh | 46 +++++++++++---- oc-reset.sh | 31 ++++++---- oc-utils-common.sh | 16 +++-- src/flsh_common_funcs.c | 4 +- src/flsh_main.c | 69 +++++++++++----------- src/img_reload.c | 2 +- 7 files changed, 181 insertions(+), 112 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index a2f26f3..6f6dd7e 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -32,13 +32,28 @@ tool_version=4.1 package_root=$(dirname $package_root) source $package_root/oc-utils-common.sh +bold=$(tput bold) +blue=$(tput setaf 4) +red=$(tput setaf 1) +green=$(tput setaf 2) +normal=$(tput sgr0) + printf "\n" -printf "===============================\n" -printf "== OpenCAPI programming tool ==\n" -printf "===============================\n" -echo oc-flash_script version is $tool_version +printf "oc-flash_script version is $tool_version\t - " printf "Tool compiled on: " ls -l $package_root/oc-flash|cut -d ' ' -f '6-8' +echo "_____________________________________________________________________${bold} ${green}" +echo " ____ _________ ____ ____ " +echo " / __ \____ ___ ____ / ____/ | / __ \/ _/ " +echo " / / / / __ \/ _ \/ __ \/ / / /| | / /_/ // / " +echo " / /_/ / /_/ / __/ / / / /___/ ___ |/ ____// / " +echo " \____/ .___/\___/_/ /_/\____/_/ |_/_/ /___/ ${blue}" +echo " ___ /_/ _ __ __" +echo " / _ \_______ ___ ____ ___ _ __ _ (_)__ ___ _ / /____ ___ / /" +echo " / ___/ __/ _ \/ _ '/ _ '/ ' \/ ' \/ / _ \/ _ '/ / __/ _ \/ _ \/ / " +echo "/_/ /_/ \___/\_, /\_,_/_/_/_/_/_/_/_/_//_/\_, / \__/\___/\___/_/ " +echo " /___/ /___/ ${normal}" +echo "_____________________________________________________________________" force=0 program=`basename "$0"` @@ -104,11 +119,11 @@ while getopts ":C:fVhr" opt; do exit 0 ;; \?) - printf "${bold}ERROR:${normal} Invalid option: -${OPTARG}\n" >&2 + printf "${bold}${red}ERROR:${normal} Invalid option: -${OPTARG}\n" >&2 exit 1 ;; :) - printf "${bold}ERROR:${normal} Option -$OPTARG requires an argument.\n" >&2 + printf "${bold}${red}ERROR:${normal} Option -$OPTARG requires an argument.\n" >&2 exit 1 ;; esac @@ -121,14 +136,14 @@ ulimit -c unlimited # make sure an input argument is provided if [ $# -eq 0 ]; then - printf "${bold}ERROR:${normal} Input argument missing\n" + printf "${bold}${red}ERROR:${normal} Input argument missing\n" usage exit 1 fi # make sure the input file exists if [[ ! -e $1 ]]; then - printf "${bold}ERROR:${normal} $1 not found\n" + printf "${bold}${red}ERROR:${normal} $1 not found\n" usage exit 1 fi @@ -136,7 +151,7 @@ fi # check if OpenCAPI boards exists capi_check=`ls /dev/ocxl 2>/dev/null | wc -l` if [ $capi_check -eq 0 ]; then - printf "${bold}ERROR:${normal} No OpenCAPI devices found\n" + printf "${bold}${red}ERROR:${normal} No OpenCAPI devices found\n" exit 1 fi @@ -144,7 +159,7 @@ fi printf "\n" # get number of cards in system n=`ls /dev/ocxl 2>/dev/null | wc -l` -printf "In this server: $n OpenCAPI card(s) found." +printf " In this server: ${bold}$n${normal} OpenCAPI card(s) found." # touch history files if not present for i in `seq 0 $(($n - 1))`; do f="/var/ocxl/card$i" @@ -154,11 +169,11 @@ for i in `seq 0 $(($n - 1))`; do done # print current date on server for comparison -printf "\n${bold}Current date is ${normal}$(date)\n\n" +printf "\n${bold} Current date is ${normal}$(date)\n\n" # print table header -printf "Following logs show last programming files (except if hardware or capi version has changed):\n" -printf "${bold}%-7s %-35s %-29s %-20s %s${normal}\n" "#" "Card slot and name" "Flashed" "by" +printf " Following logs show last programming files (except if hardware or capi version has changed):\n" +printf "${bold}%-7s %-35s %-29s %-20s %s${normal}\n" " #" "Card slot and name" "Flashed" "by" # Find all OC cards in the system allcards=`ls /dev/ocxl 2>/dev/null | awk -F"." '{ print $2 }' | sed s/$/.0/ | sort` if [ -z "$allcards" ]; then @@ -200,9 +215,13 @@ while read d ; do component_list=(${line:6:23}) bin_list=(${f:51}) #display Card number : slot - Card name - date -name of last programming registered in file - printf "%-8s %-22s %-29s %-20s \n" "Card $card_slot_hex: ${allcards_array[$i]}" "${component_list[0]}" "${f:0:29}" "${f:30:20}" + printf "${bold}%-8s${normal} %-22s %-29s %-20s \n" " Card $card_slot_hex: ${allcards_array[$i]}" "${component_list[0]}" "${f:0:29}" "${f:30:20}" #display the 2 names of bin files - printf "\t%s \n\t%s\n" "${bin_list[0]}" "${bin_list[1]}" + if [ ! -z ${bin_list[1]} ]; then + printf "\t%s \n\t%s\n" "${bin_list[0]}" "${bin_list[1]}" + else + printf "\t%s \n" "${bin_list[0]}" + fi echo "" fi done < "$package_root/oc-devices" @@ -236,13 +255,13 @@ if [ ! -z $paramcard ]; then else # prompt card to flash to # while true; do -# read -p "Which card do you want to flash? [0-$(($n - 1))] " c +# read -p " Which card do you want to flash? [0-$(($n - 1))] " c # if ! [[ $c =~ ^[0-9]+$ ]]; then -# printf "${bold}ERROR:${normal} Invalid input\n" +# printf "${bold}${red}ERROR:${normal} Invalid input\n" # else # c=$((10#$c)) # if (( "$c" >= "$n" )); then -# printf "${bold}ERROR:${normal} Wrong card number\n" +# printf "${bold}${red}ERROR:${normal} Wrong card number\n" # exit 1 # else # break @@ -253,13 +272,13 @@ else # prompt card until input is in list of available slots while ! [[ "$c" =~ ^($slot_enum)$ ]] do - echo -e "Which card number do you want to flash? [$slot_enum]: \c" | sed 's/|/-/g' + echo -e " ${green}Which card number do you want to flash? [${bold}$slot_enum${normal}]: \c" | sed 's/|/-/g' read -r c done printf "\n" card4=$(printf '%04x' "0x${c}") - echo "Slot is: $card4" + #echo "Slot is: $card4" # search for card4 occurence and get line number in list of slots ln=$(grep -n ${card4} <<<$allcards| cut -f1 -d:) c=$(($ln - 1)) @@ -273,16 +292,16 @@ PR_mode=0 FILE_EXT=${1##*.} if [[ ${fpga_manuf[$c]} == "Altera" ]]; then if [[ $FILE_EXT != "rbf" ]]; then - printf "${bold}ERROR: ${normal}Wrong file extension: .rbf must be used for boards with Altera FPGA\n" + printf "${bold}${red}ERROR: ${normal}Wrong file extension: .rbf must be used for boards with Altera FPGA\n" exit 0 fi elif [[ ${fpga_manuf[$c]} == "Xilinx" ]]; then if [[ $FILE_EXT != "bin" ]]; then - printf "${bold}ERROR: ${normal}Wrong file extension: .bin must be used for boards with Xilinx FPGA\n" + printf "${bold}${red}ERROR: ${normal}Wrong file extension: .bin must be used for boards with Xilinx FPGA\n" exit 0 fi else - printf "${bold}ERROR: ${normal}Card not listed in oc-devices or previous card failed or is not responding\n" + printf "${bold}${red}ERROR: ${normal}Card not listed in oc-devices or previous card failed or is not responding\n" exit 0 fi @@ -291,7 +310,7 @@ if [ -z "$flash_address" ]; then flash_address=${flash_partition[$c]} if [[ $1 =~ "_partial" ]] then - printf "Partial Reconfiguration mode detected.\n" + #printf "Partial Reconfiguration image has been detected.\n" PR_mode=1 fi else if [[ $1 =~ "fw_" ]] @@ -319,22 +338,23 @@ fi # Deal with the second argument if [ $flash_type == "SPIx8" ]; then if [ $# -eq 1 ]; then - printf "${bold}ERROR:${normal} Input argument missing. The selected device is SPIx8 and needs both primary and secondary bin files\n" + printf "${bold}${red}ERROR:${normal} Input argument missing for SPIx8 card (or bad card selected)\n" + printf " The device you have selected requires both primary and secondary bin files\n" bdf=`echo ${allcards_array[$c]}` - echo $bdf + #echo $bdf usage exit 1 fi #Check the second file if [[ ! -e $2 ]]; then - printf "${bold}ERROR:${normal} $2 not found\n" + printf "${bold}${red}ERROR:${normal} $2 not found\n" usage exit 1 fi #Assign secondary address flash_address2=${flash_secondary[$c]} if [ -z "$flash_address2" ]; then - printf "${bold}ERROR:${normal} The second address must be assigned in file oc-device\n" + printf "${bold}${red}ERROR:${normal} The second address must be assigned in file oc-device\n" exit 1 fi fi @@ -344,7 +364,8 @@ fi if (($force != 1)); then # prompt to confirm while true; do - printf "\n>>> REMINDER: It is MANDATORY to CLOSE all JTAG tools (SDK, hardware_manager) before starting programming.\n\n" + printf " ${bold}INFO:${normal} It is ${bold}highly recommended ${normal}to CLOSE all JTAG tools (SDK, hardware_manager) before programming\n"; + printf " This could create a conflict, lose access to the card and force you to reboot the server!\n\n"; #extract the card name of the input argument #file_to_program=`echo $1 |awk -F 'OC-' '{ print $2 }'|awk -F '_' '{ print $1 }'` @@ -352,24 +373,29 @@ if (($force != 1)); then #printf "The binary file you want to use is build for ${file_to_program}\n" #extract the name of the slot card_to_program=`echo ${board_vendor[$c]} |awk -F 'OC-' '{ print $2 }'|awk -F '(' '{ print $1 }'` - #printf "You have chosen to reprogram ${card_to_program}\n" + #printf " You have chosen to reprogram ${card_to_program}\n" - printf "You will flash the ${bold} ${card_to_program} board in slot $card4${normal} with:\n ${bold}$1${normal}\n" + if [ $PR_mode == 1 ]; then + printf " You have asked to ${bold}dynamically${normal} program the ${bold}${card_to_program}${normal} board in slot ${bold}$card4${normal} with :\n ${bold}$1${normal}\n" + else + printf " You have asked to ${bold}flash${normal} the ${bold}${card_to_program}${normal} board in slot ${bold}$card4${normal} with:\n ${bold}$1${normal}\n" + fi if [ $flash_type == "SPIx8" ]; then printf " and ${bold}$2${normal}\n" fi if [[ ${file_to_program} != ${card_to_program} ]]; then - printf "\n>>>========================================================================================================<<<\n" - printf ">>> WARNING: It sounds as if you have chosen to program a file built for a ${file_to_program} in the ${card_to_program} board!!\n" - printf ">>> You may crash and lose your card if you force the programming. Use '-f' option if you want to force it.\n" - printf ">>>========================================================================================================<<<\n" + printf "\n>>>=================================================================================<<<\n" + printf ">>> ${bold}${red}ERROR:${normal} You have chosen to program a ${bold}${card_to_program}${normal} board with a file built for a ${bold}${file_to_program}${normal}!!\n" + printf ">>> You may crash and lose your card if you force the programming.\n" + printf ">>> You can force at your own risks using the '-f' option.\n" + printf ">>>=================================================================================<<<\n" exit #else #printf "Binary filename you have provided correspond to the board you have chosen to program (${card_to_program})\n" fi - read -p "Do you want to continue? [y/n] " yn + read -p " ${green}Do you confirm? [${bold}y/n${normal}] " yn case $yn in [Yy]* ) break;; [Nn]* ) exit;; @@ -393,7 +419,7 @@ if [ $PR_mode == 1 ]; then #extract the card name of the input argument PRC_dynamic=`echo $1 |awk -F 'oc_20' '{ print $2 }' | awk -F '_PR' '{ print $2 }'|awk -F '_' '{ print $1 }'` if [ -z "$PRC_dynamic" ]; then - printf ">>> WARNING : NO dynamic PR Code in filename! <<<\n" + printf ">>> ${bold}WARNING :${normal} NO dynamic PR Code in filename! <<<\n" printf "Impossible to know if static and dynamic code match. You can continue at your own risk !\n" ask_if_like_risk=1 fi @@ -402,15 +428,16 @@ if [ $PR_mode == 1 ]; then PRC_static=`cat /var/ocxl/card$c | awk -F 'oc_20' '{ print $2 }' | awk -F '_PR' '{ print $2 }'|awk -F '_' '{ print $1 }'` #printf "From log flash file : $c ${p[$c]:0:6} $PRC_static\n" if [ -z "$PRC_static" ]; then - printf ">>> WARNING : NO static PR Code found in filename logged in Flash log files! <<<\n" + printf ">>> ${bold}WARNING :${normal} NO static PR Code found in filename logged in Flash log files! <<<\n" printf "Impossible to know if static and dynamic code match. You can continue at your own risk !\n" ask_if_like_risk=1 else if [ ${PRC_dynamic} != ${PRC_static} ]; then - printf ">>>=====================================================================================================<<<\n" - printf ">>> WARNING : Static code ${PRC_static} (flash log file) doesn't match with dynamic code ${PRC_dynamic} (your filename)!\n" - printf "You may crash and lose your card if you force the programming. Use '-f' option if you want to force it.\n" - printf ">>>=====================================================================================================<<<\n" + printf "\n>>>===================================================================================<<<\n" + printf ">>> ${bold}${red}ERROR :${normal} Static code ${bold}${PRC_static}${normal} (flash log file) doesn't match with dynamic code ${bold}${PRC_dynamic}${normal} (your filename)!\n" + printf ">>> You may crash and lose your card if you force the programming.\n" + printf ">>> You can force at your own risks using the '-f' option.\n" + printf ">>>===================================================================================<<<\n" ask_if_like_risk=1 exit else @@ -451,7 +478,7 @@ fi trap 'kill -TERM $PID; perst_factory $c' TERM INT # flash card with corresponding binary bdf=`echo ${allcards_array[$c]}` -echo "Entering card locking mechanism ..." +echo "${blue}Entering card locking mechanism ...${normal}" #LockDir=/var/ocxl/oc-flash-script.lock @@ -462,12 +489,12 @@ LockDir="$LockDirPrefix$bdf" # taken from oc-utils-common.sh # mutual exclusion if mkdir $LockDir 2>/dev/null; then - echo "$LockDir created" - trap 'rm -rf "$LockDir";echo "$LockDir removed at the end of oc-flash-script"' EXIT # This prepares a cleaning of the newly created dir + echo "${blue}$LockDir created${normal}" + trap 'rm -rf "$LockDir";echo "${blue}$LockDir removed at the end of oc-flash-script${normal}"' EXIT # This prepares a cleaning of the newly created dir # when script will output else - printf "${bold}ERROR:${normal} Existing LOCK for card ${bdf} => Another instance of this script or oc-reset maybe running\n" + printf "${bold}${red}ERROR:${normal} Existing LOCK for card ${bdf} => Another instance of this script or oc-reset maybe running\n" DateLastBoot=`who -b | awk '{print $3 " " $4}'` EpochLastBoot=`date -d "$DateLastBoot" +%s` @@ -488,7 +515,7 @@ else mkdir $LockDir else echo "$LockDir modified AFTER last boot" - printf "${bold}ERROR:${normal} Another instance of this script or oc-reset is running\n" + printf "${bold}${red}ERROR:${normal} Another instance of this script or oc-reset is running\n" echo "Exiting..." exit 10 fi @@ -515,10 +542,10 @@ if [ $RC -eq 0 ]; then if [ $PR_mode == 0 ]; then # reload code from Flash (oc-reload calls a oc_reset) # As we call routines, not shells, we keep the current card LockDir - printf "Auto reload the image from flash:\n" + printf " Auto reloading the image from flash.\n" source $package_root/oc-reload.sh -C ${allcards_array[$c]} else # In PR mode, reset cleans the logic but could be not mandatory - reset_card $bdf factory "Resetting OpenCAPI Adapter $bdf" + reset_card $bdf factory " Resetting OpenCAPI card in slot $bdf" fi fi diff --git a/oc-reload.sh b/oc-reload.sh index 1701e7a..a66a1a2 100755 --- a/oc-reload.sh +++ b/oc-reload.sh @@ -20,7 +20,14 @@ package_root=$(dirname $package_root) source $package_root/oc-utils-common.sh +bold=$(tput bold) +blue=$(tput setaf 4) +red=$(tput setaf 1) +green=$(tput setaf 2) +normal=$(tput sgr0) + program=`basename "$0"` +mylock=0 # var used to remove lock dir only if we created it # Print usage message helper function function usage() { @@ -49,7 +56,7 @@ function select_cards() { # get number of cards in system n=`ls /dev/ocxl 2>/dev/null | wc -l` - printf "$n OpenCAPI cards found.\n" + printf "${bold} $n OpenCAPI cards found.${normal}\n" # Find all OC cards in the system allcards=`ls /dev/ocxl 2>/dev/null | awk -F"." '{ print $2 }' | sed s/$/.0/ | sort` @@ -75,7 +82,7 @@ function select_cards() { if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then parse_info=($line) board_vendor[$i]=${parse_info[1]} - printf "%-8s %-30s %-20s \n" "Card $card_slot_hex: ${allcards_array[$i]} - ${board_vendor[$i]}" + printf "%-8s %-30s %-20s \n" "${bold}Card $card_slot_hex${normal}: ${allcards_array[$i]} - ${board_vendor[$i]}" fi done < "$package_root/oc-devices" i=$[$i+1] @@ -85,7 +92,7 @@ function select_cards() { # prompt card until input is not in list of available slots while ! [[ "$c" =~ ^($slot_enum)$ ]] do - echo -e "Which card number do you want to reload FPGA code from Flash and reset? [$slot_enum]: \c" | sed 's/|/-/g' + echo -e "${green} From which card number do you want to reload the Flash code? [${bold}$slot_enum]: ${normal}\c" | sed 's/|/-/g' read -r c done printf "\n" @@ -142,26 +149,45 @@ else card=$(printf '%.4x:00:00.0' "0x${c}") fi + #echo "card selected is : $card" + echo "${blue}Checking if card $card is locked${normal}" +# echo "DEBUG : LockDirPrefix is $LockDirPrefix" + LockDir="$LockDirPrefix$card" +# echo "DEBUG : LockDir is $LockDir" + # make LockDir if not present + # mutual exclusion + if mkdir $LockDir 2>/dev/null; then + echo "${blue}$LockDir created during oc-reset${normal}" + trap 'rm -rf "$LockDir";echo "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir + # when script will output + else + echo + printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" + printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" + exit 10 + fi + + + subsys=$(cat /sys/bus/pci/devices/${card}/subsystem_device) # adding specific code for 250SOC card (subsystem_id = 0x066A, former id was 0x060d for old cards) - -#if [ $subsys == "0x066a" ]; then if [[ $subsys = @("0x066a"|"0x060d") ]]; then - printf "Warning - known issue on 250SOC reload - you may need to reboot the server\n" - reload_card $card factory "Image Reloading for OpenCAPI Adapter $card (250SOC)" + printf " ${red}${bold}Warning:${normal}There is still a known issue on the 250SOC reload:\n" + printf " You may need to reboot the server to reload the code just programmed in Flash.\n\n" + reload_card $card factory " Reloading code from Flash for the OpenCAPI card in slot $card" #otherwise use the src/img_reload.c compiled code else start=`date +%s` - $package_root/oc-reload --devicebdf $card --startaddr 0x0 "Image Reloading for OpenCAPI Adapter $card (new images)" + $package_root/oc-reload --devicebdf $card --startaddr 0x0 " Reloading code from Flash for the OpenCAPI card in slot $card (new images)" end=`date +%s` runtime=$((end-start)) # in oc-reload we wait for 1 sec to see if EOS is set to 1, if not then a timeout occurs if [ $runtime -ge 1 ]; then #echo "reload with the reload_card function (old image detected)" - reload_card $card factory "Image Reloading for OpenCAPI Adapter $card" + reload_card $card factory " Reloading code from Flash for the OpenCAPI card in slot $card" else - reset_card $card factory "Resetting OpenCAPI Adapter $card" + reset_card $card factory " Resetting card $card after Image Reloading" fi fi diff --git a/oc-reset.sh b/oc-reset.sh index 561c9b3..df8c30e 100755 --- a/oc-reset.sh +++ b/oc-reset.sh @@ -21,6 +21,13 @@ package_root=$(dirname $package_root) # echo "DEBUG : Package_root is : $package_root" source $package_root/oc-utils-common.sh +bold=$(tput bold) +italic=$(tput sitm) +blue=$(tput setaf 4) +red=$(tput setaf 1) +green=$(tput setaf 2) +normal=$(tput sgr0) + program=`basename "$0"` mylock=0 # var used to remove lock dir only if we created it @@ -52,7 +59,7 @@ function select_cards() { # get number of cards in system n=`ls /dev/ocxl 2>/dev/null | wc -l` - printf "$n OpenCAPI cards found.\n" + printf "${bold} $n OpenCAPI cards found.${normal}\n" # Find all OC cards in the system allcards=`ls /dev/ocxl 2>/dev/null | awk -F"." '{ print $2 }' | sed s/$/.0/ | sort` @@ -78,7 +85,7 @@ function select_cards() { if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then parse_info=($line) board_vendor[$i]=${parse_info[1]} - printf "%-8s %-30s %-20s \n" "Card $card_slot_hex: ${allcards_array[$i]} - ${board_vendor[$i]}" + printf "%-8s %-30s %-20s \n" "${bold}Card $card_slot_hex:${normal} ${allcards_array[$i]} - ${board_vendor[$i]}" fi done < "$package_root/oc-devices" i=$[$i+1] @@ -88,7 +95,7 @@ function select_cards() { # prompt card until input is in list of available slots while ! [[ "$c" =~ ^($slot_enum)$ ]] do - echo -e "Which card number do you want to reset? [$slot_enum]: \c" | sed 's/|/-/g' + echo -e " ${green}Which card number do you want to reset? [${bold}$slot_enum${normal}]: \c" | sed 's/|/-/g' read -r c done printf "\n" @@ -110,11 +117,11 @@ while getopts ":C:Vh" opt; do exit 0 ;; \?) - printf "${bold}ERROR:${normal} Invalid option: -${OPTARG}\n" >&2 + printf "${bold}${red}ERROR:${normal} Invalid option: -${OPTARG}\n" >&2 exit 1 ;; :) - printf "${bold}ERROR:${normal} Option -$OPTARG requires an argument.\n" >&2 + printf "${bold}${red}ERROR:${normal} Option -$OPTARG requires an argument.\n" >&2 exit 1 ;; esac @@ -128,7 +135,7 @@ ulimit -c unlimited # we get number of cards in system ocapi_check=`ls /dev/ocxl 2>/dev/null | wc -l` if [ $ocapi_check -eq 0 ]; then - printf "${bold}ERROR:${normal} No OpenCAPI devices found\n" + printf "${bold}${red}ERROR:${normal} No OpenCAPI devices found\n" exit 1 fi @@ -147,20 +154,20 @@ fi - echo "card selected is : $card" - echo "Checking if card is locked" + #echo "card selected is : $card" + echo "${blue}Checking if card $card is locked${normal}" # echo "DEBUG : LockDirPrefix is $LockDirPrefix" LockDir="$LockDirPrefix$card" # echo "DEBUG : LockDir is $LockDir" # make LockDir if not present # mutual exclusion if mkdir $LockDir 2>/dev/null; then - echo "$LockDir created during oc-reset" - trap 'rm -rf "$LockDir";echo "$LockDir removed"' EXIT # This prepares a cleaning of the newly created dir + echo "${blue}$LockDir created during oc-reset${normal}" + trap 'rm -rf "$LockDir";echo "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir # when script will output else echo - printf "${bold}ERROR:${normal} $LockDir is already existing\n" + printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" exit 10 fi @@ -168,5 +175,5 @@ fi -reset_card $card factory "Resetting OpenCAPI Adapter $card" +reset_card $card factory " Resetting OpenCAPI card in slot $card" diff --git a/oc-utils-common.sh b/oc-utils-common.sh index 4e5680b..36fc38a 100755 --- a/oc-utils-common.sh +++ b/oc-utils-common.sh @@ -17,7 +17,13 @@ version=1.1 # revision 1.1 adds a check for lock file per card to avoid resetting a card under programmation log_file=/var/log/capi-utils.log -LockDirPrefix=/var/ocxl/locked_card +LockDirPrefix=/var/ocxl/locked_card_ + +bold=$(tput bold) +blue=$(tput setaf 4) +red=$(tput setaf 1) +green=$(tput setaf 2) +normal=$(tput sgr0) # Reset a card function reset_card() { @@ -48,7 +54,7 @@ function reset_card() { [ -n "$3" ] && printf "$3\n" || printf "Preparing to reset card\n" [ -n "$4" ] && reset_timeout=$4 - printf "Resetting card $1: Reset! \n" + #printf " Resetting card $1: Reset! \n" printf 0 > /sys/bus/pci/slots/$slot/power printf 1 > /sys/bus/pci/slots/$slot/power while true; do @@ -69,7 +75,7 @@ function reset_card() { if [ $ret_status -ne 0 ]; then exit 1 else - printf "Reset complete\n" + printf "${green}Reset completed.${normal}\n" fi } @@ -105,7 +111,7 @@ function reload_card() { # added by collin for image_reload # tuned for the new slot naming scheme setpci -s `cat /sys/bus/pci/slots/$slot/address`.0 638.B=01 - printf "Resetting card $1: Image Reloading ... \n" + printf " Resetting card $1 after Image Reloading \n" # subsys=$(lspci -s `cat /sys/bus/pci/slots/JP91NVB1/address`.0 -vvv |grep Subsystem |awk '{ print $NF }') subsys=$(lspci -s `cat /sys/bus/pci/slots/$slot/address`.0 -vvv |grep Subsystem |awk '{ print $NF }') @@ -145,7 +151,7 @@ function reload_card() { if [ $ret_status -ne 0 ]; then exit 1 else - printf "Image Reload complete\n" + printf "${green}Image Reload ${bold}completed.${normal}\n" fi } diff --git a/src/flsh_common_funcs.c b/src/flsh_common_funcs.c index d3f3a27..6b414ce 100644 --- a/src/flsh_common_funcs.c +++ b/src/flsh_common_funcs.c @@ -2172,10 +2172,10 @@ void fw_Page_Program(u32 devsel, u32 addr, int num_bytes, byte *wary) // 3 byt // End of test check void Check_Accumulated_Errors(void) // Check Global error flag to determine if test passed or failed { if (ERRORS_DETECTED == 0) - { printf("\n\nCheck_Accumulated_Errors: PASS (no errors detected)\n\n"); + { printf(" No error detected.\n"); return; } else - { printf("\n\nCheck_Accumulated_Errors: #### FAIL #### (%d errors detected)\n\n", ERRORS_DETECTED); + { printf("Check_Accumulated_Errors: #### FAIL #### (%d errors detected)\n", ERRORS_DETECTED); return; // main() only allows value of 0 or 1 as return values } } diff --git a/src/flsh_main.c b/src/flsh_main.c index 9cce3c3..5dad005 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -37,10 +37,9 @@ // extern void CFG_NOP2(const char*, int, int, int*); #endif - extern void my_test(); int update_image(u32 devsel,char binfile[1024], char cfgbdf[1024], int start_addr, int verbose_flag); -int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr); +int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr, int verbose_flag); int main(int argc, char *argv[]) { @@ -175,7 +174,7 @@ int main(int argc, char *argv[]) printf("Verbose in use\n"); if(dualspi_mode_flag) { - printf("Using spi x8 mode\n"); + printf(" Using spi x8 mode\n"); if(binfile[0] == '\0') { printf("ERROR: Must supply primary bitstream\n"); exit(-1); @@ -213,9 +212,9 @@ int main(int argc, char *argv[]) //adding specific code for 250SOC card (subsystem_id = 0x066A) printf("----------------------------------\n"); printf("Card with ZynqMP Detected\n"); - printf("Programming Flash with bitstream:\n %s\n",binfile); - update_image_zynqmp(binfile,cfgbdf,start_addr); - printf("Finished Programming Sequence\n"); + printf("Programming Flash with bitstream:\n %s\n\n",binfile); + update_image_zynqmp(binfile,cfgbdf,start_addr, verbose_flag); + printf("\033[1mFinished Programming Sequence\033[0m\n"); printf("----------------------------------\n"); @@ -271,18 +270,19 @@ int main(int argc, char *argv[]) num_package_lastburst = num_package_icap - num_burst * icap_burst_size; if(verbose_flag) { - printf("Flashing PR bit file of size %ld bytes. Total package: %d. \n",fsize, num_package_icap); - printf("Total burst to transfer: %d with burst size of %d. Number of package is last burst: %d.\n", + printf(" Flashing PR bit file of size %ld bytes. Total package: %d. \n",fsize, num_package_icap); + printf(" Total burst to transfer: %d with burst size of %d. Number of package is last burst: %d.\n", num_burst, icap_burst_size, num_package_lastburst); } spt = time(NULL); int print_done = 0; + printf("___________________________________________________________________________\n"); for(i=0;i 1){ percentage = (int)(i*100/num_256B_pages); if( ((percentage %5) == 0) && (prev_percentage != percentage)) { - printf("Writing image code : %d %% of %d pages \r", percentage , num_256B_pages);} + printf("\033[1m Writing\033[0m image code : \033[1m%d\033[0m %% of %d pages \r", percentage , num_256B_pages);} prev_percentage = percentage; } else { - printf("Waiting for card acknowledgement (can take up to a minute!) \r"); + printf("Waiting for card acknowledgement (\033[1mPlease be patient. It can take up to a minute!)\033[0m \r"); } ack_status = axi_read_zynq(FA_QSPI, ack_addr, FA_EXP_OFF, FA_EXP_0123, ""); @@ -639,19 +642,19 @@ int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr) } } - printf("Writing image code Completed (%d pages written) \n", num_256B_pages); + printf(" Writing image code \033[1mcompleted\033[0m \n"); axi_write_zynq(FA_QSPI, ack_addr , FA_EXP_OFF, FA_EXP_0123, 0x000000FF, ""); //printf("Number of writes in decimal: %d\n", write_count); write_count = 0; config_write(0x638, 0x00000000, 4, ""); - printf("Done copying image from DDR to flash \n"); + printf("Copying image from DDR to flash \033[1mcompleted\033[0m\n"); evt = time(NULL); et = evt - set; - printf("Total Time: %d seconds\n\n", (int)et); + printf("\033[1m Total Time: %d seconds\033[0m\n\n", (int)et); close(BIN); return 0; diff --git a/src/img_reload.c b/src/img_reload.c index a73e2a9..3d99c78 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -182,7 +182,7 @@ int main(int argc, char *argv[]) //============================================== // This sequence is using the reload writing to the HWICAP (and not the iprog_icap) printf("\n----------------------------------\n"); - printf("Reloading card in slot %s\n", cfgbdf); + printf(" Reloading code from Flash for the card in slot %s\n", cfgbdf); rdata = 0; while ((u32)rdata != (u32)SR_ICAPEn_EOS) { From fe2acd5d9d0130e57a0315d56315f6902b377bbe Mon Sep 17 00:00:00 2001 From: Bruno Mesnet Date: Fri, 19 Nov 2021 17:03:43 +0100 Subject: [PATCH 07/34] adding colors + cleaning Signed-off-by: Bruno Mesnet --- oc-flash-script.sh | 2 +- oc-reload.sh | 17 ++++++++++++----- src/flsh_main.c | 8 ++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 6f6dd7e..9ab064a 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -543,7 +543,7 @@ if [ $RC -eq 0 ]; then # reload code from Flash (oc-reload calls a oc_reset) # As we call routines, not shells, we keep the current card LockDir printf " Auto reloading the image from flash.\n" - source $package_root/oc-reload.sh -C ${allcards_array[$c]} + source $package_root/oc-reload.sh -L -C ${allcards_array[$c]} else # In PR mode, reset cleans the logic but could be not mandatory reset_card $bdf factory " Resetting OpenCAPI card in slot $bdf" diff --git a/oc-reload.sh b/oc-reload.sh index a66a1a2..68436a3 100755 --- a/oc-reload.sh +++ b/oc-reload.sh @@ -42,6 +42,7 @@ function usage() { echo " Or:" echo -e " \033[33m sudo ./oc-reload.sh -C 4 \033[0m" echo " [-V] Print program version (${version})" + echo " [-L] Force No Lock" echo " [-h] Print this help message." echo echo "Utility to reload FPGA image from the FPGA Flash." @@ -101,9 +102,10 @@ function select_cards() { # OPTIND Reset done in order to use getopts even if not the first time getopts is called (when sourcing this script by oc-flash-script.sh for example) OPTIND=1 +NO_LOCK=0 # Parse any options given on the command line -while getopts ":C:Vh" opt; do +while getopts ":C:VhL" opt; do case ${opt} in C) card=$OPTARG @@ -116,6 +118,9 @@ while getopts ":C:Vh" opt; do usage; exit 0 ;; + L) + NO_LOCK=1 + ;; \?) printf "${bold}ERROR:${normal} Invalid option: -${OPTARG}\n" >&2 exit 1 @@ -161,10 +166,12 @@ fi trap 'rm -rf "$LockDir";echo "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir # when script will output else - echo - printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" - printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" - exit 10 + if [ $NO_LOCK -eq 0 ]; then + echo + printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" + printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" + exit 10 + fi fi diff --git a/src/flsh_main.c b/src/flsh_main.c index 5dad005..fd781a6 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -462,7 +462,7 @@ int update_image(u32 devsel,char binfile[1024], char cfgbdf[1024], int start_add for(i=0;i Date: Mon, 22 Nov 2021 12:01:40 +0100 Subject: [PATCH 08/34] adapt colors to jenkins OS Signed-off-by: Bruno Mesnet --- oc-reload.sh | 30 ++++++++++++++++-------------- oc-reset.sh | 27 +++++++++++++-------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/oc-reload.sh b/oc-reload.sh index 68436a3..0160930 100755 --- a/oc-reload.sh +++ b/oc-reload.sh @@ -20,11 +20,12 @@ package_root=$(dirname $package_root) source $package_root/oc-utils-common.sh -bold=$(tput bold) -blue=$(tput setaf 4) -red=$(tput setaf 1) -green=$(tput setaf 2) -normal=$(tput sgr0) +bold=\\033[1m +green=\\033[32m +blue=\\033[34m +red=\\033[31m +normal=\\033[0m + program=`basename "$0"` mylock=0 # var used to remove lock dir only if we created it @@ -34,13 +35,13 @@ function usage() { echo "Usage: sudo ${program} [OPTIONS]" echo " [-C ] card to reload." echo " Example: if you want to reload card" - echo -e " \033[33m IBM,oc-snap.0004:00:00.1.0 \033[0m" + echo -e " ${green} IBM,oc-snap.0004:00:00.1.0 ${normal}" echo " Command line should be:" - echo -e " \033[33m sudo ./oc-reload.sh -C IBM,oc-snap.0004:00:00.1.0 \033[0m" + echo -e " ${green} sudo ./oc-reload.sh -C IBM,oc-snap.0004:00:00.1.0 ${normal}" echo " Or:" - echo -e " \033[33m sudo ./oc-reload.sh -C 0004:00:00.0 \033[0m" + echo -e " ${green} sudo ./oc-reload.sh -C 0004:00:00.0 ${normal}" echo " Or:" - echo -e " \033[33m sudo ./oc-reload.sh -C 4 \033[0m" + echo -e " ${green} sudo ./oc-reload.sh -C 4 ${normal}" echo " [-V] Print program version (${version})" echo " [-L] Force No Lock" echo " [-h] Print this help message." @@ -83,7 +84,8 @@ function select_cards() { if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then parse_info=($line) board_vendor[$i]=${parse_info[1]} - printf "%-8s %-30s %-20s \n" "${bold}Card $card_slot_hex${normal}: ${allcards_array[$i]} - ${board_vendor[$i]}" + #printf "%-8s %-30s %-20s \n" "${bold}Card $card_slot_hex${normal}: ${allcards_array[$i]} - ${board_vendor[$i]}" + printf "${bold} Card%s:${normal} %s - %s \n" "$card_slot_hex" "${allcards_array[$i]}" "${board_vendor[$i]}" fi done < "$package_root/oc-devices" i=$[$i+1] @@ -155,15 +157,15 @@ else fi #echo "card selected is : $card" - echo "${blue}Checking if card $card is locked${normal}" + echo -e "${blue}Checking if card $card is locked${normal}" # echo "DEBUG : LockDirPrefix is $LockDirPrefix" LockDir="$LockDirPrefix$card" # echo "DEBUG : LockDir is $LockDir" # make LockDir if not present # mutual exclusion if mkdir $LockDir 2>/dev/null; then - echo "${blue}$LockDir created during oc-reset${normal}" - trap 'rm -rf "$LockDir";echo "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir + echo -e "${blue}$LockDir created during oc-reset${normal}" + trap 'rm -rf "$LockDir";echo -e "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir # when script will output else if [ $NO_LOCK -eq 0 ]; then @@ -179,7 +181,7 @@ fi subsys=$(cat /sys/bus/pci/devices/${card}/subsystem_device) # adding specific code for 250SOC card (subsystem_id = 0x066A, former id was 0x060d for old cards) if [[ $subsys = @("0x066a"|"0x060d") ]]; then - printf " ${red}${bold}Warning:${normal}There is still a known issue on the 250SOC reload:\n" + printf " ${red}Warning:${normal}There is still a known issue on the 250SOC reload:\n" printf " You may need to reboot the server to reload the code just programmed in Flash.\n\n" reload_card $card factory " Reloading code from Flash for the OpenCAPI card in slot $card" diff --git a/oc-reset.sh b/oc-reset.sh index df8c30e..bc64aa5 100755 --- a/oc-reset.sh +++ b/oc-reset.sh @@ -21,12 +21,11 @@ package_root=$(dirname $package_root) # echo "DEBUG : Package_root is : $package_root" source $package_root/oc-utils-common.sh -bold=$(tput bold) -italic=$(tput sitm) -blue=$(tput setaf 4) -red=$(tput setaf 1) -green=$(tput setaf 2) -normal=$(tput sgr0) +bold=\\033[1m +green=\\033[32m +blue=\\033[34m +red=\\033[31m +normal=\\033[0m program=`basename "$0"` mylock=0 # var used to remove lock dir only if we created it @@ -36,13 +35,13 @@ function usage() { echo "Usage: sudo ${program} [OPTIONS]" echo " [-C ] card to reset." echo " Example: if you want to reset card" - echo -e " \033[33m IBM,oc-snap.0004:00:00.1.0 \033[0m" + echo -e " ${green} IBM,oc-snap.0004:00:00.1.0 ${normal}" echo " Command line should be:" - echo -e " \033[33m sudo ./oc-reset.sh -C IBM,oc-snap.0004:00:00.1.0 \033[0m" + echo -e " ${green}sudo ./oc-reset.sh -C IBM,oc-snap.0004:00:00.1.0 ${normal}" echo " Or:" - echo -e " \033[33m sudo ./oc-reset.sh -C 0004:00:00.0 \033[0m" + echo -e " ${green}sudo ./oc-reset.sh -C 0004:00:00.0 ${normal}" echo " Or:" - echo -e " \033[33m sudo ./oc-reset.sh -C 4 \033[0m" + echo -e " ${green}sudo ./oc-reset.sh -C 4 ${normal}" echo " [-V] Print program version (${version})" echo " [-h] Print this help message." echo @@ -85,7 +84,7 @@ function select_cards() { if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then parse_info=($line) board_vendor[$i]=${parse_info[1]} - printf "%-8s %-30s %-20s \n" "${bold}Card $card_slot_hex:${normal} ${allcards_array[$i]} - ${board_vendor[$i]}" + printf "${bold} Card%s:${normal} %s - %s \n" "$card_slot_hex" "${allcards_array[$i]}" "${board_vendor[$i]}" fi done < "$package_root/oc-devices" i=$[$i+1] @@ -155,15 +154,15 @@ fi #echo "card selected is : $card" - echo "${blue}Checking if card $card is locked${normal}" + echo -e "${blue}Checking if card $card is locked${normal}" # echo "DEBUG : LockDirPrefix is $LockDirPrefix" LockDir="$LockDirPrefix$card" # echo "DEBUG : LockDir is $LockDir" # make LockDir if not present # mutual exclusion if mkdir $LockDir 2>/dev/null; then - echo "${blue}$LockDir created during oc-reset${normal}" - trap 'rm -rf "$LockDir";echo "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir + echo -e "${blue}$LockDir created during oc-reset${normal}" + trap 'rm -rf "$LockDir";echo -e "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir # when script will output else echo From 958cf963be37e6c1eacaa85fe2babb2d9b33e67a Mon Sep 17 00:00:00 2001 From: Bruno Mesnet Date: Mon, 22 Nov 2021 12:15:02 +0100 Subject: [PATCH 09/34] adapt colors to jenkins OS Signed-off-by: Bruno Mesnet --- oc-reload.sh | 3 +-- oc-reset.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/oc-reload.sh b/oc-reload.sh index 0160930..751c760 100755 --- a/oc-reload.sh +++ b/oc-reload.sh @@ -84,8 +84,7 @@ function select_cards() { if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then parse_info=($line) board_vendor[$i]=${parse_info[1]} - #printf "%-8s %-30s %-20s \n" "${bold}Card $card_slot_hex${normal}: ${allcards_array[$i]} - ${board_vendor[$i]}" - printf "${bold} Card%s:${normal} %s - %s \n" "$card_slot_hex" "${allcards_array[$i]}" "${board_vendor[$i]}" + printf "${bold} Card %s:${normal} %s - %s \n" "$card_slot_hex" "${allcards_array[$i]}" "${board_vendor[$i]}" fi done < "$package_root/oc-devices" i=$[$i+1] diff --git a/oc-reset.sh b/oc-reset.sh index bc64aa5..5d1f100 100755 --- a/oc-reset.sh +++ b/oc-reset.sh @@ -84,7 +84,7 @@ function select_cards() { if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then parse_info=($line) board_vendor[$i]=${parse_info[1]} - printf "${bold} Card%s:${normal} %s - %s \n" "$card_slot_hex" "${allcards_array[$i]}" "${board_vendor[$i]}" + printf "${bold} Card %s:${normal} %s - %s \n" "$card_slot_hex" "${allcards_array[$i]}" "${board_vendor[$i]}" fi done < "$package_root/oc-devices" i=$[$i+1] From 3ffb4aafc8ce8a73f0c6d06f6f22a090680826fa Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 24 Nov 2021 15:05:39 +0100 Subject: [PATCH 10/34] oc-flash-script.sh: only working with cards available in /dev/ocxl Signed-off-by: fmoyen --- oc-flash-script.sh | 55 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 9ab064a..6a9fe1b 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -184,17 +184,18 @@ fi allcards_array=($allcards) # print card information and flash history -i=0; - slot_enum="" - delimiter="|" +i=0 +len=${#allcards_array[@]} +slot_enum="" +delimiter="|" # Collecting informations from oc-devices file #list of ".1" slots returned by lspci containing "062b" -while read d ; do - #extract the subsystem_device id to know the board id +while [ $i -lt $len ] ; do + #extract the subsystem_device id to know the board id p[$i]=$(cat /sys/bus/pci/devices/${allcards_array[$i]}/subsystem_device) # translate the slot number string to a hexa number - card_slot_hex=$(printf '%x' "0x${allcards_array[$i]::-8}") + card_slot_hex=$(printf '%x' "0x${allcards_array[$i]::-8}") # build a slot_enum of all card numbers and use it in the test menu to test user input if [ -z "$slot_enum" ]; then slot_enum=$card_slot_hex @@ -203,30 +204,30 @@ while read d ; do fi f=$(cat /var/ocxl/card$i) - while IFS='' read -r line || [[ -n $line ]]; do - if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then - parse_info=($line) - board_vendor[$i]=${parse_info[1]} - fpga_manuf[$i]=${parse_info[2]} - flash_partition[$i]=${parse_info[3]} - flash_block[$i]=${parse_info[4]} - flash_interface[$i]=${parse_info[5]} - flash_secondary[$i]=${parse_info[6]} - component_list=(${line:6:23}) - bin_list=(${f:51}) - #display Card number : slot - Card name - date -name of last programming registered in file - printf "${bold}%-8s${normal} %-22s %-29s %-20s \n" " Card $card_slot_hex: ${allcards_array[$i]}" "${component_list[0]}" "${f:0:29}" "${f:30:20}" - #display the 2 names of bin files + while IFS='' read -r line || [[ -n $line ]]; do + if [[ ${line:0:6} == ${p[$i]:0:6} ]]; then + parse_info=($line) + board_vendor[$i]=${parse_info[1]} + fpga_manuf[$i]=${parse_info[2]} + flash_partition[$i]=${parse_info[3]} + flash_block[$i]=${parse_info[4]} + flash_interface[$i]=${parse_info[5]} + flash_secondary[$i]=${parse_info[6]} + component_list=(${line:6:23}) + bin_list=(${f:51}) + #display Card number : slot - Card name - date -name of last programming registered in file + printf "${bold}%-8s${normal} %-22s %-29s %-20s \n" " Card $card_slot_hex: ${allcards_array[$i]}" "${component_list[0]}" "${f:0:29}" "${f:30:20}" + #display the 2 names of bin files if [ ! -z ${bin_list[1]} ]; then - printf "\t%s \n\t%s\n" "${bin_list[0]}" "${bin_list[1]}" + printf "\t%s \n\t%s\n" "${bin_list[0]}" "${bin_list[1]}" else - printf "\t%s \n" "${bin_list[0]}" + printf "\t%s \n" "${bin_list[0]}" fi - echo "" - fi - done < "$package_root/oc-devices" - i=$[$i+1] -done < <( lspci -d "1014":"062b" -s .1 ) + echo "" + fi + done < "$package_root/oc-devices" + i=$[$i+1] +done printf "\n" # card is set via parameter since it is positive (otherwise default to -1) From caf555e4a93f3358b4991c5c748f0973da6fed94 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 24 Nov 2021 15:57:44 +0100 Subject: [PATCH 11/34] mkdir -p /var/ocxl --- oc-flash-script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 6a9fe1b..e9debd4 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -161,6 +161,7 @@ printf "\n" n=`ls /dev/ocxl 2>/dev/null | wc -l` printf " In this server: ${bold}$n${normal} OpenCAPI card(s) found." # touch history files if not present +mkdir -p /var/ocxl for i in `seq 0 $(($n - 1))`; do f="/var/ocxl/card$i" if [[ ! -f $f ]]; then From da9214d4871b3fea7fe8854117c58020ef94d02f Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 24 Nov 2021 16:25:09 +0100 Subject: [PATCH 12/34] Just an information display --- oc-flash-script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index e9debd4..699fa10 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -219,6 +219,8 @@ while [ $i -lt $len ] ; do #display Card number : slot - Card name - date -name of last programming registered in file printf "${bold}%-8s${normal} %-22s %-29s %-20s \n" " Card $card_slot_hex: ${allcards_array[$i]}" "${component_list[0]}" "${f:0:29}" "${f:30:20}" #display the 2 names of bin files + echo + echo "Following are the provided binary files you'd like to flash:" if [ ! -z ${bin_list[1]} ]; then printf "\t%s \n\t%s\n" "${bin_list[0]}" "${bin_list[1]}" else From 776917a722ffab17cabbdb90371cc774f9370211 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 24 Nov 2021 17:14:07 +0100 Subject: [PATCH 13/34] Solved logname issue when container --- oc-flash-script.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 699fa10..e483a17 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -219,13 +219,11 @@ while [ $i -lt $len ] ; do #display Card number : slot - Card name - date -name of last programming registered in file printf "${bold}%-8s${normal} %-22s %-29s %-20s \n" " Card $card_slot_hex: ${allcards_array[$i]}" "${component_list[0]}" "${f:0:29}" "${f:30:20}" #display the 2 names of bin files - echo - echo "Following are the provided binary files you'd like to flash:" - if [ ! -z ${bin_list[1]} ]; then - printf "\t%s \n\t%s\n" "${bin_list[0]}" "${bin_list[1]}" - else - printf "\t%s \n" "${bin_list[0]}" - fi + #if [ ! -z ${bin_list[1]} ]; then + # printf "\t%s \n\t%s\n" "${bin_list[0]}" "${bin_list[1]}" + #else + # printf "\t%s \n" "${bin_list[0]}" + #fi echo "" fi done < "$package_root/oc-devices" @@ -463,10 +461,12 @@ fi #======================= # update flash history file +WhoIAm=$(logname 2>/dev/null) +if [ "$WhoIAm" == ""]; then WhoIAm="no_login_name"; fi if [ $flash_type == "SPIx8" ]; then - printf "%-29s %-20s %s %s\n" "$(date)" "$(logname)" $1 $2 > /var/ocxl/card$c + printf "%-29s %-20s %s %s\n" "$(date)" "$WhoIAm" $1 $2 > /var/ocxl/card$c else - printf "%-29s %-20s %s\n" "$(date)" "$(logname)" $1 > /var/ocxl/card$c + printf "%-29s %-20s %s\n" "$(date)" "$WhoIAm" $1 > /var/ocxl/card$c fi # Check if lowlevel flash utility is existing and executable if [ ! -x $package_root/oc-flash ]; then From 47849df7f88b5f1910cdec808e2cd7a9b2d34a27 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 24 Nov 2021 17:39:09 +0100 Subject: [PATCH 14/34] Typo --- oc-flash-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index e483a17..0e9581b 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -462,7 +462,7 @@ fi # update flash history file WhoIAm=$(logname 2>/dev/null) -if [ "$WhoIAm" == ""]; then WhoIAm="no_login_name"; fi +if [ "$WhoIAm" == "" ]; then WhoIAm="no_login_name"; fi if [ $flash_type == "SPIx8" ]; then printf "%-29s %-20s %s %s\n" "$(date)" "$WhoIAm" $1 $2 > /var/ocxl/card$c else From dea540cceaba3624834901d473309b3c5af7f71c Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 24 Nov 2021 18:25:53 +0100 Subject: [PATCH 15/34] Solving a logname command issue --- oc-flash-script.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/oc-flash-script.sh b/oc-flash-script.sh index 0e9581b..2a50a9c 100755 --- a/oc-flash-script.sh +++ b/oc-flash-script.sh @@ -461,12 +461,19 @@ fi #======================= # update flash history file -WhoIAm=$(logname 2>/dev/null) -if [ "$WhoIAm" == "" ]; then WhoIAm="no_login_name"; fi +# Note: logname command allocated to a variable like in a="$(logname)" makes this specific script just stop ! That's why the "if logname" below if [ $flash_type == "SPIx8" ]; then - printf "%-29s %-20s %s %s\n" "$(date)" "$WhoIAm" $1 $2 > /var/ocxl/card$c + if logname >/dev/null 2>&1; then # logname in a container returns nothing and fails + printf "%-29s %-20s %s %s\n" "$(date)" "$(logname)" $1 $2 > /var/ocxl/card$c + else + printf "%-29s %-20s %s %s\n" "$(date)" "no_login" $1 $2 > /var/ocxl/card$c + fi else - printf "%-29s %-20s %s\n" "$(date)" "$WhoIAm" $1 > /var/ocxl/card$c + if logname >/dev/null 2>&1; then # logname in a container returns nothing and fails + printf "%-29s %-20s %s\n" "$(date)" "$(logname)" $1 > /var/ocxl/card$c + else + printf "%-29s %-20s %s\n" "$(date)" "no_login" $1 > /var/ocxl/card$c + fi fi # Check if lowlevel flash utility is existing and executable if [ ! -x $package_root/oc-flash ]; then From 7842b262b180da6b44777624c90ace7a4ace8783 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Thu, 25 Nov 2021 15:27:17 +0100 Subject: [PATCH 16/34] Test to access config file under /OCXLSysBus --- src/flsh_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index fd781a6..a6315b6 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -127,7 +127,8 @@ int main(int argc, char *argv[]) u32 temp; int vendor,device, subsys; int BIN,i, j; - strcpy(cfg_file,"/sys/bus/pci/devices/"); + //strcpy(cfg_file,"/sys/bus/pci/devices/"); + strcpy(cfg_file,"/OCXLSysBus/"); strcat(cfg_file,cfgbdf); strcat(cfg_file,"/config"); From 9d3a2b053f347fd3993543ee786e1ceb49448b47 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Fri, 26 Nov 2021 16:21:29 +0100 Subject: [PATCH 17/34] /OCXLSysBus when /sys/bus/pci/ write is requested --- oc-utils-common.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/oc-utils-common.sh b/oc-utils-common.sh index 36fc38a..ff58fc1 100755 --- a/oc-utils-common.sh +++ b/oc-utils-common.sh @@ -55,8 +55,10 @@ function reset_card() { [ -n "$3" ] && printf "$3\n" || printf "Preparing to reset card\n" [ -n "$4" ] && reset_timeout=$4 #printf " Resetting card $1: Reset! \n" - printf 0 > /sys/bus/pci/slots/$slot/power - printf 1 > /sys/bus/pci/slots/$slot/power + #printf 0 > /sys/bus/pci/slots/$slot/power + #printf 1 > /sys/bus/pci/slots/$slot/power + printf 0 > /OCXLSysBus/slots/$slot/power + printf 1 > /OCXLSysBus/slots/$slot/power while true; do if [[ `ls /dev/ocxl 2>/dev/null | wc -l` == "$n" ]]; then break @@ -121,14 +123,14 @@ function reload_card() { # Unbinding to prevent driver to access the card before power down # TO DO : need to look for all existing /sys/bus/pci/slots/$slot/address`.X entries # for the time beiing we consider only 2 entries as implemented in https://github.com/OpenCAPI/OpenCAPI3.0_Client_RefDesign/ - echo `cat /sys/bus/pci/slots/$slot/address`.0 > /sys/bus/pci/drivers/ocxl/unbind - echo `cat /sys/bus/pci/slots/$slot/address`.1 > /sys/bus/pci/drivers/ocxl/unbind + echo `cat /sys/bus/pci/slots/$slot/address`.0 > /OCXLSysBus/drivers/ocxl/unbind + echo `cat /sys/bus/pci/slots/$slot/address`.1 > /OCXLSysBus/drivers/ocxl/unbind setpci -s `cat /sys/bus/pci/slots/$slot/address`.0 634.B=11 setpci -s `cat /sys/bus/pci/slots/$slot/address`.0 630.L=00020000 fi - printf 0 > /sys/bus/pci/slots/$slot/power - if ! printf 1 > /sys/bus/pci/slots/$slot/power 2> /dev/null + printf 0 > /OCXLSysBus/slots/$slot/power + if ! printf 1 > /OCXLSysBus/slots/$slot/power 2> /dev/null then echo ">> Card can not power-on. Reboot or power-cycle needed for re-enumeration" exit 1 From 92f96ffe25bc3d7e814499232cc2b1315cb8c29b Mon Sep 17 00:00:00 2001 From: fmoyen Date: Fri, 26 Nov 2021 16:41:40 +0100 Subject: [PATCH 18/34] OCXLSysBus/devices now --- src/flsh_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index a6315b6..05bb420 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) int vendor,device, subsys; int BIN,i, j; //strcpy(cfg_file,"/sys/bus/pci/devices/"); - strcpy(cfg_file,"/OCXLSysBus/"); + strcpy(cfg_file,"/OCXLSysBus/devices"); strcat(cfg_file,cfgbdf); strcat(cfg_file,"/config"); From 5b1c2b4fb7c72cc891b0052a927eaef61310b721 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Tue, 30 Nov 2021 11:36:17 +0100 Subject: [PATCH 19/34] Typo --- src/flsh_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index 05bb420..5116db5 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) int vendor,device, subsys; int BIN,i, j; //strcpy(cfg_file,"/sys/bus/pci/devices/"); - strcpy(cfg_file,"/OCXLSysBus/devices"); + strcpy(cfg_file,"/OCXLSysBus/devices/"); strcat(cfg_file,cfgbdf); strcat(cfg_file,"/config"); From f80cee386304c6a47d9478b4946cf2285eeb2dd2 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Tue, 30 Nov 2021 15:34:07 +0100 Subject: [PATCH 20/34] OCXLSysBus replaced by OCXLSys/bus/pci --- oc-utils-common.sh | 12 ++++++------ src/flsh_main.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/oc-utils-common.sh b/oc-utils-common.sh index ff58fc1..1c7053f 100755 --- a/oc-utils-common.sh +++ b/oc-utils-common.sh @@ -57,8 +57,8 @@ function reset_card() { #printf " Resetting card $1: Reset! \n" #printf 0 > /sys/bus/pci/slots/$slot/power #printf 1 > /sys/bus/pci/slots/$slot/power - printf 0 > /OCXLSysBus/slots/$slot/power - printf 1 > /OCXLSysBus/slots/$slot/power + printf 0 > /OCXLSys/bus/pci/slots/$slot/power + printf 1 > /OCXLSys/bus/pci/slots/$slot/power while true; do if [[ `ls /dev/ocxl 2>/dev/null | wc -l` == "$n" ]]; then break @@ -123,14 +123,14 @@ function reload_card() { # Unbinding to prevent driver to access the card before power down # TO DO : need to look for all existing /sys/bus/pci/slots/$slot/address`.X entries # for the time beiing we consider only 2 entries as implemented in https://github.com/OpenCAPI/OpenCAPI3.0_Client_RefDesign/ - echo `cat /sys/bus/pci/slots/$slot/address`.0 > /OCXLSysBus/drivers/ocxl/unbind - echo `cat /sys/bus/pci/slots/$slot/address`.1 > /OCXLSysBus/drivers/ocxl/unbind + echo `cat /sys/bus/pci/slots/$slot/address`.0 > /OCXLSys/bus/pci/drivers/ocxl/unbind + echo `cat /sys/bus/pci/slots/$slot/address`.1 > /OCXLSys/bus/pci/drivers/ocxl/unbind setpci -s `cat /sys/bus/pci/slots/$slot/address`.0 634.B=11 setpci -s `cat /sys/bus/pci/slots/$slot/address`.0 630.L=00020000 fi - printf 0 > /OCXLSysBus/slots/$slot/power - if ! printf 1 > /OCXLSysBus/slots/$slot/power 2> /dev/null + printf 0 > /OCXLSys/bus/pci/slots/$slot/power + if ! printf 1 > /OCXLSys/bus/pci/slots/$slot/power 2> /dev/null then echo ">> Card can not power-on. Reboot or power-cycle needed for re-enumeration" exit 1 diff --git a/src/flsh_main.c b/src/flsh_main.c index 5116db5..30d0ecf 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) int vendor,device, subsys; int BIN,i, j; //strcpy(cfg_file,"/sys/bus/pci/devices/"); - strcpy(cfg_file,"/OCXLSysBus/devices/"); + strcpy(cfg_file,"/OCXLSys/bus/pci/devices/"); strcat(cfg_file,cfgbdf); strcat(cfg_file,"/config"); From 489205742b079a6637fe9813839e3194015a8b43 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 1 Dec 2021 09:43:48 +0100 Subject: [PATCH 21/34] Switching verbose flag to 1 --- src/flsh_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index 30d0ecf..e4f1cbe 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -43,7 +43,7 @@ int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr, i int main(int argc, char *argv[]) { - static int verbose_flag = 0; + static int verbose_flag = 1; static int dualspi_mode_flag = 1; //default to assume x8 spi programming/loading static struct option long_options[] = { From 621ea9ee3c1b4ab9eaa587c72b0a0517d4f015b9 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 1 Dec 2021 14:03:54 +0100 Subject: [PATCH 22/34] TRC_AXI=TRC_ON --- src/flsh_global_vars.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_global_vars.c b/src/flsh_global_vars.c index 9534445..f972910 100644 --- a/src/flsh_global_vars.c +++ b/src/flsh_global_vars.c @@ -21,7 +21,7 @@ // Variables to control trace printing, one for each level of functionality. int TRC_CONFIG = TRC_OFF; // Show config_write / config_read commands -int TRC_AXI = TRC_OFF; // Show axi_write / axi_read commands +int TRC_AXI = TRC_ON; // Show axi_write / axi_read commands int TRC_FLASH = TRC_OFF; // Show flash_op commands int TRC_FLASH_CMD = TRC_OFF; // Print msg on commands to FLASH facilities From 03299d91c9bdd33ed299361eb2f696b6f350110c Mon Sep 17 00:00:00 2001 From: fmoyen Date: Wed, 1 Dec 2021 16:59:40 +0100 Subject: [PATCH 23/34] flsh_main.c: removed forced TRC_AXI=TRC_OFF --- src/flsh_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index e4f1cbe..e73b4a9 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) } TRC_FLASH_CMD = TRC_OFF; - TRC_AXI = TRC_OFF; + //TRC_AXI = TRC_OFF; TRC_CONFIG = TRC_OFF; temp = config_read(CFG_SUBSYS,"Read subsys id of card"); From 32ebc281c94741b6e81fe4b3a4ff2ead58707bba Mon Sep 17 00:00:00 2001 From: fmoyen Date: Thu, 2 Dec 2021 10:59:21 +0100 Subject: [PATCH 24/34] Modification of LockDir mechanism --- oc-reload.sh | 41 ++++++++++++++++++++--------------------- oc-reset.sh | 36 ++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/oc-reload.sh b/oc-reload.sh index 751c760..5c24aff 100755 --- a/oc-reload.sh +++ b/oc-reload.sh @@ -155,27 +155,26 @@ else card=$(printf '%.4x:00:00.0' "0x${c}") fi - #echo "card selected is : $card" - echo -e "${blue}Checking if card $card is locked${normal}" -# echo "DEBUG : LockDirPrefix is $LockDirPrefix" - LockDir="$LockDirPrefix$card" -# echo "DEBUG : LockDir is $LockDir" - # make LockDir if not present - # mutual exclusion - if mkdir $LockDir 2>/dev/null; then - echo -e "${blue}$LockDir created during oc-reset${normal}" - trap 'rm -rf "$LockDir";echo -e "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir - # when script will output - else - if [ $NO_LOCK -eq 0 ]; then - echo - printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" - printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" - exit 10 - fi - fi - - +#echo "card selected is : $card" + +if [ $NO_LOCK -eq 0 ]; then + echo -e "${blue}Checking if card $card is locked${normal}" + LockDir="$LockDirPrefix$card" + + # First, create the dirname of $LockDir (typically /var/ocxl) in case it is not yet existing ("mkdir -p" always successful even if dir already exists) + mkdir -p `dirname $LockDir` + + # Second, trying to create $LockDir locking directory (typically into /var/ocxl) and testing if the creation succeeded ("mkdir" fails if dir already exists) + if mkdir $LockDir 2>/dev/null; then + echo -e "${blue}$LockDir created during oc-reload${normal}" + trap 'rm -rf "$LockDir";echo -e "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning action of the newly created dir when script exits + else + echo + printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" + printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" + exit 10 + fi +fi subsys=$(cat /sys/bus/pci/devices/${card}/subsystem_device) # adding specific code for 250SOC card (subsystem_id = 0x066A, former id was 0x060d for old cards) diff --git a/oc-reset.sh b/oc-reset.sh index 5d1f100..d525bde 100755 --- a/oc-reset.sh +++ b/oc-reset.sh @@ -151,28 +151,24 @@ else card=$(printf '%.4x:00:00.0' "0x${c}") fi - - #echo "card selected is : $card" - echo -e "${blue}Checking if card $card is locked${normal}" -# echo "DEBUG : LockDirPrefix is $LockDirPrefix" - LockDir="$LockDirPrefix$card" -# echo "DEBUG : LockDir is $LockDir" - # make LockDir if not present - # mutual exclusion - if mkdir $LockDir 2>/dev/null; then - echo -e "${blue}$LockDir created during oc-reset${normal}" - trap 'rm -rf "$LockDir";echo -e "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning of the newly created dir - # when script will output - else - echo - printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" - printf " => Card has been locked already (by oc-flash-script or oc-reset)\n" - exit 10 - fi - - +echo -e "${blue}Checking if card $card is locked${normal}" +LockDir="$LockDirPrefix$card" + +# First, create the dirname of $LockDir (typically /var/ocxl) in case it is not yet existing ("mkdir -p" always successful even if dir already exists) +mkdir -p `dirname $LockDir` + +# Second, trying to create $LockDir locking directory (typically into /var/ocxl) and testing if the creation succeeded ("mkdir" fails if dir already exists) +if mkdir $LockDir 2>/dev/null; then + echo -e "${blue}$LockDir created during oc-reset${normal}" + trap 'rm -rf "$LockDir";echo -e "${blue}$LockDir removed${normal}"' EXIT # This prepares a cleaning action of the newly created dir when script exits +else + echo + printf "${bold}${red}ERROR:${normal} $LockDir is already existing\n" + printf " => Card has been locked already (by oc-flash-script or oc-reload)\n" + exit 10 +fi reset_card $card factory " Resetting OpenCAPI card in slot $card" From 70b5e62af8ca0c9458f1d00d55834e25cb8cba0a Mon Sep 17 00:00:00 2001 From: fmoyen Date: Thu, 2 Dec 2021 11:22:39 +0100 Subject: [PATCH 25/34] Replacing "/sys" by "/OCXLSys" for testing purpose --- src/flsh_main.c | 6 ++++-- src/img_reload.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index e73b4a9..1b8b8b6 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -417,7 +417,8 @@ int update_image(u32 devsel,char binfile[1024], char cfgbdf[1024], int start_add exit(-1); } - strcpy(cfg_file, "/sys/bus/pci/devices/"); + //strcpy(cfg_file, "/sys/bus/pci/devices/"); + strcpy(cfg_file, "/OCXLSys/bus/pci/devices/"); strcat(cfg_file, cfgbdf); strcat(cfg_file, "/config"); @@ -560,7 +561,8 @@ int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr, i exit(-1); } - strcpy(cfg_file, "/sys/bus/pci/devices/"); + //strcpy(cfg_file, "/sys/bus/pci/devices/"); + strcpy(cfg_file, "/OCXLSys/bus/pci/devices/"); strcat(cfg_file, cfgbdf); strcat(cfg_file, "/config"); diff --git a/src/img_reload.c b/src/img_reload.c index 3d99c78..672f4e1 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -119,7 +119,8 @@ int main(int argc, char *argv[]) u32 temp; int vendor,device, subsys; int BIN,i, j; - strcpy(cfg_file,"/sys/bus/pci/devices/"); + //strcpy(cfg_file,"/sys/bus/pci/devices/"); + strcpy(cfg_file,"/OCXLSys/bus/pci/devices/"); strcat(cfg_file,cfgbdf); strcat(cfg_file,"/config"); From 1bf60588fa8c1da4b5224c6cd924ca1351dbcbe3 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Thu, 2 Dec 2021 14:57:59 +0100 Subject: [PATCH 26/34] Bypassing axi_read which hangs in order to debug --- src/img_reload.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/img_reload.c b/src/img_reload.c index 672f4e1..d0843ec 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -161,11 +161,12 @@ int main(int argc, char *argv[]) if(verbose_flag) printf("Waiting for ICAP EOS set \e[1A\n"); - while ((rdata != SR_ICAPEn_EOS) && (timeout < 1)) { - rdata = axi_read(FA_ICAP, FA_ICAP_SR , FA_EXP_OFF, FA_EXP_0123, "ICAP: read SR (monitor ICAPEn)"); - time(¤t_time); - timeout = (int)difftime(current_time, start_time); - } +// FAB: this while hangs. So bypassing it to get the read_*_regs just after + //while ((rdata != SR_ICAPEn_EOS) && (timeout < 1)) { + // rdata = axi_read(FA_ICAP, FA_ICAP_SR , FA_EXP_OFF, FA_EXP_0123, "ICAP: read SR (monitor ICAPEn)"); + // time(¤t_time); + // timeout = (int)difftime(current_time, start_time); + //} // timeout can occur for old images, then use the old reload from oc-utils-common.sh if(timeout >= 1) { //printf("Timeout! EOS cannot be set \n"); @@ -179,6 +180,7 @@ int main(int argc, char *argv[]) if(verbose_flag) { read_QSPI_regs(); read_ICAP_regs(); + read_FPGA_IDCODE(); } //============================================== // This sequence is using the reload writing to the HWICAP (and not the iprog_icap) From e0e2fc1a5c06b566c1521bfcd5a2ae4fc4d2a2be Mon Sep 17 00:00:00 2001 From: fmoyen Date: Mon, 6 Dec 2021 15:26:31 +0100 Subject: [PATCH 27/34] int TRC_AXI = TRC_OFF; --- src/flsh_global_vars.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_global_vars.c b/src/flsh_global_vars.c index f972910..9534445 100644 --- a/src/flsh_global_vars.c +++ b/src/flsh_global_vars.c @@ -21,7 +21,7 @@ // Variables to control trace printing, one for each level of functionality. int TRC_CONFIG = TRC_OFF; // Show config_write / config_read commands -int TRC_AXI = TRC_ON; // Show axi_write / axi_read commands +int TRC_AXI = TRC_OFF; // Show axi_write / axi_read commands int TRC_FLASH = TRC_OFF; // Show flash_op commands int TRC_FLASH_CMD = TRC_OFF; // Print msg on commands to FLASH facilities From a89e94582bbd027ba2427430618a1fc294c60b36 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Mon, 6 Dec 2021 15:45:56 +0100 Subject: [PATCH 28/34] uncomment the while axi_read I commented for debug --- src/img_reload.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/img_reload.c b/src/img_reload.c index d0843ec..4e2b634 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -161,12 +161,12 @@ int main(int argc, char *argv[]) if(verbose_flag) printf("Waiting for ICAP EOS set \e[1A\n"); -// FAB: this while hangs. So bypassing it to get the read_*_regs just after - //while ((rdata != SR_ICAPEn_EOS) && (timeout < 1)) { - // rdata = axi_read(FA_ICAP, FA_ICAP_SR , FA_EXP_OFF, FA_EXP_0123, "ICAP: read SR (monitor ICAPEn)"); - // time(¤t_time); - // timeout = (int)difftime(current_time, start_time); - //} + + while ((rdata != SR_ICAPEn_EOS) && (timeout < 1)) { + rdata = axi_read(FA_ICAP, FA_ICAP_SR , FA_EXP_OFF, FA_EXP_0123, "ICAP: read SR (monitor ICAPEn)"); + time(¤t_time); + timeout = (int)difftime(current_time, start_time); + } // timeout can occur for old images, then use the old reload from oc-utils-common.sh if(timeout >= 1) { //printf("Timeout! EOS cannot be set \n"); From fb156bc8824fbdf5d88b1a3a8e6e6e5e9ed7f161 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Mon, 6 Dec 2021 16:09:46 +0100 Subject: [PATCH 29/34] verbose_flag=0 --- src/flsh_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index 1b8b8b6..e1bcffc 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -43,7 +43,7 @@ int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr, i int main(int argc, char *argv[]) { - static int verbose_flag = 1; + static int verbose_flag = 0; static int dualspi_mode_flag = 1; //default to assume x8 spi programming/loading static struct option long_options[] = { From 6e2688350f973174fb25adb3e6c025c889dfe4b1 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Thu, 9 Dec 2021 10:20:28 +0100 Subject: [PATCH 30/34] Switching /OCXLSys to /sys (to test mount on /sys) --- oc-utils-common.sh | 20 ++++++++++++-------- src/flsh_main.c | 12 ++++++------ src/img_reload.c | 4 ++-- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/oc-utils-common.sh b/oc-utils-common.sh index 1c7053f..b003276 100755 --- a/oc-utils-common.sh +++ b/oc-utils-common.sh @@ -55,10 +55,10 @@ function reset_card() { [ -n "$3" ] && printf "$3\n" || printf "Preparing to reset card\n" [ -n "$4" ] && reset_timeout=$4 #printf " Resetting card $1: Reset! \n" - #printf 0 > /sys/bus/pci/slots/$slot/power - #printf 1 > /sys/bus/pci/slots/$slot/power - printf 0 > /OCXLSys/bus/pci/slots/$slot/power - printf 1 > /OCXLSys/bus/pci/slots/$slot/power + printf 0 > /sys/bus/pci/slots/$slot/power + printf 1 > /sys/bus/pci/slots/$slot/power + #printf 0 > /OCXLSys/bus/pci/slots/$slot/power + #printf 1 > /OCXLSys/bus/pci/slots/$slot/power while true; do if [[ `ls /dev/ocxl 2>/dev/null | wc -l` == "$n" ]]; then break @@ -123,14 +123,18 @@ function reload_card() { # Unbinding to prevent driver to access the card before power down # TO DO : need to look for all existing /sys/bus/pci/slots/$slot/address`.X entries # for the time beiing we consider only 2 entries as implemented in https://github.com/OpenCAPI/OpenCAPI3.0_Client_RefDesign/ - echo `cat /sys/bus/pci/slots/$slot/address`.0 > /OCXLSys/bus/pci/drivers/ocxl/unbind - echo `cat /sys/bus/pci/slots/$slot/address`.1 > /OCXLSys/bus/pci/drivers/ocxl/unbind + echo `cat /sys/bus/pci/slots/$slot/address`.0 > /sys/bus/pci/drivers/ocxl/unbind + echo `cat /sys/bus/pci/slots/$slot/address`.1 > /sys/bus/pci/drivers/ocxl/unbind + #echo `cat /sys/bus/pci/slots/$slot/address`.0 > /OCXLSys/bus/pci/drivers/ocxl/unbind + #echo `cat /sys/bus/pci/slots/$slot/address`.1 > /OCXLSys/bus/pci/drivers/ocxl/unbind setpci -s `cat /sys/bus/pci/slots/$slot/address`.0 634.B=11 setpci -s `cat /sys/bus/pci/slots/$slot/address`.0 630.L=00020000 fi - printf 0 > /OCXLSys/bus/pci/slots/$slot/power - if ! printf 1 > /OCXLSys/bus/pci/slots/$slot/power 2> /dev/null + printf 0 > /sys/bus/pci/slots/$slot/power + #printf 0 > /OCXLSys/bus/pci/slots/$slot/power + if ! printf 1 > /sys/bus/pci/slots/$slot/power 2> /dev/null + #if ! printf 1 > /OCXLSys/bus/pci/slots/$slot/power 2> /dev/null then echo ">> Card can not power-on. Reboot or power-cycle needed for re-enumeration" exit 1 diff --git a/src/flsh_main.c b/src/flsh_main.c index e1bcffc..27e4507 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -127,8 +127,8 @@ int main(int argc, char *argv[]) u32 temp; int vendor,device, subsys; int BIN,i, j; - //strcpy(cfg_file,"/sys/bus/pci/devices/"); - strcpy(cfg_file,"/OCXLSys/bus/pci/devices/"); + strcpy(cfg_file,"/sys/bus/pci/devices/"); + //strcpy(cfg_file,"/OCXLSys/bus/pci/devices/"); strcat(cfg_file,cfgbdf); strcat(cfg_file,"/config"); @@ -417,8 +417,8 @@ int update_image(u32 devsel,char binfile[1024], char cfgbdf[1024], int start_add exit(-1); } - //strcpy(cfg_file, "/sys/bus/pci/devices/"); - strcpy(cfg_file, "/OCXLSys/bus/pci/devices/"); + strcpy(cfg_file, "/sys/bus/pci/devices/"); + //strcpy(cfg_file, "/OCXLSys/bus/pci/devices/"); strcat(cfg_file, cfgbdf); strcat(cfg_file, "/config"); @@ -561,8 +561,8 @@ int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr, i exit(-1); } - //strcpy(cfg_file, "/sys/bus/pci/devices/"); - strcpy(cfg_file, "/OCXLSys/bus/pci/devices/"); + strcpy(cfg_file, "/sys/bus/pci/devices/"); + //strcpy(cfg_file, "/OCXLSys/bus/pci/devices/"); strcat(cfg_file, cfgbdf); strcat(cfg_file, "/config"); diff --git a/src/img_reload.c b/src/img_reload.c index 4e2b634..145e575 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -119,8 +119,8 @@ int main(int argc, char *argv[]) u32 temp; int vendor,device, subsys; int BIN,i, j; - //strcpy(cfg_file,"/sys/bus/pci/devices/"); - strcpy(cfg_file,"/OCXLSys/bus/pci/devices/"); + strcpy(cfg_file,"/sys/bus/pci/devices/"); + //strcpy(cfg_file,"/OCXLSys/bus/pci/devices/"); strcat(cfg_file,cfgbdf); strcat(cfg_file,"/config"); From 15f57345c9baa1a3167797573f99d0f9cd3ec65b Mon Sep 17 00:00:00 2001 From: fmoyen Date: Fri, 10 Dec 2021 13:50:39 +0100 Subject: [PATCH 31/34] verbose_flag=1 --- src/flsh_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flsh_main.c b/src/flsh_main.c index 27e4507..a1257ef 100644 --- a/src/flsh_main.c +++ b/src/flsh_main.c @@ -43,7 +43,7 @@ int update_image_zynqmp(char binfile[1024], char cfgbdf[1024], int start_addr, i int main(int argc, char *argv[]) { - static int verbose_flag = 0; + static int verbose_flag = 1; static int dualspi_mode_flag = 1; //default to assume x8 spi programming/loading static struct option long_options[] = { From abbea03b0fbba0bf963c4160b5b7a0d0bfead373 Mon Sep 17 00:00:00 2001 From: fmoyen Date: Fri, 10 Dec 2021 14:04:57 +0100 Subject: [PATCH 32/34] img_reload: verbose_flag=1 --- src/img_reload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/img_reload.c b/src/img_reload.c index 145e575..9b07e7d 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { - static int verbose_flag = 0; + static int verbose_flag = 1; static int dualspi_mode_flag = 1; //default to assume x8 spi programming/loading static struct option long_options[] = { From 9839b32eb8d17a999b95d73cdab471805f01177e Mon Sep 17 00:00:00 2001 From: fmoyen Date: Fri, 10 Dec 2021 14:20:37 +0100 Subject: [PATCH 33/34] Bypassing axi_read which hangs in order to debug --- src/img_reload.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/img_reload.c b/src/img_reload.c index 9b07e7d..c08dfba 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -161,12 +161,12 @@ int main(int argc, char *argv[]) if(verbose_flag) printf("Waiting for ICAP EOS set \e[1A\n"); - - while ((rdata != SR_ICAPEn_EOS) && (timeout < 1)) { - rdata = axi_read(FA_ICAP, FA_ICAP_SR , FA_EXP_OFF, FA_EXP_0123, "ICAP: read SR (monitor ICAPEn)"); - time(¤t_time); - timeout = (int)difftime(current_time, start_time); - } +// FAB: this while hangs. So bypassing it to get the read_*_regs just after +// while ((rdata != SR_ICAPEn_EOS) && (timeout < 1)) { +// rdata = axi_read(FA_ICAP, FA_ICAP_SR , FA_EXP_OFF, FA_EXP_0123, "ICAP: read SR (monitor ICAPEn)"); +// time(¤t_time); +// timeout = (int)difftime(current_time, start_time); +// } // timeout can occur for old images, then use the old reload from oc-utils-common.sh if(timeout >= 1) { //printf("Timeout! EOS cannot be set \n"); From e261c64220815e8cb960c10f39cc0cb8ecc0677b Mon Sep 17 00:00:00 2001 From: fmoyen Date: Fri, 10 Dec 2021 14:57:31 +0100 Subject: [PATCH 34/34] img_reload debug --- src/img_reload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/img_reload.c b/src/img_reload.c index c08dfba..684cfa0 100644 --- a/src/img_reload.c +++ b/src/img_reload.c @@ -178,8 +178,8 @@ int main(int argc, char *argv[]) if(verbose_flag) { - read_QSPI_regs(); - read_ICAP_regs(); +// read_QSPI_regs(); +// read_ICAP_regs(); read_FPGA_IDCODE(); } //==============================================