diff --git a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh index e83aebb2994f..d9091e9c957f 100644 --- a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh +++ b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fpga_util.sh @@ -2,6 +2,7 @@ # shellcheck disable=SC1091 # shellcheck disable=SC2012 +# shellcheck disable=SC2034 . /usr/local/bin/openbmc-utils.sh CPLD_JTAG_SEL_L="CPLD_JTAG_SEL_L" @@ -14,6 +15,8 @@ SPI_PIM_SEL="${SMBCPLD_SYSFS_DIR}/spi_pim_en" SPI_TH4_QSPI_SEL="${SMBCPLD_SYSFS_DIR}/spi_th4_qspi_en" JTAG_CTRL="${SMBCPLD_SYSFS_DIR}/jtag_ctrl" SMB_SPIDEV="spidev1.1" +SMB_SPI="spi1.1" +SMB_MTD="" SCM_PROGRAM=false SMB_PROGRAM=false @@ -46,13 +49,14 @@ disconnect_program_paths() { gpio_set_value $SCM_FPGA_LATCH_L 1 else echo 0 > "$JTAG_EN" - echo 1 > "$PROGRAM_SEL" + echo 0 > "$PROGRAM_SEL" fi if [ "$SMB_PROGRAM" = false ]; then echo 0 > "$SPI_CTRL" echo 0 > "$JTAG_CTRL" fi + devmem_clear_bit 0x1e6e2438 8 # SPI1CS1 Function enable } connect_scm_jtag() { @@ -90,25 +94,46 @@ connect_fan_jtag() { echo 0x1 > "$JTAG_CTRL" } +bind_spi_nor() { + # Unbind spidev1.1 + if [ -e /dev/spidev1.1 ]; then + echo "$SMB_SPI" > /sys/bus/spi/drivers/spidev/unbind + fi + + # Bind + echo spi-nor > /sys/bus/spi/devices/"$SMB_SPI"/driver_override + if [ ! -e /sys/bus/spi/drivers/spi-nor/"$SMB_SPI" ]; then + echo Binding "$SMB_SPI" to ... + echo "$SMB_SPI" > /sys/bus/spi/drivers/spi-nor/bind + sleep 0.5 + fi + SMB_MTD="$(grep "$SMB_SPI" /proc/mtd |awk '{print$1}' | tr -d : | tr -d mtd)" + if test -z "$SMB_MTD"; then + echo "Failed to locate mtd partition for SPI Flash!" + exit 1 + fi +} + +unbind_spi_nor() { + # Method for unloading spi-nor driver dynamically back to spidev + echo > /sys/bus/spi/devices/"$SMB_SPI"/driver_override + if grep "$SMB_SPI" /proc/mtd > /dev/null 2>&1 ; then + echo "Unbinding spi-nor from $SMB_SPI" + echo "$SMB_SPI" > /sys/bus/spi/drivers/spi-nor/unbind + fi + if [ ! -e /dev/spidev1.1 ]; then + echo "Binding spidev back to $SMB_SPI" + echo "$SMB_SPI" > /sys/bus/spi/drivers/spidev/bind + fi +} + connect_pim_flash() { gpio_set_value $CPLD_JTAG_SEL_L 1 echo 0 > "$PROGRAM_SEL" echo 1 > "$SPI_PIM_SEL" devmem_set_bit 0x1e6e2438 8 # SPI1CS1 Function enable - - for i in $(seq 1 5); do - msg="$(flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c "MT25QL256" 2>/dev/null)" - if echo "$msg" | grep -q "Found Micron flash chip"; then - echo "Detected PIM Flash device." - return 0; - else - echo "Attempt ${i} to detect pim flash failed..." - fi - done - - echo "Failed to detect PIM Flash device with flashrom" - echo "$msg" - exit 1 + sleep 0.1 + bind_spi_nor } connect_th4_qspi_flash() { @@ -116,20 +141,9 @@ connect_th4_qspi_flash() { echo 0 > "$PROGRAM_SEL" echo 1 > "$SPI_TH4_QSPI_SEL" devmem_set_bit 0x1e6e2438 8 # SPI1CS1 Function enable - - for i in $(seq 1 5); do - msg="$(flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c "MT25QU256" 2>/dev/null)" - if echo "$msg" | grep -q "Found Micron flash chip"; then - echo "Detected TH4 QSPI Flash device." - return 0; - else - echo "Attempt ${i} to detect TH4 QSPI flash failed..." - fi - done - - echo "Failed to detect TH4 QSPI Flash device with flashrom" - echo "$msg" - exit 1 + sleep 0.1 + unbind_spi_nor # Force Re-bind SPI nor + bind_spi_nor } do_scm() { @@ -245,7 +259,7 @@ program_spi_image() { fill=$((EEPROM_SIZE - IMAGE_SIZE)) if [ "$fill" = 0 ] ; then echo "$ORIGINAL_IMAGE already 32MB, no need to resize..." - flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c "$CHIP_TYPE" -N \ + flashrom -p linux_mtd:dev="$SMB_MTD" -N \ --layout /etc/elbert_pim.layout --image "$PARTITION" $OPERATION "$ORIGINAL_IMAGE" else bs=1048576 # 1MB blocks @@ -275,7 +289,7 @@ program_spi_image() { exit 1 fi # Program the 32MB pim image - flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c "$CHIP_TYPE" -N \ + flashrom -p linux_mtd:dev="$SMB_MTD" -N \ --layout /etc/elbert_pim.layout --image "$PARTITION" $OPERATION "$TEMP_IMAGE" rm "$TEMP_IMAGE" fi @@ -323,7 +337,7 @@ read_spi_partition_image() { echo "Selected partition $PARTITION to read." - flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c "$CHIP_TYPE" \ + flashrom -p linux_mtd:dev="$SMB_MTD" \ --layout /etc/elbert_pim.layout --image "$PARTITION" -r "$TEMP" dd if="$TEMP" of="$DEST" bs=1M count="$COUNT" skip="$SKIP_MB" 2> /dev/null rm "$TEMP" @@ -365,7 +379,7 @@ do_pim() { READ) connect_pim_flash if [ -z "$3" ]; then - flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c MT25QL256 -r "$2" + flashrom -p linux_mtd:dev="$SMB_MTD" -r "$2" else read_spi_partition_image "$2" "MT25QL256" "$3" fi @@ -373,9 +387,9 @@ do_pim() { ERASE) connect_pim_flash if [ -z "$2" ]; then - flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c MT25QL256 -E + flashrom -p linux_mtd:dev="$SMB_MTD" -E else - flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c MT25QL256 \ + flashrom -p linux_mtd:dev="$SMB_MTD" \ --layout /etc/elbert_pim.layout --image "$2" -E fi ;; @@ -391,10 +405,12 @@ do_th4_qspi() { PROGRAM|VERIFY) connect_th4_qspi_flash program_spi_image "$2" "MT25QU256" full "$1" + unbind_spi_nor ;; READ) connect_th4_qspi_flash - flashrom -p linux_spi:dev=/dev/"$SMB_SPIDEV" -c "MT25QU256" -r "$2" + flashrom -p linux_mtd:dev="$SMB_MTD" -r "$2" + unbind_spi_nor ;; *) echo "TH4 QSPI only supports program/verify/read action. Exiting..." diff --git a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_manifest.json b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_manifest.json index 19685c13399c..c8e429f042b9 100755 --- a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_manifest.json +++ b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_manifest.json @@ -25,20 +25,20 @@ "priority" : 5 }, "pim_base" : { - "get_version" : "spi_pim_ver.sh | grep 'HEADER_PIM_BASE: [^NOT]' | cut -f 3 -d ' ' | uniq", - "upgrade_cmd" : "fpga_util.sh pim program {filename}", + "get_version" : "spi_pim_ver.sh | grep 'HEADER_PIM_BASE: [^NOT]' | cut -f 2 -d ' ' | uniq", + "upgrade_cmd" : "fpga_util.sh pim_base program {filename}", "post_action" : "/usr/local/bin/wedge_power.sh pimreset -a", "priority" : 5 }, "pim16q" : { - "get_version" : "fpga_ver.sh | grep 'HEADER_PIM16Q: [^NOT]' | cut -f 3 -d ' ' | uniq", - "upgrade_cmd" : "fpga_util.sh pim program {filename}", + "get_version" : "spi_pim_ver.sh | grep 'HEADER_PIM16Q: [^NOT]' | cut -f 2 -d ' ' | uniq", + "upgrade_cmd" : "fpga_util.sh pim16q program {filename}", "post_action" : "/usr/local/bin/wedge_power.sh pimreset -a; sleep 15;", "priority" : 6 }, "pim8ddm" : { - "get_version" : "fpga_ver.sh | grep 'HEADER_PIM8DDM: [^NOT]' | cut -f 3 -d ' ' | uniq", - "upgrade_cmd" : "fpga_util.sh pim program {filename}", + "get_version" : "spi_pim_ver.sh | grep 'HEADER_PIM8DDM: [^NOT]' | cut -f 2 -d ' ' | uniq", + "upgrade_cmd" : "fpga_util.sh pim8ddm program {filename}", "post_action" : "/usr/local/bin/wedge_power.sh pimreset -a; sleep 15;", "priority" : 6 } diff --git a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_versions.json b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_versions.json index 80914b4cd889..61ea5da7c176 100755 --- a/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_versions.json +++ b/meta-facebook/meta-elbert/recipes-utils/openbmc-utils/files/fw_upgrade/elbert-ufw-jsons/elbert_ufw_versions.json @@ -7,15 +7,15 @@ }, "scm" : { "filename" : "elbert_scm.astp", - "version" : "1.14", + "version" : "1.13", "hash" : "sha1sum", "hash_value" : "68993159e93575f102c63a19a3891c2630ee082b" }, "smb" : { "filename" : "elbert_smb.astp", - "version" : "1.17", + "version" : "1.18", "hash" : "sha1sum", - "hash_value" : "acec3c725ebd05cccff6346f3ea4717c6bdc89f4" + "hash_value" : "2daf9def66e5907cb97f8522ec32adad61506e4d" }, "smb_cpld" : { "filename" : "elbert_smb_cpld.astp", @@ -31,20 +31,20 @@ }, "pim_base" : { "filename" : "elbert_pim_base.abin", - "version" : "0.0", + "version" : "1.1", "hash" : "sha1sum", - "hash_value" : "" + "hash_value" : "fcb3a867378ee06f15ba2e3dfd2bc878d5466f6a" }, "pim16q" : { "filename" : "elbert_pim16q.abin", "version" : "6.4", "hash" : "sha1sum", - "hash_value" : "9bd8ce9df692e4e28b702596416b0ec54e273f2d" + "hash_value" : "dc1848b1aa4bf7f7b05a2f57555a4405f282da57" }, "pim8ddm" : { "filename" : "elbert_pim8ddm.abin", "version" : "7.3", "hash" : "sha1sum", - "hash_value" : "090c6e9c28cd701254d57baa0a57030aed28253f" + "hash_value" : "b3b95abce62b978a7242089751b28def0d2a899a" } } diff --git a/tests2/tests/elbert/external_fw_upgrade_test_individual.py b/tests2/tests/elbert/external_fw_upgrade_test_individual.py new file mode 100755 index 000000000000..49b3d8f0da07 --- /dev/null +++ b/tests2/tests/elbert/external_fw_upgrade_test_individual.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +# +# Copyright 2020-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +import unittest + +from tests.elbert.test_data.firmware_upgrade.firmware_upgrade_config import ( + FwUpgradeTest, +) + + +class BiosFwUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for Master BIOS + """ + + def test_bios_fw_upgrade(self): + super().do_external_firmware_upgrade("bios") + + +class ScmFwUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for System Control Management CPLD + """ + + def test_scm_fw_upgrade(self): + super().do_external_firmware_upgrade("scm") + + +class SmbFwUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for System Management Board CPLD + """ + + def test_smb_fw_upgrade(self): + super().do_external_firmware_upgrade("smb") + + +class SmbCpldFwUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for System Management Board Extra CPLD + """ + + def test_smb_cpld_fw_upgrade(self): + super().do_external_firmware_upgrade("smb_cpld") + + +class FanFwUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for Fan CPLD + """ + + def test_fan_fw_upgrade(self): + super().do_external_firmware_upgrade("fan") + + +class PimBaseUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for Port Interface Module CPLD Base Partition + """ + + def test_pim_base_fw_upgrade(self): + super().do_external_firmware_upgrade("pim_base") + + +class Pim16qUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for Port Interface Module CPLD PIM16Q Partition + """ + + def test_pim16q_fw_upgrade(self): + super().do_external_firmware_upgrade("pim16q") + + +class Pim8ddmUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Individual test for Port Interface Module CPLD PIM8DDM Partition + """ + + def test_pim8ddm_fw_upgrade(self): + super().do_external_firmware_upgrade("pim8ddm") diff --git a/tests2/tests/elbert/external_fw_upgrade_test_multiple.py b/tests2/tests/elbert/external_fw_upgrade_test_multiple.py new file mode 100755 index 000000000000..5d6bdb5d0943 --- /dev/null +++ b/tests2/tests/elbert/external_fw_upgrade_test_multiple.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# +# Copyright 2020-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +import unittest + +from tests.elbert.test_data.firmware_upgrade.firmware_upgrade_config import ( + FwUpgradeTest, +) + + +class CollectiveFwUpgradeTest(FwUpgradeTest, unittest.TestCase): + """ + Collective test for all components which is found in json file + """ + + def test_collective_firmware_upgrade(self): + """ + This test file will enable us to do all the upgrade and + one power cycle at the end. While this has its advantages, + it makes it impossible for us to catch which specific FW + break a device in cases a box don't come up after upgrade. + Therefore, we will skip this test for now. Please comment + out the skipTest line and uncomment the line of code of + that come right before pass to activate this test. + """ + super().do_external_firmware_upgrade() diff --git a/tests2/tests/elbert/fw_test_binary_hashSum.py b/tests2/tests/elbert/fw_test_binary_hashSum.py new file mode 100644 index 000000000000..339616807758 --- /dev/null +++ b/tests2/tests/elbert/fw_test_binary_hashSum.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# +# Copyright 2020-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +import unittest + +from common.fw_test_base_binary_hashSum import BaseBinariesHashSumTest + + +class BinaryHashTest(BaseBinariesHashSumTest, unittest.TestCase): + def set_binary_paths(self): + pass diff --git a/tests2/tests/elbert/fw_test_upgrade.py b/tests2/tests/elbert/fw_test_upgrade.py new file mode 100644 index 000000000000..35fd41b9a6fd --- /dev/null +++ b/tests2/tests/elbert/fw_test_upgrade.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +# +# Copyright 2018-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +import os +import sys +import unittest + +from utils.cit_logger import Logger + + +# When tests are discovered upgrader is not yet installed, +# catch the import failure +try: + # Upgrader and binaries need to be installed in /tmp + sys.path.append("/tmp/fw_upgrade") + import fw_json as fw_up +except Exception: + pass + + +class FwUpgradeTest(unittest.TestCase): + # + _COMPONENTS = { + "bios": [ + 1, + "/usr/local/bin/bios_util.sh write {filename}", + ], # priority=1, upgrade_cmd + "scm": [ + 2, + "fpga_util.sh scm program {filename}", # noqa B950 + ], # priority=2, upgrade_cmd + "smb": [ + 3, + "fpga_util.sh smb program {filename}", # noqa B950 + ], # priority=3, upgrade_cmd + "smb_cpld": [ + 4, + "fpga_util.sh smb_cpld program {filename}", # noqa B950 + ], # priority=4, upgrade_cmd + "fan": [ + 5, + "fpga_util.sh fan program {filename}", # noqa B950 + ], # priority=5, upgrade_cmd + "pim_base": [ + 5, + "fpga_util.sh pim_base program {filename}", # noqa B950 + ], # priority=5, upgrade_cmd + "pim16q": [ + 6, + "fpga_util.sh pim16q program {filename}", # noqa B950 + ], # priority=6, upgrade_cmd + "pim8ddm": [ + 6, + "fpga_util.sh pim8ddm program {filename}", # noqa B950 + ], # priority=6, upgrade_cmd + } + + def setUp(self): + FwJsonObj = fw_up.FwJson(os.path.dirname(fw_up.__file__)) + self.json = FwJsonObj.get_priority_ordered_json() + Logger.start(name=self._testMethodName) + + def tearDown(self): + Logger.info("Finished logging for {}".format(self._testMethodName)) + pass + + def test_fw_entity_priority_in_ordered_json(self): + Logger.info("FW Upgrade Ordered json= {}".format(self.json)) + for item, attributes in self._COMPONENTS.items(): + # Test for fw entity presence in json + with self.subTest(upgradable_component=item): + self.assertIn( + item, + self.json, + "Upgradable component {} missing in ordered json {} ".format( + item, self.json + ), + ) + # Test for fw entity priority set in json + with self.subTest(upgradable_component=item): + self.assertEqual( + attributes[0], + self.json.get(item).get("priority"), + "Component {} contains priority expected={} found={} ".format( + item, attributes[0], self.json.get(item).get("priority") + ), + ) + # Test for correct command in json + with self.subTest(upgradable_component=item): + self.assertEqual( + attributes[1], + self.json.get(item).get("upgrade_cmd"), + "Component {} contains priority expected={} found={} ".format( + item, attributes[1], self.json.get(item).get("upgrade_cmd") + ), + ) diff --git a/tests2/tests/elbert/fw_test_upgrade_dryrun.py b/tests2/tests/elbert/fw_test_upgrade_dryrun.py new file mode 100644 index 000000000000..9d3155a80952 --- /dev/null +++ b/tests2/tests/elbert/fw_test_upgrade_dryrun.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# +# Copyright 2020-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +import unittest + +from common.fw_test_base_upgrade_all_dryrun import BaseUpgradeAllDryRunTest + + +class FwUpgradeDryrunTest(BaseUpgradeAllDryRunTest, unittest.TestCase): + pass diff --git a/tests2/tests/elbert/fw_test_upgrade_utils_presence.py b/tests2/tests/elbert/fw_test_upgrade_utils_presence.py new file mode 100644 index 000000000000..c2d91c66f071 --- /dev/null +++ b/tests2/tests/elbert/fw_test_upgrade_utils_presence.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# +# Copyright 2019-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +import unittest + +from common.fw_test_base_upgrade_utils_presence import BaseFwUpgradeUtilsPresenceTest + + +class FwUpgradeUtilsPresenceTest(BaseFwUpgradeUtilsPresenceTest, unittest.TestCase): + def set_fw_upgrade_utils(self): + self.expected_fw_upgrade_utils = [ + "bios_util.sh", + "fpga_util.sh", + "fpga_ver.sh", + "spi_pim_ver.sh", + "jam", + ] diff --git a/tests2/tests/elbert/test_data/firmware_upgrade/__init__.py b/tests2/tests/elbert/test_data/firmware_upgrade/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests2/tests/elbert/test_data/firmware_upgrade/firmware_upgrade_config.py b/tests2/tests/elbert/test_data/firmware_upgrade/firmware_upgrade_config.py new file mode 100644 index 000000000000..8031b2742eb4 --- /dev/null +++ b/tests2/tests/elbert/test_data/firmware_upgrade/firmware_upgrade_config.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 +# +# Copyright 2020-present Facebook. All Rights Reserved., +# +# This program file is free software; you can redistribute it and/or modify it, +# under the terms of the GNU General Public License as published by the, +# Free Software Foundation; version 2 of the License., +# +# This program is distributed in the hope that it will be useful, but WITHOUT, +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or, +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License, +# for more details., +# +# You should have received a copy of the GNU General Public License, +# along with this program in a file named COPYING; if not, write to the, +# Free Software Foundation, Inc.,, +# 51 Franklin Street, Fifth Floor,, +# Boston, MA 02110-1301 USA, +# + +import sys +from abc import abstractmethod + +from common.base_fw_upgrade_test import DEV_SERVER_RESOURCE_PATH, BaseFwUpgradeTest + + +# Global variables +# Upgrader and binary path on dev server and bmc target BMC unit. +UUT_RESOURCE_PATH = "/mnt/data1/fw_upgrade" + +# You have to add sys path of upgrader before importing upgrader class here. +sys.path.insert(0, DEV_SERVER_RESOURCE_PATH) +try: + from entity_upgrader import FwUpgrader +except Exception: + pass + +# Override default settings +UPGRADING_TIMEOUT = { + "bios": 1200, + "scm": 120, + "smb": 120, + "smb_cpld": 60, + "fan": 60, + "pim_base": 30, + "pim8ddm": 30, + "pim16q": 30, +} +EXPECTED_KEYWORD = [ + "closed by remote host", + "not supported", + "No EEPROM/flash", + "FAIL", + "returned error", # end of failed expected keyword + "PASS", + "VERIFIED.", + "content is identical", + "bios succeeded", + "Exit code = 0... Success", + "Erase/write done", +] +NUM_LAST_FAILED_EXPECTED_KEY = 4 # zero-based number 0...N +BMC_RECONNECT_TIMEOUT = 300 +SCM_BOOT_TIME = 30 +try: + POWER_RESET_CMD = FwUpgrader._POWER_RESET_HARD +except Exception: + pass + + +class FwUpgradeTest(BaseFwUpgradeTest): + """ + Class to initialize common settings for the external firmware testing + """ + + @abstractmethod + def override_common(self): + pass + + def set_common_settings(self): + self.hostname = None + self.num_last_failed_expected_key = NUM_LAST_FAILED_EXPECTED_KEY + self.expected_keyword = EXPECTED_KEYWORD + self.upgrader_path = DEV_SERVER_RESOURCE_PATH + self.remote_bin_path = UUT_RESOURCE_PATH + self.upgrading_timeout = UPGRADING_TIMEOUT + self.bmc_reconnect_timeout = BMC_RECONNECT_TIMEOUT + self.scm_boot_time = SCM_BOOT_TIME + self.power_reset_cmd = POWER_RESET_CMD + self.override_common() + pass