Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
litex
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jonathan Currier
litex
Commits
3a72688b
Unverified
Commit
3a72688b
authored
May 21, 2019
by
enjoy-digital
Committed by
GitHub
May 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #183 from xobs/usb-to-0x43
Use 0x43/0xc3 for USB bridge magic packet
parents
10670e22
014c9505
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
litex/tools/remote/comm_usb.py
litex/tools/remote/comm_usb.py
+17
-8
No files found.
litex/tools/remote/comm_usb.py
View file @
3a72688b
...
...
@@ -20,12 +20,12 @@ import time
# The SETUP packet looks like this:
#
# +----+----+----------+----+----+
# | C
0
| 00 | ADDRESS | 04 | 00 | read packet
# | C
3
| 00 | ADDRESS | 04 | 00 | read packet
# +----+----+----------+----+----+
# 1 1 4 1 1
#
# +----+----+----------+----+----+
# | 4
0
| 00 | ADDRESS | 04 | 00 | write packet
# | 4
3
| 00 | ADDRESS | 04 | 00 | write packet
# +----+----+----------+----+----+
# 1 1 4 1 1
#
...
...
@@ -37,8 +37,8 @@ import time
# byte indicates what type of packet it is, and that it is a Wishbone Bridge
# packet. This is the value "0x40" (VENDOR type packet destined for DEVICE)
# with the "Data Phase Transfer" bit either set or cleared:
# - Read: 0xc
0
# - Write: 0x4
0
# - Read: 0xc
3
# - Write: 0x4
3
#
# The next byte is bRequest, which in the current implementation is unused.
# Set this value to 0.
...
...
@@ -103,7 +103,7 @@ class CommUSB:
def
usb_read
(
self
,
addr
,
depth
=
0
):
try
:
value
=
self
.
dev
.
ctrl_transfer
(
bmRequestType
=
0xc
0
,
value
=
self
.
dev
.
ctrl_transfer
(
bmRequestType
=
0xc
3
,
bRequest
=
0x00
,
wValue
=
addr
&
0xffff
,
wIndex
=
(
addr
>>
16
)
&
0xffff
,
...
...
@@ -111,7 +111,14 @@ class CommUSB:
if
value
is
None
:
raise
TypeError
return
int
.
from_bytes
(
value
,
byteorder
=
"little"
)
except
(
usb
.
core
.
USBError
,
TypeError
):
except
usb
.
core
.
USBError
as
e
:
if
e
.
errno
==
13
:
print
(
"Access Denied. Maybe try using sudo?"
)
self
.
close
()
self
.
open
()
if
depth
<
self
.
MAX_RECURSION_COUNT
:
return
self
.
usb_read
(
addr
,
depth
+
1
)
except
TypeError
:
self
.
close
()
self
.
open
()
if
depth
<
self
.
MAX_RECURSION_COUNT
:
...
...
@@ -127,7 +134,7 @@ class CommUSB:
def
usb_write
(
self
,
addr
,
value
,
depth
=
0
):
try
:
self
.
dev
.
ctrl_transfer
(
bmRequestType
=
0x40
,
bRequest
=
0x00
,
value
=
self
.
dev
.
ctrl_transfer
(
bmRequestType
=
0x43
,
bRequest
=
0x00
,
wValue
=
addr
&
0xffff
,
wIndex
=
(
addr
>>
16
)
&
0xffff
,
data_or_wLength
=
bytes
([(
value
>>
0
)
&
0xff
,
...
...
@@ -135,7 +142,9 @@ class CommUSB:
(
value
>>
16
)
&
0xff
,
(
value
>>
24
)
&
0xff
]
),
timeout
=
None
)
except
usb
.
core
.
USBError
:
except
usb
.
core
.
USBError
as
e
:
if
e
.
errno
==
13
:
print
(
"Access Denied. Maybe try using sudo?"
)
self
.
close
()
self
.
open
()
if
depth
<
self
.
MAX_RECURSION_COUNT
:
...
...
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