6502.org http://forum.6502.org/ |
|
Programming ATF150x with Openocd http://forum.6502.org/viewtopic.php?f=10&t=7920 |
Page 1 of 1 |
Author: | GlennSmith [ Tue Jan 09, 2024 8:07 am ] |
Post subject: | Programming ATF150x with Openocd |
PART 1 Hi all, After having spent hours & hours of head scratching and web searching I finally got a toolchain working for programming ATF1504s. Several people commented that it would be a good idea to document my work. So here goes... Toolchains These are my current toolchains for SPLD and CPLD development. I'll say it again, I'm a NEWBIE to the world of GALs / SPLDs /CPLDs. I started reading about them (on this forum, of course) less than a year ago, when I started *really* designing my 6502 WBC (c) Garth Wilson. That is to say once I realized that I could greatly reduce address decoding delays by "simply" replacing my 74xx138s with an SPLD. All that I document here is the result of my long uphill struggle to get a) my brain around the new ideas; b) the tools to work... So, what I use to effectively design for and "burn" : ATF16V8/ATF22V10 : WinCUPL -> (.jed) Arduino AfterBurner ATF150x : WinCUPL -> (.jed) ATMISP -> (.svf) OpenOCD + USB Blaster (I'm also evaluating "Digital", which is a GREAT xPLD learning tool, also the generation of either WinCUPL input files or .jed directly) So, let's get started. Turning an idea into a working design and .jed file. WinCUPL (version 5.30.4 Atmel) running under/inside Wine (8.0.2) Spoiler alert : I can't/won't give any real development advice here : perhaps someone on the forum could help-out... But I *have* braved the dragons to especially understand how the simulator works, 'cos it's very useful for seeing if the CPL code actually works as expected! Some things I've found out by accident and error, however :
Code: #!/bin/bash if [ $# -eq 0 ] then echo "Please supply a filename or file range" exit 1 fi sed -i '/\r/! s/$/\r/' $1
WinCUPL, if the wind is coming from the right direction and the dragons are sleeping, will generate a .jed file (and a useful .doc file that has a lovely drawing of the chip and it's pinouts). For the ATF16V8 or ATF22V10 chips this .jed file is all we need to program using a standard GAL programmer. The Afterburner that I mention above is an Arduino shield and is a great little project to build https://github.com/ole00/afterburner. |
Author: | drogon [ Tue Jan 09, 2024 8:33 am ] |
Post subject: | Re: Programming ATF150x with Openocd |
GlennSmith wrote: I work exclusively on Linux, and WinCUPL wants DOS/Win file endings, so before opening WinCUPL I run a short script on my .CPL You may want to see if your Linux has the commands: dos2unix and unix2dos built-in... they're quite handy for stuff like this. Thanks for the rest of this. -Gordon |
Author: | GlennSmith [ Tue Jan 09, 2024 8:41 am ] |
Post subject: | Re: Programming ATF150x with Openocd |
PART 3 Before going any further, we now need to talk nuts'n'bolts : we need to connect to our device-to-be-programmed... There are many development CPLD boards out there, many of which are compatible with the Atmel/Microchip devices. I already have far too many development boards for far too many different architectures, so I just bought a simple 44-pin breakout from the usual chinese supplier. It has to be wired with power supply and the JTAG signals, but it's not too busy for a breadboard ; Attachment: The JTAG signals from/to the USB Blaster are better seen on this schematic : Attachment: The 10-pin connector is the connection to the USB Blaster. When wiring your breadboard (or designing your own breakout/dev board), DO :
Unprotecting If, like me, you buy your first 'victims' from the same chinese supplier 'cos they're very cheap - you'll invariably find that they refuse to be programmed or even identified. Don't bin them just yet. They are most probably read/write protected (or have the JEDEC pins reprogrammed for 'user' functions). They can be unprotected simply by applying a 'programming' voltage on one special pin. The pin is refernced "Vpp" on the above schematic. For the ATF150n series, the programming voltage is 12v. Be warned, if you apply 12v to ANY OTHER PIN of your device, you'll most probably let the smoke out of the box. Keep the 12v Vpp applied and you should find that the device will be properly identified. Sometimes there's an extra surprise : the device's ID doesn't match the printing on the chip! A simple way of providing a suitable 12v on your spaghetti-board is to use an MT3608 step-up module, like this : Attachment: The input is your 5v (Vcc), you adjust the output to be 12v, and you can hot plug/unplug the 12v pin easily on the breadboard. If your design leaves the JEDEC special pins unattributed, you should only need to unlock the device once. IMPORTANT NOTES :
Now we have the hardware ready, let's get started with OpenOCD : |
Author: | GlennSmith [ Tue Jan 09, 2024 8:59 am ] |
Post subject: | Re: Programming ATF150x with Openocd |
PART4 OpenOCD (native Linux, version 0.12.0) I did have troubles with the "preferred" version in the Mint/Ubuntu repositories and also the executable images on the openocd website https://openocd.org/ . Most probably because I have just soooo many dev tools on my dev PC... So anyway I downloaded the full archive of the latest stable version and compiled and built it using the provided install tools. I also fell into the usual "clone trap" : the USB Blaster I was given is supposed to be a V2 but it isn't. So I'll try to highlight the two processes for the two types of USB blaster ( V1 : ftdi interface or V2 : native USB ). If installing from scratch, you'll need to ensure a few things for the USB communications to work (either version):
Code: # Intel FPGA Download Cable SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="0666" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6002", MODE="0666" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6003", MODE="0666" # Intel FPGA Download Cable II SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6010", MODE="0666" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6810", MODE="0666" (and no, the 666 isn't some mystical incantation - just R+W permissions !)
Blaster V1 process : ... it *should* work out of the box ... Try typing (cut/paste ) this : Code: openocd -f <your path to openocd>/scripts/interface/altera-usb-blaster.cfg -c "adapter speed 400" -c "jtag newtap ATF1504AS tap -irlen 3 -expected-id 0x0150403f" -c init -c "sleep 200" -c shutdown [ Note the "expected-id" parameter. If things don't seem to work correctly, check that the id really *does* match the ID of your chip ] You should see a transcript like : Code: Open On-Chip Debugger 0.12.0 Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : only one transport option; autoselect 'jtag' adapter speed: 400 kHz Info : usb blaster interface using libftdi Error: unable to get latency timer Info : This adapter doesn't support configurable speed Info : JTAG tap: ATF1504AS.tap tap/device found: 0x0150403f (mfg: 0x01f (Atmel), part: 0x1504, ver: 0x0) << Yipeee !! Warn : gdb services need one or more targets defined shutdown command invoked If you see this, especially the "tap/device found" part, then you're well underway ! Now's the time to check that the device ID is correct. What all the above gibberish means :
In this case "altera-usb-blaster.cfg" is the configuration script for our ftdi-based USB Blaster.
NOTE : all of these, and many more, commands are explained in the user guide (locally or online at https://openocd.org/doc-release/pdf/openocd.pdf ) NOTE : if your device refuses to identify itself, it may be that it is protected : see "Unprotecting" above. Here is a sample programming session : 1) Erasing the device (using the Erase.svf file created in ATMISP, above) : (note that your path to openocd may be different to mine) Code: openocd -f /usr/local/share/openocd/scripts/interface/altera-usb-blaster.cfg -c "adapter speed 400" -c "jtag newtap ATF1504AS tap -irlen 3 -expected-id 0x0150403f" -c init -c "svf Erase.svf" -c "sleep 200" -c shutdown From this point onwards, you shouldn' need the Vpp voltage anymore. Remember to follow the shutdown sequence, remove the 12v and away you go! 2) Programming the device (here I'm using the code for Daryl "8-bit" 's 6502<->SPI interface) : Code: openocd -f /usr/local/share/openocd/scripts/interface/altera-usb-blaster.cfg -c "adapter speed 400" -c "jtag newtap ATF1504AS tap -irlen 3 -expected-id 0x0150403f" -c init -c "svf 6502_SPI.svf" -c "sleep 200" -c shutdown Blaster V2 process : I haven't dug any deeper to find-out if there is an alternative, but using this version of the USB Blaster requires at least one file from the Quartus Lite package. As it turns-out I had already tried installing Quartus (it actually installs native Linux) to see if it would program the ATF150x chips (spoiler : it doesn't). There is a special openocd configuration file ( <path to openocd>/scripts/interface/altera-usb-blaster2.cfg ) that needs to be modified before trying to use the system. You'll need to be familiar with a text editor that can be run with "sudo" privileges (e.g. nano), to modify the file so it looks like : Code: # # Altera USB-Blaster II # adapter driver usb_blaster usb_blaster vid_pid 0x09fb 0x6010 0x09fb 0x6810 usb_blaster lowlevel_driver ublast2 usb_blaster firmware /home/glenn/intelFPGA_lite/22.1std/quartus/linux64/blaster_6810.hex [color=#BF0000]<<-- this is important[/color]. ( The higher privileges are required because the file resides in a directory where you normally only have read access. ) It is very possible that the blaster_6810.hex file is all that is required, and that it can be "procured" without treading on any copyright toes, but as I don't currently need this setup I'm not going to investigate further. Once the config file is correctly modified, the rest is exactly the same, except you replace .../interface/altera-usb-blaster.cfg with .../interface/altera-usb-blaster2.cfg. You can follow the instructions for Blaster V1, above. |
Author: | plasmo [ Tue Jan 09, 2024 11:28 am ] |
Post subject: | Re: Programming ATF150x with Openocd |
Excellent, excellent write up! I particularly interested in your way of erasing locked CPLD with .svf file. I'm a long time user of Quartus and EPM7xxxS CPLD. Quartus is much superior to WinCUPL and USB Blaster clone is much cheaper than Atmel programmer, but EPM7xxxS is no longer in production and the used parts are mostly locked. I've limited success unlocking with .pof programming file with 12V applied to /OE pin; your approach with .svf file is very interesting. I'll definitely give it a try! Bill |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |