Minimal Tube 6502decode bus snoop with FTDI USB

discuss both original and modern hardware for the bbc micro/electron
cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sat Feb 10, 2018 7:26 pm

I hooked up a PLD and now I've got the bidirectional coms working.

So far so good. I've made it play nice with a copro so you can daisy chain any external copro through it.

Code: Select all

Address        Write         Read
======================================
FEF0-FEF8      copro         copro
FEF9-FEFE      USB FIFO      USB FIFO
FEFF           tube on/off   FT232H Status
The top byte of the full Tube memory region reads as the FT232H status (data available, space available, suspend, configured). Writing bit 0 to it enables or disables the tube by blocking the ~tube signal to the daisy chain connector.

There are some GPIO on the FT232H. I'm wondering if this can be used to syncronise block reads at the BBC end for flat out reads without underflowing the 1K FIFO.. I'll think about that.

Code: Select all

.loop
LDA status (4)
LSR A (2)
BCC check_status (2)
LDA data (4)
STA (mem),Y (6)
INY (2)
BNE loop (3)
A simple read loop like above checking status each byte would be 23 cycles per byte... that's 87KB/s. The loop could be optimised. If you know the FIFO holds enough data though you can read->store without checking the status.... ~10 cycles per byte :)

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 04, 2018 3:00 pm

No progress I'm afraid because I've been working in Germany these past few weeks.

I'll get the boards ordered tomorrow or Tuesday though & then they usually take about 2 weeks to turn up. I'll only order 10 because not many people responded. I ordered box headers and the other connectors too so I can provide complete kits if people want.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Mon Mar 05, 2018 7:58 pm

Board design. I'll double check it tomorrow and get the PCBs on order.

Under the optional PLD are jumpers to short out if the PLD is not fitted (CPU snoop only).

Top:
top.png
Bottom:
bottom.png

User avatar
marcusjambler
Posts: 766
Joined: Mon May 22, 2017 12:20 pm
Location: Bradford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by marcusjambler » Mon Mar 05, 2018 9:38 pm

Hi Chris

Registering my interest in 1 built board inc programmed CPLD

Marcus

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Wed Mar 21, 2018 11:05 am

The PCBs arrived in the post today.

Topside:
Photo1276.jpg
Bottomside:
Photo1275.jpg
I will build one up and check it is all good. :)

A really unfortunate thing is that the status bit for RX data available is B0 and not B6 or B7 which would have allowed a BIT, Bxx loop for data available checking. One could ROR I suppose and reset the tube on/off flag after (if needed) or is there another way to check B0?

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Wed Mar 21, 2018 2:10 pm

Assembled:
Photo1277.jpg
I built one up and everything seems to work fine. I tested both the minimal snoop (no PLD) and the bidirectional comms (+PLD). All good it seems. :)

Normal pin headers (super cheap) can be substituted for box headers. The FT232H PCB could be soldered direct instead of using 10 pin female SIL headers.

I am still waiting on delivery of more box headers for those wishing to buy a complete kit.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Thu Mar 22, 2018 11:08 am

I have been through the costs... PayPal F&F

PCB: £2
PLD (programmed): £1.50
Connectors (all): £1.50
P&P (large letter): £1.50

I will post the JED file so if you can supply and program your own PLD then no problem. If you have the connectors or want to solder directly then that's fine. Pick'n'mix!

I also have a spare purple module which someone can have for what I paid for it... £6
Edit: Claimed by RobC

I am still waiting on the box headers... if you want to supply your own headers I can ship this week.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Fri Mar 23, 2018 10:41 am

Some box headers arrived. I ordered 30 and received 10. Thanks aliexpress seller.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Fri Mar 23, 2018 12:57 pm

Caution!

The purple modules I bought from aliexpress have dead EEPROMs. It is SMD soldering to replace the EEPROM.

Bbuy the purple modules from eBay which have CJMCU-232H on the silkscreen. Search FT232H or CJMCU-232H.

User avatar
marcusjambler
Posts: 766
Joined: Mon May 22, 2017 12:20 pm
Location: Bradford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by marcusjambler » Fri Mar 23, 2018 1:16 pm

Mines this one chris
232h.jpg

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Fri Mar 23, 2018 2:21 pm

That's the good one. The 6 pin EEPROM should have 2Pxx (e.g. 2PAP) written on it if it is a proper Microchip EEPROM.

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sat Mar 24, 2018 12:40 pm

I've just received the kit from Chris, so hopefully I'll get this up and running over the next day or two.

Thanks Chris.

RobC
Posts: 2807
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by RobC » Sat Mar 24, 2018 1:31 pm

hoglet wrote:I've just received the kit from Chris, so hopefully I'll get this up and running over the next day or two.
Me too - thanks for the speedy service Chris :D

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sat Mar 24, 2018 2:42 pm

Hi Chris,

I've got it build and connected to my Beeb now.

A few "noob" questions?

From a power supply perspective, it seems you have to have the FT232H module fitted and power up for the Tube to work. Is that expected? Are there any precautions than need to be taken with respect to power supply sequencing?

Do you have any suggestions for what software to use on Linux to do a capture? Or have you been using only Windows so far? I've tried just using cat and dd, and the transfer rate is very low. It seems to be capturing valid bytes, but I think with lots of gaps.

Also, do I need to do any configuration of the FT232H module to put it in "CPU FIFO" mode. Is this a config bit in the EEPROM, or something the driver software needs to do? As I'm actually seeing fragments of valid data, I'm assuming you have already done this to my purple board?

Dave

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sat Mar 24, 2018 3:00 pm

Good to hear they have arrived.

Over the next few days I will write up the details of how to assemble, configure and use it. As well as a few BASIC programs.

I hacked together a simple C# d2xx reader program for Windows which streams the full bus activity flawlessly on a ten year old laptop. I'll post that too - might start a github account to do that.

I've had great success using a USB port direct on the computer not through a USB hub. Your mileage may vary.
hoglet wrote:A few "noob" questions?
Shoot. I'll try to cover as much in the docs as I can think of too.
hoglet wrote:From a power supply perspective, it seems you have to have the FT232H module fitted and power up for the Tube to work. Is that expected? Are there any precautions than need to be taken with respect to power supply sequencing?
Yes the whole board is USB bus powered. You must power the USB first or you crash the BBC. I couldn't stop the FT232H from crashing the BBC with all sorts of OE tests so I gave up. The chip takes a few ms to configure and the PLD holds the Tube enable/disable state while USB power is on.
hoglet wrote: Do you have any suggestions for what software to use on Linux to do a capture? Or have you been using only Windows so far? I've tried just using cat and dd, and the transfer rate is very low. It seems to be capturing valid bytes, but I think with lots of gaps.
Windows so far. I used cat from cygwin but have saturated the VCOM mechanism stream at 1.9MB/s on my laptop. So I wrote a C# program using FTDI d2xx drivers - ten liner which captures everything with 3-5% CPU usage. I'd look at the d2xx FTDI drivers for linux.
hoglet wrote: Also, do I need to do any configuration of the FT232H module up put it in "synchronous 245 parallel mode". Is this a config bit in the EEPROM, or something the driver software needs to do?
It is the CPU mode not the synchronous mode. This is configured in the EEPROM. I did your (& RobC's) module before I posted it. I will publish instructions for everyone else soon. You just need the "FTDI prog" utility and I'll post the configuration template. I set the drive to 4mA (lowest) and schmitt trigger inputs too - which you can tinker with if you wish.

I'll probably get on the docs tomorrow. I'll reserve a few posts in this thread so all the info is together + put some links in the top post.

Chris

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sat Mar 24, 2018 6:21 pm

Hi Chris,

I've been experimenting with libftdi this afternoon:
https://www.intra2net.com/en/developer/libftdi/

They have some example code that streams using Sync 245 FIFO mode:
https://github.com/legege/libftdi/blob/ ... eam_test.c

I've been able to modify this to run in Async 245 FIFO mode, just by commenting out this section:
https://github.com/hoglet67/6502Decoder ... est.c#L245

I'm pretty sure that Async 245 FIFO mode is compatible with the way that you have wired the signals for CPU FIFO mode.

Anyway, it seems to work, and I'm able to do long, error free, captures:

Code: Select all

./build.sh
./stream_test data.bin
      0.00s total time     0.004 MiB captured     0.0 kB/s curr rate     0.0 kB/s totalrate
      1.00s total time     1.910 MiB captured  1949.1 kB/s curr rate  1952.1 kB/s totalrate
      2.00s total time     3.817 MiB captured  1949.4 kB/s curr rate  1950.8 kB/s totalrate
      3.01s total time     5.724 MiB captured  1949.4 kB/s curr rate  1950.3 kB/s totalrate
      4.01s total time     7.630 MiB captured  1949.1 kB/s curr rate  1950.0 kB/s totalrate
      5.01s total time     9.537 MiB captured  1949.4 kB/s curr rate  1949.9 kB/s totalrate
      6.01s total time    11.443 MiB captured  1949.1 kB/s curr rate  1949.8 kB/s totalrate
      7.01s total time    13.350 MiB captured  1949.4 kB/s curr rate  1949.7 kB/s totalrate
      8.01s total time    15.257 MiB captured  1949.1 kB/s curr rate  1949.6 kB/s totalrate
      9.01s total time    17.163 MiB captured  1949.4 kB/s curr rate  1949.6 kB/s totalrate
     10.02s total time    19.070 MiB captured  1949.4 kB/s curr rate  1949.6 kB/s totalrate
cleanup
Capture ended.
I've not yet got it to work correctly in CPU FIFO mode, for reasons I don't understand. It seems to be dropping data. Note the lower data rate:

Code: Select all

./stream_test xxx
      0.00s total time     0.011 MiB captured     0.0 kB/s curr rate     0.0 kB/s totalrate
      1.00s total time     1.784 MiB captured  1815.5 kB/s curr rate  1819.5 kB/s totalrate
      2.00s total time     3.554 MiB captured  1812.7 kB/s curr rate  1816.1 kB/s totalrate
      3.00s total time     5.338 MiB captured  1826.0 kB/s curr rate  1819.4 kB/s totalrate
      4.00s total time     7.120 MiB captured  1824.6 kB/s curr rate  1820.7 kB/s totalrate
CPU Utilization is ~80% compared with ~2% in Async 245 FIFO mode. So something is very different.

Is there any reason you picked CPU FIFO mode rather than Async 245 FIFO mode?

Dave

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sat Mar 24, 2018 7:24 pm

hoglet wrote: I'm pretty sure that Async 245 FIFO mode is compatible with the way that you have wired the signals for CPU FIFO mode.

I've not yet got it to work correctly in CPU FIFO mode, for reasons I don't understand. It seems to be dropping data. Note the lower data rate:
CPU FIFO mode is configured by the EEPROM. You can't configure it over the wire. The module will still be in CPU FIFO for all your tests I imagine unless you reprogrammed the EEPROM.
hoglet wrote: CPU Utilization is ~80% compared with ~2% in Async 245 FIFO mode. So something is very different.
Sounds like a driver problem. Why should there be any difference the PC end between FT232H modes? The driver could be doing something stupid like requesting a single byte per USB frame or something... High CPU usage is why it is dropping frames.
hoglet wrote: Is there any reason you picked CPU FIFO mode rather than Async 245 FIFO mode?
Yes. It matches the bus more closely & doesn't have the !RXF (!CS in CPU FIFO) & !TXE (A0 in CPU FIFO) signals. It also allows you to query the FIFO status on the host. RXF & TXE are outputs so they will be clashing with PLD CS output & A0 respectively.

But as I said I think the FT232H will be in CPU FIFO mode anyway because that is the EEPROM configured mode.

TO prove one way or the other, remove the PLD (& short J4 1-2) and scope RXF & TXE to see if they are outputs... or try switching to bi-dir comms mode and write a BASIC program to query they status and read/write or echo some data... if you get valid FT232H FIFO status then you must be in CPU FIFO - regardless of what the driver thinks.

Chris

Edit: It really ought to still be in CPU FIFO mode...
Section 4.13 of the FT232H datasheet
4.13 FT232H Mode Selection
The FT232H defaults to asynchronous serial interface (UART) mode of operation.
After a reset the required mode is determined by the contents of the external EEPROM which can be
programmed using FT_Prog.
The EEPROM contents determine if the FT232H device is configured as FT232 asynchronous serial
interface, FT245 FIFO interface, CPU-style FIFO interface, FT1248 or Fast Serial Interface.
Following a reset, the EEPROM is read and the FT232H configured for the selected mode. After device
enumeration, the FT_SetBitMode command (refer to D2XX_Programmers_Guide) can be sent to the
USB driver to switch the selected interface into other modes – asynchronous bit-bang, synchronous bitbang
or MPSSE – if required.
When in FT245 FIFO mode, the FT_SetBitMode command can be used to select Synchronous FIFO
(FT_SetBitMode = 0x40). Note that FT245 FIFO mode must be configured in the EEPROM before
selecting the Synchronous FIFO mode.
The drive strength selection, slew rate and Schmitt input function can also be configured in the EEPROM.
The MPSSE can be configured directly using the D2XX commands. The D2XX_Programmers_Guide is
available from the FTDI website. The application note AN_108 – Command Processor for MPSSE and MCU
Host Bus Emulation Modes gives further explanation and examples for the MPSSE.

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sat Mar 24, 2018 11:23 pm

cmorley wrote:
hoglet wrote: I'm pretty sure that Async 245 FIFO mode is compatible with the way that you have wired the signals for CPU FIFO mode.

I've not yet got it to work correctly in CPU FIFO mode, for reasons I don't understand. It seems to be dropping data. Note the lower data rate:
CPU FIFO mode is configured by the EEPROM. You can't configure it over the wire. The module will still be in CPU FIFO for all your tests I imagine unless you reprogrammed the EEPROM.
I reprogrammed the EEPROM (using ft_prog on Windows) to put in in 245 FIFO mode.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 6:27 am

hoglet wrote:I reprogrammed the EEPROM (using ft_prog on Windows) to put in in 245 FIFO mode.
Ahhh ok....
Did you leave the PLD off? Without the PLD did you fit all the jumpers under the PLD socket? J4 pulls CS low. J5 pulls A0 low to write to the FIFO instead of immediate send. Immediate send would kill your throughput.

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sun Mar 25, 2018 8:35 am

cmorley wrote:
hoglet wrote:I reprogrammed the EEPROM (using ft_prog on Windows) to put in in 245 FIFO mode.
Ahhh ok....
Did you leave the PLD off? Without the PLD did you fit all the jumpers under the PLD socket? J4 pulls CS low. J5 pulls A0 low to write to the FIFO instead of immediate send. Immediate send would kill your throughput.
I fitted the PLD and none of the J4/J5/J6 jumpers.

I don't see any differences in the data sheet for the way that "Send Immediate" works between Async 245 Mode and CPU Mode. But it does seem likely, given the difference in CPU Load, that I'm somehow causing "Send Immediate" to be triggered.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 9:17 am

hoglet wrote: I fitted the PLD and none of the J4/J5/J6 jumpers.

I don't see any differences in the data sheet for the way that "Send Immediate" works between Async 245 Mode and CPU Mode. But it does seem likely, given the difference in CPU Load, that I'm somehow causing "Send Immediate" to be triggered.
Ok. I know what is happening... #-o A0 is still being generated by the PLD. So every time A4..0=0x1f then F232H_A0=1 & it does a send immediate. I assume that means it sends 1 or maybe 2 frames every 32 bytes instead of 62 bytes per USB frame (IIRC)

Code: Select all

PIN 15  = ft_A0                   ; /* FT232H A0                       */
.... snip ...
top = A0 & A1 & A2 & A3 & A4;
write_tube = Tube & !RW; /* any tube range being written */
read_tube = Tube & RW; /* any tube range being written */
.... snip ...
ft_A0 = top; /* if top read then choose status reg otherwise FIFO */
I didn't include the !Tube signal in the A0 generation. If I do then a spurious send immediate would only occur if &FEFF was being accessed. Any other fix would require bodge wire & jumper/switch.

Curses. I'll sort a fix and PM the people I posted PLDs already.

Dave do you have a programmer which can program a ATF16V8B?

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sun Mar 25, 2018 9:40 am

cmorley wrote: Ok. I know what is happening... #-o A0 is still being generated by the PLD. So every time A4..0=0x1f then F232H_A0=1 & it does a send immediate. I assume that means it sends 1 or maybe 2 frames every 32 bytes instead of 62 bytes per USB frame (IIRC)
Ah, yes. That would explain why I'm only seeing the problem in CPU FIFO mode, and not in Async FIFO Mode.

If I write some 6502 code that never sets A4..0 to 0x1F, then we shouldn't see and frames dropped. I might give this a quick try.

Is Windows somehow immune to this? Or is your system fast enough to cope?
cmorley wrote: Dave do you have a programmer which can program a ATF16V8B?
Yes, I think my G540 can program these.

Dave

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 9:58 am

hoglet wrote:Ah, yes. That would explain why I'm only seeing the problem in CPU FIFO mode, and not in Async FIFO Mode.

If I write some 6502 code that never sets A4..0 to 0x1F, then we shouldn't see and frames dropped. I might give this a quick try.
Yes this should confirm it. Instruction fetches are going to be the main generator... a loop crossing &xx1f would be a killer!
hoglet wrote: Is Windows somehow immune to this? Or is your system fast enough to cope?
I definitely tested the minimal no-PLD build and I'm sure I tested the with PLD configuration but maybe not (I can't actually remember). I fully tested the comms mode and clearly didn't give PLD+snoop enough of a look.
hoglet wrote:Yes, I think my G540 can program these.
I just googled it and downloaded the device list. It is supported so I will send you a JED file shortly.

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sun Mar 25, 2018 10:02 am

hoglet wrote: If I write some 6502 code that never sets A4..0 to 0x1F, then we shouldn't see and frames dropped. I might give this a quick try.
Just to confirm your diagnosis, if I run the following program:

Code: Select all

 10 P%=&2000
 20[
 30 .test
 40 SEI
 50 .loop
 60 CLC
 70 LDA &7C00
 80 ADC #0
 90 STA &7C00
100 LDA &7C01
110 ADC #0
120 STA &7C00
130 JMP loop
140]
150 CALL test
Then capturing in CPU FIFO Mode works fine, and the load on the system is negligible.

Dave

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 11:38 am

The PLD code change fixed the issue Dave found.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 11:41 am

PCB assembly

There are 2 configuration options for the PCB.
  1. Minimal - no PLD bus snoop only
  2. Full - with PLD bus snoop + bidirectional comms
1) Minimal
  • Fit FT232H module (2x 10 pin connectors or solder directly)
  • Fit Host Tube connector (box header or pin headers)
  • Link/jumper J3 2-3, J4 1-2, J5, J6
That's all that is necessary.

2) With PLD
  • Fit FT232H module (2x 10 pin connectors or solder directly)
  • Fit Host Tube connector (box header or pin headers)
  • Optionally fit 2nd Processor connector (box header or pin headers)
  • Fit jumper J3 (don't fit J4, J5 or J6)
  • Fit PLD (20 pin DIL socket or solder directly)
Last edited by cmorley on Sun Mar 25, 2018 12:57 pm, edited 2 times in total.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 11:41 am

Purple board notes

The purple FT232H breakout boards are available on eBay. Search from FT232H or CJMCU-232H. Buy the one with CJMCU-232H printed on the silk screen. Currently £6.13 on eBay.

Caution! I ordered a couple from aliexpress but these had faulty configuration EEPROMs so stick to eBay :?

Assembly:
They come flat pack with pin headers. Solder the 2x10pin headers from the chip side so the LEDs will be face up when installed on the Tube adapter board. No need to fit the 4 pin header.

For the minimal Tube board config I recommend you cut the track to the middle LED (see photo) or remove the LED/resistor. This connection goes to the BBC's 2MHz clock buffer - cutting the track avoids unnecessary load (& pullup) on the 2MHz signal.
purple cut track.jpg
With the PLD installed on the Tube board cutting the track is less important. My board has a cut track and it works... the choice it yours!

Configuration:
The purple boards are delivered with a blank EEPROM. This needs to be programmed to set the mode & IO.

Download the FTDI FT_PROG utility.
http://www.ftdichip.com/Support/Utilities.htm#FT_PROG

Download the configuration template.
ftdi.xml
(4.19 KiB) Downloaded 18 times
  1. Install & start FT_PROG
  2. Connect your purple board
  3. Run DEVICES->SCAN AND PARSE (F5)
  4. Right click on the found device & run Apply template->From File
  5. Select the XML template
  6. Run DEVICES->Program (control P)
If FT_PROG throws an error like "device found but not recognised" then a Windows restart cures this.

Drivers:
Windows will automatically install the FTDI drivers and create a virtual com port.

Old COM ports
Most users can skip this...

If you've had your PC for ages and plugged loads of USB com devices in over the years all the low numbered com ports can be reserved. Some old apps don't like high com port numbers. Good news, you can clear them out!
  1. Right-click "Command Prompt" in Accessories and choose "Run as Administrator"
  2. Enter set devmgr_show_nonpresent_devices=1
  3. Enter start devmgmt.msc
  4. In the box that opens, select View->Show hidden devices menu
  5. Expand the ports section and whack the grey old ones (say no to remove driver question)
If you delete one you needed it will reinstall next time you connect that device to the USB so risk is low.
Last edited by cmorley on Sun Mar 25, 2018 12:55 pm, edited 1 time in total.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 11:41 am

Source

This project is open source and license free.

PCB adapter:

Schematic:
FT232H tube snoop PCB schematic.png
Gerbers:
18008.rar
(268.12 KiB) Downloaded 13 times
Programmable Logic Device:
For the bidirectional communications mode you need to fit a ATF16V8B PLD. They are still manufactured and can be bought from many distributors. Be careful ordering from eBay/aliexpress because you are likely to receive fake/remarked parts - they may work they may not!

Other 16V8 PLDs will likely work too.

Wincupl source:

Code: Select all

Name     proto ;
PartNo   18.008 ;
Date     10/02/2018 ;
Revision 01 ;
Designer CFM ;
Company  boobip.com ;
Assembly None ;
Location  ;
Device   g16v8as ;

/* *************** INPUT PINS *********************/
PIN 1   = clk_2MHzE               ; /* Host 2MHzE clock                */ 
PIN 2   = D0                      ; /* Host D0                         */ 
PIN 3   = power                   ; /* Host 5V                         */ 
PIN 4   = RW                      ; /* Host R/W                        */ 
PIN 5   = A0                      ; /* Host A0                         */ 
PIN 6   = A1                      ; /* Host A1                         */ 
PIN 7   = A2                      ; /* Host A2                         */ 
PIN 8   = A3                      ; /* Host A3                         */ 
PIN 9   = A4                      ; /* Host A4                         */ 

PIN 11  = !Tube                   ; /* Host ~Tube                      */ 

/* *************** OUTPUT PINS *********************/
PIN 12  = !par_Tube               ; /* Parasite ~Tube                  */ 
PIN 14  = !ft_CS                  ; /* FT232H ~CS                      */
PIN 15  = ft_A0                   ; /* FT232H A0                       */
PIN 16  = !ft_RD                  ; /* FT232H ~RD                      */ 
PIN 17  = !ft_WR                  ; /* FT232H ~WR                      */
PIN 19  = pld_tube_off            ; /* Disable parasite                */

/* *************** PINNODES    *********************/
PINNODE 13  = ft232h_statusread_latch; /* Ever read USB status?           */ 
PINNODE 18  = ft232h_dowrite_latch;    /* This cycle a bus write?         */ 


/* *************** DECLARATIONS ********************/


$MACRO MUX A1 A2 WS
(A1&!WS)#(A2&WS);
$MEND

$MACRO EQ A1 A2
(A1 & A2)#(!A1 & !A2);
$MEND

/* *************** LOGIC       *********************/

top = A0 & A1 & A2 & A3 & A4;
write_tube = Tube & !RW; /* any tube range being written */
read_tube = Tube & RW; /* any tube range being written */

access_parasite = !A3 & !A4 & !pld_tube_off; /* parasite tube ULA target */ 
access_ft232h_fifo = !top & !access_parasite; /* FT232H FIFO target */

/* PLD access */
write_pld_en = top & write_tube # !power; /* write on host access or power off */
write_pld_d = power & D0; /* reset if power off or value in D0 */

pld_tube_off = MUX(pld_tube_off, write_pld_d, write_pld_en); /* PLD latch */

/* FT232H USB status register access */
ft232h_statusread_latch = power & (ft232h_statusread_latch # top & read_tube & clk_2MHzE);

/* co-pro tube enable/disable generation */
par_Tube = Tube & access_parasite;

/* FT232H read/write control */
ft232h_dowrite = access_ft232h_fifo & write_tube;
ft232h_dowrite_latch = MUX(ft232h_dowrite_latch, ft232h_dowrite, clk_2MHzE);

ft_CS = 'b'1; /* permanent chip select */
ft_RD = !access_parasite & read_tube & clk_2MHzE; /* read unless parasite region & active */
ft_WR = ft232h_dowrite_latch & !clk_2MHzE; /* write in FIFO region only */
ft_A0 = ft232h_statusread_latch & top & read_tube; /* if top read then choose status reg otherwise FIFO */
JED file + source:
PLD JED + source.zip
(3.5 KiB) Downloaded 15 times
Last edited by cmorley on Sun Mar 25, 2018 2:03 pm, edited 1 time in total.

cmorley
Posts: 1237
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by cmorley » Sun Mar 25, 2018 11:42 am

Operation

I have the bus snoop working perfectly on a 10 year old laptop. You don't need the latest kit. Snoop collects 2MB per second which is fine for USB2 and older PCs.

For the best results I connect straight to a USB2 plug on the laptop. Avoid hubs as these add extra delay.

Power

The FT232H board and PLD are powered from the USB. Power it up before you power the BBC - or the BBC will crash when the FT232H chip initialises & tramples the data bus :(

Bi-Directional comms

The FTDI virtual com port (VCP) driver on the PC works fine for bidir comms because the max data rate is 'slow' for a PC... even at 200KB/s.

You can therefore use any terminal program or serial program on the PC including the the command line type and copy redirection to a COM port. Some PC programs won't use high COM port numbers. You can change the COM port number of the FT232H module to suit. Mine is COM8 in all the examples.

If using the command line (cmd.exe) make sure you put the COM port in 8-bit mode (default is 7bit).

Code: Select all

mode com8:9600,n,8,1
Dump something to the COM port with:

Code: Select all

type file.txt > com8:
copy file.txt \\.\com8
copy file.txt com8
The syntax \\.\ works for high COM port numbers. Use /b with copy to copy binary instead of text.
Read from COM port with:

Code: Select all

type com8: > test.txt
copy com8 test.txt
If using copy then stop the transfer by sending ESC (char 27).

You can use any terminal program which supports COM ports. COM ports are easy to program for especially in modern frameworks like .NET

On the BBC end for trivial work you can use BASIC e.g.

Code: Select all

REM Wait for byte and print
REP.U.(?&FEFF AND1):P.?&FEFE
REM send an A
?&FEFE=ASC("A")
Note: using ? in BASIC to write performs a spurious read so this will consume an input byte! With this limitation you can still do a lot like transfer files streaming to BPUT etc.

It is better to use assembler though. This can be called from BASIC by USR or CALL of course.

Code: Select all

.waitrx:LDA &FEFF:LSR A:BCC waitrx \ wait for byte
LDA &FEFE \ read from PC
.waittx:LDA &FEFF:BIT #2: BNE waittx \ wait for space
STX &FEFE \ write to PC
Registers & flags. This table is printed on the PCB :)
table.png
The FT232H has two 1KB FIFOs, one each for TX & RX.

Snoop

If your computer is recent you might be able to use type to read the 2MB/s snoop stream without dropping any packets. My 10 year old laptop can't quite keep up.

Code: Select all

type com8 > snoop.bin
If your computer is _really_ fast you can pipe it straight to the decode6502 tool! =P~

The FTDI D2xx driver will work at 2MB/s on an old PC using 5% CPU. It is trivial to use from C# & .NET

Code: Select all

            var ftdi = new FTD2XX_NET.FTDI();
            FTDI.FT_STATUS r;

            uint devcount = 0;
            r = ftdi.GetNumberOfDevices(ref devcount);

            var devlist = new FTDI.FT_DEVICE_INFO_NODE[devcount];

            r = ftdi.GetDeviceList(devlist);
            r = ftdi.OpenByDescription("USB <-> Serial Converter");
            r = ftdi.SetDataCharacteristics(FTDI.FT_DATA_BITS.FT_BITS_8, FTDI.FT_STOP_BITS.FT_STOP_BITS_1, FTDI.FT_PARITY.FT_PARITY_NONE);

            int totalbytes = 0;
            int reqbytes = 2000000 * 1;
            int rnum = 3968;

            var buf = new byte[reqbytes];
            var smallbuf = new byte[rnum];

            MemoryStream ms = new MemoryStream(buf);

            while (totalbytes < reqbytes)
            {
                int fetchn = Math.Min(rnum, reqbytes - totalbytes);

                uint n = 0;
                r = ftdi.Read(smallbuf, (uint)fetchn, ref n);
                totalbytes += (int)n;
                ms.Write(smallbuf, 0, (int)n);
            }
A read tool is on my todo list... PM me if you want something and I'll push it up my priorities!

Build hoglet's 6502 decode for use on Windows

You can build the tool on cygwin or WSL. I looked briefly for the command line options library for Windows but gave up... this is the only dependancy which prevents you simply compiling native Windows (or other).

cgywin - GUI installer
  • Install cygwin from http://www.cygwin.com
  • install gcc & the libargp & libargp-devel library hoglet uses
  • get hoglet's source https://github.com/hoglet67/6502Decoder
  • edit the build.sh command to "gcc -Wall -O3 -D_GNU_SOURCE -o decode6502 src/main.c src/em_6502.c src/profiler.c -largp"
  • build with "./build.sh"
  • "./decode6502.exe" to run
That's it!

With cygwin you can run cygwin executables from the cygwin terminal or Windows - from command prompt or launched from another process e.g. notepad++
Last edited by cmorley on Fri Apr 20, 2018 11:53 am, edited 3 times in total.

User avatar
hoglet
Posts: 9091
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Minimal Tube 6502decode bus snoop with FTDI USB

Post by hoglet » Sun Mar 25, 2018 1:40 pm

Reserved: Linux notes

Post Reply

Return to “8-bit acorn hardware”