How to get iManufacturerstring from USB MSD through SDK?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get iManufacturerstring from USB MSD through SDK?

884 Views
XK1
Contributor II

dear
This is the USB MSD device descriptor structure:

typedef struct _usb_descriptor_device
{
uint8_t bLength; /* Size of this descriptor in bytes */
uint8_t bDescriptorType; /* DEVICE Descriptor Type */
uint8_t bcdUSB[2]; /* UUSB Specification Release Number in Binary-Coded Decimal, e.g. 0x0200U */
uint8_t bDeviceClass; /* Class code */
uint8_t bDeviceSubClass; /* Sub-Class code */
uint8_t bDeviceProtocol; /* Protocol code */
uint8_t bMaxPacketSize0; /* Maximum packet size for endpoint zero */
uint8_t idVendor[2]; /* Vendor ID (assigned by the USB-IF) */
uint8_t idProduct[2]; /* Product ID (assigned by the manufacturer) */
uint8_t bcdDevice[2]; /* Device release number in binary-coded decimal */
uint8_t iManufacturer; /* Index of string descriptor describing manufacturer */
uint8_t iProduct; /* Index of string descriptor describing product */
uint8_t iSerialNumber; /* Index of string descriptor describing the device serial number */
uint8_t bNumConfigurations; /* Number of possible configurations */
} usb_descriptor_device_t;

How to get iManufacturer&iProduct&iSerialNumber string from USB MSD through SDK?

0 Kudos
6 Replies

817 Views
XK1
Contributor II

revise:

getDescriptorParam.descriptorIndex = deviceInstance->deviceDescriptor->iManufacturer;

0 Kudos

818 Views
XK1
Contributor II

Add the following code to get the manufacturer string, which can be used as a reference.

 

usb_host_devices.h

typedef enum _usb_host_device_enumeration_status
{

................................................

kStatus_DEV_GetDesManufacturer,

...............................................

}

 

usb_host_devices.c

#define MANUF_LEN 0xff

uint8_t manuf_data[MANUF_LEN]={0};
uint8_t manuf_string[MANUF_LEN]={0};

 

static const usb_host_enum_process_entry_t s_EnumEntries[] = {

........................................................
{
kStatus_DEV_GetDesManufacturer,
kStatus_DEV_SetAddress,
USB_HostProcessCallback,
},
/* kStatus_DEV_GetDes */
{
kStatus_DEV_GetCfg9,
kStatus_DEV_GetDes,
USB_HostProcessCallback,
},

 ........................................................................
};

 

static usb_status_t USB_HostProcessState(usb_host_device_instance_t *deviceInstance)
{

.....................................................

case kStatus_DEV_GetDesManufacturer:
                                          getDescriptorParam.descriptorBuffer = (uint8_t *)manuf_data;
                                          getDescriptorParam.descriptorLength = MANUF_LEN;
                                          getDescriptorParam.descriptorType = USB_DESCRIPTOR_TYPE_STRING;
                                          getDescriptorParam.descriptorIndex = 1U;
                                          getDescriptorParam.languageId = 251U;

                                          transfer->setupPacket->bmRequestType |= USB_REQUEST_TYPE_DIR_IN;
                                          transfer->setupPacket->bRequest = USB_REQUEST_STANDARD_GET_DESCRIPTOR;
                                          status = USB_HostStandardSetGetDescriptor(deviceInstance, transfer, &getDescriptorParam);
                                          break;

........................................

}

 

 

static usb_status_t USB_HostProcessCallback(usb_host_device_instance_t *deviceInstance, uint32_t dataLength)
{

................................................................................................

case kStatus_DEV_GetDesManufacturer:
                                 USBH_ParseStringDesc(manuf_data,manuf_string,MANUF_LEN);
                                 usb_echo("Manufacturer=%s|\r\n",manuf_string);
                                 break;

.................................................................................................

}

 

static void USBH_ParseStringDesc (uint8_t* psrc,uint8_t* pdest,uint16_t length){
              uint16_t strlength;
              uint16_t idx;

              if ( psrc[1] == USB_DESCRIPTOR_TYPE_STRING){
                            strlength = ( ( (psrc[0]-2) <= length) ? (psrc[0]-2) :length);
                            psrc += 2;

                           for (idx = 0; idx < strlength; idx+=2 ){
                                     *pdest = psrc[idx];
                                     pdest++;
                            }
                           *pdest = 0; 
                }
}

 

861 Views
XK1
Contributor II

I want to read the string information of manufacturer, product and serial number of USB disk on rt1021 development board, but I can't find the corresponding function in SDK to get them. I only see the index value of manufacturer, product and serial number in SDK. I want to know how to get the corresponding string information through the index value. In addition, there is a similar function in the SDK of STM32, which can obtain the corresponding string information through the index value.

The function of STM32 is as follows: usbh_ Get_ StringDesc(USB_ OTG_ CORE_ HANDLE *pdev, USBH_ HOST *phost,uint8_ t string_ index,uint8_ t *buff,uint16_ t length))

0 Kudos

851 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
After checking, I think the Host USB stack hasn't provided a similar API until now, I'll dig deeper later to find whether an alternative way to get the string descriptor.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

843 Views
XK1
Contributor II

Thank you. I'll try to write it myself.

871 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Actually, I'm not very clear with your question, so please explain it in detail again.
Hope it helps.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos