Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
SPEC7
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
SPEC7
Commits
6d7d40ea
Commit
6d7d40ea
authored
Oct 04, 2021
by
Pascal Bos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ps_vuart, renamed pl_vuart.
updated README
parent
672cae07
Pipeline
#2276
failed with stage
in 2 minutes and 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
213 additions
and
1 deletion
+213
-1
spec7_pl_vuart.py
sw/spec7-tools/Pcie_vuart/spec7_pl_vuart.py
+88
-0
spec7_ps_vuart.py
sw/spec7-tools/Pcie_vuart/spec7_ps_vuart.py
+120
-0
README.md
sw/spec7-tools/README.md
+5
-1
No files found.
sw/spec7-tools/Pcie_vuart/spec7_pl_vuart.py
0 → 100644
View file @
6d7d40ea
#!/usr/bin/python3
#
# Simple terminal interface to the uart of the WR core
#
# Depending on the presents of the Xilinx XDMA driver
# Based on the Single AXI4 memory mapped (MM) user interface of the The Xilinx
# DMA/Bridge Subsystem for PCI Express (pg195)
#
# Author: Ton Damen, tond@nikhef.nl
# Date: 8/4/2020
#
import
os
import
sys
import
argparse
import
time
import
termios
import
pdb
syscon_addr
=
0x40400
vuart_addr
=
0x40500
xmda_user_fd
=
0
;
parser
=
argparse
.
ArgumentParser
(
description
=
'Terminal interface to the uart of the wr core on the SPEC card'
)
parser
.
add_argument
(
'--device'
,
'-d'
,
default
=
'/dev/spec7_bar0'
,
help
=
'device path name, default is /dev/spec7'
)
args
=
parser
.
parse_args
()
def
str2int
(
s
):
try
:
if
(
len
(
s
)
>
0
and
s
[
0
:
2
]
==
'0x'
):
val
=
int
(
s
[
2
:],
16
)
else
:
val
=
int
(
s
)
return
val
except
ValueError
:
sys
.
exit
(
'Invalid value: {}'
.
format
(
s
))
def
vuart_getc
():
while
True
:
data
=
os
.
pread
(
xdma_user_fd
,
4
,
vuart_addr
+
0x14
)
rx_reg
=
int
.
from_bytes
(
data
,
"little"
)
if
(
rx_reg
&
0x100
)
!=
0
:
return
rx_reg
&
0xff
else
:
return
-
1
def
vuart_putc
(
c
):
while
True
:
data
=
os
.
pread
(
xdma_user_fd
,
4
,
vuart_addr
+
0x10
)
if
(
int
.
from_bytes
(
data
,
"little"
)
&
0x100
)
!=
0
:
break
time
.
sleep
(
0.1
)
os
.
pwrite
(
xdma_user_fd
,
c
.
to_bytes
(
4
,
'little'
),
vuart_addr
+
0x10
)
stdio_fd
=
sys
.
stdin
.
fileno
()
old
=
termios
.
tcgetattr
(
stdio_fd
)
new
=
termios
.
tcgetattr
(
stdio_fd
)
# [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
new
[
0
]
=
termios
.
IGNPAR
new
[
1
]
=
0
new
[
2
]
=
termios
.
B9600
|
termios
.
CS8
|
termios
.
CLOCAL
|
termios
.
CREAD
new
[
3
]
=
0
new
[
6
][
termios
.
VMIN
]
=
0
new
[
6
][
termios
.
VTIME
]
=
0
print
(
'Type C-a to exit
\n
'
)
try
:
termios
.
tcsetattr
(
stdio_fd
,
termios
.
TCSADRAIN
,
new
)
xdma_user_fd
=
os
.
open
(
args
.
device
,
os
.
O_RDWR
)
while
True
:
key
=
sys
.
stdin
.
read
(
1
)
if
(
len
(
key
)
>
0
):
if
key
==
chr
(
1
):
break
else
:
vuart_putc
(
ord
(
key
))
c
=
vuart_getc
()
if
c
>
0
:
sys
.
stdout
.
write
(
chr
(
c
))
sys
.
stdout
.
flush
()
except
OSError
as
error
:
sys
.
exit
(
'Device i/o failed: {}'
.
format
(
error
))
finally
:
termios
.
tcsetattr
(
stdio_fd
,
termios
.
TCSADRAIN
,
old
)
sw/spec7-tools/Pcie_vuart/spec7_ps_vuart.py
0 → 100755
View file @
6d7d40ea
#!/usr/bin/python3
#
# Simple terminal interface to the second uart of the WR core
#
# Based on the Single AXI4 memory mapped (MM) user interface of the The Xilinx
# DMA/Bridge Subsystem for PCI Express (pg195)
#
# Author: Ton Damen, tond@nikhef.nl
# Date: 23/9/2021
#
import
os
import
sys
import
argparse
import
time
import
termios
import
pdb
vuart_reg_fifo_in
=
0x80000
vuart_reg_fifo_out
=
0x80004
vuart_reg_status
=
0x80008
vuart_reg_control
=
0x8000C
status_mask_rx_ready
=
1
status_mask_tx_empty
=
4
default_device
=
'/dev/spec7_bar0'
mm_fd
=
0
;
parser
=
argparse
.
ArgumentParser
(
description
=
'Terminal interface to the second uart of the wr core on the SPEC7 card'
)
parser
.
add_argument
(
'--device'
,
'-d'
,
default
=
default_device
,
help
=
'device path name, default is '
+
default_device
)
parser
.
add_argument
(
'--transmit'
,
'-t'
,
default
=
""
,
help
=
'transmit string'
)
args
=
parser
.
parse_args
()
def
get_status
():
return
int
.
from_bytes
(
os
.
pread
(
mm_fd
,
4
,
vuart_reg_status
),
"little"
)
def
str2int
(
s
):
try
:
if
(
len
(
s
)
>
0
and
s
[
0
:
2
]
==
'0x'
):
val
=
int
(
s
[
2
:],
16
)
else
:
val
=
int
(
s
)
return
val
except
ValueError
:
sys
.
exit
(
'Invalid value: {}'
.
format
(
s
))
def
vuart_getc
():
while
True
:
if
get_status
()
&
status_mask_rx_ready
!=
0
:
data
=
os
.
pread
(
mm_fd
,
4
,
vuart_reg_fifo_in
)
return
int
.
from_bytes
(
data
,
"little"
)
&
0xff
;
else
:
return
-
1
def
vuart_putc
(
c
):
cnt
=
100
# 10 sec
while
cnt
>
0
:
if
get_status
()
&
status_mask_tx_empty
!=
0
:
break
time
.
sleep
(
0.1
)
cnt
-=
1
if
cnt
==
0
:
print
(
"write time-out"
)
return
-
1
os
.
pwrite
(
mm_fd
,
c
.
to_bytes
(
4
,
'little'
),
vuart_reg_fifo_out
)
return
0
def
vuart_puts
(
s
):
n
=
len
(
s
)
i
=
0
while
i
<
n
:
if
vuart_putc
(
ord
(
s
[
i
]))
<
0
:
return
-
1
i
+=
1
return
0
stdio_fd
=
sys
.
stdin
.
fileno
()
old
=
termios
.
tcgetattr
(
stdio_fd
)
new
=
termios
.
tcgetattr
(
stdio_fd
)
# [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
new
[
0
]
=
termios
.
IGNPAR
new
[
1
]
=
0
new
[
2
]
=
termios
.
B9600
|
termios
.
CS8
|
termios
.
CLOCAL
|
termios
.
CREAD
new
[
3
]
=
0
new
[
6
][
termios
.
VMIN
]
=
0
new
[
6
][
termios
.
VTIME
]
=
0
print
(
'Type C-a to exit
\n
'
)
try
:
termios
.
tcsetattr
(
stdio_fd
,
termios
.
TCSADRAIN
,
new
)
mm_fd
=
os
.
open
(
args
.
device
,
os
.
O_RDWR
)
if
args
.
transmit
!=
""
:
if
vuart_puts
(
args
.
transmit
)
>
0
:
sys
.
exit
(
"Terminated"
)
while
True
:
key
=
sys
.
stdin
.
read
(
1
)
if
(
len
(
key
)
>
0
):
if
key
==
chr
(
1
):
break
else
:
if
vuart_putc
(
ord
(
key
))
!=
0
:
break
c
=
vuart_getc
()
if
c
>
0
:
sys
.
stdout
.
write
(
chr
(
c
))
sys
.
stdout
.
flush
()
except
OSError
as
error
:
sys
.
exit
(
'Device i/o failed: {}'
.
format
(
error
))
finally
:
termios
.
tcsetattr
(
stdio_fd
,
termios
.
TCSADRAIN
,
old
)
sw/spec7-tools/README.md
View file @
6d7d40ea
...
...
@@ -31,7 +31,11 @@ PCIe_vuart
------------
A python script to emulate a termios terminal to utilize an uart connection on the White Rabbit ref design.
./spec7-tools/Pcie_vuart/spec7_vuart.py
./spec7-tools/Pcie_vuart/spec7_pl_vuart.py
Another script in this directory uses the same technology to communicate with an AXI-UART that is connected to the PS.
./spec7-tools/Pcie_vuart/spec7_ps_vuart.py
SMBus_reset
------------
...
...
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