element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
BeagleBoard
  • Products
  • Dev Tools
  • Single-Board Computers
  • BeagleBoard
  • More
  • Cancel
BeagleBoard
Blog BBB - FPGA / CPLD Programmer for the BeagleBone Black
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join BeagleBoard to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 11 Oct 2013 6:33 PM Date Created
  • Views 5833 views
  • Likes 7 likes
  • Comments 28 comments
  • fpga_prototyping
  • fpga_tools
  • cpld
  • jtag
  • beaglebone_black
  • programming_tool
  • xilinx
  • jtag_tool
  • bbb
  • node.js
  • programmers_and_erasers
  • fpga_development_kit
  • bb_black
  • beagle_bone_black
Related
Recommended

BBB - FPGA / CPLD Programmer for the BeagleBone Black

shabaz
shabaz
11 Oct 2013

Introduction

This was a quick (and interesting) project, to get the BBB prepared for programming programmable logic. If you’re interested in implementing programmable logic, then this is a useful first step so that you have a tool for programming the devices.

 

The solution here allows you to program Xilinx parts (CPLDs and FPGAs) at zero cost (assuming you have a BeagleBone Blackassuming you have a BeagleBone Black).

 

It is browser-based and simple to use with drag-and-drop programming. Just drag your programming file from the desktop onto the beagle in the browser.. no menu or CLI at all. It was surprisingly fast, too. It takes just a few seconds to program a small CPLD. For a simple project using this programmer, see here.

 

image

How Does it Work?

Xilinx programmable logic chips (FPGAs and CPLDs) have a JTAG interface; the BBB runs some software that can take a programming file and send it over some I/O pins that are connected to the target device JTAG interface.

 

The code is easy to implement because Xilinx have done the hard work - they have code and a paper, and their existing code was adapted slightly. For the BBB I/O, the C library here was used and this made it a quick thing to get running.

 

For the web interface, Node.js is used (thanks to Drew for making me aware of it!), and some javascript code called dropzone found on the Internet is used to get the drag-and-drop functionality implemented. I had a little difficulty with MIME and UTF-8, and if anyone has a better solution than my quick hack, it would be appreciated. It needs some thorough testing still - I just tested with a small file, using FF, IE and Chrome.

 

Getting Ready for Programming

Creating the programmer described here, or using it, does not require the Xilinx development environment, but you do need to download it if you’re interested in programmable logic designs. Also, download it much in advance to requiring it because is quite large (multiple GBytes) so be prepared for a very long download. They also offer DVDs but they can take months to arrive, so really the only option is to download. The location to download is shown here.

image

 

Obtain a Development Board

You will also need a test board to play with; there are a few options. In the CPLD space, these options are worth considering:

 

  1. Purchase a blank board and parts (Gazunty Pi) at low cost – Intended for the RPi, but it would be fine with the programmer here. The Gazunty Pi uses a XC9500XL device
  2. Purchase a pre-built board (£15) from Farnell (Digilent board) or Newark that uses a XC2C64A device
  3. Build your own test board on prototyping board (will supply more detail later if there is interest) – I chose a XC2C64A device (UK Farnell link / US Newark link).

 

Photos of the three options are below. (Derek from Gazunty Pi, I hope you don’t mind me using your photo).

image

 

image

 

image

 

 

I went with options 2 and 3 because I’m familiar with that particular part. Despite it being surface-mount, it is large (0.8mm pitch pins) and easy to hand-solder with a normal iron. Also hardly any pins need wiring for test purposes so a SMD prototyping adapter board can be used rather than a custom PCB.

 

For the circuit diagram, you could follow the Digilent board circuit. The green bit in the photo above is a voltage regulator and you can see a few small capacitors were soldered directly on the prototyping adapter board.

 

Regardless of option you choose, it is worthwhile buying a small oscillator too for reasons to be explained later, and soldering it on somewhere. You can see it on the underside here, soldered upside down. I chose 32MHz - just gone out of stock! But any value in that ballpark will be fine, e.g. a 20MHz oscillator.

 

image

 

In the FPGA space there are several options too. Perhaps the lowest cost (but good value) board is the Papilio One from Seeed Studio ($38). However a CPLD is a better choice to start off with.

image

 

How to use the Programmer

There are just four signals and 0V that need connecting from the BBB to the Xilinx device. They are indicated in the diagram here (used the Digilent board as an example).

image

 

Once you have the BBB powered up, type

node index.js

This will start up the web server, and then you can browse to:

http://xx.xx.xx.xx:8081/index.html

Then just drag the desired file onto the dog, and it will program the board within seconds. It doesn’t give any indicaton of completion today :-) I might get round to implementing that but, after programming, the target device will immediately begin execution so you can see that the programming is complete. There is no need for a power-cycle either; to reprogram the device, just drag another file onto the beagle. If you wish to use a command line option, the syntax is:

./xprog_app my_programming_file.xsvf

 

The photo shows a typical use scenario - there are six wires between the CPLD board and the BBB (TMS, TDI, TDO, TCK, GND) and also VCC so that the CPLD board is being powered from the BBB. The BBB is plugged into a DC supply and into the network so that it has an IP address, and a web browser can allow you to drag the file to be programmed into it.

image

 

Compiling the Software

For convenience, create a folder on the BBB off the home directory (e.g. call it development, and inside it another folder called xprog and unzip the code inside there. Install the GPIO library from here. To compile the code, type:

make clean
make

(If you make any code changes, type  make clean  first - there is a bug in the makefile).

Then, plug in the wires to the CPLD board and run the code as described above.

 

The code is still fresh so there may be bugs. If you spot any, please let me know! It has been tested on a single CPLD so far.

(Code now attached).

 

Attachments:
xprog_v1.zip
  • Sign in to reply

Top Comments

  • sa-penguin
    sa-penguin over 11 years ago +3
    For other development boards, look to: http://dangerousprototypes.com/docs/CPLD:_Complex_programmable_logic_devices XC9572XL or XC2C64A CPLDs for low cost. That's where I got mine from, anyway.
  • Problemchild
    Problemchild over 10 years ago in reply to shabaz +2
    Hey Shabaz I nearly forgot about this article you did. It's really good, It explains how to clock config data effectively into those programmable devices. As Mike said I think there's mileage in doing…
  • baccari
    baccari over 7 years ago +2
    Hi Shabaz thank you for the informations .
  • shabaz
    shabaz over 7 years ago in reply to NigelB

    Hi Nigel,

     

    Thanks for the feedback! I recently attempted to use a Pi as a programmer (just reusing code written by others) for microcontrollers too, so I'll write that up sometime too. The BBB/Pi are like universal tools, it is awesome.

    I finally ordered the 'PocketBeagle', I'll post up some photos and thoughts later on today - it reduces costs even further, lots of possibilities using that as a mini programmer too : )

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • NigelB
    NigelB over 7 years ago

    Great article - being able to programme these devices without shelling out a load of money is often the one thing holding us all back from playing with these devices. I really must try this, as I do already have a BBB.

     

    The article also looks well presented and clearly written - but I suppose I should use the article by giving it a go myself before rating it...

     

    Great stuff, Shabaz, keep up the good work sharing these gems with us!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baccari
    baccari over 7 years ago
    Hi Shabaz

     

    thank you for the informations .

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 7 years ago in reply to baccari

    Hi Baccar,

     

    All of that stuff is implemented by Xilinx code, not by me. I only made changes so that when the code wanted to set or read a pin, then the BeagleBone Black's pins are used. As you say, iolib.c. is used for this. My main work effort was only to implement that portion, all the clever stuff was already in the Xilinx code, and I did not need to try to understand it, my task was straightforward.

    The iolib code is documented here: https://beta.element14.com/community/community/designcenter/single-board-computers/next-gen_beaglebone/blog/2013/10/10/b…

    I don't know of a good book on JTAG however.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baccari
    baccari over 7 years ago

    Hi Shabaz

     

    Thanks for 2 books "The C Programming Language" and "Problem Solving and Program Design in C".

    I m also beginner , can you give me name of book  to configure JTAG  with embeded c because i don 't understand file iollib.c



    Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube