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
Show 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
...
@@ -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
%08
x [
%08
x]"
%
(
group_range
,
data
,
byte_addr
))
log_msg
(
"
%
s: 0x
%08
x [
%08
x]"
%
(
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
(
"
%8
x :
%
s (
%
s)"
%
(
fld_value
,
fld
[
'name'
],
fld
[
'description'
]
))
log_msg
(
"
%8
x :
%
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
un
loaded"
)
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
moun
ted: reconnect SSD"
,
2
)
log_msg
(
"SATA failed, SSD was not
detec
ted: 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
)
...
...
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