From 382d52843f08f79f6680bdaeefcc47382b6f7e77 Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Fri, 28 Jul 2017 20:57:51 +0300 Subject: [PATCH] [mellanox]: Move FW upgrade script to base image. (#849) - Download files to target/files directory (instead of target/debs) - Clean python-weels log files --- .../build_templates/sonic_debian_extension.j2 | 6 ++++ files/build_templates/swss.service.j2 | 4 ++- .../broadcom/docker-syncd-brcm/Dockerfile.j2 | 2 +- platform/mellanox/docker-syncd-mlnx-rpc.mk | 1 - platform/mellanox/docker-syncd-mlnx.mk | 3 +- .../mellanox/docker-syncd-mlnx/Dockerfile.j2 | 3 +- platform/mellanox/fw.mk | 2 ++ .../mlnx-fw-upgrade.sh | 3 -- platform/mellanox/one-image.mk | 1 + slave.mk | 28 +++++++++++++------ 10 files changed, 35 insertions(+), 18 deletions(-) rename platform/mellanox/{docker-syncd-mlnx => }/mlnx-fw-upgrade.sh (94%) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 77c5457327..a84b7070a5 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -221,3 +221,9 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autor sudo cp {{src}} $FILESYSTEM_ROOT/{{dst}} {% endif -%} {% endfor -%} + +{% if sonic_asic_platform == "mellanox" %} +sudo mkdir -p $FILESYSTEM_ROOT/etc/mlnx/ +sudo cp target/files/$MLNX_FW $FILESYSTEM_ROOT/etc/mlnx/fw-SPC.mfa +sudo cp platform/mellanox/mlnx-fw-upgrade.sh $FILESYSTEM_ROOT/usr/bin/ +{% endif %} diff --git a/files/build_templates/swss.service.j2 b/files/build_templates/swss.service.j2 index 1fc9127f26..ed6b852f18 100644 --- a/files/build_templates/swss.service.j2 +++ b/files/build_templates/swss.service.j2 @@ -18,8 +18,10 @@ ExecStartPre=/usr/bin/docker exec database redis-cli -n 1 FLUSHDB ExecStartPre=/usr/bin/docker exec database redis-cli -n 2 FLUSHDB {% if sonic_asic_platform == 'mellanox' %} -ExecStartPre=/etc/init.d/sxdkernel start +TimeoutStartSec=3min ExecStartPre=/usr/bin/mst start +ExecStartPre=/usr/bin/mlnx-fw-upgrade.sh +ExecStartPre=/etc/init.d/sxdkernel start ExecStartPre=/sbin/modprobe i2c-dev ExecStartPre=/bin/bash -c "/usr/share/sonic/device/$(sonic-cfggen -v platform)/hw-management start" {% elif sonic_asic_platform == 'cavium' %} diff --git a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 index 76af952cef..96ae65ee88 100755 --- a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 @@ -19,7 +19,7 @@ debs/{{ deb }}{{' '}} ## TODO: add kmod into Depends RUN apt-get install -f kmod -COPY ["debs/dsserve", "debs/bcmcmd", "start.sh", "/usr/bin/"] +COPY ["files/dsserve", "files/bcmcmd", "start.sh", "/usr/bin/"] RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] diff --git a/platform/mellanox/docker-syncd-mlnx-rpc.mk b/platform/mellanox/docker-syncd-mlnx-rpc.mk index e8e55e71e8..f27242ce17 100644 --- a/platform/mellanox/docker-syncd-mlnx-rpc.mk +++ b/platform/mellanox/docker-syncd-mlnx-rpc.mk @@ -3,7 +3,6 @@ DOCKER_SYNCD_MLNX_RPC = docker-syncd-mlnx-rpc.gz $(DOCKER_SYNCD_MLNX_RPC)_PATH = $(PLATFORM_PATH)/docker-syncd-mlnx-rpc $(DOCKER_SYNCD_MLNX_RPC)_DEPENDS += $(SYNCD_RPC) $(LIBTHRIFT) -$(DOCKER_SYNCD_MLNX_RPC)_FILES += $(MLNX_FW) $(DOCKER_SYNCD_MLNX_RPC)_LOAD_DOCKERS += $(DOCKER_SYNCD_MLNX) SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_MLNX_RPC) ifeq ($(ENABLE_SYNCD_RPC),y) diff --git a/platform/mellanox/docker-syncd-mlnx.mk b/platform/mellanox/docker-syncd-mlnx.mk index 2675399b70..2da5961fc0 100644 --- a/platform/mellanox/docker-syncd-mlnx.mk +++ b/platform/mellanox/docker-syncd-mlnx.mk @@ -2,8 +2,7 @@ DOCKER_SYNCD_MLNX = docker-syncd-mlnx.gz $(DOCKER_SYNCD_MLNX)_PATH = $(PLATFORM_PATH)/docker-syncd-mlnx -$(DOCKER_SYNCD_MLNX)_DEPENDS += $(SYNCD) $(MFT) $(PYTHON_SDK_API) -$(DOCKER_SYNCD_MLNX)_FILES += $(MLNX_FW) +$(DOCKER_SYNCD_MLNX)_DEPENDS += $(SYNCD) $(PYTHON_SDK_API) $(DOCKER_SYNCD_MLNX)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE) SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_MLNX) ifneq ($(ENABLE_SYNCD_RPC),y) diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index 79661e0ef7..966ef35ac9 100755 --- a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 @@ -18,9 +18,8 @@ RUN dpkg -i \ debs/{{ deb }}{{' '}} {%- endfor %} -COPY ["start.sh", "mlnx-fw-upgrade.sh", "/usr/bin/"] +COPY ["start.sh", "/usr/bin/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] -COPY ["/debs/fw-SPC-*-EVB.mfa", "/etc/mlnx/fw-SPC.mfa"] ## Clean up RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y diff --git a/platform/mellanox/fw.mk b/platform/mellanox/fw.mk index 8260b9d566..8e916d8176 100644 --- a/platform/mellanox/fw.mk +++ b/platform/mellanox/fw.mk @@ -3,3 +3,5 @@ MLNX_FW = fw-SPC-rel-13_1224_0140-EVB.mfa $(MLNX_FW)_URL = $(MLNX_SDK_BASE_URL)/$(MLNX_FW) SONIC_ONLINE_FILES += $(MLNX_FW) + +export MLNX_FW diff --git a/platform/mellanox/docker-syncd-mlnx/mlnx-fw-upgrade.sh b/platform/mellanox/mlnx-fw-upgrade.sh similarity index 94% rename from platform/mellanox/docker-syncd-mlnx/mlnx-fw-upgrade.sh rename to platform/mellanox/mlnx-fw-upgrade.sh index 0efb3ce9ec..b27d7095e2 100755 --- a/platform/mellanox/docker-syncd-mlnx/mlnx-fw-upgrade.sh +++ b/platform/mellanox/mlnx-fw-upgrade.sh @@ -47,7 +47,4 @@ if [[ ${required_fw_version} == ${fw_version} ]]; then else echo "Mellanox firmware required version is ${required_fw_version}. Installing compatible version..." run_or_fail "mlxfwmanager -i ${fw_file} -u -f -y" - - # exit from here so that syncd service will restart - exit 0 fi diff --git a/platform/mellanox/one-image.mk b/platform/mellanox/one-image.mk index 1aa8da3928..9293e6a727 100644 --- a/platform/mellanox/one-image.mk +++ b/platform/mellanox/one-image.mk @@ -5,4 +5,5 @@ $(SONIC_ONE_IMAGE)_MACHINE = mellanox $(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie $(SONIC_ONE_IMAGE)_DEPENDS += $(SX_KERNEL) $(KERNEL_MFT) $(MFT) $(MLNX_HW_MANAGEMENT) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES) +$(SONIC_ONE_IMAGE)_FILES += $(MLNX_FW) SONIC_INSTALLERS += $(SONIC_ONE_IMAGE) diff --git a/slave.mk b/slave.mk index abd7458bd9..745dc2baa1 100644 --- a/slave.mk +++ b/slave.mk @@ -24,6 +24,7 @@ RULES_PATH = rules TARGET_PATH = target DOCKERS_PATH = dockers DEBS_PATH = $(TARGET_PATH)/debs +FILES_PATH = $(TARGET_PATH)/files PYTHON_WHEELS_PATH = $(TARGET_PATH)/python-wheels PROJECT_ROOT = $(shell pwd) @@ -44,6 +45,7 @@ endif configure : @mkdir -p target/debs + @mkdir -p target/files @mkdir -p target/python-wheels @echo $(PLATFORM) > .platform @@ -121,9 +123,9 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_COPY_DEBS)) : $(DEBS_PATH)/% : .platform # SOME_NEW_FILE = some_new_file # $(SOME_NEW_FILE)_PATH = path/to/some_new_file # SONIC_COPY_FILES += $(SOME_NEW_FILE) -$(addprefix $(DEBS_PATH)/, $(SONIC_COPY_FILES)) : $(DEBS_PATH)/% : .platform +$(addprefix $(FILES_PATH)/, $(SONIC_COPY_FILES)) : $(FILES_PATH)/% : .platform $(HEADER) - cp $($*_PATH)/$* $(DEBS_PATH)/ $(LOG) || exit 1 + cp $($*_PATH)/$* $(FILES_PATH)/ $(LOG) || exit 1 $(FOOTER) ############################################################################### @@ -147,7 +149,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_ONLINE_DEBS)) : $(DEBS_PATH)/% : .platform # SOME_NEW_FILE = some_new_file # $(SOME_NEW_FILE)_URL = https://url/to/this/file # SONIC_ONLINE_FILES += $(SOME_NEW_FILE) -$(addprefix $(DEBS_PATH)/, $(SONIC_ONLINE_FILES)) : $(DEBS_PATH)/% : .platform +$(addprefix $(FILES_PATH)/, $(SONIC_ONLINE_FILES)) : $(FILES_PATH)/% : .platform $(HEADER) wget --no-use-server-timestamps -O $@ $($*_URL) $(LOG) $(FOOTER) @@ -313,11 +315,13 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_SIMPLE_DOCKER_IMAGES)) : $(TARGET_PATH)/%.g $(FOOTER) # Targets for building docker images -$(addprefix $(TARGET_PATH)/, $(SONIC_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform docker-start $$(addprefix $(DEBS_PATH)/,$$($$*.gz_DEPENDS) $$($$*.gz_FILES)) $$(addprefix $(PYTHON_WHEELS_PATH)/,$$($$*.gz_PYTHON_WHEELS)) $$(addsuffix -load,$$(addprefix $(TARGET_PATH)/,$$($$*.gz_LOAD_DOCKERS))) $$($$*.gz_PATH)/Dockerfile.j2 +$(addprefix $(TARGET_PATH)/, $(SONIC_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .platform docker-start $$(addprefix $(DEBS_PATH)/,$$($$*.gz_DEPENDS)) $$(addprefix $(FILES_PATH)/,$$($$*.gz_FILES)) $$(addprefix $(PYTHON_WHEELS_PATH)/,$$($$*.gz_PYTHON_WHEELS)) $$(addsuffix -load,$$(addprefix $(TARGET_PATH)/,$$($$*.gz_LOAD_DOCKERS))) $$($$*.gz_PATH)/Dockerfile.j2 $(HEADER) mkdir -p $($*.gz_PATH)/debs $(LOG) + mkdir -p $($*.gz_PATH)/files $(LOG) mkdir -p $($*.gz_PATH)/python-wheels $(LOG) sudo mount --bind $(DEBS_PATH) $($*.gz_PATH)/debs $(LOG) + sudo mount --bind $(FILES_PATH) $($*.gz_PATH)/files $(LOG) sudo mount --bind $(PYTHON_WHEELS_PATH) $($*.gz_PATH)/python-wheels $(LOG) # Export variables for j2. Use path for unique variable names, e.g. docker_orchagent_debs $(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_debs=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_DEPENDS),RDEPENDS))\n" | awk '!a[$$0]++')) @@ -341,7 +345,7 @@ $(DOCKER_LOAD_TARGETS) : $(TARGET_PATH)/%.gz-load : .platform docker-start $$(TA ############################################################################### # targets for building installers with base image -$(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform onie-image.conf $$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)) $$(addprefix $(DEBS_PATH)/,$$($$*_INSTALLS)) $(addprefix $(DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL) $(IGB_DRIVER) $(SONIC_DEVICE_DATA) $(SONIC_UTILS)) $$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS)) $$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE)) +$(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform onie-image.conf $$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)) $$(addprefix $(DEBS_PATH)/,$$($$*_INSTALLS)) $$(addprefix $(FILES_PATH)/,$$($$*_FILES)) $(addprefix $(DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL) $(IGB_DRIVER) $(SONIC_DEVICE_DATA) $(SONIC_UTILS)) $$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS)) $$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE)) $(HEADER) ## Pass initramfs and linux kernel explicitly. They are used for all platforms export initramfs_tools="$(DEBS_PATH)/$(INITRAMFS_TOOLS)" @@ -411,11 +415,19 @@ SONIC_CLEAN_DEBS = $(addsuffix -clean,$(addprefix $(DEBS_PATH)/, \ $(SONIC_PYTHON_STDEB_DEBS) \ $(SONIC_DERIVED_DEBS) \ $(SONIC_EXTRA_DEBS))) + +SONIC_CLEAN_FILES = $(addsuffix -clean,$(addprefix $(FILES_PATH)/, \ + $(SONIC_ONLINE_FILES) \ + $(SONIC_COPY_FILES))) + $(SONIC_CLEAN_DEBS) : $(DEBS_PATH)/%-clean : .platform $$(addsuffix -clean,$$(addprefix $(DEBS_PATH)/,$$($$*_MAIN_DEB))) @# remove derived or extra targets if main one is removed, because we treat them @# as part of one package @rm -f $(addprefix $(DEBS_PATH)/, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS)) +$(SONIC_CLEAN_FILES) : $(FILES_PATH)/%-clean : .platform + @rm -f $(FILES_PATH)/$* + SONIC_CLEAN_TARGETS += $(addsuffix -clean,$(addprefix $(TARGET_PATH)/, \ $(SONIC_DOCKER_IMAGES) \ $(SONIC_SIMPLE_DOCKER_IMAGES) \ @@ -429,9 +441,9 @@ $(SONIC_CLEAN_WHEELS) : $(PYTHON_WHEELS_PATH)/%-clean : .platform @rm -f $(PYTHON_WHEELS_PATH)/$* clean-logs : .platform - @rm -f $(TARGET_PATH)/*.log $(DEBS_PATH)/*.log + @rm -f $(TARGET_PATH)/*.log $(DEBS_PATH)/*.log $(FILES_PATH)/*.log $(PYTHON_WHEELS_PATH)/*.log -clean : .platform clean-logs $$(SONIC_CLEAN_DEBS) $$(SONIC_CLEAN_TARGETS) $$(SONIC_CLEAN_WHEELS) +clean : .platform clean-logs $$(SONIC_CLEAN_DEBS) $$(SONIC_CLEAN_FILES) $$(SONIC_CLEAN_TARGETS) $$(SONIC_CLEAN_WHEELS) ############################################################################### ## all @@ -443,6 +455,6 @@ all : .platform $$(addprefix $(TARGET_PATH)/,$$(SONIC_ALL)) ## Standard targets ############################################################################### -.PHONY : $(SONIC_CLEAN_DEBS) $(SONIC_CLEAN_TARGETS) $(SONIC_CLEAN_WHEELS) clean distclean configure +.PHONY : $(SONIC_CLEAN_DEBS) $(SONIC_CLEAN_FILES) $(SONIC_CLEAN_TARGETS) $(SONIC_CLEAN_WHEELS) clean distclean configure .INTERMEDIATE : $(SONIC_INSTALL_TARGETS) $(SONIC_INSTALL_WHEELS) $(DOCKER_LOAD_TARGETS) docker-start .platform