Last year, I acquired my first VIC-20 and when I discovered that someone shared the Gerber files for a fairly recent version of the Final Expansion 3 (english) for that machine on Github, I decided to set out and build one of those, of course. The FE3 might be a story for a later post, though. Because in order to build that cartridge, I first had to find an affordable way to program the ATF1504 CPLD that is used here.
The ATF1504 has a JTAG interface and that was the obvious choice for the task. I had a CJMCU (?) FT232HQ breakout board (from eBay) lying around that I had used before together with OpenOCD to successfully program the Xlinix CPLDs used in the replacement PLA.
First though, I had to convert the JED file for the CPLD into a SVF file that I could then play over the JTAG interface. After some research, more trial-and-error and a little help from the folks at Forum64, I learned that this could be done using the ATMISP tool provided by Atmel.
Next, I whipped up a temporary adapter on a breadboard and tried to write the resulting SVF file to the CPLD using different players — with no success. After some time spent debugging my setup, I ordered additional ATF1504 ICs from a more reliable source. With these, I was finally able to program the CPLD using OpenOCD:
bin-x64\openocd.exe -f scripts\interface\ftdi\um232h.cfg -c "adapter_khz 400" -c "transport select jtag" -c "jtag newtap ATF1504AS tap -irlen 3 -expected-id 0x0150403f" -c init -c "svf VC20FINAL-V3-2.svf" -c "sleep 200" -c shutdown
It turned out that the devices from the first batch that I received weren’t quite as new as the seller had claimed. They had been used before and probably programmed in a way that disabled the JTAG interface. Luckily, I received another reply on Forum64 hinting at a way to bring those ICs back to life.
Though (almost) not documented in the datasheet, the OE1 pin of the ATF1504 doubles as Vpp. According to the author of the post, applying 12V to that PIN through a current limiting resistor would reset the JTAG functionality. So I added a 12V power supply to the breadboard contraption and created another SVF file to erase the CPLD, again using ATMISP. And indeed, with 12V on OE1 I was able to erase the used ATF1504!
bin-x64\openocd.exe -f scripts\interface\ftdi\um232h.cfg -c "adapter_khz 400" -c "transport select jtag" -c "jtag newtap ATF1504AS tap -irlen 3 -expected-id 0x0150403f" -c init -c "svf atf1504as-erase.svf" -c "sleep 200" -c shutdown
In order to be able to reproduce all of this later more easily, I decided to write this blog post and I moved on to create a custom PCB that would replace the breadboard adapter and plug as a “hat” onto the FTDI board.
I had to wait quite a while for the last components to arrive, but then I was able to successfully assemble and test the ATF1504-FT232HQ Shield. It features a MAX662 boost converter to produce the 12V programming voltage on-board.
As usual, the project files for the adapter board are available on Github. Finally, a big thanks to the ever helpful crowd on Forum64 who guided me along the way!
bei microchip ist ATMISP nicht mehr zu finden … kannst du das tool auf github hochladen? danke!
Well, no, for obvious reasons I cannot upload proprietary software to Github. But it is really easy to find it on Microchip’s site if you use a search engine: https://www.microchip.com/design-centers/fpgas-and-plds/splds-cplds/pld-design-resources
Thank you for your project
Can you give your version of openocd. With the last version (OpenOCD 0.10.0 ), I don’t have the same syntax and it’s not working
Sure, I’ve been using OpenOCD version 0.10.0-rc2.
I have encountered the same problem when I try to program a ATF1502, I have used Altera USB Blaster and UrJtag. After connecting OE1 to 12 volt the chip back to life! I’m be able to program only 1 chip of 2, one not respond at all even if I use the above trick, anyway thank for the help!
This works great, it took some hours to figure it all out but now it works great!
thank you for releasing this project for free for people to use, helped me alot and salvaged 18 ATF1502AS that i could not program before! (cheap aliexpress :p)
What type of capacitor are you using for C7 and C8. Seems to be a KEMET one. If I open the KiCAD file it says it should be a SMD 1206 (3216 metric). But I couldn’t find one at the usual suppliers.
Looking at the schematics again now, I noticed a typing error: both C7 and C8 should have 4.7uF as described in the datasheet for the MAX662A. Maybe, this is already what you were struggling with. I used polarized tantalum caps but I can’t tell anymore where I got them from. They should be easy enough to find though, e.g. part no. “T491B 4,7U 20” at Reichelt.
I’ve tried to program my svf file to the ATF1504AS. I get the following message:
Open On-Chip Debugger 0.11.0 (2021-03-07-12:52)
Licensed under GNU GPL v2
For bug reports, read
adapter speed: 400 kHz
Info : clock speed 400 kHz
Info : JTAG tap: ATF1504AS.tap tap/device found: 0x0150403f (mfg: 0x01f (Atmel), part: 0x1504, ver: 0x0)
Warn : gdb services need one or more targets defined
svf processing file: “Z80_512K.svf”
Time used: 0m0s0ms
svf file programmed successfully for 0 commands with 0 errors
shutdown command invoked
What does the warning mean. Is the CPLD programmed? I cannot find any target definitions for the ATF1504AS within OPENOCD.
I am not exactly sure what the warning means, but I’m also getting it and it does not matter for our simple flashing purposes. The rest of the output you are getting from OpenOCD looks good, too. Except for the part saying “0 commands with 0 errors”, which probably means that your CPLD has not been programmed.
Do you have any of your F232HQ shield boards lying around? I’m trying to work out what I need to program the ATF1504 for the same Final Expansion 3 project and am struggling a bit 🙂 I have a TL866 II programmer, a GQ4x4 programmer and a Waveshare DLC10 Platform Cable USB CPLD/FPGA programmer but none seems to be able to program the ATF1504. I saw your project here and thought I might reach out to you to see if you have anything left over when you made your hats up?
I’m almost certain that I still have a few of those PCBs lying around. But unfortunately, I also suspect that shipping to the UK might be more expensive that having 5 more of them made and shipped from China…
Ahh – you’re not in the UK? That’s a pity.. I generated the gerbers from the github you have setup but jlcpcb tells me that there’s an error with them.. not sure what it is..
Could you generate the gerbers from your latest design and email them to me, if that’s not an imposition?
I have also shared this project on PCBWay. So, if you don’t mind using them instead you could order the PCBs directly.
Hello, I am trying to program my atf1504as, could you tell me if the CJMCU FT232HQ has to be configured first before connecting it to the atf1504as, my chips also have the jtag blocked but I can’t unlock them with the 12v in the OE1, thanks.
No, I did not have to configure the FTDI-Module in any way. As far as I know, all the necessary configuration is volatile and taken care of by OpenOCD. Maybe your chips aren’t just locked but actually broken?
Pingback: MSX-USB - The Retro hacker