From fae47fd5db20dfc636287268d39999b30287524d Mon Sep 17 00:00:00 2001 From: "Walter F.J. Mueller" Date: Sun, 8 Jan 2017 19:50:00 +0100 Subject: [PATCH] Auto-dection of Digilent boards with FT2232HQ interface - ti_rri: allow --term=USBD for Digilent autodetect - ti_w11: allow -tuD,.... for Digilent autodetect; add -bn4d --- doc/w11a_os_guide.md | 77 ++++++++++++++++++----------------------- tools/bin/ti_rri | 38 ++++++++++++++++++-- tools/bin/ti_w11 | 34 +++++++++++------- tools/man/man1/ti_rri.1 | 10 +++--- tools/man/man1/ti_w11.1 | 29 ++++++++++------ 5 files changed, 116 insertions(+), 72 deletions(-) diff --git a/doc/w11a_os_guide.md b/doc/w11a_os_guide.md index 13d7c689..cfefbf4d 100644 --- a/doc/w11a_os_guide.md +++ b/doc/w11a_os_guide.md @@ -13,12 +13,13 @@ ### I/O emulation setup All UNIBUS peripherals which exchange data (currently DL11, LP11, PC11, RK11, -and RL11) are currently emulated via a backend process. The communication -between FPGA board and backend server can be via +RL11, RPRH and TM11 ) are currently emulated via a backend process. The +communication between FPGA board and backend server can be via - Serial port - via an integrated USB-UART bridge - - on arty, basys3, and nexys4 with a `FT2232HQ`, allows up to 12M Baud + - on Arty, Basys3, and Nexys4 and Nexys4 DDR with a `FT2232HQ`, + allows up to 12M Baud - on nexys3 with a `FT232R`, allows up to 2M Baud - via RS232 port, as on s3board and nexys2 - using a serial port (/dev/ttySx) is limited to 115 kBaud on most PCs. @@ -30,7 +31,7 @@ between FPGA board and backend server can be via - also allows to configure the FPGA over the same USB connection - Notes: - - A 10M Baud connection, like on a nexys4, gives disk access rates and + - A 12M Baud connection, like on a nexys4, gives disk access rates and throughputs much better than the real hardware of the 70's and is well suitable for practical usage. - In an OS with good disk caching like 2.11BSD the impact of disk speed @@ -43,14 +44,15 @@ between FPGA board and backend server can be via Recommended setup for best performance (boards ordered by vintage): -| Board | Channel/Interface | nom. speed | peak transfer rate | -| :---- | :---------------- | :--------- | -----------------: | -| arty | USB-UART bridge | 10M Baud | 910 kB/sec | -| basys3 | USB-UART bridge | 10M Baud | 910 kB/sec | -| nexys4 | USB-UART bridge | 10M Baud | 910 kb/sec | -| nexys3 | Cypress FX2 USB | USB2.0 speed | 30000 kB/sec | -| nexys3 | Cypress FX2 USB | USB2.0 speed | 30000 kB/sec | -| s3board | RS232+USB-RS232 cable | 460k Baud | 41 kB/sec | +| Board | Channel/Interface | nom. speed | peak transfer rate | +| :--------- | :--------------------- | :----------- | -----------------: | +| Arty | USB-UART bridge | 12M Baud | 1090 kB/sec | +| Basys3 | USB-UART bridge | 12M Baud | 1090 kB/sec | +| Nexys4 DDR | USB-UART bridge | 12M Baud | 1090 kb/sec | +| Nexys4 | USB-UART bridge | 12M Baud | 1090 kb/sec | +| Nexys3 | Cypress FX2 USB | USB2.0 speed | 30000 kB/sec | +| Nexys2 | Cypress FX2 USB | USB2.0 speed | 30000 kB/sec | +| S3board | RS232+USB-RS232 cable | 460k Baud | 41 kB/sec | ### FPGA Board setup @@ -58,43 +60,29 @@ Recommended setups - Arty - connect USB cable to micro-USB connector labeled 'J10' - - to configure via vivado hardware server - - make .vconfig - + - to configure via vivado hardware server `make .vconfig` - Basys3 - connect USB cable to micro-USB connector labeled 'PROG' - - to configure via vivado hardware server - - make .vconfig - + - to configure via vivado hardware server `make .vconfig` -- Nexys4 +- Nexys4 and Nexys4 DDR - connect USB cable to micro-USB connector labeled 'PROG' - - to configure via vivado hardware server - - make .vconfig + - to configure via vivado hardware server `make .vconfig` - Nexys3 - use Cypress FX for configure and and rlink communication - connect USB cable to micro-USB connector labeled 'USB PROG' - - to configure via FX2 and jtag tool - - make .jconfig + - to configure via FX2 and jtag tool `make .jconfig` - Nexys2 - connect USB cable to mini-USB connector (between RS232 and PS/2 port) - - to configure via FX2 and jtag tool - - make .jconfig + - to configure via FX2 and jtag tool `make .jconfig` - S3board - connect the USB-RS232 cable to the RS232 port - connect a JTAG programmer (e.g. Xilinx USB Cable II) to JTAG pins - - to configure via ISE Impact - - make .iconfig + - to configure via ISE Impact `make .iconfig` ### Rlink and Backend Server setup @@ -114,7 +102,7 @@ All examples below use the same basic setup - for arty over serial SWI = 0110 (gives console light emulation...) - ti_w11 -tu,12M,break,xon @_boot.tcl + ti_w11 -tuD,12M,break,xon @_boot.tcl **Note**: the arty w11a has currently only 176 kB memory (all from BRAMS!) unix-v5 works fine. XXDP, RT11 and RSX-11M should work. @@ -123,17 +111,17 @@ All examples below use the same basic setup - for b3 over serial SWI = 00000000 00101000 (gives console light display on LEDS) - ti_w11 -tu,12M,break,xon @_boot.tcl + ti_w11 -tuD,12M,break,xon @_boot.tcl **Note**: the basys3 w11a has only 176 kB memory (all from BRAMS!) unix-v5 works fine. XXDP, RT11 and RSX-11M should work. 211bsd will not boot, either most RSX-11M+ systems. - - for n4 over serial + - for n4 or n4d over serial SWI = 00000000 00101000 (gives console light display on LEDS) - ti_w11 -tu,12M,break,cts @_boot.tcl + ti_w11 -tuD,12M,break,cts @_boot.tcl - for n2,n3 over fx2 @@ -146,12 +134,15 @@ All examples below use the same basic setup ti_w11 -tu,460k,break,xon @_boot.tcl Notes: - - on ``, the serial device number - - check with `ls /dev/ttyUSB*` to see what is available - - `` is typically '1' if a single `FT2232HQ` based boardis connected, - like a arty, basys3, or nexys4. Initially two ttyUSB devices show up, - the lower is for FPGA config and will disappear when Vivado hardware - server is used once. The upper provides the data connection. + - the letter after `-tu` is either the serial device number, + denoted as ``, or the letter `D` for auto-detection of + Digilent boards with a FT2232HQ based interface. + - for Arty, Basys3 and Nexys4 board simply use `D` + - otherwise check with `ls /dev/ttyUSB*` to see what is available + - `` is typically '1' if a single `FT2232HQ` based board is connected, + like an Arty, Basys3, or Nexys4. Initially two ttyUSB devices show up, + the lower is for FPGA configuration and will disappear when the Vivado + hardware server is used once. The upper provides the data connection. - `` is typically '0' if only a single USB-RS232 cable is connected - on LED display diff --git a/tools/bin/ti_rri b/tools/bin/ti_rri index 97a3354b..de7ce445 100755 --- a/tools/bin/ti_rri +++ b/tools/bin/ti_rri @@ -1,8 +1,8 @@ #! /usr/bin/env tclshcpp # -*- tcl -*- -# $Id: ti_rri 799 2016-08-21 09:20:19Z mueller $ +# $Id: ti_rri 843 2017-01-08 18:15:27Z mueller $ # -# Copyright 2011-2016 by Walter F.J. Mueller +# Copyright 2011-2017 by Walter F.J. Mueller # # This program is free software; you may redistribute and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -15,6 +15,7 @@ # # Revision History: # Date Rev Version Comment +# 2017-01-08 843 1.4.3 allow --term=USBD for Digilent autodetect # 2015-01-09 776 1.2.2 add --tout option to setup rlc timeout before connect # 2015-01-09 631 1.2.1 use rlc get/set rather config # 2014-11-07 601 1.2 use tclshcpp (C++ based) rather tclsh @@ -258,6 +259,39 @@ if { $opts(term) } { set baud [lindex $nlist 1] if {$dev eq ""} {set dev "USB0"} if {$baud eq ""} {set baud "115k"} + + # autodetect Digilent usb device look to udev signature + # E: ID_SERIAL=Digilent_Digilent_USB_Device_ + # E: ID_USB_INTERFACE_NUM=01 + # Note on INTERFACE_NUM: '00' is configuration, '01' is communication EP + # + if {$dev eq "USBD" || $dev eq "/dev/ttyUSBD"} { + set dev_usbd {} + foreach udev [lsort [glob -nocomplain "/dev/ttyUSB*"]] { + set path [exec udevadm info -q path -n $udev] + set text [exec udevadm info --export -p $path] + set id_id {} + set id_sn {} + set id_in {} + foreach line [split $text "\n"] { + set line [string trim $line] + regexp -- {^E: ID_SERIAL=(.*)_(\d*)$} $line matched id_id id_sn + regexp -- {^E: ID_USB_INTERFACE_NUM=(.*)$} $line matched id_in + } + if {$id_id eq "Digilent_Digilent_USB_Device" && $id_in eq "01"} { + set dev_usbd $udev + break + } + } + if {$dev_usbd ne ""} { + set dev $dev_usbd + # puts "-I: Digilent USB interface detected: $dev_usbd" + } else { + puts "-E: no Digilent USB interface detected" + return 1 + } + } + set url "term:$dev?baud=$baud" foreach opt [lrange $nlist 2 end] { if {$opt ne ""} {append url ";$opt"} diff --git a/tools/bin/ti_w11 b/tools/bin/ti_w11 index e0a9cb8b..9e06867b 100755 --- a/tools/bin/ti_w11 +++ b/tools/bin/ti_w11 @@ -1,11 +1,12 @@ #!/usr/bin/perl -w -# $Id: ti_w11 835 2016-12-31 10:00:14Z mueller $ +# $Id: ti_w11 843 2017-01-08 18:15:27Z mueller $ # -# Copyright 2013-2016 by Walter F.J. Mueller +# Copyright 2013-2017 by Walter F.J. Mueller # License disclaimer see License.txt in $RETROBASE directory # # Revision History: # Date Rev Version Comment +# 2017-01-08 843 1.4.1 allow -tuD,.... for Digilent autodetect; add -bn4d # 2016-12-31 834 1.4 use rw11::shell by default; add -ns to suppress it # 2016-06-18 776 1.3.5 use ti_rri --tout now # 2016-03-20 748 1.3.4 BUGFIX: add portsel oob for -fx; @@ -44,13 +45,14 @@ my $opt_tmu; my $opt_ghw; my $tirri; my $val_term; -my $val_tb_s3 = "tbw $sysbase/s3board/tb/tb_w11a_s3 -fifo"; -my $val_tb_n2 = "tbw $sysbase/nexys2/tb/tb_w11a_n2 -fifo"; -my $val_tb_n3 = "tbw $sysbase/nexys3/tb/tb_w11a_n3 -fifo"; -my $val_tb_b3 = "tbw $sysbase/basys3/tb/tb_w11a_b3 -fifo"; -my $val_tb_n4 = "tbw $sysbase/nexys4/tb/tb_w11a_n4 -fifo"; -my $val_tb_bn4 = "tbw $sysbase/nexys4_bram/tb/tb_w11a_br_n4 -fifo"; -my $val_tb_bar = "tbw $sysbase/arty_bram/tb/tb_w11a_br_arty -fifo"; +my $val_tb_s3 = "tbw $sysbase/s3board/tb/tb_w11a_s3 -fifo"; +my $val_tb_n2 = "tbw $sysbase/nexys2/tb/tb_w11a_n2 -fifo"; +my $val_tb_n3 = "tbw $sysbase/nexys3/tb/tb_w11a_n3 -fifo"; +my $val_tb_b3 = "tbw $sysbase/basys3/tb/tb_w11a_b3 -fifo"; +my $val_tb_n4 = "tbw $sysbase/nexys4/tb/tb_w11a_n4 -fifo"; +my $val_tb_bn4 = "tbw $sysbase/nexys4_bram/tb/tb_w11a_br_n4 -fifo"; +my $val_tb_bn4d = "tbw $sysbase/nexys4d_bram/tb/tb_w11a_br_n4d -fifo"; +my $val_tb_bar = "tbw $sysbase/arty_bram/tb/tb_w11a_br_arty -fifo"; my $val_tb; my $val_e; @@ -118,6 +120,12 @@ while (scalar(@ARGV)) { $val_tb = $val_tb_bn4; shift @ARGV; + } elsif ($curarg =~ m{^-bn4s$} ) { # -bn4d (prim serport fine) + $opt_io = 'f'; + $opt_f = '1'; + $val_tb = $val_tb_bn4d; + shift @ARGV; + } elsif ($curarg =~ m{^-bar$} ) { # -bar (use -fx by default) $opt_io = 'f'; $opt_f = 'x'; @@ -128,7 +136,7 @@ while (scalar(@ARGV)) { $opt_f = $1; shift @ARGV; - } elsif ($curarg =~ m{^-t([su])(\d?),?} ) { # -t[su]... + } elsif ($curarg =~ m{^-t([su])(\d+|D),?} ) { # -t[su]... my $devnam = ($1 eq 's') ? '/dev/ttyS' : '/dev/ttyUSB'; my $devnum = $2; my ($dev,$baud,$opt1,$opt2) = split /,/,$curarg; @@ -140,7 +148,7 @@ while (scalar(@ARGV)) { } $opt_io = 't'; - $val_term = sprintf '%s%d,%s', $devnam, $devnum, $baud; + $val_term = sprintf '%s%s,%s', $devnam, $devnum, $baud; $val_term .= ",$opt1" if defined $opt1; $val_term .= ",$opt2" if defined $opt2; shift @ARGV; @@ -354,8 +362,8 @@ sub print_usage { print " setup options for FPGA connects:\n"; print " -u use --cuff connect\n"; print " -t.. use --term connect\n"; - print " -ts*[,opts] use /dev/ttyS* (* is device number)\n"; - print " -tu*[,opts] use /dev/ttyUSB* (* is device number)\n"; + print " -ts*[,opts] use /dev/ttyS* (* = device number)\n"; + print " -tu*[,opts] use /dev/ttyUSB* (* = device number or 'D')\n"; print " opts can be ',break', ',xon'\n"; print " common options:\n"; print " -ll set rlink logging level to (using --logl=)\n"; diff --git a/tools/man/man1/ti_rri.1 b/tools/man/man1/ti_rri.1 index a11040c9..c889f9a9 100644 --- a/tools/man/man1/ti_rri.1 +++ b/tools/man/man1/ti_rri.1 @@ -1,11 +1,11 @@ .\" -*- nroff -*- -.\" $Id: ti_rri.1 776 2016-06-18 17:22:51Z mueller $ +.\" $Id: ti_rri.1 843 2017-01-08 18:15:27Z mueller $ .\" -.\" Copyright 2013-2016 by Walter F.J. Mueller +.\" Copyright 2013-2017 by Walter F.J. Mueller .\" .\" ------------------------------------------------------------------ . -.TH TI_RRI 1 2016-06-18 "Retro Project" "Retro Project Manual" +.TH TI_RRI 1 2017-01-08 "Retro Project" "Retro Project Manual" .\" ------------------------------------------------------------------ .SH NAME ti_rri \- \fBRlink\fP Backend Server @@ -102,7 +102,9 @@ open a serial port type \fBrlink\fP port. Optional arguments are .RS .IP \fBname\fP tty device name, default is 'USB0'. If \fIname\fP does not start with '/' -the name is prefixed with '/dev/tty'. +the name is prefixed with '/dev/tty'. The special device name 'USBD' +triggers the auto-detection of a Digilent board with a FT2232C based +interface. .IP \fBbaud\fP serial port baud rate, default is '115k'. Allowed baud rate settings are: .RS diff --git a/tools/man/man1/ti_w11.1 b/tools/man/man1/ti_w11.1 index 48a0fd92..8767550e 100644 --- a/tools/man/man1/ti_w11.1 +++ b/tools/man/man1/ti_w11.1 @@ -1,11 +1,11 @@ .\" -*- nroff -*- -.\" $Id: ti_w11.1 834 2016-12-30 15:19:09Z mueller $ +.\" $Id: ti_w11.1 843 2017-01-08 18:15:27Z mueller $ .\" -.\" Copyright 2013-2015 by Walter F.J. Mueller +.\" Copyright 2013-2017 by Walter F.J. Mueller .\" .\" ------------------------------------------------------------------ . -.TH TI_W11 1 2015-11-01 "Retro Project" "Retro Project Manual" +.TH TI_W11 1 2017-01-08 "Retro Project" "Retro Project Manual" .\" ------------------------------------------------------------------ .SH NAME ti_w11 \- Quick starter for \fBti_rri\fP with \fBw11\fP CPU designs @@ -36,15 +36,19 @@ executing it. .IP \fB-u\fP use \fB\-\-cuff\fP connect (USB via Cypress FX2) .IP \fB-t\fIDN\fR[,\fIopts\fP] -use \fB\-\-term\fP connect, \fID\fP specifies device name, \fIN\fP -specified the device number, and \fIopts\fP the addtional options -a \fB\-\-term\fP can hold (e.g. break or xon). \fID\fP is mapped as +use \fB\-\-term\fP connect. +\fID\fP specifies device name. \fIN\fP specifies +the device number, or in case of the character 'D' the auto-detection of a +Digilent board with a FT2232C based interface. +\fIopts\fP specified the addtional options a \fB\-\-term\fP can hold +(e.g. break or xon). +\fID\fP is mapped as .RS .PD 0 .IP \fBs\fP 4 use /dev/ttyS* (* is device number \fIN\fP) .IP \fBu\fP 4 -use /dev/ttyUSB* (* is device number \fIN\fP) +use /dev/ttyUSB* (* is device number \fIN\fP or 'D') .PD .RE . @@ -56,6 +60,8 @@ start \fItb_w11a_b3\fP simulation (Basys3, default \fB-fx\fP) start \fItb_w11a_n4\fP simulation (Nexys4) .IP \fB-bn4\fP start \fItb_w11a_br_n4\fP simulation (Nexys4, BRAM only) +.IP \fB-bn4d\fP +start \fItb_w11a_br_n4d\fP simulation (Nexys4 DDR, BRAM only) .IP \fB-bar\fP start \fItb_w11a_br_arty\fP simulation (Arty, BRAM only, default \fB-fx\fP) .IP \fB-n3\fP @@ -117,13 +123,16 @@ Connected via USB, communication via Cypress FX2. \fBti_rri\fP(1) will be started and the given boot script executed. Typical way to start Nexys2 and Nexys3 boards. -.IP "\fBti_w11 -tu2,10M,break,cts @211bsd_rl_boot.tcl\fR" 4 +.IP "\fBti_w11 -tu2,12M,break,cts @211bsd_rl_boot.tcl\fR" 4 Assumes a FPGA board with a \fBw11\fP CPU design already configured. Connected via USB, communication via an USB UART. In this case the -device \fI/dev/ttyUSB2\fP will be used, with \fI10 MBaud\fP, \fIbreak\fP to +device \fI/dev/ttyUSB2\fP will be used, with \fI12 MBaud\fP, \fIbreak\fP to trigger auto-bauding, and \fIcts\fP to use hardware handshake. \fBti_rri\fP(1) will be started and the given boot script executed. -Typical way to start Nexys4 boards. + +.IP "\fBti_w11 -tuD,12M,break,cts @211bsd_rl_boot.tcl\fR" 4 +Like above, but now the USB device will be autodetected. +Typical way to start a Nexys4 board. .IP "\fBti_w11 -n3 -e $RETROBASE/tools/asm-11/w11/sys/dl11/simple_out.mac\fR" Will start the \fItb_w11a_n3\fP test bench in \fBghdl\fP(1), on the fly