patch for fxload to support newer FX2LP parts
Hello
I'm using Cypress EZ-USB FX2LP devices which have 16K of on-board memory and I've exceeded the 8K limit for FX2 parts in fxload.
Based on Dave Brownell's advice here:
http://sourceforge.net/mailarchive/message.php?msg_name=3EC822B6.70801%40pacbell.net
"Better to teach it about that particular chip,
rather than break every standard an21 or fx chip;
just add a new "-t type" option. "fxload" is
100% correct for the devices it claims to support!"
I've patched the latest CVS fxload to support the FX2LP by adding type fx2lp
I tried to be not too intrusive but if types are going to grow, it might be better to add an enumerated type to pass down to the work functions. For this patch, I added a new memory range test function fx2lp_is_external() and added another boolean argument lp to ezusb_load_ram(int fd, const char *path, int fx2, int lp, int stage).
This patch works for on-board memory loading on the hardware I have. I also think it is benign for external RAM loading or EEPROM programming but I have not tested this on hardware.
All the best
Harry McNally
fxload/ezusb.c +40 -2
@@ -96,6 +96,25 @@return 1 ; } +/* +* return true iff [addr,addr+len) includes external RAM +* for Cypress EZ-USB FX2LP +*/ +static int fx2lp_is_external (unsigned short addr,size_t len) +{ +/* 1st 16KB for data/code, 0x0000-0x3fff */ +if (addr <=0x3fff ) +return ((addr + len) >0x4000 ); + +/* and 512 for data, 0xe000-0xe1ff */ +else if (addr >=0xe000 && addr <=0xe1ff ) +return ((addr + len) >0xe200 ); + +/* otherwise, it's certainly external */ +else +return 1 ; +} +/*****************************************************************************/ #if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,5 ,3 )
@@ -506,7 +525,7 @@* memory is written, expecting a second stage loader to have already * been loaded. Then file is re-parsed and on-chip memory is written. */ -int ezusb_load_ram (int fd,const char *path,int fx2,int stage) +int ezusb_load_ram (int fd,const char *path,int fx2,int lp,int stage) {FILE *image;unsigned short cpucs_addr;
@@ -524,7 +543,10 @@/* EZ-USB original/FX and FX2 devices differ, apart from the 8051 core */ if (fx2) { cpucs_addr =0xe600 ; - is_external = fx2_is_external; +if (lp) + is_external = fx2lp_is_external; +else + is_external = fx2_is_external; }else { cpucs_addr =0x7f92 ; is_external = fx_is_external;
@@ -697,6 +719,22 @@ (config &0x01 ) ?400 :100 ); + }else if (strcmp ("fx2lp" , type) ==0 ) { + first_byte =0xC2 ; + cpucs_addr =0xe600 ; + is_external = fx2lp_is_external; + ctx.ee_addr =8 ; + config &=0x4f ; +logerror ( +"FX2: config = 0x%02x, %sconnected, I2C = %d KHz\n" , + config, + (config &0x40 ) ?"dis" :"" , +// NOTE: old chiprevs let CPU clock speed be set +// or cycle inverted here. You shouldn't use those. +// (Silicon revs B, C? Rev E is nice!) + (config &0x01 ) ?400 :100 + ); + }else if (strcmp ("fx" , type) ==0 ) { first_byte =0xB6 ; cpucs_addr =0x7f92 ;
fxload/ezusb.h +3 -2
@@ -25,13 +25,14 @@/* * This function loads the firmware from the given file into RAM. * The file is assumed to be in Intel HEX format. If fx2 is set, uses -* appropriate reset commands. Stage == 0 means this is a single stage +* appropriate reset commands. If lp is set, the device is a later +* FX2LP and available RAM is 16K. Stage == 0 means this is a single stage * load (or the first of two stages). Otherwise it's the second of * two stages; the caller preloaded the second stage loader. * * The target processor is reset at the end of this download. */ -extern int ezusb_load_ram (int dev,const char *path,int fx2,int stage); +extern int ezusb_load_ram (int dev,const char *path,int fx2,int lp,int stage);/*
fxload/fxload.8 +6 -1
@@ -54,6 +54,7 @@ These controllers have several package options, and can be set up with external memory (on-chip memory is usually about 8K), EEPROMs, and ROMs when device costs allow. +The more recent FX2LP devices have 16K of on-chip memory. .PP This uses "usbfs" (older name: "usbdevfs") to access devices, and issues vendor specific control requests
@@ -164,9 +165,13 @@ .I fx (Cypress' updated version, the EZ-USB FX), or .I fx2 -(the Cypress EZ-USB FX2, supporting high speed transfers). +(the Cypress EZ-USB FX2, supporting high speed transfers), or +.I fx2lp +(the later FX2 parts which have 16K of on-board RAM). Except when writing to EEPROM, all that normally matters when downloading firmware is whether or not the device uses an FX2. +The fx2 type will download firmware to the FX2LP when the +memory load addresses do not exceed 8K. .TP .B "\-v" Prints some diagnostics, such as download addresses and sizes,
fxload/main.c +12 -7
@@ -27,7 +27,7 @@* looking for the device. * * -I <path> -- Download this firmware (intel hex) -* -t <type> -- uController type: an21, fx, fx2 +* -t <type> -- uController type: an21, fx, fx2, fx2lp * -s <path> -- use this second stage loader * -c <byte> -- Download to EEPROM, with this config byte *
@@ -146,6 +146,7 @@if (strcmp (optarg,"an21" )// original AnchorChips parts &&strcmp (optarg,"fx" )// updated Cypress versions &&strcmp (optarg,"fx2" )// Cypress USB 2.0 versions + &&strcmp (optarg,"fx2lp" )// Later Cypress USB 2.0 version ) {logerror ("illegal microcontroller type: %s\n" , optarg); goto usage;
@@ -190,7 +191,7 @@fputs ("[-s loader] [-c config_byte]\n" , stderr);fputs ("\t\t[-L link] [-m mode]\n" , stderr);fputs ("... [-D devpath] overrides DEVICE= in env\n" , stderr); -fputs ("... device types: one of an21, fx, fx2\n" , stderr); +fputs ("... device types: one of an21, fx, fx2, fx2lp\n" , stderr);fputs ("... at least one of -I, -L, -m is required\n" , stderr);return -1 ; }
@@ -199,6 +200,7 @@int fd =open (device_path,O_RDWR );int status;int fx2; +int lp;if (fd ==-1 ) {logerror ("%s : %s\n" ,strerror (errno), device_path);
@@ -208,8 +210,11 @@if (type ==0 ) { type ="fx" ;/* an21-compatible for most purposes */ fx2 =0 ; - }else - fx2 = (strcmp (type,"fx2" ) ==0 ); + lp =0 ; + }else { + fx2 = (strncmp (type,"fx2" ,3 ) ==0 ); + lp = (strcmp (type,"fx2lp" ) ==0 ); + }if (verbose)logerror ("microcontroller type: %s\n" , type);
@@ -218,7 +223,7 @@/* first stage: put loader into internal memory */ if (verbose)logerror ("1st stage: load 2nd stage loader\n" ); - status =ezusb_load_ram (fd, stage1, fx2,0 ); + status =ezusb_load_ram (fd, stage1, fx2, lp,0 );if (status !=0 )return status;
@@ -226,14 +231,14 @@if (config >=0 ) status =ezusb_load_eeprom (fd, ihex_path, type, config);else - status =ezusb_load_ram (fd, ihex_path, fx2,1 ); + status =ezusb_load_ram (fd, ihex_path, fx2, lp,1 );if (status !=0 )return status; }else {/* single stage, put into internal memory */ if (verbose)logerror ("single stage: load on-chip memory\n" ); - status =ezusb_load_ram (fd, ihex_path, fx2,0 ); + status =ezusb_load_ram (fd, ihex_path, fx2, lp,0 );if (status !=0 )return status; }
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel