From 171215fa2528b35064bd9d11f6958d9898bdc26a Mon Sep 17 00:00:00 2001 From: Larry Snizek Date: Fri, 1 Feb 2019 20:59:56 +0000 Subject: [PATCH 1/3] DFU debugging tool --- dfu_debug/config.xscope | 1 + dfu_debug/dfu_handler.h | 13 ++++ dfu_debug/makefile | 12 ++++ dfu_debug/requests.c | 138 ++++++++++++++++++++++++++++++++++++ dfu_debug/requests.h | 11 +++ dfu_debug/test.xc | 25 +++++++ dfu_debug/uac_hwresources.h | 9 +++ dfu_debug/vfst_base_usb.xn | 122 +++++++++++++++++++++++++++++++ dfu_debug/xua.h | 46 ++++++++++++ dfu_debug/xud.xc | 72 +++++++++++++++++++ dfu_debug/xud_device.h | 54 ++++++++++++++ 11 files changed, 503 insertions(+) create mode 100644 dfu_debug/config.xscope create mode 100644 dfu_debug/dfu_handler.h create mode 100644 dfu_debug/makefile create mode 100644 dfu_debug/requests.c create mode 100644 dfu_debug/requests.h create mode 100644 dfu_debug/test.xc create mode 100644 dfu_debug/uac_hwresources.h create mode 100644 dfu_debug/vfst_base_usb.xn create mode 100644 dfu_debug/xua.h create mode 100644 dfu_debug/xud.xc create mode 100644 dfu_debug/xud_device.h diff --git a/dfu_debug/config.xscope b/dfu_debug/config.xscope new file mode 100644 index 000000000..7e6978c08 --- /dev/null +++ b/dfu_debug/config.xscope @@ -0,0 +1 @@ + diff --git a/dfu_debug/dfu_handler.h b/dfu_debug/dfu_handler.h new file mode 100644 index 000000000..7493cfce2 --- /dev/null +++ b/dfu_debug/dfu_handler.h @@ -0,0 +1,13 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#ifndef __dfu_handler_h__ +#define __dfu_handler_h__ + +#include + +#ifdef __XC__ +[[distributable]] [[combinable]] +#endif +void DFUHandler(SERVER_INTERFACE(i_dfu, i), + NULLABLE_RESOURCE(chanend, c_user_cmd)); + +#endif diff --git a/dfu_debug/makefile b/dfu_debug/makefile new file mode 100644 index 000000000..1f60b961d --- /dev/null +++ b/dfu_debug/makefile @@ -0,0 +1,12 @@ +# Copyright (c) 2019, XMOS Ltd, All rights reserved +XUA = ../lib_xua/src/dfu + +all: + xcc vfst_base_usb.xn \ +-Os -lquadflash \ +-D XUD_SERIES_SUPPORT=4 -D DFU_DEBUG=1 -D START_IN_DFU=1 \ +-I . -I ${XUA} \ +${XUA}/dfu.xc ${XUA}/flash_interface.c ${XUA}/flashlib_user.c \ +config.xscope \ +test.xc xud.xc requests.c + xobjdump -d a.xe > objdump diff --git a/dfu_debug/requests.c b/dfu_debug/requests.c new file mode 100644 index 000000000..3416570ac --- /dev/null +++ b/dfu_debug/requests.c @@ -0,0 +1,138 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#include +#include +#include +#include +#include +#include +#include "xud_device.h" +#include "dfu_interface.h" +#include "dfu_types.h" +#include "xua.h" +#include "xua_dfu.h" +#include "requests.h" + +#define DFU_BLOCK 64 + +void get_status(CLIENT_INTERFACE(i_dfu, i)) +{ + printf("+ get_status\n"); + + USB_SetupPacket_t sp; + + sp.bmRequestType.Recipient = USB_BM_REQTYPE_RECIP_INTER; + sp.bmRequestType.Type = USB_BM_REQTYPE_TYPE_CLASS; + sp.bmRequestType.Direction = USB_BM_REQTYPE_DIRECTION_D2H; + sp.bRequest = DFU_GETSTATUS; + sp.wValue = 0; + sp.wIndex = 0; + sp.wLength = 1; + + XUD_ep epout = 0, epin = 0; + int reset = 0; + + DFUDeviceRequests(epout, &epin, &sp, (chanend)NULL, 0, i, &reset); + + int data_len = 0; + unsigned char data[64]; + + xud_read_get_data(data, &data_len); + + printf("- get_data %d state=%d timeout=%d next_state=%d\n", + data_len, data[0], data[1], data[4]); +} + +void download_block(CLIENT_INTERFACE(i_dfu, i), int block_num, + unsigned char data[], int data_length) +{ + if (data_length == 0) { + printf("+ download_block %d 0 NULL\n", block_num); + } + else { + printf("+ download_block %d %d 0x%x 0x%x\n", block_num, data_length, + data[0], data[data_length - 1]); + } + + USB_SetupPacket_t sp; + + sp.bmRequestType.Recipient = USB_BM_REQTYPE_RECIP_INTER; + sp.bmRequestType.Type = USB_BM_REQTYPE_TYPE_CLASS; + sp.bmRequestType.Direction = USB_BM_REQTYPE_DIRECTION_H2D; + sp.bRequest = DFU_DNLOAD; + sp.wValue = block_num; + sp.wIndex = 0; + sp.wLength = data_length; + + if (data_length > 0) + xud_prepare_set_data(data, data_length); + + XUD_ep epout = 0, epin = 0; + int reset = 0; + + DFUDeviceRequests(epout, &epin, &sp, (chanend)NULL, 0, i, &reset); + + int set_status = xud_read_set_status(); + + printf("- set_status %d\n", set_status); +} + +void download(CLIENT_INTERFACE(i_dfu, i), const char file_name[]) +{ + FILE *f = fopen(file_name, "rb" ); + assert(f != NULL); + fseek(f, 0, SEEK_END); + int file_size = (int)ftell(f); + fseek(f, 0, SEEK_SET); + int num_blocks = file_size / DFU_BLOCK; + int remainder = file_size - num_blocks * DFU_BLOCK; + unsigned char block[DFU_BLOCK]; + int block_count = 0; + + for (int j = 0; j < num_blocks; j++) { + memset(block, 0, DFU_BLOCK); + fread(block, 1, DFU_BLOCK, f); + download_block(i, block_count, block, DFU_BLOCK); + get_status(i); + block_count++; + } + + if (remainder > 0) { + memset(block, 0, DFU_BLOCK); + fread(block, 1, remainder, f); + download_block(i, block_count, block, DFU_BLOCK); + get_status(i); + } + + // zero length to terminate + download_block(i, 0, block, 0); + get_status(i); +} + +void revertfactory(CLIENT_INTERFACE(i_dfu, i)) +{ + printf("+ revertfactory\n"); + + USB_SetupPacket_t sp; + + sp.bmRequestType.Recipient = USB_BM_REQTYPE_RECIP_INTER; + sp.bmRequestType.Type = USB_BM_REQTYPE_TYPE_CLASS; + sp.bmRequestType.Direction = USB_BM_REQTYPE_DIRECTION_H2D; + sp.bRequest = XMOS_DFU_REVERTFACTORY; + sp.wValue = 0; + sp.wIndex = 0; + sp.wLength = 0; + + XUD_ep epout = 0, epin = 0; + int reset = 0; + + DFUDeviceRequests(epout, &epin, &sp, (chanend)NULL, 0, i, &reset); + + int set_status = xud_read_set_status(); + + printf("- set_status %d\n", set_status); +} + +void initialise(void) +{ + DFUReportResetState((chanend)NULL); +} diff --git a/dfu_debug/requests.h b/dfu_debug/requests.h new file mode 100644 index 000000000..f29d50429 --- /dev/null +++ b/dfu_debug/requests.h @@ -0,0 +1,11 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#ifndef __requests_h__ +#define __requests_h__ + +#include + +void initialise(void); +void download(CLIENT_INTERFACE(i_dfu, i), const char file_name[]); +void revertfactory(CLIENT_INTERFACE(i_dfu, i)); + +#endif diff --git a/dfu_debug/test.xc b/dfu_debug/test.xc new file mode 100644 index 000000000..8279aea2f --- /dev/null +++ b/dfu_debug/test.xc @@ -0,0 +1,25 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#include +#include +#include "xua.h" +#include "dfu_interface.h" +#include "dfu_handler.h" +#include "requests.h" + +void test(client interface i_dfu i) +{ + initialise(); + download(i, "222.bin"); + //revertfactory(i); + exit(0); +} + +int main(void) +{ + interface i_dfu i; + par { + test(i); + DFUHandler(i, null); + } + return 0; +} diff --git a/dfu_debug/uac_hwresources.h b/dfu_debug/uac_hwresources.h new file mode 100644 index 000000000..8bd07b5c1 --- /dev/null +++ b/dfu_debug/uac_hwresources.h @@ -0,0 +1,9 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#ifndef __uac_hwresources_h__ +#define __uac_hwresources_h__ + +#include + +#define CLKBLK_FLASHLIB XS1_CLKBLK_1 + +#endif diff --git a/dfu_debug/vfst_base_usb.xn b/dfu_debug/vfst_base_usb.xn new file mode 100644 index 000000000..fa7bafc14 --- /dev/null +++ b/dfu_debug/vfst_base_usb.xn @@ -0,0 +1,122 @@ + + + Board + Mic Array Motherboard - Quad Tile - 167BGA + + + tileref tile[4] + tileref usb_tile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dfu_debug/xua.h b/dfu_debug/xua.h new file mode 100644 index 000000000..6c6711f50 --- /dev/null +++ b/dfu_debug/xua.h @@ -0,0 +1,46 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#ifndef __xua_h__ +#define __xua_h__ + +#include + +#define DFU_VENDOR_ID 0x20B1 +#define DFU_PID 19 +#define BCD_DEVICE 0x220 + +#define XUA_DFU_EN 1 + +#define QUAD_SPI_FLASH 1 + +#define FL_QUADDEVICE_ISSI_IS25LQ016B_12_5MHZ \ +{ \ + 20, /* Enum value to identify the flashspec in a list */ \ + 256, /* page size */ \ + 8192, /* num pages */ \ + 3, /* address size */ \ + 4, /* log2 clock divider */ \ + 0x9F, /* QSPI_RDID */ \ + 0, /* id dummy bytes */ \ + 3, /* id size in bytes */ \ + 0x9D4015, /* device id */ \ + 0x20, /* QSPI_SE */ \ + 4096, /* Sector erase is always 4KB */ \ + 0x06, /* QSPI_WREN */ \ + 0x04, /* QSPI_WRDI */ \ + PROT_TYPE_NONE, /* no protection */ \ + {{0,0},{0x00,0x00}}, /* QSPI_SP, QSPI_SU */ \ + 0x02, /* QSPI_PP */ \ + 0xEB, /* QSPI_READ_FAST */ \ + 1, /* 1 read dummy byte */ \ + SECTOR_LAYOUT_REGULAR, /* mad sectors */ \ + {4096,{0,{0}}}, /* regular sector sizes */ \ + 0x05, /* QSPI_RDSR */ \ + 0x01, /* QSPI_WRSR */ \ + 0x01, /* QSPI_WIP_BIT_MASK */ \ +} + +#define DFU_FLASH_DEVICE FL_QUADDEVICE_ISSI_IS25LQ016B_12_5MHZ + +#define FLASH_MAX_UPGRADE_SIZE (512 * 1024) + +#endif diff --git a/dfu_debug/xud.xc b/dfu_debug/xud.xc new file mode 100644 index 000000000..2d674f302 --- /dev/null +++ b/dfu_debug/xud.xc @@ -0,0 +1,72 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#include +#include +#include +#include "xud_device.h" + +static unsigned char set_data[64]; +static int set_data_len = 0; + +static unsigned char get_data[64]; +static int get_data_len = 0; + +static int set_status = 0; + +XUD_Result_t XUD_GetBuffer(XUD_ep ep_out, unsigned char buffer[], + unsigned &length) +{ + assert(set_data_len > 0); + memcpy(buffer, set_data, set_data_len); + length = set_data_len; + set_data_len = 0; + return 0; +} + +XUD_Result_t XUD_DoGetRequest(XUD_ep ep_out, XUD_ep ep_in, + unsigned char buffer[], unsigned length, + unsigned requested) +{ + assert(length <= sizeof(get_data)); + assert(get_data_len == 0); + memcpy(get_data, buffer, length); + get_data_len = length; + return 0; +} + +XUD_Result_t XUD_DoSetRequestStatus(XUD_ep ep_in) +{ + assert(set_status == 0); + set_status = 1; + return 0; +} + +void xud_prepare_set_data(unsigned char data[], int data_len) +{ + assert(data_len <= sizeof(set_data)); + assert(set_data_len == 0); + memcpy(set_data, data, data_len); + set_data_len = data_len; +} + +int xud_read_set_status(void) +{ + if (set_status) { + set_status = 0; + return 1; + } + else { + return 0; + } +} + +void xud_read_get_data(unsigned char data[], int &data_len) +{ + if (get_data_len > 0) { + memcpy(data, get_data, get_data_len); + data_len = get_data_len; + get_data_len = 0; + } + else { + data_len = 0; + } +} diff --git a/dfu_debug/xud_device.h b/dfu_debug/xud_device.h new file mode 100644 index 000000000..0a159c926 --- /dev/null +++ b/dfu_debug/xud_device.h @@ -0,0 +1,54 @@ +// Copyright (c) 2019, XMOS Ltd, All rights reserved +#ifndef __xud_device_h__ +#define __xud_device_h__ + +#include + +#define USB_BM_REQTYPE_DIRECTION_H2D 0 +#define USB_BM_REQTYPE_DIRECTION_D2H 1 + +#define USB_BM_REQTYPE_TYPE_STANDARD 0 +#define USB_BM_REQTYPE_TYPE_CLASS 1 +#define USB_BM_REQTYPE_TYPE_VENDOR 2 + +#define USB_BM_REQTYPE_RECIP_DEV 0 +#define USB_BM_REQTYPE_RECIP_INTER 1 +#define USB_BM_REQTYPE_RECIP_EP 2 +#define USB_BM_REQTYPE_RECIP_OTHER 3 + +#define USB_DESCTYPE_CONFIGURATION 2 + +#define DFU_PRODUCT_STR_INDEX 0 +#define DFU_MANUFACTURER_STR_INDEX 0 + +typedef struct { + unsigned char Recipient; + unsigned char Type; + unsigned char Direction; +} USB_BmRequestType_t; + +typedef struct { + USB_BmRequestType_t bmRequestType; + unsigned char bRequest; + unsigned short wValue; + unsigned short wIndex; + unsigned short wLength; +} USB_SetupPacket_t; + +typedef int XUD_ep; +typedef int XUD_Result_t; + +XUD_Result_t XUD_GetBuffer(XUD_ep ep_out, unsigned char buffer[], + REFERENCE_PARAM(unsigned, length)); + +XUD_Result_t XUD_DoGetRequest(XUD_ep ep_out, XUD_ep ep_in, + unsigned char buffer[], unsigned length, + unsigned requested); + +XUD_Result_t XUD_DoSetRequestStatus(XUD_ep ep_in); + +void xud_prepare_set_data(unsigned char data[], int data_len); +int xud_read_set_status(void); +void xud_read_get_data(unsigned char data[], REFERENCE_PARAM(int, data_len)); + +#endif From 587bd61e794f44755bc222c9683fc18cb120434d Mon Sep 17 00:00:00 2001 From: Larry Snizek Date: Fri, 1 Feb 2019 21:02:01 +0000 Subject: [PATCH 2/3] Message print lines in DFU code to be used by debugging tool --- lib_xua/src/dfu/dfu.xc | 25 ++++++++++++++++++ lib_xua/src/dfu/flash_interface.c | 44 ++++++++++++++++++++++++++++--- lib_xua/src/dfu/flashlib_user.c | 7 +++++ 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/lib_xua/src/dfu/dfu.xc b/lib_xua/src/dfu/dfu.xc index 6e370b6c0..d7236c009 100644 --- a/lib_xua/src/dfu/dfu.xc +++ b/lib_xua/src/dfu/dfu.xc @@ -3,6 +3,7 @@ #if (XUA_DFU_EN== 1) #include #include +#include #ifndef NO_USB #include "xud_device.h" @@ -107,6 +108,9 @@ static int DFU_Detach(unsigned int timeout, chanend ?c_user_cmd, unsigned &DFU_s static int DFU_Dnload(unsigned int request_len, unsigned int block_num, const unsigned request_data[16], chanend ?c_user_cmd, int &return_data_len, unsigned &DFU_state) { +#if DFU_DEBUG + printstr("DFU_Dnload\n"); +#endif unsigned int fromDfuIdle = 0; return_data_len = 0; int error; @@ -162,6 +166,9 @@ static int DFU_Dnload(unsigned int request_len, unsigned int block_num, const un flash_cmd_write_page((cmd_data, unsigned char[])); DFU_state = STATE_DFU_MANIFEST_SYNC; +#if DFU_DEBUG + printstr("DFU_state -> STATE_DFU_MANIFEST_SYNC\n"); +#endif } else { @@ -195,6 +202,9 @@ static int DFU_Dnload(unsigned int request_len, unsigned int block_num, const un subPagesLeft--; DFU_state = STATE_DFU_DOWNLOAD_SYNC; +#if DFU_DEBUG + printstr("DFU_state -> STATE_DFU_DOWNLOAD_SYNC\n"); +#endif } return 0; @@ -262,6 +272,9 @@ static int DFU_Upload(unsigned int request_len, unsigned int block_num, unsigned static int DFU_GetStatus(unsigned int request_len, unsigned data_buffer[16], chanend ?c_user_cmd, unsigned &DFU_state) { +#if DFU_DEBUG + printstr("DFU_GetStatus\n"); +#endif unsigned int timeout = 0; data_buffer[0] = timeout << 8 | (unsigned char)DFU_status; @@ -278,6 +291,9 @@ static int DFU_GetStatus(unsigned int request_len, unsigned data_buffer[16], cha break; case STATE_DFU_DOWNLOAD_SYNC: DFU_state = STATE_DFU_DOWNLOAD_IDLE; +#if DFU_DEBUG + printstr("DFU_state -> STATE_DFU_DOWNLOAD_IDLE\n"); +#endif break; case STATE_DFU_MANIFEST_SYNC: // Check if complete here @@ -349,6 +365,9 @@ int DFUReportResetState(chanend ?c_user_cmd) unsigned int cmd_data[16]; inDFU = 1; g_DFU_state = STATE_DFU_IDLE; +#if DFU_DEBUG + printstr("DFU_state -> STATE_DFU_IDLE\n"); +#endif return inDFU; } @@ -362,6 +381,9 @@ int DFUReportResetState(chanend ?c_user_cmd) if (currentTime - DFUTimerStart > DFUResetTimeout) { g_DFU_state = STATE_APP_IDLE; +#if DFU_DEBUG + printstr("DFU_state -> STATE_APP_IDLE (timeout)\n"); +#endif inDFU = 0; } else @@ -545,6 +567,9 @@ int DFUDeviceRequests(XUD_ep ep0_out, XUD_ep &?ep0_in, USB_SetupPacket_t &sp, ch unsigned int dfuState = g_DFU_state; int dfuResetOverride; +#ifdef DFU_DEBUG + printstr("DFUDeviceRequests\n"); +#endif if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D) { // Host to device diff --git a/lib_xua/src/dfu/flash_interface.c b/lib_xua/src/dfu/flash_interface.c index 69d66b973..dbed5d419 100755 --- a/lib_xua/src/dfu/flash_interface.c +++ b/lib_xua/src/dfu/flash_interface.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "xua.h" @@ -23,7 +24,11 @@ #define FLASH_MAX_UPGRADE_SIZE (128 * 1024) #endif -#define FLASH_ERROR() do {} while(0) +#if DFU_DEBUG +#define FLASH_ERROR() __builtin_trap() +#else +#define FLASH_ERROR() do {} while (0) +#endif static int flash_device_open = 0; static fl_BootImageInfo factory_image; @@ -58,6 +63,9 @@ void DFUCustomFlashDisable() /* Returns non-zero for error */ int flash_cmd_init(void) { +#if DFU_DEBUG + printstr("flash_cmd_init\n"); +#endif fl_BootImageInfo image; if (!flash_device_open) @@ -78,13 +86,22 @@ int flash_cmd_init(void) if (fl_getFactoryImage(&image) != 0) { +#if DFU_DEBUG + printstr("fl_getFactoryImage !0\n"); +#endif return 1; } +#if DFU_DEBUG + printstr("fl_getFactoryImage 0\n"); +#endif factory_image = image; if (fl_getNextBootImage(&image) == 0) { +#if DFU_DEBUG + printstr("fl_getNextBootImage 0\n"); +#endif upgrade_image_valid = 1; upgrade_image = image; } @@ -148,6 +165,9 @@ static void begin_write() { result = fl_startImageAdd(&factory_image, FLASH_MAX_UPGRADE_SIZE, 0); } while (result > 0); +#if DFU_DEBUG + printstr("fl_startImageAdd done\n"); +#endif if (result < 0) FLASH_ERROR(); @@ -179,10 +199,16 @@ int flash_cmd_write_page(unsigned char *data) if (fl_endWriteImage() != 0) FLASH_ERROR(); +#if DFU_DEBUG + printstr("fl_endWriteImage done\n"); +#endif // Sanity check fl_BootImageInfo image = factory_image; if (fl_getNextBootImage(&image) != 0) FLASH_ERROR(); +#if DFU_DEBUG + printstr("fl_getNextBootImage 0\n"); +#endif break; } current_flash_subpage_index = 0; @@ -210,9 +236,18 @@ int flash_cmd_write_page_data(unsigned char *data) if (current_flash_subpage_index == 4) { - if (fl_writeImagePage(current_flash_page_data) != 0) - FLASH_ERROR(); + int ret = fl_writeImagePage(current_flash_page_data); +#if DFU_DEBUG + printstr("fl_writeImagePage 0x"); + printhex(current_flash_page_data[0]); + printstr(" 0x"); + printhex(current_flash_page_data[255]); + printstr(" "); + printintln(ret); +#endif pages_written++; + if (ret != 0) + FLASH_ERROR(); } return 0; @@ -220,6 +255,9 @@ int flash_cmd_write_page_data(unsigned char *data) int flash_cmd_erase_all(void) { +#if DFU_DEBUG + printstr("flash_cmd_erase_all\n"); +#endif fl_BootImageInfo tmp_image = upgrade_image; if (upgrade_image_valid) diff --git a/lib_xua/src/dfu/flashlib_user.c b/lib_xua/src/dfu/flashlib_user.c index d3ffa205f..24a262000 100644 --- a/lib_xua/src/dfu/flashlib_user.c +++ b/lib_xua/src/dfu/flashlib_user.c @@ -58,6 +58,9 @@ fl_PortHolderStruct p_flash = /* return 1 for opened ports successfully */ int flash_cmd_enable_ports() { +#if DFU_DEBUG + printstr("flash_cmd_enable_ports\n"); +#endif int result = 0; #ifdef QUAD_SPI_FLASH /* Ports not shared */ @@ -90,6 +93,10 @@ int flash_cmd_enable_ports() #ifdef DFU_FLASH_DEVICE #ifdef QUAD_SPI_FLASH result = fl_connectToDevice(&p_qflash, flash_devices, 1); +#if DFU_DEBUG + printstr("fl_connectToDevice "); + printintln(result); +#endif #else result = fl_connectToDevice(&p_flash, flash_devices, 1); #endif From 66b9f34797e313185c9d6cffdbb327b7d38f21b6 Mon Sep 17 00:00:00 2001 From: Larry Snizek Date: Mon, 18 Feb 2019 12:10:56 +0000 Subject: [PATCH 3/3] More DFU debugging prints --- lib_xua/host/xmosdfu/xmosdfu.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib_xua/host/xmosdfu/xmosdfu.cpp b/lib_xua/host/xmosdfu/xmosdfu.cpp index a0aca676e..7948c759b 100644 --- a/lib_xua/host/xmosdfu/xmosdfu.cpp +++ b/lib_xua/host/xmosdfu/xmosdfu.cpp @@ -164,6 +164,7 @@ int dfu_getStatus(unsigned int interface, unsigned char *state, unsigned int *ti *timeout = (data[0] >> 8) & 0xffffff; *nextState = data[1] & 0xff; *strIndex = (data[1] >> 8) & 0xff; + printf("- get_data 6 state=%d timeout=%d next_state=%d\n", *state, *timeout, *nextState); return 0; } @@ -198,6 +199,12 @@ int dfu_download(unsigned int interface, unsigned int block_num, unsigned int si { //printf("... Downloading block number %d size %d\r", block_num, size); /* Returns actual data size transferred */ + if (data == NULL) { + printf("+ download_block %d %d NULL\n", block_num, size); + } + else { + printf("+ download_block %d %d 0x%x 0x%x\n", block_num, size, data[0], data[size - 1]); + } unsigned int transfered = libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, DFU_DNLOAD, block_num, interface, data, size, 0); return transfered; }