Commit 22c3a8b8 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

case: SSD is not connected

parent 503100cc
...@@ -22,6 +22,9 @@ DRIVER_RELOAD_LIMIT = 5 ...@@ -22,6 +22,9 @@ DRIVER_RELOAD_LIMIT = 5
DRIVER_WAIT_TIME = 10 DRIVER_WAIT_TIME = 10
DRIVER_UNLOAD_TRIES = 30 DRIVER_UNLOAD_TRIES = 30
#global
DEVICE_NOT_CONNECTED = True
def colorize(string, color, bold): def colorize(string, color, bold):
color=color.upper() color=color.upper()
attr = [] attr = []
...@@ -74,6 +77,9 @@ def shout(cmd): ...@@ -74,6 +77,9 @@ def shout(cmd):
def connection_errors(): def connection_errors():
global DEVICE_NOT_CONNECTED
result = True result = True
skip0 = True skip0 = True
MAXI1_ADDR = 0x80000000 MAXI1_ADDR = 0x80000000
...@@ -93,6 +99,8 @@ def connection_errors(): ...@@ -93,6 +99,8 @@ def connection_errors():
fld_value = (data >> fld['start_bit']) & ((1 << fld['num_bits']) - 1) fld_value = (data >> fld['start_bit']) & ((1 << fld['num_bits']) - 1)
if first_line: if first_line:
log_msg("%s: 0x%08x [%08x]"%(group_range, data, byte_addr)) log_msg("%s: 0x%08x [%08x]"%(group_range, data, byte_addr))
if data!=0:
DEVICE_NOT_CONNECTED = False
first_line = False first_line = False
if fld_value or not skip0: if fld_value or not skip0:
log_msg("%8x : %s (%s)"%(fld_value, fld['name'], fld['description'] )) log_msg("%8x : %s (%s)"%(fld_value, fld['name'], fld['description'] ))
...@@ -106,6 +114,8 @@ def connection_errors(): ...@@ -106,6 +114,8 @@ def connection_errors():
def reset_device(): def reset_device():
result = False result = False
sleep(0.5)
for i in range(RESET_LIMIT): for i in range(RESET_LIMIT):
if not connection_errors(): if not connection_errors():
log_msg("connection error ("+str(i)+"), resetting device",4) log_msg("connection error ("+str(i)+"), resetting device",4)
...@@ -143,7 +153,7 @@ def unload_ahci_elphel_driver(): ...@@ -143,7 +153,7 @@ def unload_ahci_elphel_driver():
log_msg("AHCI driver unloading timeout") log_msg("AHCI driver unloading timeout")
sleep(2) sleep(2)
else: else:
log_msg("AHCI driver unloaded") log_msg("AHCI driver is not loaded")
break break
else: else:
log_msg("AHCI driver unloaded") log_msg("AHCI driver unloaded")
...@@ -167,13 +177,16 @@ def load_driver(): ...@@ -167,13 +177,16 @@ def load_driver():
for i in range(DRIVER_RELOAD_LIMIT): for i in range(DRIVER_RELOAD_LIMIT):
log_msg("Loading SATA driver ("+str(i)+")") log_msg("Loading SATA driver ("+str(i)+")")
result = reload_driver(i) result = reload_driver()
if result: if result:
break break
if not result: if not result:
log_msg("SATA failed, SSD was not mounted: reconnect SSD",2) log_msg("SATA failed, SSD was not detected: reconnect SSD",2)
shout("echo 0 > "+STATEFILE) shout("echo 0 > "+STATEFILE)
else:
if DEVICE_NOT_CONNECTED:
log_msg("SSD was not detected, ahci_elphel driver is loaded",4)
else: else:
log_msg("SATA ok, SSD detected after "+str(i)+" tries") log_msg("SATA ok, SSD detected after "+str(i)+" tries")
shout("echo 1 > "+STATEFILE) shout("echo 1 > "+STATEFILE)
...@@ -196,7 +209,7 @@ def check_device(): ...@@ -196,7 +209,7 @@ def check_device():
return result return result
def reload_driver(i): def reload_driver():
unload_ahci_elphel_driver() unload_ahci_elphel_driver()
# check once # check once
...@@ -209,6 +222,9 @@ def reload_driver(i): ...@@ -209,6 +222,9 @@ def reload_driver(i):
sleep(DRIVER_WAIT_TIME) sleep(DRIVER_WAIT_TIME)
result = check_device() result = check_device()
if DEVICE_NOT_CONNECTED:
result = True
return result return result
mem = x393_mem.X393Mem(0,0,1) mem = x393_mem.X393Mem(0,0,1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment