Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393_sata
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393_sata
Commits
22c3a8b8
Commit
22c3a8b8
authored
Mar 02, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
case: SSD is not connected
parent
503100cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
x393sata_eyesis4pi_control.py
py393sata/x393sata_eyesis4pi_control.py
+22
-6
No files found.
py393sata/x393sata_eyesis4pi_control.py
View file @
22c3a8b8
...
...
@@ -22,6 +22,9 @@ DRIVER_RELOAD_LIMIT = 5
DRIVER_WAIT_TIME
=
10
DRIVER_UNLOAD_TRIES
=
30
#global
DEVICE_NOT_CONNECTED
=
True
def
colorize
(
string
,
color
,
bold
):
color
=
color
.
upper
()
attr
=
[]
...
...
@@ -74,6 +77,9 @@ def shout(cmd):
def
connection_errors
():
global
DEVICE_NOT_CONNECTED
result
=
True
skip0
=
True
MAXI1_ADDR
=
0x80000000
...
...
@@ -93,6 +99,8 @@ def connection_errors():
fld_value
=
(
data
>>
fld
[
'start_bit'
])
&
((
1
<<
fld
[
'num_bits'
])
-
1
)
if
first_line
:
log_msg
(
"
%
s: 0x
%08
x [
%08
x]"
%
(
group_range
,
data
,
byte_addr
))
if
data
!=
0
:
DEVICE_NOT_CONNECTED
=
False
first_line
=
False
if
fld_value
or
not
skip0
:
log_msg
(
"
%8
x :
%
s (
%
s)"
%
(
fld_value
,
fld
[
'name'
],
fld
[
'description'
]
))
...
...
@@ -106,6 +114,8 @@ def connection_errors():
def
reset_device
():
result
=
False
sleep
(
0.5
)
for
i
in
range
(
RESET_LIMIT
):
if
not
connection_errors
():
log_msg
(
"connection error ("
+
str
(
i
)
+
"), resetting device"
,
4
)
...
...
@@ -143,7 +153,7 @@ def unload_ahci_elphel_driver():
log_msg
(
"AHCI driver unloading timeout"
)
sleep
(
2
)
else
:
log_msg
(
"AHCI driver
un
loaded"
)
log_msg
(
"AHCI driver
is not
loaded"
)
break
else
:
log_msg
(
"AHCI driver unloaded"
)
...
...
@@ -167,15 +177,18 @@ def load_driver():
for
i
in
range
(
DRIVER_RELOAD_LIMIT
):
log_msg
(
"Loading SATA driver ("
+
str
(
i
)
+
")"
)
result
=
reload_driver
(
i
)
result
=
reload_driver
()
if
result
:
break
if
not
result
:
log_msg
(
"SATA failed, SSD was not
moun
ted: reconnect SSD"
,
2
)
log_msg
(
"SATA failed, SSD was not
detec
ted: reconnect SSD"
,
2
)
shout
(
"echo 0 > "
+
STATEFILE
)
else
:
log_msg
(
"SATA ok, SSD detected after "
+
str
(
i
)
+
" tries"
)
if
DEVICE_NOT_CONNECTED
:
log_msg
(
"SSD was not detected, ahci_elphel driver is loaded"
,
4
)
else
:
log_msg
(
"SATA ok, SSD detected after "
+
str
(
i
)
+
" tries"
)
shout
(
"echo 1 > "
+
STATEFILE
)
...
...
@@ -196,7 +209,7 @@ def check_device():
return
result
def
reload_driver
(
i
):
def
reload_driver
():
unload_ahci_elphel_driver
()
# check once
...
...
@@ -208,7 +221,10 @@ def reload_driver(i):
load_ahci_elphel_driver
()
sleep
(
DRIVER_WAIT_TIME
)
result
=
check_device
()
if
DEVICE_NOT_CONNECTED
:
result
=
True
return
result
mem
=
x393_mem
.
X393Mem
(
0
,
0
,
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment