Hello All,

I have used Altera (now Intel) FPGA. Part number EP4CE22F17C8N. For hardware description please check out this post.

Project prepared and compiled in Intel Quartus Prime Lite Edition 16.1. This is the free version and it can be downloaded here.

Building FPGA firmware

Here are the step-by-step instructions for cooking up the firmware:

  • Checkout the source code from github:
git checkout https://github.com/aospan/joker-tv-fpga
  • Open the project file joker_tv/joker_tv.qpf in Quartus software.
  • Choose “Processing->Start Compilation”.
  • Choose “File -> Convert Programming Files -> Open Conversion Setup Data …”. Then choose file joker_tv.cof and press “Generate” button. File joker_tv.jic should be generated.
  • To generate joker_tv.bin file you should execute joker_tv/generate_bin_fw.sh script.

After compilation you can program firmware into SPI flash on “Joker TV” device. There are two ways to do this.

Programming with JTAG

This method is used by developers or by end-users for debricking device if the firmware is faulty. You need a USB byte-blaster in order to do this. It can be ordered on eBay for about $5.

Steps to update FPGA firmware using JTAG

  • Connect the JTAG (Altera USB byte-blaster) to the Joker TV board using a JTAG ribbon cable.
  • Connect the Joker TV to PC using a USB cable.
  • Connect the JTAG (Altera USB byte-blaster) to a PC using a USB cable.

  • If you have not installed Quartus software then download Altera Quartus Programmer (stand alone) from the following link: http://dl.altera.com/16.1/?product=qprogrammer#tabs-4
  • Start Altera Quartus Programmer and choose the compiled above joker-tv.jic file or download pre-compiled firmware joker_tv-0.18-jic. Please check the following picture for the steps. Step 5 shows the final status.

  • If you see 100% (Successful) then the Joker TV FPGA firmware is uploaded and you can disable Altera JTAG Byte-blaster and reconnect Joker TV to your PC.
  • Continue with normal use of the Joker TV device.

Programming using joker-tv app over USB cable

This method is default for firmware upgrades and does not require any special hardware tools. Just run the following command:

joker-tv -w joker_tv.bin

Powering off the device is required. Just reconnect it to the USB port.

FPGA firmware description

Here is a compilation status and used FPGA resources:

Quartus Prime Version 16.1.0 Build 196 10/24/2016 SJ Lite Edition
Revision Name joker_tv
Top-level Entity Name joker_tv
Family Cyclone IV E
Device EP4CE22F17C8
Timing Models Final
Total logic elements 3,062 / 22,320 ( 14 % )
Total registers 1595Total pins 146 / 154 ( 95 % )
Total virtual pins 0
Total memory bits 313,856 / 608,256 ( 52 % )
Embedded Multiplier 9-bit elements 0 / 132 ( 0 % )
Total PLLs 1 / 4 ( 25 % )

USB protocol implementation

All usb related code lives inside the usb folder. The code is based on Daisho project.

I have implemented USB Iscohronous transfers. End Point 3 (EP3 IN) is Transport Stream endpoint that contains media data (raw transport stream). We send 1024 bytes data packets every microframe (every 125 usecs). This allows us to reach total speed:

1024 bytes * 1/0.000125 = 8192000 bytes/sec or 62.5 Mbit/sec

Also, USB standby signalling implemented. This functionality important for using “Joker TV” device under Windows and Mac (OSx) because of enabled “standby” by default in this OS’s.  And for Windows OS special USB\MS_COMP_WINUSB compatibility ID implemented, so we don’t need to install special drivers. Built-in winusb.sys/winusb.dll drivers will be used.

You don’t need to install special drivers under Windows OS

Transport Stream (TS) processing

Transport Stream (TS) processing module lives inside the ts folder. TS deserializer, TS selector and FIFO (In-memory 32KB) is a main parts of this module. For testing purposes I have implemented Transport Stream generator with predefined pattern. So, we can use tscheck utility for data correctness check.

I2C and SPI buses access

I have used OpenCores I2C and SPI implementations. They lives inside opencores_i2c  and spi folders respectively.

Misc stuff

Simple protocol for host-device commands implemented. It lives in joker_control folder.

Also, testbenches are prepared for some modules.

Print Friendly

Leave a Reply

Your email address will not be published. Required fields are marked *