======================================== notes_dhr.txt 2019, 2020 ======================================== I brought a USB Logic Analyzer Device Set Compatible To Saleae 24MHz-8CH For ARM FPGA M100 off eBay. They are based on the Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 With SigRok and Pulseview from https://sigrok.org/ they provide a really good tool. eBay then suggested Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 USB 2.0 Development Kit These use an 8051 core that boots from the USB, or an external 24LC128 EEPROM. At the time I wanted a microprocessor that executes code from RAM. ======================================== Links and webpages ======================================== Use the SDCC compiler: http://sdcc.sourceforge.net/ This WIKI is useful. http://www.geeetech.com/wiki/index.php/CY7C68013 - two links The is useful for building, but the examples don't work for my boards:- https://github.com/djmuhlestein/fx2lib This is really useful. Problems with __ in include files. https://www.triplespark.net/elec/periph/USB-FX2/software/ Others:- https://github.com/makestuff/fx2tools https://github.com/makestuff/libfx2loader ======================================== Issues:- ======================================== * These are very useful for uploading code to the CY7C68013:- ~/Desktop/cypress/cycfx2prog-0.47 ~/Desktop/fx2lib-master/examples/doug/fx2_programmer * The header files may need work for SDCC. - /usr/share/sdcc/scripts/keil2sdcc.pl * Not all the eBay boards are the same concerning the eeprom link. * The logic Analyser has no output pins to turn on and off. * The logic analyser has a 24LC02, the boards have 24LC128 - ADDR is 1/2 bytes. * the 56 pin CY7C68013 does not have a serial port, so I bit-banged one * The fx2lib-master/examples are for a different board where the LEDs are indirectly connected * use OEA=0xff to turn on the outputs for the eBay boards. /* enable port A as outputs */ OEA = 0xFF; IOA = 0xaa; delay(200); IOA = 0x55; delay(800); ======================================== Drivers ======================================== You need to install libusb-dev sudo apt-get install libusb-dev pi@raspberrypi:~ $ sudo apt-get install libusb-dev Reading package lists... Done Building dependency tree Reading state information... Done libusb-dev is already the newest version (2:0.1.12-30). The following package was automatically installed and is no longer required: libserialport0 Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded. pi@raspberrypi:~ $ Remember when you plug in USB, the device supplies a VID:PID, which is used to identfy the driver to load and for this chip firmware to upload. There are usbdrivers that allow user prgrams code more control. ======================================== Accessing the device. ======================================== /* find out about usb devices using lsusb */ Bus 001 Device 009: ID 04b4:8613 Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 USB 2.0 Development Kit Bus 001 Device 012: ID 0925:3881 Lakeview Research Saleae Logic pi@raspberrypi:~/Desktop/fx2lib-master/examples/doug/fx2_programmer $ lsusb Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. Bus 002 Device 003: ID 26bd:9917 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 010: ID 138a:0097 Validity Sensors, Inc. Bus 001 Device 009: ID 5986:111c Acer, Inc Bus 001 Device 008: ID 8087:0a2b Intel Corp. Bus 001 Device 007: ID 0781:5573 SanDisk Corp. Bus 001 Device 006: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader Bus 001 Device 012: ID 0925:3881 Lakeview Research Saleae Logic Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub pi@raspberrypi:~ $ lsusb Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 006: ID 138a:0097 Validity Sensors, Inc. Bus 001 Device 005: ID 5986:111c Acer, Inc Bus 001 Device 004: ID 8087:0a2b Intel Corp. Bus 001 Device 003: ID 0781:5573 SanDisk Corp. Bus 001 Device 002: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader Bus 001 Device 009: ID 04b4:8613 Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 USB 2.0 Development Kit Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub pi@raspberrypi:~ $ pi@raspberrypi:~/Desktop/fx2lib-master/examples/doug/fx2_programmer $ ./fx2_programmer 001 012 dumpbuss Using device 012 on bus 001 vendor id 0x0925 product id 0x3881 pi@raspberrypi:~/Desktop/fx2lib-master/examples/doug/fx2_programmer $ ./fx2_programmer 001 012 dumpbusses Using device 012 on bus 001 vendor id 0x0925 product id 0x3881 pi@raspberrypi:~/Desktop/fx2lib-master/examples/doug/fx2_programmer $ use lsusb to get bus and device numbers ./fx2_programmer 001 012 dump 0 1000 use OEA=0xff to turn on the outputs. /* enable port A as outputs */ OEA = 0xFF; IOA = 0xaa; delay(200); IOA = 0x55; delay(800); python ihx2iic.py build/lights.ihx lights.iic https://www.triplespark.net/elec/periph/USB-FX2/eeprom/ pi@raspberrypi:~/Desktop/cypress/cycfx2prog-0.47 $ ./cycfx2prog prg:i2c.ihx pi@raspberrypi:~/Desktop/cypress/cycfx2prog-0.47 $ ./cycfx2prog run pi@raspberrypi:~/Desktop/cypress/cycfx2prog-0.47 $ ./cycfx2prog --help Usage: cycfx2prog [-d=BUS.DEV] [id=VV.PP[.N]] [commands...] Options: --help print this and then exit --version print version information and then exit --list list devices and busses and then exit -d=BBB.DDD set device to use e.g. 006.003; if not specified, first unconfigured Cypress FX2 is used. Use --list to get BBB and DDD (bus and device number, not ID). -id=VV.PP[.N] set vendor and product ID in hex; default 04b4.8613 for unconfigured FX2. N is the n-th device to use, default 0. Commands: Must be specified after all options. reset reset 8051 by putting reset low run start the 8051 by putting reset high prg:FILE program 8051; FILE is an Intel hex file (.ihx); will reset the 8051 before download; use "run" afterwards delay:NN make a delay for NN msec set:ADR,VAL set byte at address ADR to value VAL dram:ADR,LEN dump RAM content: LEN bytes starting at ADR dbulk:EP,L[,N] bulk read N (default: 1) buffers of size L from endpoint EP (1,2,4,6,8) and dump them; L<0 to allow short reads sbulk:EP,STR send string STR as bulk message to endpoint EP (1,2,4,6,8) fbulk:EP,FILE[,CS] send FILE as bulk message to endpoint EP (1,2,4,6,8) stdin if no file specified; chunk size CS with default 64 bench_bulk:EP,L[,CS] bench reading L bytes from endpoint EP (chunk size CS) NOTE: This uses libusb and is slow on the host side! altif:[IF] set alt interface for next bulk IO; none for FX2 default ctrl:TYPE,REQUEST[,VALUE[,INDEX]] send a zero-length control message Cypress FX2(LP) programmer tool v0.47 copyright (c) 2006--2009 by Wolfgang Wieser pi@raspberrypi:~/Desktop/cypress/cycfx2prog-0.47 $ ./cycfx2prog -d001.011 prg:i2c.ihx run Illegal option "-d001.011". pi@raspberrypi:~/Desktop/cypress/cycfx2prog-0.47 $ ./cycfx2prog -d=001.011 prg:i2c.ihx run Using ID 0925:3881 on 001.011. Putting 8051 into reset. Programming 8051 using "i2c.ihx". Putting 8051 out of reset. pi@raspberrypi:~/Desktop/cypress/cycfx2prog-0.47 $ lsusb Bus 002 Device 002: ID 0bda:0316 Realtek Semiconductor Corp. Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 008: ID 138a:0097 Validity Sensors, Inc. Bus 001 Device 007: ID 5986:111c Acer, Inc Bus 001 Device 006: ID 8087:0a2b Intel Corp. Bus 001 Device 005: ID 0781:5573 SanDisk Corp. Bus 001 Device 004: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader Bus 001 Device 011: ID 0925:3881 Lakeview Research Saleae Logic Bus 001 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub pi@raspberrypi:~/Desktop/cypress/cycfx2prog-0.47 $ ======================================== Booting the CY7C68013. ======================================== The CY7C68013 has a default bootloader built in. It looks for an iic eeprom at 0x51 and read the first byte. 1) if C0 VID PID boot from USB lead. 2) if C2 VID PID code. 3) else eprom content not code, and use default VID:PID If the CY7C68013 boots from the eeprom, the eeprom needs programming using the iic format. There is a tool: python ihx2iic.py build/lights.ihx lights.iic ./cycfx2prog is very useful, but does not have secondary boot commands for filling 24LC128 eeprom Use Raspbarry Pi and ri2ceprom_rpi_24LC128_0x51_.c to write to 24LC128 I used fx2lib i2c.c example, but it needs amendin to get timing right. I have uploaded i2c.c which can be used to write eeprom if you cannot connect Raspberry Pi. You need sudo apt-get install libuser-dev and SDCC I modified i2c.c to write to the eeprom to reprogram the VID:PID, but does not upload an iic file to the eeprom. http://www.dougrice.plus.com/dev/cypress/i2c.c It tries to write to the IIC 24LC128. The link may need moving to enable writing to the ROM. ======================================== Getting a Serial COM Port loopback example to work. ======================================== These examples allow the eBay boards and logic analyser to be programmed as a COM port. https://www.triplespark.net/elec/periph/USB-FX2/software/ https://www.triplespark.net/elec/periph/USB-FX2/software/advanced_examples.html#convert_serial ======================================== Getting /home/pi/Desktop/cypress/fx2pipe-0.8 to compile ======================================== Download from: https://www.triplespark.net/elec/periph/USB-FX2/ when you type make there are lots of errors. You need to add __ e.g. #define ALLOCATE_EXTERN #ifdef ALLOCATE_EXTERN #define EXTERN //#define _AT_(a) at a #else #define EXTERN extern //#define _AT_ ;/ ## / #endif #define _AT_(a) __at a #define xdata __xdata #define sfr __sfr #define at __at //#define NOP _asm nop _endasm #define NOP __asm nop __endasm # This might have helped, but I did not find it: * The header files may need work for SDCC. - /usr/share/sdcc/scripts/keil2sdcc.pl ======================================== Conclusion:- ======================================== The little USB Logic analyser can be really useful. The Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 is interesting. ======================================== Other links for sorting:- ======================================== https://peterelectronics.blogspot.com/2011/12/cy7c68013a-usb.html http://www.colecovision.eu/mcs51/CY7C68013A%20EZ-USB%20FX2LP%20USB2.0%20Development%20Board%20Serial.shtml http://allmybrain.com/2008/10/24/a-few-open-source-tips-for-the-cypress-fx2lp-ez-usb-cy7c68013a/