From f1f04bf4a1d0aa16e27cd685e68bb92a0a8486fa Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Mon, 3 Dec 2018 11:37:31 -0800 Subject: [PATCH 1/8] Update arista drivers submodule --- platform/barefoot/sonic-platform-modules-arista | 2 +- platform/broadcom/sonic-platform-modules-arista | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/barefoot/sonic-platform-modules-arista b/platform/barefoot/sonic-platform-modules-arista index 49088611fc5c..0fc0c23d8bb8 160000 --- a/platform/barefoot/sonic-platform-modules-arista +++ b/platform/barefoot/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 49088611fc5c339c8a8d18e78c354c16aca33704 +Subproject commit 0fc0c23d8bb8826d6431f35aff12ad1a5e098395 diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index 49088611fc5c..0fc0c23d8bb8 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 49088611fc5c339c8a8d18e78c354c16aca33704 +Subproject commit 0fc0c23d8bb8826d6431f35aff12ad1a5e098395 From 357aff991585797d531d54a363da5f31ecdce06c Mon Sep 17 00:00:00 2001 From: Boyang Yu Date: Mon, 3 Dec 2018 11:41:58 -0800 Subject: [PATCH 2/8] Ignore the possible timestamp warning in tar extraction --- files/Aboot/boot0.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index a476f5c27e9e..b61498f97544 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -130,7 +130,7 @@ extract_image() { mkdir -p "$image_path/{{ DOCKERFS_DIR }}" if [ -n "$sonic_upgrade" ]; then - TAR_EXTRA_OPTION="--numeric-owner" + TAR_EXTRA_OPTION="--numeric-owner --warning=no-timestamp" fi ## extract docker archive From 12237c416bea0c5268eba665955ab346140f0fde Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Thu, 22 Nov 2018 11:00:51 -0800 Subject: [PATCH 3/8] Add verbosity toggle to boot0 Console logging is slow because of the 9600 baud rate. Some time can be saved by decreasing the console verbosity. --- files/Aboot/boot0.j2 | 64 +++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index b61498f97544..1cb1c8ab554f 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -32,6 +32,7 @@ # - KERNEL : relative path to the kernel to execute # - INITRD : relative path to the initrd to load # - CMDLINE : place to find the default kernel cmdline to use for the platform +# - VERBOSE : setting it to 1 will enable debug traces # # By default the boot0 script will behave for an Aboot based behavior. # Options can be provided to only run some features of this script. @@ -39,19 +40,22 @@ # Extra kernel parameters can be provided at runtime by the user by adding them # into a kernel-params file. -set -x - image_name="image-%%IMAGE_VERSION%%" +dockerfs="{{ FILESYSTEM_DOCKERFS }}" do_not_clean="do-not-clean" kernel_params="kernel-params" aboot_machine="arista_unknown" +info() { printf "%04.2f: $@\n" "$(cut -f1 -d' ' /proc/uptime)"; } +err() { info "Error: $@"; } +warn() { info "Warning: $@"; } + # extract mount point from the swi path, e.g., /mnt/flash/sonic.swi --> /mnt/flash if [ -z "$target_path" ]; then if [ -z "$swipath" ]; then - echo "target_path= is required when swipath= is not provided" + err "target_path= is required when swipath= is not provided" exit 1 fi target_path=$(df "$swipath" | tail -1 | tr -s " " | cut -d ' ' -f6) @@ -65,6 +69,9 @@ boot_config="$target_path/boot-config" bootconfigvars="KERNEL INITRD CONSOLESPEED PASSWORD NETDEV NETAUTO NETIP NETMASK NETGW NETDOMAIN NETDNS NETHW memtest" flash_re=" /mnt/flash| /host" +# for backward compatibility with the sonic_upgrade= behavior +install="${install:-${sonic_upgrade:-}}" + parse_environment_config() { for n in ${bootconfigvars}; do eval v="\$$n" @@ -110,7 +117,7 @@ update_next_boot() { local default="$(get_boot_config SWI_DEFAULT)" if [ -z "$default" ]; then - echo "warning: no variable SWI_DEFAULT available" + warn "boot-config has no variable SWI_DEFAULT" else update_boot_config SWI "$default" fi @@ -119,26 +126,29 @@ update_next_boot() { extract_image() { mkdir -p "$image_path" + info "Extracting swi content" ## Unzip the image except boot0 and dockerfs archive - unzip -oq "$swipath" -x boot0 {{ FILESYSTEM_DOCKERFS }} -d "$image_path" + unzip -oq "$swipath" -x boot0 "$dockerfs" -d "$image_path" ## detect rootfs type rootfs_type=`grep " $target_path " /proc/mounts | cut -d' ' -f3` + info "Extracting $dockerfs from swi" ## vfat does not support symbol link - if [ -n "$sonic_upgrade" ] || [ "$rootfs_type" != "vfat" ]; then + if [ -n "$install" ] || [ "$rootfs_type" != "vfat" ]; then mkdir -p "$image_path/{{ DOCKERFS_DIR }}" - if [ -n "$sonic_upgrade" ]; then + if [ -n "$install" ]; then TAR_EXTRA_OPTION="--numeric-owner --warning=no-timestamp" fi ## extract docker archive - unzip -oqp "$swipath" {{ FILESYSTEM_DOCKERFS }} | tar xzf - -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION + info "Unpacking $dockerfs" + unzip -oqp "$swipath" "$dockerfs" | tar xzf - -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION else ## save dockerfs archive in the image directory - unzip -oq "$swipath" {{ FILESYSTEM_DOCKERFS }} -d "$image_path" - echo "$target_path is $rootfs_type, extract {{ FILESYSTEM_DOCKERFS }} in later stage" + unzip -oq "$swipath" "$dockerfs" -d "$image_path" + info "Unpacking $dockerfs delayed to initrd because $target_path is $rootfs_type" fi ## use new reduced-size boot swi @@ -263,7 +273,7 @@ write_boot_configs() { elif [ -f /sys/class/net/eth0/address ]; then echo "hwaddr_ma1=$(cat /sys/class/net/eth0/address)" >> /tmp/append else - echo "ERROR: Management port is not found." + err "Management port not found." fi # use extra parameters from kernel-params hook if the file exists @@ -292,10 +302,16 @@ run_kexec() { local kernel="${KERNEL:-$(find $image_path/boot -name 'vmlinuz-*' -type f | head -n 1)}" local initrd="${INITRD:-$(find $image_path/boot -name 'initrd.img-*' -type f | head -n 1)}" + if ! $verbose; then + # Start showing systemd information from the first failing unit if any. + # systemd.show_status=false or quiet can be used to silence systemd entierly + cmdline="$cmdline systemd.show_status=auto" + fi + kexec --load --initrd="$initrd" --append="$cmdline" "$kernel" [ -z "$testonly" ] || exit 0 - echo "kexecing..." + info "Kexecing..." kexec --exec } @@ -311,7 +327,7 @@ if [ -f "$target_path/$do_not_clean" ]; then fi # Parse the cmdline options (used from EOS or from SONiC) -if [ ! -z "$install" ] || [ ! -z "$sonic_upgrade" ]; then +if [ ! -z "$install" ]; then # install from SONiC or EOS in_aboot=false do_clean=false @@ -326,11 +342,24 @@ elif [ $# -ne 0 ]; then exit 1 fi +# Verbosity can be defined by the caller, default to false otherwise +verbose=${verbose:-false} +if [ -f "$target_path/verbose-boot" ] || + [ "$(get_boot_config VERBOSE)" = "1" ] || + ! $in_aboot; then + verbose=true +fi + +# enable shell debug mode to get the most verbosity +if $verbose; then + set -x +fi + # install the image if newer if $do_install; then # we expect the swi to install to be a non empty file if [ ! -s "$swipath" ]; then - echo "The swipath= environment variable does not point to a valid SWI" + err "The swipath= environment variable does not point to a valid SWI" exit 1 fi @@ -340,11 +369,17 @@ if $do_install; then if [ "$GIT_REVISION" != "$LOCAL_IMAGEHASH" ] || [ ! -z "$force" ]; then if $do_clean; then + info "Cleaning flash content $target_path" clean_flash fi + info "Installing image under $image_path" extract_image + + info "Generating boot-config, machine.conf and cmdline" write_boot_configs + else + info "Using previously installed image" fi fi @@ -353,4 +388,3 @@ if $do_kexec; then update_next_boot run_kexec fi - From 423fcc43a68ea6b6f08577f72a3e5b22443fad2d Mon Sep 17 00:00:00 2001 From: Qing Wang Date: Wed, 14 Nov 2018 16:26:58 -0800 Subject: [PATCH 4/8] Add hook mechanism in boot0. Support additional features in boot0 via hooks. Hooks are unpacked and executed at post-install or pre-exec time. --- files/Aboot/boot0.j2 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index 1cb1c8ab554f..bfd072777685 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -61,6 +61,8 @@ if [ -z "$target_path" ]; then target_path=$(df "$swipath" | tail -1 | tr -s " " | cut -d ' ' -f6) fi image_path="$target_path/$image_name" +hook_path="$image_path/platform/hooks" +data_path="$image_path/platform/data" cmdline_base="$target_path/kernel-params-base" cmdline_image="$image_path/kernel-cmdline" @@ -315,6 +317,21 @@ run_kexec() { kexec --exec } +get_sorted_hooks() { + echo $(find "$1" -name '[0-9][0-9]-*' -type f) +} + +run_hooks() { + if [ -d "$hook_path/$1" ]; then + for hook in $(get_sorted_hooks "$hook_path/$1"); do + if [ ! -z "$hook" ]; then + info "Running hook $hook" + . "$hook" + fi + done + fi +} + # In Aboot no option will be provided therefore these are the default values to use in_aboot=true do_clean=true @@ -378,6 +395,8 @@ if $do_install; then info "Generating boot-config, machine.conf and cmdline" write_boot_configs + + run_hooks post-install else info "Using previously installed image" fi @@ -385,6 +404,7 @@ fi # chainloading using kexec if $do_kexec; then + run_hooks pre-kexec update_next_boot run_kexec fi From 6c6b98cd05acecf0fa7a31f0f7bffa5f79741b6b Mon Sep 17 00:00:00 2001 From: Boyang Yu Date: Mon, 3 Dec 2018 11:43:03 -0800 Subject: [PATCH 5/8] Fix the random swap of storage devices For arista 7050 switches running with linux 4.9, it is likely the device name of flash drive (/dev/sda) and usb (/dev/sdb) randomly swap in kernel booting, depending on which one is ready first. It breaks the expectation that flash will be mounted as root by setting root=/dev/sda1. This patch will correct ROOT to flash device refering to the path under block_flash. --- files/initramfs-tools/arista-convertfs.j2 | 89 +++++++++++++++-------- 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/files/initramfs-tools/arista-convertfs.j2 b/files/initramfs-tools/arista-convertfs.j2 index abcf0c81b559..7b315b7725c6 100644 --- a/files/initramfs-tools/arista-convertfs.j2 +++ b/files/initramfs-tools/arista-convertfs.j2 @@ -19,20 +19,25 @@ block_flash='' aboot_flag='' backup_file='' -# Get the fullpath of flash device, e.g., /dev/sda -get_flash_dev() { - for dev in $(ls /sys/block); do - local is_mmc=$(echo "$dev" | grep 'mmcblk.*boot.*' | cat) - if [ -n "$is_mmc" ]; then - continue - fi - local devid=$(realpath "/sys/block/$dev/device") - local is_device=$(echo "$devid" | grep '^/sys/devices/' | cat) - local is_flash=$(echo "$devid" | grep "$block_flash" | cat) - if [ -n "$is_device" -a -n "$is_flash" ]; then - flash_dev="/dev/$dev" - return 0 - fi +# Wait until get the fullpath of flash device, e.g., /dev/sda +wait_get_flash_dev() { + local try_rounds=30 + while [ $try_rounds -gt 0 ]; do + for dev in $(ls /sys/block); do + local is_mmc=$(echo "$dev" | grep 'mmcblk.*boot.*' | cat) + if [ -n "$is_mmc" ]; then + continue + fi + local devid=$(realpath "/sys/block/$dev/device") + local is_device=$(echo "$devid" | grep '^/sys/devices/' | cat) + local is_flash=$(echo "$devid" | grep "$block_flash" | cat) + if [ -n "$is_device" -a -n "$is_flash" ]; then + flash_dev="/dev/$dev" + return 0 + fi + done + sleep 1 + try_rounds=$(( $try_rounds - 1 )) done return 1 } @@ -95,6 +100,22 @@ fixup_flash_permissions() { setfacl -Rb "$flash_mnt" } +# Update ROOT device referring to the path under block_flash +# This is for the occasional name swap between /dev/sda and /dev/sdb +update_root() { + # Check that root=/dev/*, ignoring any cases like root=UUID=* + [ "${ROOT#/dev}" = "${ROOT}" ] && return 0 + + # Replace the beginning chars of ROOT by the ones of flash_dev with same index +{% raw %} + prefix_length="${#flash_dev}" +{% endraw %} + part_id="${ROOT:$prefix_length}" + ROOT="$flash_dev$part_id" + + echo "ROOT=$ROOT" > /conf/param.conf +} + # Extract kernel parameters set -- $(cat /proc/cmdline) for x in "$@"; do @@ -111,10 +132,24 @@ for x in "$@"; do ;; esac done -root_dev="$ROOT" -#Check aboot and root_dev is vfat +#Check aboot [ -z "$aboot_flag" ] && exit 0 + +# Get flash dev name +if [ -z "$block_flash" ]; then + echo "Error: flash device info is not provided" + exit 1 +fi +if ! wait_get_flash_dev; then + echo "Error: flash device is not found" + exit 1 +fi + +# If root=/dev/*, update ROOT to the device under block_flash +update_root + +root_dev="$ROOT" if [ -z "$root_dev" ]; then echo "Error: root device name is not provided" exit 1 @@ -126,22 +161,12 @@ fi # exit when the root is ext4 if ! blkid | grep "$root_dev.*vfat" -q; then - mkdir -p "$root_mnt" - mount -t ext4 "$root_dev" "$root_mnt" - fixup_flash_permissions "$root_mnt" - umount "$root_mnt" - rmdir "$root_mnt" - exit 0 -fi - -# Get flash dev name -if [ -z "$block_flash" ]; then - echo "Error: flash device info is not provided" - exit 1 -fi -if ! get_flash_dev; then - echo "Error: flash device is not found" - exit 1 + mkdir -p "$root_mnt" + mount -t ext4 "$root_dev" "$root_mnt" + fixup_flash_permissions "$root_mnt" + umount "$root_mnt" + rmdir "$root_mnt" + exit 0 fi # Check memory size for tmpfs From 0aeae271a9e562d3890fc8e5940731e63f7144bb Mon Sep 17 00:00:00 2001 From: Yury Murashka Date: Thu, 29 Nov 2018 11:14:03 +0100 Subject: [PATCH 6/8] Fix 7170 sensors.conf file Fix critical temperature settings for MAX6658 sensors --- device/arista/x86_64-arista_7170_64c/sensors.conf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/device/arista/x86_64-arista_7170_64c/sensors.conf b/device/arista/x86_64-arista_7170_64c/sensors.conf index 196769f95c0c..732cb92a96ef 100644 --- a/device/arista/x86_64-arista_7170_64c/sensors.conf +++ b/device/arista/x86_64-arista_7170_64c/sensors.conf @@ -13,7 +13,11 @@ chip "max6658-i2c-8-4c" set temp1_max 100 set temp1_crit 110 + set temp1_min -55 + set temp2_max 100 + set temp2_crit 110 + set temp2_min -55 ignore temp2 chip "dps1900-i2c-6-58" @@ -42,10 +46,12 @@ chip "max6658-i2c-81-4c" label temp1 "Rear air temp1" label temp2 "Rear air temp2" - set temp1_max 50 - set temp1_crit 60 - set temp2_max 50 - set temp2_crit 60 + set temp1_max 70 + set temp1_crit 80 + set temp1_min -55 + set temp2_max 70 + set temp2_crit 80 + set temp2_min -55 chip "lm73-i2c-96-48" label temp1 "Front air temp" From 2001329ee7b58874918a3fcf2b42456a1d64d567 Mon Sep 17 00:00:00 2001 From: Yury Murashka Date: Wed, 3 Oct 2018 11:14:03 +0100 Subject: [PATCH 7/8] Fix 7170 fancontrol --- .../arista/x86_64-arista_7170_64c/fancontrol | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/device/arista/x86_64-arista_7170_64c/fancontrol b/device/arista/x86_64-arista_7170_64c/fancontrol index 639185a7119f..90a078b7c419 100644 --- a/device/arista/x86_64-arista_7170_64c/fancontrol +++ b/device/arista/x86_64-arista_7170_64c/fancontrol @@ -1,10 +1,10 @@ INTERVAL=5 -DEVPATH=hwmon1=devices/pci0000:00/0000:00:1c.0/0000:06:00.0/i2c-8/8-004c hwmon3=devices/pci0000:ff/0000:ff:0b.3/i2c-93/93-0060 -DEVNAME=hwmon1=max6658 hwmon3=rook_cpld -FCTEMPS=hwmon3/pwm4=hwmon1/temp1_input hwmon3/pwm3=hwmon1/temp1_input hwmon3/pwm2=hwmon1/temp1_input hwmon3/pwm1=hwmon1/temp1_input -FCFANS=hwmon3/pwm4=hwmon3/fan4_input hwmon3/pwm3=hwmon3/fan3_input hwmon3/pwm2=hwmon3/fan2_input hwmon3/pwm1=hwmon3/fan1_input -MINTEMP=hwmon3/pwm4=50 hwmon3/pwm3=50 hwmon3/pwm2=50 hwmon3/pwm1=50 -MINPWM=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128 -MAXTEMP=hwmon3/pwm4=60 hwmon3/pwm3=60 hwmon3/pwm2=60 hwmon3/pwm1=60 -MINSTART=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128 -MINSTOP=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128 +DEVPATH=hwmon2=devices/pci0000:00/0000:00:1c.0/0000:06:00.0/i2c-8/8-004c hwmon4=devices/pci0000:ff/0000:ff:0b.3/i2c-93/93-0060 +DEVNAME=hwmon2=max6658 hwmon4=rook_cpld +FCTEMPS=hwmon4/pwm4=hwmon2/temp1_input hwmon4/pwm3=hwmon2/temp1_input hwmon4/pwm2=hwmon2/temp1_input hwmon4/pwm1=hwmon2/temp1_input +FCFANS=hwmon4/pwm4=hwmon4/fan4_input hwmon4/pwm3=hwmon4/fan3_input hwmon4/pwm2=hwmon4/fan2_input hwmon4/pwm1=hwmon4/fan1_input +MINTEMP=hwmon4/pwm4=50 hwmon4/pwm3=50 hwmon4/pwm2=50 hwmon4/pwm1=50 +MINPWM=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128 +MAXTEMP=hwmon4/pwm4=60 hwmon4/pwm3=60 hwmon4/pwm2=60 hwmon4/pwm1=60 +MINSTART=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128 +MINSTOP=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128 From ec63edf2f54fef0b56a4c9a0b5206bdf4d27c2e8 Mon Sep 17 00:00:00 2001 From: Shawn Li Date: Mon, 3 Dec 2018 11:59:05 -0800 Subject: [PATCH 8/8] Do not remove aquota.user file in boot0 This file is a filesystem protected file used by EOS. It can be simply removed and will make the SONiC installation failed if not skipped. --- files/Aboot/boot0.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index bfd072777685..7420c6a037de 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -90,6 +90,7 @@ clean_flash() { [ $f != "boot-config" ] && [ $f != "$kernel_params" ] && [ $f != "$cmdline_base" ] && + [ $f != "aquota.user" ] && [ $f != "old_config" ] && [ $f != "minigraph.xml" ] then