6502.org http://forum.6502.org/ |
|
Programming ATF150x with Openocd http://forum.6502.org/viewtopic.php?f=10&t=7920 |
Page 1 of 2 |
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 |
Author: | cbscpe [ Wed Jul 17, 2024 2:03 pm ] |
Post subject: | Re: Programming ATF150x with Openocd |
I'm stuck with ATMISP not starting, it says FTD2xx.dll missing. There is no such thing for Windows 11 on ARM, I'm running Windows in Parallels on a MacBook Air M3. Anyone here that has ATMIPS V7.3 running on Windows 11 on ARM? |
Author: | BigDumbDinosaur [ Wed Jul 17, 2024 5:40 pm ] |
Post subject: | Re: Programming ATF150x with Openocd |
GlennSmith wrote: PART 1 Hi all, After having spent hours & hours of head scratching and web searching I finally got a toolchain working for programming ATF1504s...Some things I've found out by accident and error, however :
I'm just now getting around to reading this topic. Regarding DOS vs. UNIX line termination, as Gordon notes, some Linux distros have the unix2dos utility to make the conversion (and there is dos2unix to go the other way). In case you don’t have unix2dos on your machine, I’ve attached source code so you can build it. unix2dos runs at least 100 times faster than a BASH script when working on a file that is entirely UNIX line ends. Attachment:
|
Author: | GlennSmith [ Sat Jul 20, 2024 7:36 am ] |
Post subject: | Re: Programming ATF150x with Openocd |
Quote: In case you don’t have unix2dos on your machine, I’ve attached source code so you can build it. unix2dos runs at least 100 times faster than a BASH script when working on a file that is entirely UNIX line ends. Thanks BDD. And -at last- the penny has dropped that the tool is called unix to dos, not linux. So, yes, I already had it from the beginning. But the speed thing isn't really important. Besides, I'm quite nostalgic of the time on my HP1000 when I had time to go make a cup of tea when I compiled a Pascal/1000 program |
Author: | GlennSmith [ Sat Jul 20, 2024 7:41 am ] |
Post subject: | Re: Programming ATF150x with Openocd |
@cbscope Quote: I'm stuck with ATMISP not starting, it says FTD2xx.dll missing. Did you get past that hurdle? I'm assuming that it's looking for the USB driver, but I'm not sure where you should pick it up from - unless it's the "standard" FTD232 driver? I have so many things running under wine on my system I don't really know where any of the DLLs came from. |
Author: | cbscpe [ Thu Jul 25, 2024 7:57 pm ] |
Post subject: | Re: Programming ATF150x with Openocd |
No I had no success. I also tried to manually install the FTDI drivers for Windows on ARM. Now the JTAG programmer ATDH1150USB is recognized and the drivers are loaded, but ATMISP still exits with the message FTD2xx.dll missing. I have contacted microchip support and they will look into the issue. It is really the last missing piece in order to be able to migrate everything to my M3 notebook. As a workaround I still have a MacBook Pro with an Intel with bootcamp. I even managed to get W10 running in a emulated i86 VM in UTM on my M3 but it is extremely slow. I‘m also still looking into a command line solution to create svf files, unfortunately the chn file does not allow to save svf as output, so using atmisp as commandline does not work. I let you know when I have an answer from microchip. |
Author: | hoglet [ Thu Jul 25, 2024 9:02 pm ] |
Post subject: | Re: Programming ATF150x with Openocd |
cbscpe wrote: I‘m also still looking into a command line solution to create svf files, unfortunately the chn file does not allow to save svf as output, so using atmisp as commandline does not work. I let you know when I have an answer from microchip. An alternative to ATMISP for converting Atmel .jed files to .svf is an open source tool called fuseconv. This is part of Project Bureau, which is reverse engineering the Atmel CPLDs: https://whitequark.github.io/prjbureau/ ... econv.html The tool itself can be found in the Project Bureau github repository: https://github.com/whitequark/prjbureau It's written in python, so it cross platform. I've used this successfully myself on an ATF1508AS: https://stardot.org.uk/forums/viewtopic ... 55#p417055 https://stardot.org.uk/forums/viewtopic ... 96#p415696 No Windows system is required! Dave |
Author: | AndrewP [ Fri Jul 26, 2024 8:22 am ] |
Post subject: | Re: Programming ATF150x with Openocd |
plasmo wrote: 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 Just making a note for myself that a lot of plasmo's adventures with EPM7xxxS devices are posted here: ATF1504AS: Questions about this CPLD And also that the LabTool-48UXP lists all the EPM7xxx devices as supported. Including the non-jtag non-S versions. But I have no idea where to buy the LabTool-48UXP, where to buy the adapters for the MAX7000 devices or if the LabTool-48UXP can supply the 12V needed put locked devices back in programming mode. |
Author: | GlennSmith [ Thu Aug 01, 2024 1:33 pm ] |
Post subject: | Re: Programming ATF150x with Openocd |
@cbscpe, and just for completeness: on a different thread, akohlbecker said : Quote: I did have some trouble initially with FTDI drivers, but putting the FTD2XX.DLL file found in this archive https://ftdichip.com/wp-content/uploads/2022/02/CDM-v2.12.36.4-for-ARM64-Signed-Distributable.zip inside the ATMISP directory made it work. I did have to use the one from the "x86" folder.
|
Author: | cbscpe [ Sun Aug 11, 2024 6:58 pm ] |
Post subject: | Re: Programming ATF150x with Openocd |
GlennSmith wrote: @cbscpe Quote: I'm stuck with ATMISP not starting, it says FTD2xx.dll missing. Did you get past that hurdle? I'm assuming that it's looking for the USB driver, but I'm not sure where you should pick it up from - unless it's the "standard" FTD232 driver? I have so many things running under wine on my system I don't really know where any of the DLLs came from. Microchip stated that I should use the standard FTDI drivers and manually install them as it is required for Windows 11 on ARM and described in the document from FTDI. After that the JTAG programmer is recognized as USB device and the drivers are loaded, however ATMISP still refuses to start as it does not find the ftd2xx.dll. Alan from Microchip asked me to make some tests and create some screenshot. I also told him, that the FTDI standard drivers for Windows 11 on ARM do not include the 32 to 64 bit bridge DLL (typically located in c:\windows\SysWOW64) in order to allow 32 bit applications to access USB devices on a 64 bit OS (and Windows 11 on ARM is 64 bit only), he promised to get back, but I haven't heard anything from him since about a week. I will ping him. Also I will try the project bureau scripts that translate the .JED into a .SVF. These are python scripts. And then I will try to play the SVF file via openecd to program an ATF1504. If this works I would no longer need ATMISP, next week I should find some time to test this. |
Page 1 of 2 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |