From c256ca6b6660511f73c688e9781f395abd5f3e81 Mon Sep 17 00:00:00 2001 From: Paul Molloy Date: Wed, 30 Nov 2016 00:03:40 -0600 Subject: [PATCH] testing some bigger transfer sizes removing some printing. --- host/source/dictionary.c | 2 +- host/source/dictionary.h | 6 +----- host/source/test.c | 31 ++++++++++++++++--------------- host/source/usb_operations.c | 1 + host/source/usb_operations.h | 2 +- shared/shared_dict_buffer.h | 17 +++++++++++++++++ 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/host/source/dictionary.c b/host/source/dictionary.c index c231dfa..9f4916b 100644 --- a/host/source/dictionary.c +++ b/host/source/dictionary.c @@ -159,7 +159,7 @@ int dictionary_call( USBtransfer *transfer, uint8_t dictionary, uint8_t opcode, check(rbuf[0] == SUCCESS, "retro programmer had error: %d, dict:%d, opcode:%d/%x, addr:%x, data:%x",rbuf[0], dictionary, opcode, opcode, addr, miscdata) } else { //just print xfr cnt - printf(" xf: %d\n",xfr_cnt); + //printf(" xf: %d\n",xfr_cnt); } diff --git a/host/source/dictionary.h b/host/source/dictionary.h index e280644..361d012 100644 --- a/host/source/dictionary.h +++ b/host/source/dictionary.h @@ -11,7 +11,7 @@ //include prior to other file includes //that way DEBUG can be turned on/off for this file alone //uncomment to DEBUG this file alone -#define DEBUG +//#define DEBUG //"make debug" to get DEBUG msgs on entire program #include "dbg.h" @@ -19,10 +19,6 @@ #include "shared_errors.h" #include "shared_dictionaries.h" -//uncomment to DEBUG this file alone -#define DEBUG -//"make debug" to get DEBUG msgs on entire program -#include "dbg.h" int dictionary_call( USBtransfer *transfer, uint8_t dictionary, uint8_t opcode, uint16_t addr, uint8_t miscdata, uint8_t endpoint, uint8_t *buffer, uint16_t length); diff --git a/host/source/test.c b/host/source/test.c index f3532f2..1d0831e 100644 --- a/host/source/test.c +++ b/host/source/test.c @@ -8,70 +8,71 @@ int test_function( USBtransfer *transfer ) debug("reset butters"); dictionary_call( transfer, BUFFER, RAW_BUFFER_RESET, 0, 0, USB_IN, NULL, 0); dictionary_call( transfer, BUFFER, RAW_BANK_STATUS, 0, 0, USB_IN, NULL, 0); - debug("allocate buff0 128B"); //id:basebank num32B banks + debug("allocate buff0 256B"); //id:basebank num32B banks dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER0, 0x1000, 4, USB_IN, NULL, 0); - debug("allocate buff1 128B"); //id:basebank num32B banks + debug("allocate buff1 256B"); //id:basebank num32B banks dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER1, 0x2004, 4, USB_IN, NULL, 0); debug("status"); //id:basebank num32B banks dictionary_call( transfer, BUFFER, RAW_BANK_STATUS, 0, 0, USB_IN, NULL, 0); dictionary_call( transfer, BUFFER, RAW_BANK_STATUS, 4, 0, USB_IN, NULL, 0); - uint8_t load_in[128]; - uint8_t load_out[128]; + uint8_t load_in[256]; + uint8_t load_out[256]; int i = 0; load_in[0] = 0xEE; //print load printf("load_in data:"); - for (i=0; i<128; i++) { + for (i=0; i<256; i++) { printf(" %x",load_in[i]); } printf("\n"); debug("read payload0 uninitialized"); - dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 128); + dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254); //print load printf("load_in data:"); - for (i=0; i<128; i++) { + for (i=0; i<256; i++) { printf(" %x",load_in[i]); } printf("\n"); //fill load with 0-127 - for (i=0; i<128; i++) { + for (i=0; i<256; i++) { load_out[i] = i; } //print contents before sending printf("load_out with data:"); - for (i=0; i<128; i++) { + for (i=0; i<256; i++) { printf(" %x",load_out[i]); } printf("\n"); debug("send payload0"); - dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_OUT, load_out, 128); + dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_OUT, load_out, 254); debug("read payload0"); - dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 128); + dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254); //print load printf("load_in data:"); - for (i=0; i<128; i++) { + for (i=0; i<256; i++) { printf(" %x",load_in[i]); } printf("\n"); clock_t tstart, tstop; tstart = clock(); - for ( i = (1024 * 4); i>0; i--) { - dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_OUT, load_out, 128); + //for ( i = (1024 * 2); i>0; i--) { + for ( i = (1033 * 2); i>0; i--) { + dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_out, 254); } tstop = clock(); float timediff = ( (float)(tstop-tstart) / CLOCKS_PER_SEC); printf("total time: %fsec, speed: %fKBps", timediff, (512/timediff)); - //128byte transfers currently clocking in around 21KBps + //256byte transfers currently clocking in around 21KBps // dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER2, 0x3508, 4); diff --git a/host/source/usb_operations.c b/host/source/usb_operations.c index 568a931..90a0105 100644 --- a/host/source/usb_operations.c +++ b/host/source/usb_operations.c @@ -233,6 +233,7 @@ void close_usb(libusb_context *context, libusb_device_handle *handle) int usb_transfer( USBtransfer *transfer ) { check( transfer->wLength <= MAX_VUSB, "Can't transfer more than %d bytes!", MAX_VUSB); + //check( transfer->wLength <= MAX_VUSB_LONGXFR, "Can't transfer more than %d bytes!", MAX_VUSB_LONGXFR); if ( transfer->wLength != 0) { check( transfer->data != NULL, "data buffer isn't initialized it's: %s", transfer->data); diff --git a/host/source/usb_operations.h b/host/source/usb_operations.h index c732acf..c2dc57a 100644 --- a/host/source/usb_operations.h +++ b/host/source/usb_operations.h @@ -43,7 +43,7 @@ #define TIMEOUT_5_SEC 5000 //Max transfer length -#define MAX_VUSB 245 //Max VUSB transfers without long transfers enabled +#define MAX_VUSB 254 //Max VUSB transfers without long transfers enabled #define USB_NO_MSG 255 //designates transfer with no message #define MAX_VUSB_LONGXFR 16384 //16KByte biggest value 16bit wLength can hold diff --git a/shared/shared_dict_buffer.h b/shared/shared_dict_buffer.h index e8de5b4..7a0e5d2 100644 --- a/shared/shared_dict_buffer.h +++ b/shared/shared_dict_buffer.h @@ -233,6 +233,23 @@ // start programming mid usb transfer once it's full. Want to make effor to hide flash programming // wait time behind usb transfer time. +// some speed testing: +// 128Byte OUT (write) transfers with long transfers DISABLED: 20.04sec/512KByte = 25.55KBps +// 128Byte OUT (write) transfers with long transfers ENABLED: 20.7 sec/512KByte = 24.7 KBps +// 256Byte OUT (write) transfers with long transfers ENABLED: 18.56sec/512KByte = 27.6 KBps +// 254Byte OUT (write) transfers with long transfers DISABLED: 17.9 sec/512KByte = 28.6 KBps (assuming 2 bytes stuffed in setup packet) +// 254Byte IN (read) with long xfr DISABLED, w/o usbFuncRd: 30.9 sec/512KByte = 16.5 KBps +// 254Byte IN (read) with long xfr DISABLED, w/usbFuncRd: 34.9 sec/512KByte = 14.7 KBps +// +// These tests did nothing with payload once it arrived, so these are practical maximums of V-usb. +// Conclusion: +// -enabling long transfers slows writes (and probably reads) +// -reads are much slower than writes. +// -enabling usbFunctionRead is slower compared to using usbFunctionSetup alone. +// -using 254B xfrs with 2 bytes stuffed in setup packet gives decent boost. +// this is primarily due to speed up of not having long transfers enabled. +// -not actually certain enabling long transfers will slow down reads, but it certainly does for writes. +// #endif