As I alluded to in a previous post, I’ve come up with a way to program my Altera Cyclone II FPGA with a $15 FT232RL USB to UART Bridge, avoiding the $300 investment in one of Altera’s USB-Blaster cables.
I’m going to break this tutorial up into three separate posts. The first has already been uploaded: libFTDI v0.18 with Ubuntu (Lucid Lynx), which describes how to install the proper version of the hardware drivers on Ubuntu. This post, being the second in the series, will cover the hardware modifications required to interface the FT232RL with an FPGA setup. The third post will show the Python code used to push the FPGA configuration file down to the FPGA bit by bit.
The Cyclone II FPGA has a few different methods for configuration as described by the Altera Cyclone II Handbook:
- Active serial (AS) : Configuration using serial configuration devices (EPCS1, EPCS4, EPCS16 or EPCS64 devices). These can be described as basically non-volatile memory blocks that hold your configuration file. The Cyclone II will actually access this memory to configure itself on power-up.
- Passive serial (PS) : Configuration using enhanced configuration devices (EPC4, EPC8, and EPC16 devices), EPC2 and EPC1 configuration devices, an intelligent host (microprocessor), or a download cable.
- JTAG-based configuration : Configuration via JTAG pins using a download cable, an intelligent host (microprocessor), or the JamTM Standard Test and Programming Language (STAPL)
Previously, I had been configuring the Cyclone II on my SparkFun breakout board using the JTAG configuration method. Now I decided I wanted to start using a USB connection instead of the antiquated parallel port required for the Altera JTAG programmer, but to be honest this decision was partially based on the fact that my new computer has no parallel port. 😉
For this USB programming solution, we will be using the Passive Serial (PS) configuration method where our computer will act as the intelligent host.
The following diagram shows how we need to configure the breakoutboard for Passive Serial:
Here is the breakout board schematic showing the modifications we need to make: Removing four solder jumpers, and connecting half of one jumper to the supply voltage (Original Schematic here):
And here is the breakout board layout showing the changes to be made:
Finally, here is a picture of the changes made on my breakout board:
Okay, now we need to connect the FT232RL Breakout-board (BOB) to our Cyclone II BOB. First, let me show you the schematic for the FT232RL Breakout Board:
We are going to be using the FT232RL in bitbang mode. According to Table 2.1 of the FT232R Bit Bang Mode’s application note we have the following pin-outs for bitbang mode:
Bit Bang Pin | Chip Pins | Name |
0 | 1 | TXD |
1 | 5 | RXD |
2 | 3 | RTS |
3 | 11 | CTS |
4 | 2 | DTR |
5 | 9 | DSR |
6 | 10 | DCD |
7 | 6 | RI |
For convenience, I’ve drawn out where the bitbang pins are on the breakoutboard:
Now, our final step in setting up the hardware is to connect the DATA0, DCLK and NCONFIG pins of the Cyclone II to the FT232RL breakout board:
- Connect Pin 20 (DATA0) of the Cyclone II BOB to the BitBang Pin 0 of the FT232RL.
- Connect Pin 21 (DCLK) to BitBang Pin 1.
- Connect Pin 26 (NCONFIG) to Bitbang Pin 2.
Here is a capture from the Cyclone II BOB Schematic:
Finally, here is a picture of my FT232RL BOB inserted into my protoboard, you can see I ran some wires from the eight BitBang lines to the side of the protoboard for easier access.
That concludes the hardware modifications required for programming the Cyclone II (on a SparkFun BOB) using the FT232RL. Next post I’ll show the software required to process a configuration file and send it to the Cyclone II, bit by bit.
(Teaser: I’m currently working on a MUX system that will allow us to “reconnect” those FT232RL pins to I/O pins of the Cyclone II, instead of always being connected to the FPGA’s config pins. With a little work it should give us the ability to program and communicate with the FPGA for less than $15! 🙂 )
[…] Programming an Altera Cyclone II FPGA with a FT232RL USB to UART BridgeHere I show how to program the FPGA via USB instead of using the Parallel port. I found a way to manually bit bang the configuration file into the FPGA using Python and an FT232RL breakout board. […]
Hey Russell,
That is one option, however at the time I wanted to continue using those CBUS pins for their other features (48MHz CLK, RD & WR strobe).
With a few MUX’s we might be able to use only 1 CBUS pin to switch between config and general mode.
While I was in the middle of sourcing the MUX’s I needed I stumbled across the DE0-Nano. Since it was so much cheaper than anything I could put together I decided to abandon my little bare-bones FPGA project.
Let me know if you get it working, I’m curious if the CBUS is any slower programming the FPGA than the BitBanging on the main port.
Best regards,
Chris
Hey Chris
‘(Teaser: I’m currently working on a MUX system that will allow us to “reconnect” those FT232RL pins to I/O pins of the Cyclone II, instead of always being connected to the FPGA’s config pins. With a little work it should give us the ability to program and communicate with the FPGA for less than $15! )’
The FT232RL has an extra 5bits (CBUS) you could use 3 of these bits to configure the FPGA leaving the main 8BIT bus free for communication. I am will be trying this approach my self very soon 🙂
Hi, I think it should be possible.
Take a look at the Altera handbook (link in article) at the configuration section, look for the “in circuit programming” for the AS configuration. This link might also be useful: http://www.altera.com/literature/hb/cfg/cyc_c51014.pdf
I’m not positive what the communication protocol is to program the EP2c8, this could be the tricky part.
This might be another option: http://www.altera.com/literature/an/an370.pdf
Good luck, check back and let us know if you’re successful.
Hello and thank you for your very informative tutorial Chris Zeh.
I have a config classic ep2c8 + epcs1 connected with a programmable via a JTAG port. With your schematic description and some modification, it would be possible to program the epcs1 the FT232?
Thank
[…] and install the hardware drivers in Ubuntu that we need to use to access the FT232RL functions. The second part describes the hardware modifications and connections required to interface the FT232RL to […]
Excellent! I’m sure the guys on the libftdi mailinglist will help us out if we get stuck porting the code.
I really like the idea of having more I/O pins between the FPGA and USB. I’m thinking about using some paging techniques or using a serial protocol because of the limited 232RL I/O, but maybe upgrading to the 2232H would be the better bet. I look forward to getting this working on your setup.
Hi Bryan,
I’m almost finished writing the next post showing the Python code. Hopefully I’ll have it up tonight, but I might not have time until this weekend.
I think the code I’m using on the FT232RL should be pretty similar to what you would need for the FT2232H. For sure the algorithm for generating the bit-stream will be the same.
Thanks for leaving a comment, sometimes I need motivation to get me back on track with the blogging 😉
Yeah I think the only differences are that the FT2232H has two channels and can do high speed usb. After you finish your post, I could do some additional testing of your code on my setup and then post my results.
Holy cow. Am I glad I stumbled upon your blog. I’m trying to do something very similar to what you just accomplished. I’ve been trying to program the FPGA on a Morph-IC-II development board from FTDI. Which is an Altera CyloneII connected to the ftdi FT2232H chip. Also I’m trying to do this from an arm system running Debian, so that kinda forces me to use libftdi, which I’ve been struggling with on how to use to the Altera passive serial interface. Any who I can’t wait to see how you did this with a python program.
So, I am using the “ECS-2200B-240 5V 1/2 Size”, which is the digikey part #XC275-ND…. the 5V version. However, I have it connected to my 3.3V supply and everything is working just fine. I vaguely remember finding an App note, or FAQ indicating this should be okay, but now I can’t find it… hmmm.
(I should note: 4.6V is the absolute max voltage that the CII can handle on the I/O pins…1.8V max on the VCCINT pin)
Looking over their part numbering guide (http://www.ecsxtal.com/store/pdf/oscillator_partnumber_guide.pdf), there should be a so called ECS-2203B-240 part with the 3.3V option, however I cannot find such a part. I’ll send an email to their rep and make sure I’m not misusing this part… I’ll let you know.
I’m glad you like what I’ve got going on here at idle-logic. I appreciate the feedback!
Those terasic boards are great, I used that DE1 board back in college. The SparkFun board isn’t the cheapest setup on the market, but like you said, gets you access to all the I/O.
I’d be interested in hearing what kind of projects you’re working on… if you need a bunch of I/O a bet it’s something pretty cool. 🙂
Thanks Chris, I’ll send them an email. I also have a question regarding the ecs-2200 crystal you’re using. The datasheet mentions the 3.3V crystal is optional (digikey only has 5V versions)? Can I just use the 5V version?
Your site is really helpfull for me to get the Sparkfun board going ! I have a couple of Terasic FPGA boards , but the Sparkfun board is really great if you just need lots of I/O 🙂
I sent an email to the guys who make the ece-2200B-240. (They got back to me in literally 15 minutes… which is awesome!).
They said:
“The part you are using is built with a 5V IC. There is a statement on the data sheet that mentions a 3.3V operation (optional) meaning we can supply with a 3.3V IC. Since you are using a low relatively low frequency there is not much risk that the clock could change modes at the lower voltage vs. if
you were using a 50 MHz or 80 MHz part.
(I think I took the “optional” to mean I can optionally set the supply to 3.3V… whoops ;-))
In a second email he recommended the ECS-3953M (Digikey part #XC791CT-ND) for $3.08.
So it sounds like we’re probably okay prototyping with the 2200-240, but probably will want to switch when building up a PCB.
Hi Toon, thanks for dropping by. I sent an email to SparkFun’s tech support (techsupport@sparkfun.com) and within a day they sent me the Eagle Files.
Hi Chris, were did you find the eagle pcb lacout of the Sparkfun Altera bord ?