• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    C
  • License
    BSD 3-Clause "New...
  • Created almost 7 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Treat your Cypress FX3 a little like a logic analyzer or software defined bus.

fx3fun

Treat your Cypress FX3 a little like a logic analyzer or realtime software defined bus. Specifically I'm interested in the CYUSB3011-BZXC/CYUSB3012.

I'm trying to turn it into a logic analyzer. I've been playing with a kit, specifically the $45 http://www.cypress.com/documentation/development-kitsboards/cyusb3kit-003-ez-usb-fx3-superspeed-explorer-kit - and I've found it to be incredibly powerful. This project is split up into a few components.

(1) The Firmware: It is firmware that turns the GPIF-II bus into a 16-bit, 100 MHz sampling device. Synchronously receiving data and storing it in a buffer to stream back to a computer. My firmware sets up the isochronous pipes in such a way to transfer data back at about 250 MB/s. Also, control messages are really easy to send, so this could also be a really useful tool for programming chips, too! Currently, I'm still using the Windows tools to compile, but shouldn't be hard to use GCC ARM to compile in Linux, especially with the Official Cypress SDK.

(2) CyprIO (pronounced saɪˈpirˈēˈō): My C-library for use in Windows (with CyUSB32.sys) or Linux (with libusb) that lets you talk to my firmware on the cpress chip. Originally Cypress offered a CyAPI that let you use C++ to talk to their parts, but in digging into it, I found that it was extremely overbearing, and just not a good fit for many of the projects I wanted. Speicifically, more library-style operations, i.e. introducing into sigrok, etc. So, I re-wrote it, in C. Also, a side benefit of this is you can compile it and use it in Windows with only TCC (a 6MB package). All header files needed to compile are included. No Visual Studio needed or anything.

The PC-side software works in Windows (TCC) or Linux (GCC). Test in both as of Dec 31, 2017. Who knows if it'll keep working.

(3) isotest - make control transfer to start sampling GPIF bus and receives data coming back. (Uses CyprIO)

(4) cyprflash - tool that uses CyprIO to boot images on the FX3, and potentially flash a tool that allows writing to an I2C EEPROM on-board, using the official cypress flasher firmware. NOTE: Shouldn't be hard to support an SPI EEPROM, but I don't have a board with SPI EEPROM to test against.

Cypress FX3 as a Possible Logic Analyzer

Brief installation notes.

  • git clone this repo somewhere.
  • Download they Cypress EZ-USB FX3 SDK for Linux from here: https://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit
  • You will find "fx3_firmware_linux.tar.gz" and you can take that and drop "cyfx3sdk" in the same folder that "fx3fun" is located in, so they are parallel.
  • Make a folder in your home folder called Cypress
  • Unzip, from the SDK the following folders into Cypress
    • arm-2013.11
    • cyusb_linux_1.0.5
    • eclipse * I don't think this is required.

Add the following to your .bashrc

export PATH=$PATH:$HOME/Cypress/arm-2013.11/bin
export FX3_INSTALL_PATH=$HOME/Cypress/cyfx3sdk
export ARMGCC_INSTALL_PATH=$HOME/Cypress/arm-2013.11
export ARMGCC_VERSION=4.8.1
export CYUSB_ROOT=$HOME/Cypress/cyusb_linux_1.0.4
  • . ~/.bashrc
  • Optional if you want to build the firmware:
    • cd fx3fun/testproject/USBIsoSource
    • make
    • cp ?????? TODO: How to do firmware? BIG TODO: No, really how do you actually make the firmware?
    • On Windows it looks like it uses elf2img.exe
    • cd ../../
  • cd cyprflash
  • make
  • Hold the PMODE jumper shorted.
  • sudo ./cyprflash -i -f streaming_image.img
  • cd ..
  • Reboot board, make sure it's up:
    • lsusb -vv -d 04b4:00f1
  • ISO Test
    • cd isotest

Licensing

Though everything I am writing may be licensed under the MIT/x11 license OR the NewBSD license (Both of which are compaible with the GPL/LGPL/AFL), there remain some questions about compiling against the Cypress API. I am still looking into this but hope to clear up questions regarding this soon.

Project Log

Dec 25, 2017:

I got a Windows 10 PC for once in my life, and decided to dust off the Cypress FX3 Devkit I got two years ago.

Reading Appnote about getting started: http://www.cypress.com/documentation/application-notes/an75705-getting-started-ez-usb-fx3 - specifically the PDF http://www.cypress.com/file/139296/download

Install the: http://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit

Oh wait... it supports Linux (Rebooting to Linux)

Ok, installing "Download EZ-USB FX3 SDK v1.3.3 for Linux" ... WOW 413 MB is kinda big for something as tiny as I'd expect this to be.

sudo apt-get install lib32z1 qt4-qmake qt4-dev-tools qt4-linguist-tools qt-sdk libusb-1.0-0-dev eclipse-platform

Follow installion procedure in http://www.cypress.com/system/files/document/files/FX3_SDK_Linux_Support_0.pdf

Untar contents of all .tar.gz's embedded in the main .tar.gz downloaded to ~/Cypress

Add to .bashrc, the following:

export PATH=$PATH:$HOME/Cypress/arm-2013.11/bin
export FX3_INSTALL_PATH=$HOME/Cypress/cyfx3sdk
export ARMGCC_INSTALL_PATH=$HOME/Cypress/arm-2013.11
export ARMGCC_VERSION=4.8.1
export CYUSB_ROOT=$HOME/Cypress/cyusb_linux_1.0.4

Open new terminal.

cd $FX3_INSTALL_PATH/util/elf2img
gcc elf2img.c -o elf2img -Wall

Then

cd ~/Cypress/cyusb_linux_1.0.4
make
sudo ./install.sh

Now, I'm reading ~/Cypress/cyfx3sdk/doc/firmware/GettingStartedWithFX3SDK.pdf

Err... then I noticed https://community.cypress.com/thread/18526 ... say no Linux support for the GPIF-II designer (Which is a critical component) why on earth would they bother releasing a Linux ...

They recommend mono?

BACK ON TRACK

Go get this thing... (I may not use it?)

VVV Note added later... I don't think the thing here is useful at all.

cd ~/Cypress
git clone https://github.com/nickdademo/cyfwstorprog_linux
make
cd ~/Cypress/cyusb_linux_1.0.4/bin
sudo ./cyusb_linux

(Make sure it works)

Open the SDK.

cd ~/Cypress/eclipse
./ezUsbSuite

New workspace in: /home/cnlohr/Cypress/test_workspace

Ok, the GPIF button is greyed out. This is lame. Switch back to Windows.

In Windows, get and install... http://www.cypress.com/file/139276 ... COMPLETE Installation.

Run C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\Eclipse

Make project at C:\projects\fx3fun\testproject

Ok. Seriously. Why is the GPIF Designer button still grey. I gotta figure out how to build a simple project. I've been at this for almost an hour.

Back to the getting started tab. http://www.cypress.com/file/139296/download

Create a new project with the eclipse thing at C:\projects\fx3fun\testproject ...

File -> Import... "General" "Existing Projects" C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\gpif_examples\cyfxsrammaster + MAKE SURE TO click "copy project into workspace"

Build release version.

C:\projects\fx3fun\testproject\SRAMMaster\Release\SRAMMaster.img now exists.

Run C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin\CyControl.exe

Make sure J4 and J3 are on. Burn to ram the image file.

Maybe that worked?

Looks like it probably did, however, I think I want a debugger so I can get printf messages.

How do I do this debug thing. Connecting to COM5 with 115,200 doesn't show anything, even on the debug firmware, though it seems to with the defualt firmware.

I added a CyU3PDebugPrint command. Works like a charm..

static void
SRAMAppThread_Entry (
        uint32_t input)
{
    /* Initialize the debug module */
    CyFxSRAMApplnDebugInit ();
    CyU3PDebugPrint (CY_FX_DEBUG_PRIORITY, "Debug Test\n" );

I SEE IT!!!

Ok. We're cruising now.

Got it. The cyfxsrammaster project was cool... But, let's first see if we can actually talk to an app via USB 3.0. Maybe some sort of speed test to make sure we can sustain the needed speeds?

Delete that project.

Try File->Import... General/Existing "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxisosrc" I want an isochronous source! (Don't forget to check the copy workspace box.)

Build and flash (in debug)

Fire up "streamer.exe" from C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin

Osnap. It works. Fast. My computer seems to handle 256MB/s pretty well. Our target is 200MB/s, so I'd say we're doing pretty good.

Their app is all C++'d up... So, I am looking through the code for it as well as this... https://github.com/Cornell-RPAL/occam/blob/master/indigosdk-2.0.15/third/cyusb/CyAPI.cpp

Their code is called with USBDevice = new CCyUSBDevice((HANDLE)this->Handle,CYUSBDRV_GUID,true);

Yep... totally ripping it off... slowly. Spent 2 hours so far... Now, I can at least get a handle to the device. Still need to start sending it control messages to set up the isochronous endpoint.

Maybe tomorrow?

Then, who knows!

12/26/2017:

Spent another hour working away with my teststream.c thing... Then started to wonder if libUSB could be leveraged... Tempting...

I'll keep chugging away for a bit, I guess.

Still going after about 6 hours. Time to take a break. Was mostly just converting over code to CyprIO.

NEAT! The very first time after it compiled, it ran! Committing.

Only getting 12 MB/sec, though. I think it's cause I'm creating and deleting all my transfers.

TODO: Where are we doing the equivelent of if (USBDevice->SetAltIntfc(i) == true )?

AH! Looking at Streamer.h they do their own custom function to get data that queues up a bunch of buffers.

We shall do the same.

Man, I'm glad I didn't give up and go another route right now.

Well, computer just did the Win10 equivelent of bluescreening and I lost one of my source files. Thankfully it only took ~15 mins to edit from the last git commit.

Gotta start git committing more frequently.

AWW MAN YEAAAAAAAA. Turns out was an uninitialized value. P.S. Neat article. Need to be careful about the overlapped structures. https://blogs.msdn.microsoft.com/oldnewthing/20110202-00/?p=11613 Thanks https://twitter.com/cnlohr/status/945907823560613888 @Mr_Red_Beard

So, now, if you open the Cypress app and select the second option for the data flow, you get 256,000 kB/s via both apps.

Seriously... how does SetAltIntfc work? It does seem to set some configuration the device... Found it. return CyprIOControl(ths, IOCTL_ADAPT_SELECT_INTERFACE, &alt, 1L);

Works like a charm.

Now to figure out why the data's all wrong. I was just being dumb. Data went where I wanted it.

Ok, got rid of a ton of stuff from Cypress. Still more to get rid of. But man this is curising along well. About 1% or less CPU utilization at 256 MB/sec.

MOVING OVER TO THE USB SIDE

The GPIF designer is pretty easy to use. Took a bit to get the hang of it, but I think I can make something with a data buffer, and one state that just does a ton of data in.

12/27/2017:

Spend 20 minutes dinking more... I think it's time to ask for help and go do regular work.

https://community.cypress.com/message/148992#148992

Well, got that working. Was a simple buffer problem.

I'm gonna need a way of selecting between different run modes, maybe slower modes, too. Better get control messages going. libusb did it right. We should mimic them.

This is totally kicking my butt. My function somehow differs from theirs.

Some sort of strange stack corruption. Reading/writing values on the stack seems hosed. Need to understand more.

INCREDIBLE!!! So, if you start sending data to an iso port and then disconnect, if the data is still sending from the GPIF bus, and you don't send to it.

Video time!

Ok, video didn't go well.

2 AM 12/29/2017: Trying out different sizes of DMA, etc. Looks like it works in chunks of 2048 just fine but still overflows incessently.

Post reply to https://community.cypress.com/thread/32169

Dinked around for about an hour, got nowhere with the bandwidth, though I did notice I can overclock my bus to 8/7ths of 100 MHz :-D

Gave up around 8 AM...

12/29 2:00 PM Started again. Had to use a watermark or fifo-space-left operation with extra states, but it worked! (2 hours more)

Started again at 10:45 PM. How hard is it to flash custom firmware? Or maybe I should cleanup Cyprio?

They provide "c_sharp/controlcenter/Form1.cs" which is 3,000 lines long. :(.

(only spent 15 minutes this time)

12/30 Midnight: Starting again.

Just found out all of the cypress stuff goes through CyUSB3.sys. http://www.cypress.com/file/145261/download Looks like it all gets piped through a kernel mode driver I got, so it turns out it does take a driver :( -- but apparently it's an easy-for-windows-to-deal-with driver!!!

Spent about 2 hours looking at the hex of the cypress images and a USBPcap dump of a successful flash of the device using the Cypress tool. That should have taken way less time.

Now, to figure out why my messages I think are CONTROL OUT messages are turning into CONTROL IN messages >.<

Got it to boot!!! (RAM only, no writing to flash!)

NEXT: How do we flash to the I2C EEPROM? (3:00 AM)

Apparently, that's easy. First, RAM it to the Flasher firmware. Then call flash commands. (0x40/0xBA/(Windex/Wvalue) of the raw binary image. No interpretation needed.

AND NOW IT WORKS WITH I2C EEPROM (3:50 AM)

Dec 30, starting around 8 PM... Porting to Linux.

Just mostly #define out the stuff that is flagrantly Windows.

Booted back into Windows to make sure it was still working. It wasn't. Also, while in Windows, ditched any of the CyUSB3 stuff in critical path. It could be replaced by generic calls to the control transfer stuff.

WOOHH SUCCESSFULLY FLASHING IN LINUX!!! (11:08 PM!)

Woah this isochronous thing was kicking my butt. 12:54 AM, Dec 31, 2017. Iso in linux looks weird, but seems to be working. I'm worried it may be dropping packets.

Back and forth to Windows once more and everything works in both.

Dec 31, 1:09 AM. Remerging back into master.

More Repositories

1

rawdrawandroid

Build android apps without any java, entirely in C and Make
C
3,408
star
2

espusb

Software-only ESP8266 USB Device
C
1,452
star
3

mini-rv32ima

A tiny C header-only risc-v emulator.
C
1,410
star
4

channel3

ESP8266 Analog Broadcast Television Interface
C
1,277
star
5

ch32v003fun

An open source software development stack for the CH32V003, a 10¢ 48 MHz RISC-V Microcontroller
C
674
star
6

colorchord

Chromatic Sound to Light Conversion System
C
663
star
7

noeuclid

Non-euclidean GPU Raytraced Game
C
647
star
8

esp8266ws2812i2s

ESP8266-based I2S-output WS2812(B) Driver
C
536
star
9

avrcraft

Minecraft server optimized for 8-bit devices.
C
435
star
10

rv003usb

CH32V003 RISC-V Pure Software USB Controller
C
328
star
11

ws2812esp8266

DEPRECATED. Please use esp8266ws2812i2s. No really, stop forking and starring this.
C
298
star
12

esp82xx

Useful ESP8266 C Environment
C
289
star
13

espthernet

ESP8266 10-Base-T Ethernet Driver
C
246
star
14

nosdk8266

Trying to make ESP8266 projects without a big SDK.
C
235
star
15

esp8266rawpackets

Raw Packet Experiments on the ESP8266
JavaScript
148
star
16

epaper_projects

C
145
star
17

voxeltastic

View 3D Volume with Translucency in WebGL
JavaScript
143
star
18

shadertrixx

CNLohr's repo for his Unity assets and other shader notes.
ShaderLab
137
star
19

cnovr

CNLohr's OpenVR Misadventures
C
128
star
20

ethertiny

A firmware-only half-duplex 10Base-T implementation for AVRs
PostScript
121
star
21

cnixxi

My experiment with nixie tubes.
C
112
star
22

wiflier

ESP8266-based Quadcopter Brain
KiCad Layout
93
star
23

embeddedDOOM

"emdoom" - a port of DOOM targeted for memory-strapped systems.
C
90
star
24

espwebc3

An in-browser integrated development platform for the ESP32-C3
HTML
84
star
25

esplocalizer

ESP8266 with IMU, Barometer and Battery
C++
83
star
26

esp8266oddclock

What happens when you rip the ESP8266's stable clock source out from under it's feet?
C
81
star
27

esptracker

Lighthouse-based tracker using the TS4231
C
60
star
28

rawdrawandroidexample

Example app using rawdrawandroid as a submodule.
C
59
star
29

wifirxpower

Linux-based WiFi RX Power Grapher
C
59
star
30

pylotron

Embedded VNC-based FPS.
C
58
star
31

esp32s2-cookbook

Low-level tests with the ESP32-S2
C
48
star
32

androidusbtest

Access external devices from Android apps directly in C.
C
46
star
33

superlongexposure

FFMPEG-based tool for non-linear compositing video into long exposures.
C
41
star
34

tplink-raw-wifi

Test using tp-links to do raw wifi.
C
41
star
35

pi_tpi

Using a Raspberry Pi to program an ATTiny10 9 5 or 4
C
39
star
36

what_im_up_to

Just my dumping ground for ideas.
37
star
37

tsopenxr

Single-file header for simple OpenXR Framework use with C
C
36
star
38

t85loudspeaker

ATTiny85 Sound Output
C
35
star
39

avr_vhf

Channel 3 VHF Broadcasting with an AVR
C++
34
star
40

esp8266_dmx_explorer

C
32
star
41

esp8266duplexi2s

Generic duplex communication on the I2S bus in the ESP8266.
C
31
star
42

lamenet

A way of making a really awful network connection.
C
31
star
43

dumbcraft8266

My first stab at a Minecraft-enabled firmware for the ESP8266
C
30
star
44

swadges2017

MAGFest Swag Badges 2017 Firmware
C
29
star
45

cnballpit-vrc

C#
28
star
46

cnhardware

C
28
star
47

esp8266_link_test

Test link between an ESP8266 and a base station or another ESP8266 easily.
KiCad Layout
26
star
48

brokeredupdateandsync

CN's VRC Tools and Prefabs
C#
26
star
49

tinycc-win64-installer

A quick way to use tinyCC on Windows.
NSIS
25
star
50

wificompositer

Various tools I used to collect and composite data from a wifi device into an image.
C
24
star
51

miniosc

Single-file-header OSC library for C (includes platform-independent sockets)
C
21
star
52

esp32-cnlohr-demo

My always-incomplete ESP32 fun zone
C
20
star
53

spreadgine

An OpenGL ES engine with WebGL Output.
C
19
star
54

slapsplat

GLSL
19
star
55

oledscope

Playing around with a 128x128 OLED module
C
19
star
56

cnlohr_social_media_tools

Various social media interface tools.
C
18
star
57

assembly-notes

My repo for a guide to and notes on assembly lagnuage, inling, etc.
18
star
58

usb2812

ATMega32u2 USB driver for WS2812 LEDs.
C
18
star
59

x11framegrab

Small static program for taking screenshots of x11 screens and saving/streaming as a variety of formats.
C
18
star
60

esp8266lighthouse

DO NOT USE THIS PROJECT - WILL BE SUPERCEDED
C
17
star
61

wasm_integrated

An example of how you can fully integrate wasm into a webpage. No need for fetching or any of that jazz.
HTML
17
star
62

swadge-vrchat-bridge

C
16
star
63

magfestbadges

The codebase, schematics, etc. of the MAGFest Badges.
C
16
star
64

cntools

Incomplete-ish C "libraries"
C
16
star
65

wi07clight

Using the wi07c's ESP8266 to control a desk light.
C
16
star
66

avrjslinux

JSLinux Running on an AVR with I/O Port Remapping
JavaScript
14
star
67

tinyispterm

An SPI terminal for USB Tiny ISP compatible AVR prorgammers.
Python
14
star
68

esp32-c3-cntest

C
13
star
69

h264fun

Fun with h264 (mostly encoding)
C
13
star
70

tensigral_lamp

My PCB Tensegrity structure lamp.
C
12
star
71

addressable_leds

Charles's list of addressable LEDs
12
star
72

kelvindmmwifi

Adding some sweet wifis to a kelvin multimeter.
KiCad Layout
11
star
73

attiny85_tb

ATTiny85 Test Bench Tool with Screw Terminals
Eagle
10
star
74

voxeltastic-vrc

Voxel Tracing Shader for VRChat
ShaderLab
10
star
75

esp32s2_dmx512_usb

C
10
star
76

rawdrawwasm

My stab at rawdraw on wasm.
HTML
10
star
77

swadgeguide

My guide for making swadges.
HTML
9
star
78

terriblewordsearch

A C tool for making terrible word searches.
C
9
star
79

cndvr

Assembly
9
star
80

flexcrt

A header for CRTs to allow for scattered writes.
HLSL
8
star
81

swadge2019

the repo for the 2019 swadge
C
8
star
82

espbadapple

Bad Apple in 62kB or bust.
C
8
star
83

donut

MAGFest /is/ a donut.
C
8
star
84

minimal_stm32f407

STM32F407 Minimal self-contained Makefile-based build environment (Plus printf!)
C
8
star
85

esp8266irxmit

ESP8266 IR Transmistter
C
7
star
86

minimal_stm32f303

STM32F303 Minimal self-contained Makefile-based build environment (Plus printf!)
C
7
star
87

netlink_without_libnl

Testing using the kernel's netlink, more specifically nl80211 without libnl or genl
C
7
star
88

wxrchat

Distributed WebXR Chat Application
C
6
star
89

esp32_ethernet_test

My Ethernet on the ESP32 Test (incomplete!)
C
6
star
90

tinyisp-micro

My USBTinyISP (with an ATTiny44)
KiCad Layout
6
star
91

esp_network_rgb

JavaScript
6
star
92

charlesvideotools

Linux Video Creation Notes and Tools
C
5
star
93

esp_nonos_sdk

Patchwork of various esp_nonos_sdk subsystems.
C
5
star
94

in99

Gain a superficial of topics in 99 seconds.
5
star
95

shader_perf_grass_comparison

Fake test for checking perf of different shader types.
ShaderLab
5
star
96

stm32f042_fun

My fun repo for the STM32f042
C
4
star
97

bridgesim

Project abandoned. Library code probably has problems.
C
4
star
98

avr_ledprojector

Using an AVR with an mlx90614 to project temperatures!
KiCad Layout
4
star
99

esp8266_32x32panel

An attempt at driving 32x32 panels with an ESP8266.
KiCad Layout
4
star
100

sk6812rgbyspectraldata

Just an email I got from Andrew Sowa
4
star