From ff8823199f375d709a689dd017950d575b649df6 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Wed, 28 Feb 2007 01:23:19 +0000 Subject: Merge xpp rev. 3495: ------------------------------------------------------------------------ r2243 | tzafrir | 2007-02-28 02:05:59 +0200 (Wed, 28 Feb 2007) | 4 lines * xpp rev. 3495: fix a race in the FXO driver of recent weeks. * Add the Astribank BRI driver (though still needs bristuffed zaptel to build and thus will not build by default) ------------------------------------------------------------------------ r2239 | tzafrir | 2007-02-27 08:14:18 +0200 (Tue, 27 Feb 2007) | 18 lines Xorcom rev. 3491: * Version of xpp modules is set from xpp/.version, rather than "unknown". * Astribank devices are now initialized in parallel: faster startup when there are multiple Astribanks. * Re-added support for the old format of /proc/xpp/sync write: (echo N 0 > /proc/xpp/sync ) . The new format (SYNC=NN) is preffered. * Firmware update to fix a PCM issue. * Fixed a build issue with kernel 2.6.8 . * Fixed missing initialization in Zaptel::Xpp::Xbus . * genzaptelconf will now set FXS ports as LS by default. To set them as KS, use fxs_default_start=ks in /etc/default/zaptel / /etc/sysconfig/zaptel (Also a workaround for #7755 ). * Groundwork for sync from zaptel master span: if zaptel is built with ZAPTEL_SYNC_TIC (see zaptel/team/tzafrir/sync ), xpp will report its drift from the zaptel sync master. * USB firmware update: had bad lines checksums (and fxload did not report). * fpga_load can now better report bad hex file checksum ;-) . ------------------------------------------------------------------------ r2223 | tzafrir | 2007-02-24 03:05:05 +0200 (Sat, 24 Feb 2007) | 3 lines Add the Zaptel and Zaptel::Xpp perl modules, and some simple utilities that use them. disabled by default for now. ------------------------------------------------------------------------ r2222 | tzafrir | 2007-02-24 02:55:05 +0200 (Sat, 24 Feb 2007) | 2 lines Make the xpp/utils/Makefile in 1.2 closer to the one in 1.4 . git-svn-id: http://svn.digium.com/svn/zaptel/trunk@2247 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- xpp/utils/fpga_load.c | 71 +++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 33 deletions(-) (limited to 'xpp/utils/fpga_load.c') diff --git a/xpp/utils/fpga_load.c b/xpp/utils/fpga_load.c index 426e6a6..2c03704 100644 --- a/xpp/utils/fpga_load.c +++ b/xpp/utils/fpga_load.c @@ -10,8 +10,21 @@ static const char rcsid[] = "$Id$"; -#define ERR(fmt, arg...) fprintf(stderr, "%s: ERROR: " fmt, progname, ## arg) -#define INFO(fmt, arg...) fprintf(stderr, "%s: " fmt, progname, ## arg) +#define ERR(fmt, arg...) do { \ + if(verbose >= LOG_ERR) \ + fprintf(stderr, "%s: ERROR: " fmt, \ + progname, ## arg); \ + } while(0); +#define INFO(fmt, arg...) do { \ + if(verbose >= LOG_INFO) \ + fprintf(stderr, "%s: " fmt, \ + progname, ## arg); \ + } while(0); +#define DBG(fmt, arg...) do { \ + if(verbose >= LOG_DEBUG) \ + fprintf(stderr, "%s: DBG: " fmt, \ + progname, ## arg); \ + } while(0); static int verbose = LOG_WARNING; static char *progname; @@ -229,14 +242,13 @@ int eeprom_set(struct my_usb_device *mydev, const struct myeeprom *eeprom) char buf[PACKET_SIZE]; struct fpga_packet_header *phead = (struct fpga_packet_header *)buf; - if(verbose >= LOG_DEBUG) - INFO("%s Start...\n", __FUNCTION__); + DBG("%s Start...\n", __FUNCTION__); assert(mydev != NULL); phead->header.op = EEPROM_SET; memcpy(&phead->d.eeprom_set.data, eeprom, EEPROM_SIZE); len = sizeof(phead->d.eeprom_set) + sizeof(phead->header.op); if(verbose >= LOG_DEBUG) { - INFO("%s write %d bytes\n", __FUNCTION__, len); + DBG("%s write %d bytes\n", __FUNCTION__, len); dump_packet((char *)phead, len); } ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, len, TIMEOUT); @@ -262,7 +274,7 @@ int eeprom_set(struct my_usb_device *mydev, const struct myeeprom *eeprom) return -EINVAL; } if(verbose >= LOG_DEBUG) { - INFO("%s read %d bytes\n", __FUNCTION__, ret); + DBG("%s read %d bytes\n", __FUNCTION__, ret); dump_packet(buf, ret); } return 0; @@ -279,12 +291,11 @@ int eeprom_get(struct my_usb_device *mydev) assert(mydev != NULL); eeprom = &mydev->eeprom; - if(verbose >= LOG_DEBUG) - INFO("%s Start...\n", __FUNCTION__); + DBG("%s Start...\n", __FUNCTION__); phead->header.op = EEPROM_GET; len = sizeof(phead->header.op); /* warning: sending small packet */ if(verbose >= LOG_DEBUG) { - INFO("%s write %d bytes\n", __FUNCTION__, len); + DBG("%s write %d bytes\n", __FUNCTION__, len); dump_packet(buf, len); } ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, len, TIMEOUT); @@ -310,7 +321,7 @@ int eeprom_get(struct my_usb_device *mydev) return -EINVAL; } if(verbose >= LOG_DEBUG) { - INFO("%s read %d bytes\n", __FUNCTION__, ret); + DBG("%s read %d bytes\n", __FUNCTION__, ret); dump_packet(buf, ret); } memcpy(eeprom, &phead->d.eeprom_get.data, EEPROM_SIZE); @@ -339,8 +350,7 @@ int send_hexline(struct my_usb_device *mydev, struct hexline *hexline, int seq) phead->d.data_packet.reserved = 0x00; memcpy(phead->d.data_packet.data, data, len); len += sizeof(hexline->d.content.header); - if(verbose >= LOG_DEBUG) - INFO("%04d+\r", seq); + DBG("%04d+\r", seq); ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, len, TIMEOUT); if(ret < 0) { ERR("bulk_write failed: %s\n", usb_strerror()); @@ -357,8 +367,7 @@ int send_hexline(struct my_usb_device *mydev, struct hexline *hexline, int seq) return ret; } else if(ret == 0) return 0; - if(verbose >= LOG_INFO) - INFO("%04d-\r", seq); + DBG("%04d-\r", seq); phead = (struct fpga_packet_header *)buf; if(phead->header.op != STATUS_REPLY) { ERR("Got unexpected reply op=%d\n", phead->header.op); @@ -372,13 +381,11 @@ int send_hexline(struct my_usb_device *mydev, struct hexline *hexline, int seq) case FW_FAIL_RESET: case FW_FAIL_TRANS: ERR("status reply %s (%d)\n", load_status2str(status), status); - if(verbose >= LOG_INFO) - dump_packet(buf, ret); + dump_packet(buf, ret); return -EPROTO; default: ERR("Unknown status reply %d\n", status); - if(verbose >= LOG_INFO) - dump_packet(buf, ret); + dump_packet(buf, ret); return -EPROTO; } return 0; @@ -468,9 +475,11 @@ int my_usb_device_init(const char devpath[], struct my_usb_device *mydev) config_desc = mydev->dev->config; interface = config_desc->interface; iface_desc = interface->altsetting; - if(verbose >= LOG_INFO) - INFO("Vendor:Product=%04X:%04X Class=%d (endpoints=%d)\n", - dev_desc->idVendor, dev_desc->idProduct, dev_desc->bDeviceClass, iface_desc->bNumEndpoints); + INFO("Vendor:Product=%04X:%04X Class=%d (endpoints=%d)\n", + dev_desc->idVendor, + dev_desc->idProduct, + dev_desc->bDeviceClass, + iface_desc->bNumEndpoints); if(iface_desc->bInterfaceClass != 0xFF) { ERR("Wrong Interface class %d\n", iface_desc->bInterfaceClass); return 0; @@ -518,8 +527,7 @@ int renumerate_device(struct my_usb_device *mydev) int ret; assert(mydev != NULL); - if(verbose >= LOG_INFO) - INFO("Renumerating\n"); + DBG("Renumerating\n"); phead->header.op = RENUMERATE; ret = usb_bulk_write(mydev->handle, MY_EP_OUT, (char *)phead, 1, TIMEOUT); if(ret < 0) { @@ -541,10 +549,11 @@ int fpga_load(struct my_usb_device *mydev, const struct hexdata *hexdata) unsigned int j = 0; int ret; int finished = 0; + const char *v = hexdata->version_info; + v = (v[0]) ? v : "Unknown"; assert(mydev != NULL); - if(verbose >= LOG_INFO) - INFO("Start...\n"); + INFO("FPGA_LOAD (version %s)\n", v); /* * i - is the line number * j - is the sequence number, on USB 2, i=j, but on @@ -561,8 +570,7 @@ int fpga_load(struct my_usb_device *mydev, const struct hexdata *hexdata) return 0; } if(hexline->d.content.header.tt == TT_EOF) { - if(verbose >= LOG_INFO) - INFO("End of data\n"); + DBG("End of data\n"); finished = 1; continue; } @@ -579,8 +587,7 @@ int fpga_load(struct my_usb_device *mydev, const struct hexdata *hexdata) j += ret; } } - if(verbose >= LOG_INFO) - INFO("Finished...\n"); + DBG("Finished...\n"); return 1; } @@ -731,8 +738,7 @@ int main(int argc, char *argv[]) if(vendor || product || release || serial || source ) opt_read_eeprom = opt_write_eeprom = 1; #endif - if(verbose >= LOG_INFO) - INFO("Startup %s\n", devpath); + DBG("Startup %s\n", devpath); if(!my_usb_device_init(devpath, &mydev)) { ERR("Failed to initialize USB device '%s'\n", devpath); @@ -792,8 +798,7 @@ int main(int argc, char *argv[]) show_device_info(&mydev); } #endif - if(verbose >= LOG_INFO) - INFO("Exiting\n"); + DBG("Exiting\n"); dev_err: my_usb_device_cleanup(&mydev); return ret; -- cgit v1.2.3