Examples showing how to download firmware to a EZ-USB (AN21xx/FX/FX1/FX2/FX2LP)

Question: Are there any examples showing how to download firmware to a EZ-USB (AN21xx/FX/FX1/FX2/FX2LP) device using the CyAPI.lib/CyUSB.dll in a host application and the CyUSB.sys driver?

 

Answer:

Yes. We have Control center example which uses LoadRAM() and LoadExternalRam() APIs of CyUSB.dll to download code to FX1/FX2/FX2LP. You can find control center source code in C:\Program Files\Cypress\Cypress Suite USB 3.4.1\CyUSB.NET\examples\Control Center after installing Suiteusb. Following is the steps of how the APIs achieve this,

The firmware download to EZ-USB (AN21xx/FX/FX1/FX2/FX2LP) uses the A0 Vendor command and is called anchor download. The value field in this vendor command is used to specify the memory location to be written. The limitation of A0 vendor command is that it can write only to the internal memory and the CPU should be held in reset when it is used. A0 vendor command can also write to the 8051RES bit of CPUCS. To put the CPU in reset send A0 vendor command with E600H (for FX1/FX2/FX2LP for older parts like FX use 7F92H) as value and 01 as data. To bring the CPU out of reset send 00 as data.

The logical flow of downloading firmware is parse the input file (.hex) of the firmware. If it contains code that is to be written to external memory then download vend_ax (configured to reside only in internal memory) example to the device using A0 vendor commands. Now when the CPU is brought out of reset the device is running Vend_ax example. Vend_ax example provides A3 vendor command which is capable of writing to external memory so the code that is to reside on the external memory is loaded using A3 vendor command. A3 vendor command also uses the value field to specify the memory location to be written. After this the CPU is put in reset and the code that is to reside in internal memory is written using A0 vendor command. Now bring the CPU out of reset.

Note:- The firmware .hex file generated using keil uVision follows intel hex format.