From e5de256abf9686a683659676f26d621fbc4d1988 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sun, 5 Feb 2017 02:48:47 +0000 Subject: [PATCH] build one aboot image on arista platform --- .gitmodules | 3 +++ build_image.sh | 27 ++++++++++++++----- files/Aboot/{boot0 => boot0.j2} | 16 +++++++---- onie-image.conf | 6 +++++ platform/broadcom/one-aboot.mk | 8 ++++++ platform/broadcom/platform-modules-arista.mk | 10 +++++++ platform/broadcom/rules.mk | 4 ++- .../broadcom/sonic-platform-modules-arista | 1 + platform/generic/aboot-image.mk | 4 +-- 9 files changed, 64 insertions(+), 15 deletions(-) rename files/Aboot/{boot0 => boot0.j2} (91%) create mode 100644 platform/broadcom/one-aboot.mk create mode 100644 platform/broadcom/platform-modules-arista.mk create mode 160000 platform/broadcom/sonic-platform-modules-arista diff --git a/.gitmodules b/.gitmodules index 9e92d29e50ad..35e7290b8000 100644 --- a/.gitmodules +++ b/.gitmodules @@ -50,3 +50,6 @@ [submodule "platform/broadcom/sonic-platform-modules-s6000"] path = platform/broadcom/sonic-platform-modules-s6000 url = https://github.com/Azure/sonic-platform-modules-s6000 +[submodule "sonic-platform-modules-arista"] + path = platform/broadcom/sonic-platform-modules-arista + url = https://github.com/lguohan/sonic-1 diff --git a/build_image.sh b/build_image.sh index dc8d796ca8d9..03e518a5fb9c 100755 --- a/build_image.sh +++ b/build_image.sh @@ -19,9 +19,10 @@ } GIT_REVISION=$(git rev-parse --short HEAD) -mkdir -p `dirname $OUTPUT_ONIE_IMAGE` -sudo rm -f $OUTPUT_ONIE_IMAGE if [ "$IMAGE_TYPE" = "onie" ]; then + echo "Build ONIE installer" + mkdir -p `dirname $OUTPUT_ONIE_IMAGE` + sudo rm -f $OUTPUT_ONIE_IMAGE ## Generate an ONIE installer image ## Note: Don't leave blank between lines. It is single line command. ./onie-mk-demo.sh $TARGET_PLATFORM $TARGET_MACHINE $TARGET_PLATFORM-$TARGET_MACHINE-$ONIEIMAGE_VERSION \ @@ -29,15 +30,27 @@ if [ "$IMAGE_TYPE" = "onie" ]; then $ONIE_INSTALLER_PAYLOAD ## Use 'aboot' as target machine category which includes Aboot as bootloader elif [ "$IMAGE_TYPE" = "aboot" ]; then - ## Add Aboot boot0 file into the image - cp $ONIE_INSTALLER_PAYLOAD $OUTPUT_ONIE_IMAGE - pushd files/Aboot && sudo zip -g $OLDPWD/$OUTPUT_ONIE_IMAGE boot0; popd + echo "Build Aboot installer" + mkdir -p `dirname $OUTPUT_ABOOT_IMAGE` + sudo rm -f $OUTPUT_ABOOT_IMAGE + sudo rm -f $ABOOT_BOOT_IMAGE + ## Add main payload + cp $ONIE_INSTALLER_PAYLOAD $OUTPUT_ABOOT_IMAGE + ## Add Aboot boot0 file + j2 -f env files/Aboot/boot0.j2 ./onie-image.conf > files/Aboot/boot0 + pushd files/Aboot && zip -g $OLDPWD/$OUTPUT_ABOOT_IMAGE boot0; popd + pushd files/Aboot && zip -g $OLDPWD/$ABOOT_BOOT_IMAGE boot0; popd echo "$GIT_REVISION" >> .imagehash - zip -g $OUTPUT_ONIE_IMAGE .imagehash + zip -g $OUTPUT_ABOOT_IMAGE .imagehash + zip -g $ABOOT_BOOT_IMAGE .imagehash rm .imagehash echo "SWI_VERSION=42.0.0" > version - zip -g $OUTPUT_ONIE_IMAGE version + zip -g $OUTPUT_ABOOT_IMAGE version + zip -g $ABOOT_BOOT_IMAGE version rm version + + zip -g $OUTPUT_ABOOT_IMAGE $ABOOT_BOOT_IMAGE + rm $ABOOT_BOOT_IMAGE else echo "Error: Non supported target platform: $TARGET_PLATFORM" exit 1 diff --git a/files/Aboot/boot0 b/files/Aboot/boot0.j2 similarity index 91% rename from files/Aboot/boot0 rename to files/Aboot/boot0.j2 index b326f0e289a6..6836f780ac44 100644 --- a/files/Aboot/boot0 +++ b/files/Aboot/boot0.j2 @@ -44,17 +44,23 @@ extract_image() { ## Clean old directory for read-write layer rm -rf "$target_path/rw" + ## Clean docker directory + rm -rf "$target_path/var" + ## Unzip the image unzip -oq "$swipath" -x boot0 -d "$target_path" - ## Clean old directory for docker - rm -rf "$target_path/var/lib/docker" + ## Remove installer swi as it has lots of redundunt contents + rm -f $swipath - ## Further extract docker archive - tar xf "$target_path/dockerfs.tar.gz" -C "$target_path" + ## Further extract docker archive + tar xf "$target_path/{{ FILESYSTEM_DOCKERFS }}" -C "$target_path" ## clean up docker archive - rm -f "$target_path/dockerfs.tar.gz" + rm -f "$target_path/{{ FILESYSTEM_DOCKERFS }}" + + ## replace with boot swi + mv "$target_path/{{ ABOOT_BOOT_IMAGE }}" "$swipath" } write_machine_config() { diff --git a/onie-image.conf b/onie-image.conf index 61fad731b975..70228bbf2498 100644 --- a/onie-image.conf +++ b/onie-image.conf @@ -23,3 +23,9 @@ FILESYSTEM_DOCKERFS=dockerfs.tar.gz ## Output file name for onie installer OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin + +## Output file name for aboot installer +OUTPUT_ABOOT_IMAGE=target/sonic-aboot-$TARGET_MACHINE.swi + +## Aboot boot image name +ABOOT_BOOT_IMAGE=.sonic-boot.swi diff --git a/platform/broadcom/one-aboot.mk b/platform/broadcom/one-aboot.mk new file mode 100644 index 000000000000..fde8e06ff787 --- /dev/null +++ b/platform/broadcom/one-aboot.mk @@ -0,0 +1,8 @@ +# sonic broadcom one image installer + +SONIC_ONE_ABOOT_IMAGE = sonic-aboot-broadcom.swi +$(SONIC_ONE_ABOOT_IMAGE)_MACHINE = broadcom +$(SONIC_ONE_ABOOT_IMAGE)_IMAGE_TYPE = aboot +$(SONIC_ONE_ABOOT_IMAGE)_DEPENDS += $(BRCM_OPENNSL_KERNEL) $(ARISTA_PLATFORM_MODULE) +$(SONIC_ONE_ABOOT_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES) +SONIC_INSTALLERS += $(SONIC_ONE_ABOOT_IMAGE) diff --git a/platform/broadcom/platform-modules-arista.mk b/platform/broadcom/platform-modules-arista.mk new file mode 100644 index 000000000000..46f8709f53e9 --- /dev/null +++ b/platform/broadcom/platform-modules-arista.mk @@ -0,0 +1,10 @@ +# Arista Platform modules + +ARISTA_PLATFORM_MODULE_VERSION = 1.0 + +export ARISTA_PLATFORM_MODULE_VERSION + +ARISTA_PLATFORM_MODULE = sonic-platform-arista_$(ARISTA_PLATFORM_MODULE_VERSION)_amd64.deb +$(ARISTA_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-arista +$(ARISTA_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +SONIC_DPKG_DEBS += $(ARISTA_PLATFORM_MODULE) diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk index cd34b9c23bf6..e783f3cdbf9b 100644 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -1,9 +1,11 @@ include $(PLATFORM_PATH)/sdk.mk include $(PLATFORM_PATH)/sai.mk include $(PLATFORM_PATH)/platform-modules-s6000.mk +include $(PLATFORM_PATH)/platform-modules-arista.mk include $(PLATFORM_PATH)/docker-orchagent-brcm.mk include $(PLATFORM_PATH)/docker-syncd-brcm.mk include $(PLATFORM_PATH)/one-image.mk +include $(PLATFORM_PATH)/one-aboot.mk BCMCMD = bcmcmd $(BCMCMD)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmcmd?sv=2015-04-05&sr=b&sig=X3bFApmsNFmcnWM9mSGRxBugPcg%2FgJCHh5hhSuV1M2c%3D&se=2030-08-23T14%3A41%3A56Z&sp=r" @@ -13,7 +15,7 @@ $(DSSERVE)_URL = "https://sonicstorage.blob.core.windows.net/packages/dsserve?sv SONIC_ONLINE_FILES += $(BCMCMD) $(DSSERVE) -SONIC_ALL += $(SONIC_ONE_IMAGE) +SONIC_ALL += $(SONIC_ONE_IMAGE) $(SONIC_ONE_ABOOT_IMAGE) # Inject brcm sai into sairedis $(LIBSAIREDIS)_DEPENDS += $(BRCM_OPENNSL) $(BRCM_SAI) $(BRCM_SAI_DEV) diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista new file mode 160000 index 000000000000..5a1871d8070b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-arista @@ -0,0 +1 @@ +Subproject commit 5a1871d8070b1fea0fbc30fcf91ff984ac6ec295 diff --git a/platform/generic/aboot-image.mk b/platform/generic/aboot-image.mk index 0f332eb75402..64b841f856ea 100644 --- a/platform/generic/aboot-image.mk +++ b/platform/generic/aboot-image.mk @@ -1,7 +1,7 @@ # sonic aboot installer -SONIC_GENERIC_ABOOT_IMAGE = sonic-aboot.bin -$(SONIC_GENERIC_ABOOT_IMAGE)_MACHINE = aboot +SONIC_GENERIC_ABOOT_IMAGE = sonic-aboot-generic.swi +$(SONIC_GENERIC_ABOOT_IMAGE)_MACHINE = generic $(SONIC_GENERIC_ABOOT_IMAGE)_IMAGE_TYPE = aboot $(SONIC_GENERIC_ABOOT_IMAGE)_DEPENDS = $(SONIC_GENERIC_ABOOT_IMAGE)_DOCKERS =