From: Vasant H. <heg...@li...> - 2018-01-16 16:15:07
|
On P9, OPAL exports firmware information via device tree (/ibm,firmware-versions node). Even recent hostboot firmware on P8 BMC system exports these information via mini device tree. Lets add support to parse device tree to get firmware information. If firmware information is not present in device tree then fall back to existing ipmi method. Signed-off-by: Vasant Hegde <heg...@li...> --- scripts/update_flash_nv | 50 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/scripts/update_flash_nv b/scripts/update_flash_nv index 0ef765c..cb51a8d 100755 --- a/scripts/update_flash_nv +++ b/scripts/update_flash_nv @@ -58,6 +58,9 @@ DT_PATH=/proc/device-tree DT_FW_MI_FILE=${DT_PATH}/ibm,opal/firmware/mi-version DT_FW_ML_FILE=${DT_PATH}/ibm,opal/firmware/ml-version +# Firmware versions device tree node +DT_PATH_FW_NODE=${DT_PATH}/ibm,firmware-versions + # Code update status values FLASH_SUCCESS=0 # Success FLASH_PARAM_ERR=-1 # Parameter error @@ -587,7 +590,44 @@ opp_manage_flash() { exit $E_SUCCESS } -opp_display_current_fw_version() { +# Use device tree to get firmware version +opp_display_dt_firmware_version() { + local prop_prod="" + + echo + echo "Firmware version:" + + # Different BMCs uses different device tree property to display + # product name. + if [ -f $DT_PATH_FW_NODE/IBM ]; then + prop_prod=IBM + elif [ -f $DT_PATH_FW_NODE/open-power ]; then + prop_prod=open-power + elif [ -f $DT_PATH_FW_NODE/buildroot ]; then + prop_prod=buildroot + fi + + if [ "$prop_prod" != "" ]; then + echo " Product Version : $prop_prod-$(tr -d '\0' < $DT_PATH_FW_NODE/$prop_prod)" + fi + + for i in `ls $DT_PATH_FW_NODE` + do + if [ "$i" = "$prop_prod" ]; then + continue + fi + if [ "$i" = "name" ]; then + continue + fi + if [ "$i" = "phandle" ] || [ "$i" = "linux,phandle" ]; then + continue + fi + echo " Product Extra : $i-$(tr -d '\0' < $DT_PATH_FW_NODE/$i)" + done +} + +# Use inband ipmi interface to get firmware version +opp_display_ipmi_fw_version() { which ipmitool >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "update_flash: ipmitool command not found." @@ -609,6 +649,14 @@ opp_display_current_fw_version() { echo "Firmware version:" ipmitool fru print $id +} + +opp_display_current_fw_version() { + if [ -d $DT_PATH_FW_NODE ]; then + opp_display_dt_firmware_version + else + opp_display_ipmi_fw_version + fi exit $E_SUCCESS } |