Skip to content

Commit 70e2ea1

Browse files
[202205][Mellanox] Place FW binaries under platform directory instead of squashfs (#13838)
Fixes #13568 Backport of #13837 Upgrade from old image always requires squashfs mount to get the next image FW binary. This can be avoided if we put FW binary under platform directory which is easily accessible after installation: admin@r-spider-05:~$ ls /host/image-fw-new-loc.0-dirty-20230208.193534/platform/fw-SPC.mfa /host/image-fw-new-loc.0-dirty-20230208.193534/platform/fw-SPC.mfa admin@r-spider-05:~$ ls -al /tmp/image-fw-new-loc.0-dirty-20230208.193534-fs/etc/mlnx/fw-SPC.mfa lrwxrwxrwx 1 root root 66 Feb 8 17:57 /tmp/image-fw-new-loc.0-dirty-20230208.193534-fs/etc/mlnx/fw-SPC.mfa -> /host/image-fw-new-loc.0-dirty-20230208.193534/platform/fw-SPC.mfa - Why I did it 202211 and above uses different squashfs compression type that 201911 kernel can not handle. Therefore, we avoid mounting squashfs altogether with this change. - How I did it Place FW binary under /host/image-/platform/mlnx/, soft links in /etc/mlnx are created to avoid breaking existing scripts/automation. /etc/mlnx/fw-SPCX.mfa is a soft link always pointing to the FW that should be used in current image mlnx-fw-upgrade.sh is updated to prefer /host/image-/platform/mlnx location and fallback to /etc/mlnx in squashfs in case new location does not exist. This is necessary to do image downgrade. - How to verify it Upgrade from 201911 to 202205 202205 to 201911 downgrade 202205 -> 202205 reboot ONIE -> 202205 boot (First FW burn) Signed-off-by: Stepan Blyschak <[email protected]>
1 parent 3c81038 commit 70e2ea1

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

files/build_templates/sonic_debian_extension.j2

+12-4
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,18 @@ sudo cp {{src}} $FILESYSTEM_ROOT/{{dst}}
909909
{% endfor -%}
910910

911911
{% if sonic_asic_platform == "mellanox" %}
912-
sudo mkdir -p $FILESYSTEM_ROOT/etc/mlnx/
913-
sudo cp $files_path/$MLNX_SPC_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC.mfa
914-
sudo cp $files_path/$MLNX_SPC2_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC2.mfa
915-
sudo cp $files_path/$MLNX_SPC3_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC3.mfa
912+
declare -rA FW_FILE_MAP=( \
913+
[$MLNX_SPC_FW_FILE]="fw-SPC.mfa" \
914+
[$MLNX_SPC2_FW_FILE]="fw-SPC2.mfa" \
915+
[$MLNX_SPC3_FW_FILE]="fw-SPC3.mfa" \
916+
)
917+
sudo mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/fw/asic/
918+
sudo mkdir -p $FILESYSTEM_ROOT_ETC/mlnx/
919+
for fw_file_name in ${!FW_FILE_MAP[@]}; do
920+
sudo cp $files_path/$fw_file_name $FILESYSTEM_ROOT/$PLATFORM_DIR/fw/asic/${FW_FILE_MAP[$fw_file_name]}
921+
# Link old FW location to not break existing automation/scripts
922+
sudo ln -s /host/image-$SONIC_IMAGE_VERSION/$PLATFORM_DIR/fw/asic/${FW_FILE_MAP[$fw_file_name]} $FILESYSTEM_ROOT/etc/mlnx/${FW_FILE_MAP[$fw_file_name]}
923+
done
916924
sudo cp $files_path/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/etc/mlnx/issu-version
917925
sudo cp $files_path/$MLNX_FFB_SCRIPT $FILESYSTEM_ROOT/usr/bin/mlnx-ffb.sh
918926
sudo cp $files_path/$MLNX_ONIE_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_ONIE_FW_UPDATE

platform/mellanox/mlnx-fw-upgrade.j2

+24-11
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ declare -r UNKN_ASIC="unknown"
3232
declare -r UNKN_MST="unknown"
3333

3434
declare -rA FW_FILE_MAP=( \
35-
[$SPC1_ASIC]="/etc/mlnx/fw-SPC.mfa" \
36-
[$SPC2_ASIC]="/etc/mlnx/fw-SPC2.mfa" \
37-
[$SPC3_ASIC]="/etc/mlnx/fw-SPC3.mfa" \
35+
[$SPC1_ASIC]="fw-SPC.mfa" \
36+
[$SPC2_ASIC]="fw-SPC2.mfa" \
37+
[$SPC3_ASIC]="fw-SPC3.mfa" \
3838
)
3939

4040
IMAGE_UPGRADE="${NO_PARAM}"
@@ -181,17 +181,17 @@ function RunCmd() {
181181
}
182182

183183
function UpgradeFW() {
184-
local -r _FS_MOUNTPOINT="$1"
184+
local -r _FW_BIN_PATH="$1"
185185

186186
local -r _ASIC_TYPE="$(GetAsicType)"
187187
if [[ "${_ASIC_TYPE}" = "${UNKN_ASIC}" ]]; then
188188
ExitFailure "failed to detect ASIC type"
189189
fi
190190

191-
if [ ! -z "${_FS_MOUNTPOINT}" ]; then
192-
local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}"
191+
if [ ! -z "${_FW_BIN_PATH}" ]; then
192+
local -r _FW_FILE="${_FW_BIN_PATH}/${FW_FILE_MAP[$_ASIC_TYPE]}"
193193
else
194-
local -r _FW_FILE="${FW_FILE_MAP[$_ASIC_TYPE]}"
194+
local -r _FW_FILE="/etc/mlnx/${FW_FILE_MAP[$_ASIC_TYPE]}"
195195
fi
196196

197197
if [ ! -f "${_FW_FILE}" ]; then
@@ -234,16 +234,29 @@ function UpgradeFWFromImage() {
234234
local -r _NEXT_SONIC_IMAGE="$(sonic-installer list | grep "Next: " | cut -f2 -d' ')"
235235
local -r _CURRENT_SONIC_IMAGE="$(sonic-installer list | grep "Current: " | cut -f2 -d' ')"
236236

237-
local -r _FS_PATH="/host/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs"
238-
local -r _FS_MOUNTPOINT="/tmp/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}-fs"
239-
240237
if [[ "${_CURRENT_SONIC_IMAGE}" == "${_NEXT_SONIC_IMAGE}" ]]; then
241238
ExitSuccess "firmware is up to date"
239+
fi
240+
241+
# /host/image-<version>/platform/fw/asic is now the new location for FW binaries.
242+
# Prefere this path and if it does not exist use squashfs as a fallback.
243+
local -r _PLATFORM_FW_BIN_PATH="/host/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}/platform/fw/asic/"
244+
245+
if [[ -d "${_PLATFORM_FW_BIN_PATH}" ]]; then
246+
LogInfo "Using FW binaries from ${_PLATFORM_FW_BIN_PATH}"
247+
248+
UpgradeFW "${_PLATFORM_FW_BIN_PATH}"
242249
else
250+
local -r _FS_PATH="/host/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs"
251+
local -r _FS_MOUNTPOINT="/tmp/image-${_NEXT_SONIC_IMAGE#SONiC-OS-}-fs"
252+
local -r _FW_BIN_PATH="${_FS_MOUNTPOINT}/etc/mlnx/"
253+
254+
LogInfo "Using FW binaries from ${_FW_BIN_PATH}"
255+
243256
mkdir -p "${_FS_MOUNTPOINT}"
244257
mount -t squashfs "${_FS_PATH}" "${_FS_MOUNTPOINT}"
245258

246-
UpgradeFW "${_FS_MOUNTPOINT}"
259+
UpgradeFW "${_FW_BIN_PATH}"
247260

248261
umount -rf "${_FS_MOUNTPOINT}"
249262
rm -rf "${_FS_MOUNTPOINT}"

0 commit comments

Comments
 (0)