Another Home-Brew - Z180

General "chat", not necessarily MTX related
Martin A
Posts: 459
Joined: 09 Nov 2013 21:03

Re: Another Home-Brew - Z180

Post by Martin A » 08 Feb 2020 23:47

Using PVC insulated wire is a LOT trickier than using the Kynar covered "stuff" designed for wire wrapping.

PVC tends to shrink back when a hot iron is placed on the wire, Kynar doesn't, that makes a massive difference when you've got a few hundred, (or thousand) points to wire.

Bill B
Posts: 243
Joined: 26 Jan 2014 16:31

Re: Another Home-Brew - Z180

Post by Bill B » 07 Mar 2020 22:14

I have not had much free time to work on this recently, but I am making slow progress.

At least I now know that my EPM7032S chips are not JTAG locked :)

Altera developed the Jam Standard Test and Programming Language for defining the signals needed to program and test JTAG devices. The idea is that the language can be implemented on embedded devices to provide in-system modification, see the description here.

The source for a Jam interpreter can be downloaded from here. Although the download is nominally a Windows executable, it is actually a self-extracting zip file, and can be expanded on Linux using "unzip jp_25.exe", without having to run the file.

I edited the source to use RPi GPIO to read and write the JTAG signals, and used a 74HCT245 to raise the outputs to 5v and a resistor divider to drop TDO back to 3.3v.

A Jam file to read the ID code of a chip is available from here. Running this file with my modified Jam player gives:

Code: Select all

pi@raspberrypi:~/JAM $ ./jam -gtck=17,tms=22,tdi=23,tdo=27 -f1000 -aread_idcode idcode.jam
Jam STAPL Player Version P01 (20170909)
Copyright (C) 1997-2004 Altera Corporation

******************************************************************************
* Altera Chain Interrogation Version 5.0                                     *
*   Copyright (c) 1999-2007 Altera Corporation.  All Rights Reserved.        *
******************************************************************************
Chain Continuity Checker
  Chain Continuity during IR is not stuck at zero or one
******************************************************************************
Chain Length -- Load IR of all ones then count DR length
  Number of Devices is 1
******************************************************************************
IR Length Calculator
  Instruction Register Length is 10
******************************************************************************
IDCODE Reader
  ---------- | ---- ------------------- ------------- - |
  TDO -> TDI | Rev  Device              Mfgr          1 |
  ---------- | ---- ------------------- ------------- - |
  Device #1  | 0000 0111 0000 0011 0010 0000 1101 110 1 | 
  ---------- | ---- ------------------- ------------- - |
******************************************************************************
Device Identifier -- Search for device name from list of device IDCODE values
  ---------- |      ------------------- -------------   |
  TDO -> TDI |      Device              Mfgr            |
  ---------- |      ------------------- -------------   |
  Device #1  |      EPM7032S            Altera          |
  ---------- |      ------------------- ------------- - |
******************************************************************************
Exit code = 0... Success
I repeated this with each of my EPM7032S so I know that they all have working JTAG.

As described in the documentation, Quartus can produce Jam files which it should be possible to program the chip. So I generated the Jam file for my design. A single Jam file can perform a number of different actions, one of which can be selected by the -a switch when running the Jam player. Once again, testing the ID code looks hopeful:

Code: Select all

pi@raspberrypi:~/JAM $ ./jam -gtck=17,tms=22,tdi=23,tdo=27 -f1000 -aCHECK_IDCODE Z180_EC_Mem_CPLD.jam 
Jam STAPL Player Version P01 (20170909)
Copyright (C) 1997-2004 Altera Corporation

Device #1 IDCODE is 070320DD
DONE
Exit code = 0... Success
However, trying to use the Jam player to actually program one of the chips results in:

Code: Select all

pi@raspberrypi:~/JAM $ ./jam -gtck=17,tms=22,tdi=23,tdo=27 -f1000 -aERASE Z180_EC_Mem_CPLD.jam 
Jam STAPL Player Version P01 (20170909)
Copyright (C) 1997-2004 Altera Corporation

Unrecognized device
Exit code = 6... Unrecognized device

pi@raspberrypi:~/JAM $ ./jam -gtck=17,tms=22,tdi=23,tdo=27 -f1000 -aPROGRAM Z180_EC_Mem_CPLD.jam 
Jam STAPL Player Version P01 (20170909)
Copyright (C) 1997-2004 Altera Corporation

Unrecognized device
Exit code = 6... Unrecognized device
This is not the first time I have run across this problem. I also encountered it a few years back when attempting to use Jam to program an EPM7128S for my CFX-II.

The Jam files are simply text files, containing instructions in the Jam language, and it is possible to edit them and insert diagnostics. I have done so, and I know exactly where in the source the code is exiting. However the code is fairly cryptic, so although I know where the chip is being rejected, I don't understand why. It may be it is testing for a blank chip (although that would not make sense for the erase action).

It would be possible to just bypass the test and let the code continue. But if that part of the Jam code is faulty, I don't have any confidence that the actual programming code is correct, and I could end out just locking the chip.

So back to trying to work out why programming with my USB Blaster clone is not working :( This is the first project I have tried to use this on.

Martin A
Posts: 459
Joined: 09 Nov 2013 21:03

Re: Another Home-Brew - Z180

Post by Martin A » 08 Mar 2020 15:08

If you have a "spare" EPM7128, you could shove that into the CFX-II and test your USB blaster with that. And hopefully confirm that it is working.

Bill B
Posts: 243
Joined: 26 Jan 2014 16:31

Re: Another Home-Brew - Z180

Post by Bill B » 21 Mar 2020 18:00

Finally found the first issue with my USB Blaster clone. The ten wire data cable had been assembled with one of the connectors reversed :o

I did not have a spare connector, and these IDC connectors are not meant to be removable. However, with some careful levering I was eventually able to remove the reversed connector, and put it back again the correct way around, shortening the cable by a cm. Having done so the cable has been carefully checked for both continuity of each connection, and short circuits between adjacent pins, and tests OK.

However, I am still not having much luck :(

I am using the Tools / JTAG Chain Debugger option in Quartus:

Testing with a EPM7032S on a breadboard, with no power applied to the chip, I get
JTAG_3.png
JTAG_3.png (1.89 KiB) Viewed 1165 times
which is not surprising. If I also apply 5v to the 7032 then I get no response to either the JTAG chain test or the IDCODE iteration test.

So next move was to try the same tests against my CFX-II. Result with no power applied was the "No device detected", as expected. However, applying 5v to the CFX-II and repeating the JTAG chain test gives variable results, one of which is shown below:
JTAG_1.png
JTAG_1.png (35.98 KiB) Viewed 1165 times
However, on repeated tests I have seen one, two or three devices detected, either with Unknown ID, or random IDs.

Following Martin's experience I have tried replacing the USB cable to the USB Blaster, but that does not make any difference.

Possibilities:
  • My USB Blaster was faulty from the beginning.
  • It has been damaged connecting it while the cable was twisted.
  • There is something else that I am still missing.

Bill B
Posts: 243
Joined: 26 Jan 2014 16:31

Re: Another Home-Brew - Z180

Post by Bill B » 31 May 2020 14:49

This project has not been abandoned. it is just taking longer than expected.

It got put on the back burner while I played with CFX-II video, but I am now, sort of, back on it. The problem is still that of programming the CPLD. Having had one programmer that I purchased fail, I am disinclined to buy another. While I thank the various offers of the loan of a programmer, I prefer to be independent.

I always prefer to make my own tools where possible. Searching the net, there are a number of designs published for a DIY USB-Blaster. These all seem to link back to one source http://sa89a.net/mp.cgi/ele/ub.htm (in Japanese). This design uses a PIC18F14K50 microcontroller. Trouble is that needs another programmer to configure.

As a side note, I took the top off of the USB-Blaster clone I purchased and it contains one PIC18F14K50 and two LVC125A, so almost certainly derived from the above design.

Not wishing to get involved in an infinite regression of programming tools, I tried to think what else I might use that would not require any special tools. My first thought was to use a Raspberry Pi Zero, which can be used as a USB gadget. This eventually failed owing to a limitation with the RPi Zero USB interface that I was not able to overcome :( The details can be found here.

However, I have not given up. My next idea is to try using a Teensy 3.5. That is also able to act as a USB slave device.

Martin A
Posts: 459
Joined: 09 Nov 2013 21:03

Re: Another Home-Brew - Z180

Post by Martin A » 31 May 2020 19:56

If you've got an older PC with a parallel port, you could consider building a byte blaster. The circuit for those is on the net, and seems to be 2 chips and some passives.

Bill B
Posts: 243
Joined: 26 Jan 2014 16:31

Re: Another Home-Brew - Z180

Post by Bill B » 01 Jun 2020 18:35

I do have some old PCs with parallel ports, but I doubt any of them are up to running Quartus.

One option would be to try and purchase a serial / parallel card for the (reasonably) modern PC I am running Quartus on.

Slightly more interesting would be to try and run Quartus within some form of VM, and then hook into the VM pseudo-parallel port, Would then need to send the output to an RPi to drive the JTAG, and get the result back. I doubt I could do that fast enough, unless I can run the VM on an RPi 4, but that would require QEMU or similar to emulate x86.

What would be really nice is if somebody had published the EthernetBlaster protocol. Unless Quartus used any significant crypto, that should be easy to emulate. But I can't find anything published. I did try a simple Python script. I saw Quartus connect, but it was then clearly expecting some response, and without knowing what I was unable to get any further.

Bill B
Posts: 243
Joined: 26 Jan 2014 16:31

Re: Another Home-Brew - Z180

Post by Bill B » 17 Jun 2020 14:22

Forward progress at last :o

I (eventually) managed to turn a Teensy 3.5 into a "USB Blaster" clone. Details here. Breadboard testing suggests that the resulting programmed EPM7032S behaves as expected.

Since, as part of my work on CFX video, I built a Raspberry Pi powered programmer for Flash ROM chips, I just need to write some initial firmware, and I should be able to test my first board.

And then start work on the second board. No idea how long that will take.

User avatar
1024MAK
Posts: 612
Joined: 24 Dec 2012 03:01
Location: Looking forward to summer, in Somerset, UK

Re: Another Home-Brew - Z180

Post by 1024MAK » 17 Jun 2020 19:49

👍 :D

Mark

Martin A
Posts: 459
Joined: 09 Nov 2013 21:03

Re: Another Home-Brew - Z180

Post by Martin A » 19 Jun 2020 22:09

Sheesh that's a lot of work to get the CPLS programmed!

But it's done now :D

Post Reply