Skip to content

Commit 989b600

Browse files
Staphylolguohan
authored andcommitted
[device/arista]: Update (#2336)
* Update arista drivers submodule * Ignore the possible timestamp warning in tar extraction * 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. * Add hook mechanism in boot0. Support additional features in boot0 via hooks. Hooks are unpacked and executed at post-install or pre-exec time. * Fix 7170 sensors.conf file Fix critical temperature settings for MAX6658 sensors * 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. * Fix 7170 fancontrol * 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.
1 parent aedfd6e commit 989b600

File tree

6 files changed

+149
-63
lines changed

6 files changed

+149
-63
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
INTERVAL=5
2-
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
3-
DEVNAME=hwmon1=max6658 hwmon3=rook_cpld
4-
FCTEMPS=hwmon3/pwm4=hwmon1/temp1_input hwmon3/pwm3=hwmon1/temp1_input hwmon3/pwm2=hwmon1/temp1_input hwmon3/pwm1=hwmon1/temp1_input
5-
FCFANS=hwmon3/pwm4=hwmon3/fan4_input hwmon3/pwm3=hwmon3/fan3_input hwmon3/pwm2=hwmon3/fan2_input hwmon3/pwm1=hwmon3/fan1_input
6-
MINTEMP=hwmon3/pwm4=50 hwmon3/pwm3=50 hwmon3/pwm2=50 hwmon3/pwm1=50
7-
MINPWM=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128
8-
MAXTEMP=hwmon3/pwm4=60 hwmon3/pwm3=60 hwmon3/pwm2=60 hwmon3/pwm1=60
9-
MINSTART=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128
10-
MINSTOP=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128
2+
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
3+
DEVNAME=hwmon2=max6658 hwmon4=rook_cpld
4+
FCTEMPS=hwmon4/pwm4=hwmon2/temp1_input hwmon4/pwm3=hwmon2/temp1_input hwmon4/pwm2=hwmon2/temp1_input hwmon4/pwm1=hwmon2/temp1_input
5+
FCFANS=hwmon4/pwm4=hwmon4/fan4_input hwmon4/pwm3=hwmon4/fan3_input hwmon4/pwm2=hwmon4/fan2_input hwmon4/pwm1=hwmon4/fan1_input
6+
MINTEMP=hwmon4/pwm4=50 hwmon4/pwm3=50 hwmon4/pwm2=50 hwmon4/pwm1=50
7+
MINPWM=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128
8+
MAXTEMP=hwmon4/pwm4=60 hwmon4/pwm3=60 hwmon4/pwm2=60 hwmon4/pwm1=60
9+
MINSTART=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128
10+
MINSTOP=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128

device/arista/x86_64-arista_7170_64c/sensors.conf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ chip "max6658-i2c-8-4c"
1313

1414
set temp1_max 100
1515
set temp1_crit 110
16+
set temp1_min -55
1617

18+
set temp2_max 100
19+
set temp2_crit 110
20+
set temp2_min -55
1721
ignore temp2
1822

1923
chip "dps1900-i2c-6-58"
@@ -42,10 +46,12 @@ chip "max6658-i2c-81-4c"
4246
label temp1 "Rear air temp1"
4347
label temp2 "Rear air temp2"
4448

45-
set temp1_max 50
46-
set temp1_crit 60
47-
set temp2_max 50
48-
set temp2_crit 60
49+
set temp1_max 70
50+
set temp1_crit 80
51+
set temp1_min -55
52+
set temp2_max 70
53+
set temp2_crit 80
54+
set temp2_min -55
4955

5056
chip "lm73-i2c-96-48"
5157
label temp1 "Front air temp"

files/Aboot/boot0.j2

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,37 @@
3232
# - KERNEL : relative path to the kernel to execute
3333
# - INITRD : relative path to the initrd to load
3434
# - CMDLINE : place to find the default kernel cmdline to use for the platform
35+
# - VERBOSE : setting it to 1 will enable debug traces
3536
#
3637
# By default the boot0 script will behave for an Aboot based behavior.
3738
# Options can be provided to only run some features of this script.
3839
#
3940
# Extra kernel parameters can be provided at runtime by the user by adding them
4041
# into a kernel-params file.
4142

42-
set -x
43-
4443
image_name="image-%%IMAGE_VERSION%%"
44+
dockerfs="{{ FILESYSTEM_DOCKERFS }}"
4545

4646
do_not_clean="do-not-clean"
4747
kernel_params="kernel-params"
4848

4949
aboot_machine="arista_unknown"
5050

51+
info() { printf "%04.2f: $@\n" "$(cut -f1 -d' ' /proc/uptime)"; }
52+
err() { info "Error: $@"; }
53+
warn() { info "Warning: $@"; }
54+
5155
# extract mount point from the swi path, e.g., /mnt/flash/sonic.swi --> /mnt/flash
5256
if [ -z "$target_path" ]; then
5357
if [ -z "$swipath" ]; then
54-
echo "target_path= is required when swipath= is not provided"
58+
err "target_path= is required when swipath= is not provided"
5559
exit 1
5660
fi
5761
target_path=$(df "$swipath" | tail -1 | tr -s " " | cut -d ' ' -f6)
5862
fi
5963
image_path="$target_path/$image_name"
64+
hook_path="$image_path/platform/hooks"
65+
data_path="$image_path/platform/data"
6066

6167
cmdline_base="$target_path/kernel-params-base"
6268
cmdline_image="$image_path/kernel-cmdline"
@@ -65,6 +71,9 @@ boot_config="$target_path/boot-config"
6571
bootconfigvars="KERNEL INITRD CONSOLESPEED PASSWORD NETDEV NETAUTO NETIP NETMASK NETGW NETDOMAIN NETDNS NETHW memtest"
6672
flash_re=" /mnt/flash| /host"
6773

74+
# for backward compatibility with the sonic_upgrade= behavior
75+
install="${install:-${sonic_upgrade:-}}"
76+
6877
parse_environment_config() {
6978
for n in ${bootconfigvars}; do
7079
eval v="\$$n"
@@ -81,6 +90,7 @@ clean_flash() {
8190
[ $f != "boot-config" ] &&
8291
[ $f != "$kernel_params" ] &&
8392
[ $f != "$cmdline_base" ] &&
93+
[ $f != "aquota.user" ] &&
8494
[ $f != "old_config" ] &&
8595
[ $f != "minigraph.xml" ]
8696
then
@@ -110,7 +120,7 @@ update_next_boot() {
110120
local default="$(get_boot_config SWI_DEFAULT)"
111121

112122
if [ -z "$default" ]; then
113-
echo "warning: no variable SWI_DEFAULT available"
123+
warn "boot-config has no variable SWI_DEFAULT"
114124
else
115125
update_boot_config SWI "$default"
116126
fi
@@ -119,26 +129,29 @@ update_next_boot() {
119129
extract_image() {
120130
mkdir -p "$image_path"
121131

132+
info "Extracting swi content"
122133
## Unzip the image except boot0 and dockerfs archive
123-
unzip -oq "$swipath" -x boot0 {{ FILESYSTEM_DOCKERFS }} -d "$image_path"
134+
unzip -oq "$swipath" -x boot0 "$dockerfs" -d "$image_path"
124135

125136
## detect rootfs type
126137
rootfs_type=`grep " $target_path " /proc/mounts | cut -d' ' -f3`
127138

139+
info "Extracting $dockerfs from swi"
128140
## vfat does not support symbol link
129-
if [ -n "$sonic_upgrade" ] || [ "$rootfs_type" != "vfat" ]; then
141+
if [ -n "$install" ] || [ "$rootfs_type" != "vfat" ]; then
130142
mkdir -p "$image_path/{{ DOCKERFS_DIR }}"
131143

132-
if [ -n "$sonic_upgrade" ]; then
133-
TAR_EXTRA_OPTION="--numeric-owner"
144+
if [ -n "$install" ]; then
145+
TAR_EXTRA_OPTION="--numeric-owner --warning=no-timestamp"
134146
fi
135147

136148
## extract docker archive
137-
unzip -oqp "$swipath" {{ FILESYSTEM_DOCKERFS }} | tar xzf - -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION
149+
info "Unpacking $dockerfs"
150+
unzip -oqp "$swipath" "$dockerfs" | tar xzf - -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION
138151
else
139152
## save dockerfs archive in the image directory
140-
unzip -oq "$swipath" {{ FILESYSTEM_DOCKERFS }} -d "$image_path"
141-
echo "$target_path is $rootfs_type, extract {{ FILESYSTEM_DOCKERFS }} in later stage"
153+
unzip -oq "$swipath" "$dockerfs" -d "$image_path"
154+
info "Unpacking $dockerfs delayed to initrd because $target_path is $rootfs_type"
142155
fi
143156

144157
## use new reduced-size boot swi
@@ -263,7 +276,7 @@ write_boot_configs() {
263276
elif [ -f /sys/class/net/eth0/address ]; then
264277
echo "hwaddr_ma1=$(cat /sys/class/net/eth0/address)" >> /tmp/append
265278
else
266-
echo "ERROR: Management port is not found."
279+
err "Management port not found."
267280
fi
268281

269282
# use extra parameters from kernel-params hook if the file exists
@@ -292,13 +305,34 @@ run_kexec() {
292305
local kernel="${KERNEL:-$(find $image_path/boot -name 'vmlinuz-*' -type f | head -n 1)}"
293306
local initrd="${INITRD:-$(find $image_path/boot -name 'initrd.img-*' -type f | head -n 1)}"
294307

308+
if ! $verbose; then
309+
# Start showing systemd information from the first failing unit if any.
310+
# systemd.show_status=false or quiet can be used to silence systemd entierly
311+
cmdline="$cmdline systemd.show_status=auto"
312+
fi
313+
295314
kexec --load --initrd="$initrd" --append="$cmdline" "$kernel"
296315

297316
[ -z "$testonly" ] || exit 0
298-
echo "kexecing..."
317+
info "Kexecing..."
299318
kexec --exec
300319
}
301320

321+
get_sorted_hooks() {
322+
echo $(find "$1" -name '[0-9][0-9]-*' -type f)
323+
}
324+
325+
run_hooks() {
326+
if [ -d "$hook_path/$1" ]; then
327+
for hook in $(get_sorted_hooks "$hook_path/$1"); do
328+
if [ ! -z "$hook" ]; then
329+
info "Running hook $hook"
330+
. "$hook"
331+
fi
332+
done
333+
fi
334+
}
335+
302336
# In Aboot no option will be provided therefore these are the default values to use
303337
in_aboot=true
304338
do_clean=true
@@ -311,7 +345,7 @@ if [ -f "$target_path/$do_not_clean" ]; then
311345
fi
312346

313347
# Parse the cmdline options (used from EOS or from SONiC)
314-
if [ ! -z "$install" ] || [ ! -z "$sonic_upgrade" ]; then
348+
if [ ! -z "$install" ]; then
315349
# install from SONiC or EOS
316350
in_aboot=false
317351
do_clean=false
@@ -326,11 +360,24 @@ elif [ $# -ne 0 ]; then
326360
exit 1
327361
fi
328362

363+
# Verbosity can be defined by the caller, default to false otherwise
364+
verbose=${verbose:-false}
365+
if [ -f "$target_path/verbose-boot" ] ||
366+
[ "$(get_boot_config VERBOSE)" = "1" ] ||
367+
! $in_aboot; then
368+
verbose=true
369+
fi
370+
371+
# enable shell debug mode to get the most verbosity
372+
if $verbose; then
373+
set -x
374+
fi
375+
329376
# install the image if newer
330377
if $do_install; then
331378
# we expect the swi to install to be a non empty file
332379
if [ ! -s "$swipath" ]; then
333-
echo "The swipath= environment variable does not point to a valid SWI"
380+
err "The swipath= environment variable does not point to a valid SWI"
334381
exit 1
335382
fi
336383

@@ -340,17 +387,25 @@ if $do_install; then
340387

341388
if [ "$GIT_REVISION" != "$LOCAL_IMAGEHASH" ] || [ ! -z "$force" ]; then
342389
if $do_clean; then
390+
info "Cleaning flash content $target_path"
343391
clean_flash
344392
fi
345393

394+
info "Installing image under $image_path"
346395
extract_image
396+
397+
info "Generating boot-config, machine.conf and cmdline"
347398
write_boot_configs
399+
400+
run_hooks post-install
401+
else
402+
info "Using previously installed image"
348403
fi
349404
fi
350405

351406
# chainloading using kexec
352407
if $do_kexec; then
408+
run_hooks pre-kexec
353409
update_next_boot
354410
run_kexec
355411
fi
356-

files/initramfs-tools/arista-convertfs.j2

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,25 @@ block_flash=''
1919
aboot_flag=''
2020
backup_file=''
2121

22-
# Get the fullpath of flash device, e.g., /dev/sda
23-
get_flash_dev() {
24-
for dev in $(ls /sys/block); do
25-
local is_mmc=$(echo "$dev" | grep 'mmcblk.*boot.*' | cat)
26-
if [ -n "$is_mmc" ]; then
27-
continue
28-
fi
29-
local devid=$(realpath "/sys/block/$dev/device")
30-
local is_device=$(echo "$devid" | grep '^/sys/devices/' | cat)
31-
local is_flash=$(echo "$devid" | grep "$block_flash" | cat)
32-
if [ -n "$is_device" -a -n "$is_flash" ]; then
33-
flash_dev="/dev/$dev"
34-
return 0
35-
fi
22+
# Wait until get the fullpath of flash device, e.g., /dev/sda
23+
wait_get_flash_dev() {
24+
local try_rounds=30
25+
while [ $try_rounds -gt 0 ]; do
26+
for dev in $(ls /sys/block); do
27+
local is_mmc=$(echo "$dev" | grep 'mmcblk.*boot.*' | cat)
28+
if [ -n "$is_mmc" ]; then
29+
continue
30+
fi
31+
local devid=$(realpath "/sys/block/$dev/device")
32+
local is_device=$(echo "$devid" | grep '^/sys/devices/' | cat)
33+
local is_flash=$(echo "$devid" | grep "$block_flash" | cat)
34+
if [ -n "$is_device" -a -n "$is_flash" ]; then
35+
flash_dev="/dev/$dev"
36+
return 0
37+
fi
38+
done
39+
sleep 1
40+
try_rounds=$(( $try_rounds - 1 ))
3641
done
3742
return 1
3843
}
@@ -95,6 +100,22 @@ fixup_flash_permissions() {
95100
setfacl -Rb "$flash_mnt"
96101
}
97102

103+
# Update ROOT device referring to the path under block_flash
104+
# This is for the occasional name swap between /dev/sda and /dev/sdb
105+
update_root() {
106+
# Check that root=/dev/*, ignoring any cases like root=UUID=*
107+
[ "${ROOT#/dev}" = "${ROOT}" ] && return 0
108+
109+
# Replace the beginning chars of ROOT by the ones of flash_dev with same index
110+
{% raw %}
111+
prefix_length="${#flash_dev}"
112+
{% endraw %}
113+
part_id="${ROOT:$prefix_length}"
114+
ROOT="$flash_dev$part_id"
115+
116+
echo "ROOT=$ROOT" > /conf/param.conf
117+
}
118+
98119
# Extract kernel parameters
99120
set -- $(cat /proc/cmdline)
100121
for x in "$@"; do
@@ -111,10 +132,24 @@ for x in "$@"; do
111132
;;
112133
esac
113134
done
114-
root_dev="$ROOT"
115135

116-
#Check aboot and root_dev is vfat
136+
#Check aboot
117137
[ -z "$aboot_flag" ] && exit 0
138+
139+
# Get flash dev name
140+
if [ -z "$block_flash" ]; then
141+
echo "Error: flash device info is not provided"
142+
exit 1
143+
fi
144+
if ! wait_get_flash_dev; then
145+
echo "Error: flash device is not found"
146+
exit 1
147+
fi
148+
149+
# If root=/dev/*, update ROOT to the device under block_flash
150+
update_root
151+
152+
root_dev="$ROOT"
118153
if [ -z "$root_dev" ]; then
119154
echo "Error: root device name is not provided"
120155
exit 1
@@ -126,22 +161,12 @@ fi
126161

127162
# exit when the root is ext4
128163
if ! blkid | grep "$root_dev.*vfat" -q; then
129-
mkdir -p "$root_mnt"
130-
mount -t ext4 "$root_dev" "$root_mnt"
131-
fixup_flash_permissions "$root_mnt"
132-
umount "$root_mnt"
133-
rmdir "$root_mnt"
134-
exit 0
135-
fi
136-
137-
# Get flash dev name
138-
if [ -z "$block_flash" ]; then
139-
echo "Error: flash device info is not provided"
140-
exit 1
141-
fi
142-
if ! get_flash_dev; then
143-
echo "Error: flash device is not found"
144-
exit 1
164+
mkdir -p "$root_mnt"
165+
mount -t ext4 "$root_dev" "$root_mnt"
166+
fixup_flash_permissions "$root_mnt"
167+
umount "$root_mnt"
168+
rmdir "$root_mnt"
169+
exit 0
145170
fi
146171

147172
# Check memory size for tmpfs

0 commit comments

Comments
 (0)