I am trying to update the firmware on an Atmel device from a Windows CE environment. Here is snippet of my source code:
uint8_t buf[127];
struct libusb_device_handle *handle=NULL;
fp = fopen("\\Nandflash\\a.hex", "r+");
size_t re = fread(buf, 4, 1, fp);
cstatus = libusb_control_transfer(
handle,
LIBUSB_ENDPOINT_OUT|
LIBUSB_REQUEST_TYPE_VENDOR|
LIBUSB_RECIPIENT_INTERFACE,
0xA0, //Upload
0x01, //Address of the device
0,buf, sizeof(buf), 100);
I am keep getting -9
as result of the control transfer. How can I fix this problem?
You are using a NULL handle value in your libusb_control_transfer function. You will need to initialize libusb and open the device to be able to talk to it: