Skip to content

Commit

Permalink
ELBERT: Multiboot Support (#102)
Browse files Browse the repository at this point in the history
Summary:
This PR has the changes necessary to support multiboot.

facebookexternal/openbmc.arista#1 - fpga_util changes to support multiboot
facebookexternal/openbmc.arista#2 - Update CIT fw tests in conjunction with this change

Change facebookexternal/openbmc.arista#1: fpga_util.sh
For elbert fpga_util spi flash devices, let's use spi-nor driver.
The issue with loading this driver at dts is that some devices might not
be enabled or behind a mux. Instead add a method bind_spi_nor which will
enable this driver in userspace after the muxes are set properly.

Interacting with this mtd device will not do anything unless the mux is
selected which is only in the context of fpga_util.sh

I am leaving some code in case we decide to go back to spidev in the
future.

Testing:
Able to reprogram and pimreset different PIM types and see images being
reloaded. There is still some issue intermittently where PIM stay
showing up as 'VERSION NOT DETECTED' and we are investigating,
However, this can be recoved via powercycle or reprogramming, and is
only 2-3/100 cycles.

Able to read TH4 QSPI with this change as well. For TH4 QSPI we re-bind
the spi-nor to re-initialize it. Since this upgrade is rare we will just
bind everytime.

Change facebookexternal/openbmc.arista#2: Update Elbert FW CIT tests
- Update manifest jsons to match latest programmables
- Add CIT and external fw upgrade test cases

Example Logs:
NOTE: you can ignore bios issues

```
% python3 cit_runner.py --platform elbert --run-test "tests.elbert.external_fw_upgrade_test_multip
le" --external --bmc-host fd7a:629f:52a4:1b1c:d6af:f7ff:fe2f:320d --firmware-opt-args="-f -v"
test_collective_firmware_upgrade (tests.elbert.external_fw_upgrade_test_multiple.CollectiveFwUpgradeTest)
This test file will enable us to do all the upgrade and ... Start firmware upgrade test!
Connecting to UUT ....................................................... Done
Checking version ........................................................ Warning
Warning!
bios: Cannot get current version on UUT, defaulting to upgrade
Checking binary on UUT .................................................. Done                                                                     [95/5226]
Updating: bios .......................................................... Done
Updating: scm ........................................................... Done
Updating: smb ........................................................... Done
Updating: smb_cpld ...................................................... Done
Updating: fan ........................................................... Done
Updating: pim_base ...................................................... Done
Updating: pim16q ........................................................ Done
Updating: pim8ddm ....................................................... Done
Power cycle UUT ......................................................... Done
Reconnecting to DUT ..................................................... Done
Checking version ........................................................ Warning
Warning!
bios: Cannot get current version on UUT, defaulting to upgrade

***********************************************************************************
                                    Test Summary
***********************************************************************************
     Name       Previous     Current      Package        Result   Time elapsed
-----------------------------------------------------------------------------------
     bios         N/A          N/A          4.10         Passed      86.81s
     scm          1.13         1.13         1.13         Passed      65.83s
     smb          1.18         1.18         1.18         Passed      66.06s
   smb_cpld       4.1          4.1          4.1          Passed      26.35s
     fan          1.2          1.2          1.2          Passed      26.44s
   pim_base       1.1          1.1          1.1          Passed      5.28s
    pim16q        6.4          6.4          6.4          Passed      7.49s
   pim8ddm        7.3          7.3          7.3          Passed      7.51s
-----------------------------------------------------------------------------------
ok

----------------------------------------------------------------------
Ran 1 test in 621.406s

Pull Request resolved: facebookexternal/openbmc.arista#102

Reviewed By: mikechoifb

fbshipit-source-id: a67b5e19c3
  • Loading branch information
joancaneus authored and facebook-github-bot committed Nov 4, 2020
1 parent f2258b4 commit 710cafd
Show file tree
Hide file tree
Showing 11 changed files with 494 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -90,46 +94,56 @@ 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() {
gpio_set_value $CPLD_JTAG_SEL_L 1
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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -365,17 +379,17 @@ 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
;;
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
;;
Expand All @@ -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..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
97 changes: 97 additions & 0 deletions tests2/tests/elbert/external_fw_upgrade_test_individual.py
Original file line number Diff line number Diff line change
@@ -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")
43 changes: 43 additions & 0 deletions tests2/tests/elbert/external_fw_upgrade_test_multiple.py
Original file line number Diff line number Diff line change
@@ -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()
Loading

0 comments on commit 710cafd

Please sign in to comment.