[201811] Dell: Fix S6000 reboot issue (#6688)

#### Why I did it
Reboot command in Dell S6000 failed to reboot the switch.

#### How I did it
Added retry mechanism and CPU reset.
This commit is contained in:
Aravind Mani 2021-02-17 05:07:44 +05:30 committed by GitHub
parent 7d0c9f4b3b
commit ca76c05890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,13 +1,63 @@
#!/bin/sh
#!/usr/bin/env python
# Export GPIO10 if needed
[ -d /sys/class/gpio/gpio10 ] || echo 10 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio10/direction
import sys
import os
import struct
#Toggle GPIO10 pin (to reset MUX)
echo 1 > /sys/class/gpio/gpio10/value
echo 0 > /sys/class/gpio/gpio10/value
PORT_RES = '/dev/port'
NVRAM_RES = '/dev/nvram'
COLD_RESET = 0xE # Cold Reset
WARM_RESET = 0x6 # Warm Reset
RESET_REG = 0xCF9
def io_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if fd < 0:
print('file open failed %s" % resource')
return
if os.lseek(fd, offset, os.SEEK_SET) != offset:
print('lseek failed on %s' % resource)
return
ret = os.write(fd, struct.pack('B', val))
if ret != 1:
print('write failed %d' % ret)
return
os.close(fd)
#Power Reset
echo 1 > /sys/devices/platform/dell-s6000-cpld.0/power_reset
def power_reset(val):
with open('/sys/devices/platform/dell-s6000-cpld.0/power_reset', 'w') as p:
p.write(str(int(val)) + '\n')
p.flush()
def gpio_direction(pin, direction):
kernpath = '/sys/class/gpio/gpio'+str(pin)+'/direction'
with open(('kernpath'), 'w') as p:
p.write(str(direction) + '\n')
p.flush()
def gpio_set(pin, value):
kernpath = '/sys/class/gpio/gpio'+str(pin)+'/value'
with open(('kernpath'), 'w') as p:
p.write(str(int(value)) + '\n')
p.flush()
def gpio_export(value):
with open('/sys/class/gpio/export', 'w') as p:
p.write(str(int(value)) + '\n')
p.flush()
if __name__ == "__main__":
retry_count = 0
io_reg_write(NVRAM_RES, 0x49, COLD_RESET)
while retry_count < 3:
if not os.path.isdir("/sys/class/gpio/gpio10"):
gpio_export(10)
gpio_direction("10", "out")
# Toggle GPIO10 pin (to reset MUX)
gpio_set("10", 1)
gpio_set("10", 0)
power_reset(1)
retry_count += 1
io_reg_write(PORT_RES, RESET_REG, COLD_RESET)