|
|||||||||||
Technical Support Support Resources
Product Information |
MDK MIDDLEWARE: Set Inquiry Data of a Logical Unit During RuntimeInformation in this knowledgebase article applies to:
QUESTIONI am developing a USB Device Mass Storage Class (MSC) application. I'd like to use the same binary image in production. How do I reconfigure the inquiry data of a logical unit during runtime? ANSWERIn the configuration file "USBD_Config_MSC_#.h", find the following code: //This is the default for USB Device MSC #0 logical unit #define USBD_MSC0_LUN1_INQUIRY_DATA "Keil " \ "Disk LUN 1 " \ "1.0 " Replace the above section with the following code: #include <stdint.h> extern uint8_t msc0_runtime_inquiry_string[]; #define USBD_MSC0_LUN1_INQUIRY_DATA msc0_runtime_inquiry_string Then in a source file, define the default string and the new inquiry string: uint8_t msc0_runtime_inquiry_string[28] = "Vendor " /* Vendor Information: 8 bytes */ \ "Product " /* Product Identification: 16 bytes */ \ "Rev " /* Product Revision Level: 4 bytes */ \ ; uint8_t msc0_runtime_inquiry_string_new[28] = "Vendor B" /* Vendor Information: 8 bytes */ \ "Product 2" /* Product Identification: 16 bytes */ \ "Rev2" /* Product Revision Level: 4 bytes */ \ ; Then in the application, a simple copy can update the inquiry string: #include "rl_usb.h" #include <string.h> extern uint8_t msc0_runtime_inquiry_string[]; extern uint8_t msc0_runtime_inquiry_string_new[]; //... memcpy( msc0_runtime_inquiry_string, msc0_runtime_inquiry_string_new, 28); //... USBD_Initialize (0); /* USB Device 0 Initialization */ USBD_Connect (0); /* USB Device 0 Connect */ //... to use the new inquiry string inside the USB Device. The memcpy() can be called before or after the USB layer is initialized. For a unique label in the inquiry string, many Cortex-M devices already have a unique device ID that would be an ideal addition. Note: In this example, the application stores the strings in RAM. If the new string is dynamically generated during runtime (in a one-time event) then a robust application should store the new inquiry string in an area of non-volatile memory to protect the data from a power cycle. The filesystem integrated with the USB MSC layer could backup the new string, as long as it is not a RAM-based filesystem. The presence of an earlier startup string would also have to be acceptable. MORE INFORMATION
Last Reviewed: Friday, January 8, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.