EZ-USB, FX, FX2 are very popular. The reason why, it is very affodable solution for development wiht firmware loading via USB it self.However, firmware development is still hard for us. EZ-USB series devices are manufactured/sold by Cypress semiconductor.It is needed Keil-compiler for firmware development of EZ-USB series devices. Software Development Kit(SDK) contains trial version of Keil compiler. However, the trial version compiler has limitation of 4KB for firmware building.
-
Purpose
On the other hand, we also have free compiler system. SDCC is the most famous compiler for our purpose. It can create object code not only 8051(as used in EZ-USB) but also PIC. However, frame-work of USB is very big, it has been coded by Keil-compiler system as well. Still we have difference between Keil-compiler and SDCC. It means quite difficult to port SDCC system from Keil-compiler. Also, we encountered a problem which is called "Reinventing the wheel".
fenrir has been creating FX2 system. He has opened a ported code on his blog as well. Also it has BBS system on the blog which contains useful information for using SDCC.
OK, ofcourse. As usually, we need long time for starting-up that type of program. I hope to reduce time of starting-up, for concentrating application side as well.
-
Sample code
Caution:
Since, following sample code are ported from bulkloop. Some code are tested until Renum-level as well. It is needed for enought testing, if you use your own project.Those code are compiled by SDCC version is 2.7.0.
-
Tools
- Cypress FX2 SDK
Cypress provide SDK for EZ-USB FX2 system. It should be installed before developing for avoiding driver loading problem. More detail information from here (totally written in Japanese).
- SDCC
SDCC is a free compiler system. You can download it which is adapted your operating system from here. For windows sytem is easiest installing as well.
- make
You don't have to install "make", if you are using Unix operating system for firmaware development. Also, you are using Windows operatitng system. You have to find out "make"(a.k.a MinGW gmake?) and install your system by your self.
- Binary translation tools
Usually, firmware is generated as intel-hex format. Binary translation is very useful for using application software.
- Windows
Use "Hex2Bix" which is installed with Cypress SDK.
- UNIX
Use objcopy
You have to confirm path-setting for tools. Not conciously, for using the tools which are invoked from make file.
- Binary to C source code converter
I guess that "binary to C source code converter tool is delivered by previous version of SDK. I could not find that type of tool in current version of Cypress SDK. bin2c is very useful tool, if you delivered combine firmware + host software within one file.
- Windows
Windows OS does not have compiling environment, I prepare execute code.
- UNIX 系 OS
You can use freely compile at UNIX OS from source code as well.
- How to use
- How to make firm.c
Firstly, you have to make filename.bix. Also set path for bin2c. Finally, do following command.
bin2c filename.bix
firm.c is created in current directory.
- How to combine firmware to host software
extern unsigned char firmware[] =
#include "firmware.c"
This array should be transfered FX2 command.
-
How to use
- De-compress file
Download and de-compress your target directly.
- Creating library
Create library before firmware building.
- cd lib
- make (refer following instraction for firmware building)
- Building firmware
- How to download firmware
-
Know How
- No Renumration
Device Descriptor alignment is not started from even boundary. We have to trim with "void resume_isr(void) interrupt WKUP_VECT" of fw.c
fw.c
void resume_isr(void) interrupt WKUP_VECT
{
EZUSB_CLEAR_RSMIRQ();
// alignment end of fw.c
_asm;
.even
// nop; // comment out this if needed
_endasm;
}
with/without nop for trimming alignment.
-
Wanted
-
Thanks to
We have to thank to Pionners
- fenrir
Base porting from Keil compiler to SDCC (as great work).
- Optimize
Provide FX2/ChameleonFX2 kit and sample firmware code
- myst
Advise for "How to make Makefile".
- K.K.
bin2c create and contribution
|