cancel
Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Articles

FX3: IsBootLoaderRunning() Function in libcyusb Linux - KBA231809

ChaitanyaV_61
Employee

FX3: IsBootLoaderRunning() Function in libcyusb Linux - KBA231809

Version: **

 

Question: How do I check if the FX3 bootloader is running using the Linux SDK or what is the equivalent of the IsBootLoaderRunning() function in FX3 Linux SDK?

Answer:

FX3 Linux SDK does not have a specific function to check if the FX3 bootloader is running.

But, the functionality can be achieved using the vendor command 0xA0 through control transfer (cyusb_control_transfer() function).

The vendor command 0xA0 is implemented in FX3 Bootloader for firmware download and upload, and the same command can be used to check if the FX3 is in bootloader mode.

A single byte IN control transfer with request code 0xA0 is initiated. If the control transfer succeeds and returns a byte, then the bootloader in running.

Control transfer parameters:

bRequest = 0xA0;

bmRequestType = 0xC0;

wValue = 0x0000;

wIndex = 0x0000;

wLength = 1;

Control Transfer function prototype from FX3 Linux SDK:

int cyusb_control_transfer (cyusb_handle *h, unsigned char bmRequestType,

unsigned char bRequest, unsigned short wValue,

unsigned short wIndex, unsigned char *data,

unsigned short wLength, unsigned int timeout);

Sample Code:

int num = cyusb_open();

printf("number of devices = %d\n", num);

if (num <= 0)

return -1;

cyusb_handle *h = cyusb_gethandle(0);

unsigned short vid = cyusb_getvendor(h);

unsigned short pid = cyusb_getproduct(h);

printf("vid = %04x,  pid  = %04x\n" , vid, pid);

unsigned char bmReqType = 0xC0;

unsigned char bRequest = 0xA0;

unsigned short wValue = 0x0000;

unsigned short wIndex = 0x0000;

unsigned short wLength = 1;

unsigned char buf_data[1] = {0};

unsigned int timeout = 5000;

int retval = cyusb_control_transfer (h, bmReqType, bRequest, wValue, wIndex, buf_data, wLength, timeout);

if(retval>0)

printf("fx3 bootloader running\n");

else

printf("fx3 bootloader not running\n");

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎Dec 10, 2020 05:30 AM
Updated by:
 
Contributors