HDMI2USB FX2 Firmware

Contents:

Indices and tables

struct usb_cdc_line_coding
#include <cdc.h>

Public Members

__u8 bDTERate0
__u8 bDTERate1
__u8 bDTERate2
__u8 bDTERate3
__u8 bCharFormat
__u8 bParityType
__u8 bDataBits
file lights.c
#include <fx2regs.h>#include <fx2types.h>#include <delay.h>#include “fx2lights.h”

Example firmware that flashes LEDs.

On the Atlys this is LD14 (DONE), on the FX2 miniboard D1 and D2 and on the Opsis it is D2

Functions

void init_lights(void)
void main(void)
file serial.c
#include <delay.h>#include <fx2macros.h>#include <fx2regs.h>#include <fx2types.h>

Defines

PD3
BAUD

Functions

void usart_init(void)
void usart_send_byte(BYTE c)
void usart_send_string(const char *s)
void main(void)

Variables

__sbit __at PD3 USART
file app.c
#include <fx2regs.h>#include <fx2macros.h>#include <eputils.h>#include <delay.h>#include <setupdat.h>#include <makestuff.h>#include “defs.h”#include “debug.h”#include “cdc.h”#include “uvc.h”#include “read-serialno.h”

Functions

void TD_Init(void)
void TD_Poll(void)
void uart_init()
void mainInit(void)
void mainLoop(void)
uint8 handleVendorCommand(uint8 cmd)

Variables

const uint8 dev_strings[]
file cdc-config.h

Defines

CDC_H2D_RESET(x)
CDC_H2D_EP(x)
bmCDC_H2D_EP(x)
CDC_D2H_RESET(x)
CDC_D2H_EP(x)
bmCDC_D2H_EP(x)
CDC_INT_EP(x)
bmCDC_INT_EP(x)
file cdc.c
#include <fx2regs.h>#include <fx2macros.h>#include <delay.h>#include “cdc.h”

Defines

SYNCDELAY

Functions

void cdc_receive_poll()
BOOL cdc_handle_command(BYTE cmd)

Variables

volatile WORD cdc_queued_bytes = 0
struct usb_cdc_line_coding cdc_current_line_coding = { .bDTERate0 = LSB(2400), .bDTERate1 = MSB(2400), .bDTERate2 = 0, .bDTERate3 = 0, .bCharFormat = USB_CDC_1_STOP_BITS, .bParityType = USB_CDC_NO_PARITY, .bDataBits = 8 }
file cdc.h
#include <fx2types.h>#include “cdc-config.h”

Defines

cdc_can_send
cdc_queue_data(data)
cdc_send_queued_data
__u8

The defines and structures found below comes from the Linux kernel and are found in include/uapi/linux/usb/cdc.h

__le16
__le32
USB_CDC_REQ_SET_LINE_CODING
USB_CDC_REQ_GET_LINE_CODING
USB_CDC_REQ_SET_CONTROL_LINE_STATE
USB_CDC_1_STOP_BITS
USB_CDC_1_5_STOP_BITS
USB_CDC_2_STOP_BITS
USB_CDC_NO_PARITY
USB_CDC_ODD_PARITY
USB_CDC_EVEN_PARITY
USB_CDC_MARK_PARITY
USB_CDC_SPACE_PARITY

Functions

void cdcuser_receive_data(BYTE *data, WORD length)
BOOL cdcuser_set_line_rate(DWORD baud_rate)
BOOL cdc_handle_command(BYTE cmd)
void cdc_receive_poll()

Variables

volatile WORD cdc_queued_bytes
file debug.c
#include <fx2regs.h>#include <makestuff.h>#include “debug.h”
file debug.h
#include <makestuff.h>

Functions

void usartInit(void)
void usartSendByte(uint8 c)
void usartSendByteHex(uint8 byte)
void usartSendWordHex(uint16 word)
void usartSendLongHex(uint32 word)
void usartSendString(const char *s)
file defs.h

Defines

SYNCDELAY
EP0BUF_SIZE
bmSKIP
bmPORTS
bmGPIF
bmFIFOS
bmBULK
bmBUF2X
bmEP1INBSY
bmEP1OUTBSY
bmAPTREN
bmAPTR1INC
bmAPTR2INC
bmDYN_OUT
bmENH_PKT
REQDIR_DEVICETOHOST
REQDIR_HOSTTODEVICE
REQTYPE_CLASS
REQTYPE_STANDARD
REQTYPE_VENDOR
mainInit(x)
mainLoop(x)
handleVendorCommand

Variables

__sfr __at AUTODAT1
__sfr __at AUTODAT2
file firmware.c
#include <fx2macros.h>#include <fx2ints.h>#include <autovector.h>#include <delay.h>#include <setupdat.h>#include “cdc.h”

Defines

printf(...)

Copyright (C) 2009 Ubixum, Inc.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

SYNCDELAY

Functions

void main_loop()
void main_init()
void main()
void resume_isr()
void sudav_isr()
void usbreset_isr()
void hispeed_isr()
void suspend_isr()
void ISR_USART0(void)

Variables

volatile __bit dosud =FALSE
volatile __bit dosuspend =FALSE
file makestuff.h
#include <stddef.h>#include <stdbool.h>

Defines

WARN_UNUSED_RESULT
DLLEXPORT(t)
PFSZD
PFSZH
WORD_LENGTH
NULL
swap16(x)
CONCAT_INTERNAL(x, y)
CONCAT(x, y)
STR_INTERNAL(x)
STR(x)
VA_EXPAND(x)
VA_NARGS(...)
VA_NARGS_INTERNAL(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, N, ...)
FAIL(code, label)
CHECK_INTERNAL3(condition, code, label)
CHECK_INTERNAL4(condition, code, label, prefix)
CHECK_INTERNAL5(condition, code, label, ...)
CHECK_STATUS(...)

Typedefs

typedef unsigned char uint8
typedef unsigned short uint16
typedef unsigned long long uint64
typedef signed char int8
typedef signed short int16
typedef signed int int32
typedef unsigned int uint32
typedef signed long long int64
typedef unsigned int bitfield
file read-serialno.c
#include <i2c.h>

Defines

PROM_ADDRESS
PROM_ID_OFFSET
PROM_ID_SIZE

Functions

char hex(BYTE value)
void patch_serial_number(BYTE index, BYTE value)
void patch_usb_serial_number_with_eeprom_macaddress()

Variables

__xdata char dev_serial[]
file read-serialno.h

Functions

void patch_usb_serial_number_with_eeprom_macaddress()
file softserial.c
#include “debug.h”#include “softserial.h”

Functions

void soft_sio0_init(WORD baud_rate)
void soft_putchar(char c)
char soft_getchar(void)
file softserial.h
#include “fx2types.h”

Functions

void soft_sio0_init(WORD baud_rate)
void soft_putchar(char c)
char soft_getchar()
file to-uart.c
#include <stdio.h>#include <fx2regs.h>#include <fx2macros.h>#include <serial.h>#include <delay.h>#include <autovector.h>#include <setupdat.h>#include <eputils.h>#include <i2c.h>#include “cdc.h”

Defines

SYNCDELAY

Copyright (C) 2009 Ubixum, Inc.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Functions

BOOL cdcuser_set_line_rate(DWORD baud_rate)
void cdcuser_receive_data(BYTE *data, WORD length)
void uart_init()
file uvc.c
#include “uvc.h”#include <fx2regs.h>#include <fx2macros.h>#include <setupdat.h>#include <eputils.h>#include <delay.h>#include “cdc-config.h”

Defines

SYNCDELAY

Functions

BOOL handleUVCCommand(BYTE cmd)
BYTE handle_get_configuration()
BOOL handle_set_configuration(BYTE cfg)
BOOL handle_get_interface(BYTE ifc, BYTE *alt_ifc)
BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc)
BOOL handle_get_descriptor()

Variables

BYTE valuesArray[26] = { 0x01,0x00, 0x01, 0x01, 0x2A,0x2C,0x0A,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x05,0x00, 0x00,0x20,0x1C,0x00, 0x00,0x04,0x00,0x00 }
BYTE fps[2][4] = {{0x2A,0x2C,0x0A,0x00},{0x54,0x58,0x14,0x00}}
BYTE frameSize[2][4] = {{0x00,0x00,0x18,0x00},{0x00,0x20,0x1C,0x00}}
BYTE Configuration
BYTE AlternateSetting = 0
file uvc.h
#include <fx2types.h>

Defines

UVC_GET_CUR
UVC_GET_MIN
UVC_GET_MAX

Functions

BOOL handleUVCCommand(BYTE cmd)
file README.md
dir examples
dir hdmi2usb
dir examples/lights
dir examples/serial
page index

This repository contains the firmware used in the HDMI2USB project on the Cypress FX2 chip found on boards such as the Numato Opsis and the Digilent Atlys boards.

Firmware is generally compiled with [SDDC 3.6]() and the sdas8051 assembler. Older versions might work but have been known to generate incorrect firmware.

microload is firmware which loads a second stage firmware from an FPGA via I2C.

In microload every program byte counts and thus is hand coded in assembly.

The firemware is used on the Numato Opsis board to allows the FPGA to switch the FX2 functionality.

eeprom-unconfigured will cause the Cypress FX2 which boot with a given VID/PID and then wait for full firmware to be loaded via USB.

The JTAG firmware is used to allow loading gateware onto an FPGA.

This is the primary firmware for HDMI2USB functionality.

The firmware is responsible for transporting the video data off of the FPGA. It does this by enumerating as a USB Video Class device; a standard way of interfacing devices such as webcams to a host. Linux, Windows and OS X all include support out of the box for reading taking to such devices.

The firmware is also used for control and debugging of the system, through a USB Communications Class Device. This is a common way of attaching serial ports to the system, and under Linux it can be accessed at /dev/ttyUSBX.

Cypress EZ-USB FX2LP

FIXME: Put some documentation about the FX2 here.

Cypress EZ-USB FX2LP

Boards

  • FX2 - CY7C68013A_100AC - 100 pin version
  • EEPROM - 24AA02E48 - 256*bytes* (128 usable)
  • Bank A/Port A, Bank B/Port B, Bank C/Port D, Bank F/Port C, Bank H/RDY+CTRL - FPGA IO Pins
  • Bank G/Port E connected to FPGA JTAG.
  • 2 x Hardware UARTs
  • 1 x Interrupts?
  • Further Documentation

  • FX2 - CY7C68013A-56 - 56 pin version
  • EEPROM - 24AA128 - 16k*bytes*
  • Bank A/Port A, Bank B/Port B, RDY+CTRL - FPGA IO Pins
  • Bank C/Port D connected to FPGA JTAG.
  • Further Documentation

Building

make -f Makefile.fx2 load-fx2

will build and flash the FX2 firmware. This requires the hdmi2usb-mode-switch command, which on Debian Sid and Stretch can be installed using the hdmi2usb-mode-switch package, otherwise see HDMI2USB-mode-switch.

There are three ways to run hdmi2usb-mode-switch:

  1. As root
  1. Install the unbind-helper as a setuid binary
  1. Install the udev-rules which sets the permissions of the unbind.