Skip to main content
ABasi.2
Senior
November 27, 2025
Question

USBX MSC *media_status value meaning

  • November 27, 2025
  • 4 replies
  • 232 views

Hello!

i'm developing a firmware that use an SD card connected to USBX MSC, and i have a couple of question

 

i want to understand better the  ULONG *media_status value returned in the function :

UINT USBD_STORAGE_Status(VOID *storage_instance, ULONG lun,
 ULONG media_id,ULONG *media_status) 

UINT USBD_STORAGE_Flush(VOID *storage_instance, ULONG lun, ULONG number_blocks,
 ULONG lba, ULONG *media_status)

UINT USBD_STORAGE_Write(VOID *storage_instance, ULONG lun, UCHAR *data_pointer,
 ULONG number_blocks, ULONG lba, ULONG *media_status) 

UINT USBD_STORAGE_Read(VOID *storage_instance, ULONG lun, UCHAR *data_pointer,
 ULONG number_blocks, ULONG lba, ULONG *media_status) 

 i'm hoping that value is related to the SCSI code value that windows need from a USB MSC

is it true? beyond UX_SUCCESS which value can i use? for example to indicate the media as changed  or is readonly?

how can the functions ULONG USBD_STORAGE_GetMediaLastLba(VOID) and ULONG USBD_STORAGE_GetMediaBlocklength(VOID) can be fired againafter initialization? (maybe i have changed the SD card)

 

whats the meaning of this function? 

UINT USBD_STORAGE_Notification(VOID *storage_instance, ULONG lun, ULONG media_id,
 ULONG notification_class, UCHAR **media_notification,
 ULONG *media_notification_length)

 

thank you!

 

best reguards

 

4 replies

Technical Moderator
November 27, 2025

Hi @ABasi.2 

Checking USBX documentation I found  : media_status should be filled out exactly like the media status callback return value. Check here for further details.

The return value of your read/write/flush functions is only UX_SUCCESS or UX_ERROR. It could be UX_STATE_NEXT in standalone applications.

About USBD_STORAGE_Notification is not commonly used in simple applications. Its purpose to provide a buffer with notification data to the host.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
ABasi.2
ABasi.2Author
Senior
November 27, 2025

HELLO @FBL 

media_status should be filled out exactly like the media status callback return value and what does it mean? if i want to tell windows the media as changed? or if is now read only?

how to do that?

where the SCSI code are used?

 

The return value of your read/write/flush functions is only UX_SUCCESS or UX_ERROR. It could be UX_STATE_NEXT in standalone applications. ok for that, is the only "OK or error" return

 

About USBD_STORAGE_Notification is not commonly used in simple applications. Its purpose to provide a buffer with notification data to the host.

my isn't a "simple application" there is documentation about that?

 

i need to make a professional use of USBX msc , with using changed media , media in read only, ability to disconnect and reconnect the SD card , use of SCSI code ecc

 

there is a complex example or at least documentation about that?

 

thank you

 

 

Technical Moderator
November 27, 2025

Unfortunately all examples provided are typical and not complex @ABasi.2 

You've found the same reference !

I'm not the expert in USBX maybe someone else can help on this!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
ABasi.2
ABasi.2Author
Senior
November 27, 2025

Hello @FBL 

i thank you for your effort to give me information, is very appreciated

but maybe a ST Employee expert in USBX can give us some more precise answer

 

best reguards

Technical Moderator
November 28, 2025

Hi @ABasi.2 

It should be interesting in case implementing device msc with multiple LUNs; So far, I don't see any example supporting it.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
ABasi.2
ABasi.2Author
Senior
December 3, 2025

Hello @FBL 

it will be interesting for sure

 

but for me it's also interesting to have a project in which i can change the file on the media (i'm using SD card) and tell to the PC in wich the MSC is connected that the media in changed

 

also for this there is no example

 

i'm still hoping for a good hint about that..

 

maybe one of your collegue at ST expert in USBX can answer?

 

best reguards

Technical Moderator
December 3, 2025

Hi @ABasi.2 

An internal ticket 223015 is submitted to USB experts to check if possible to provide any reference example.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
ABasi.2
ABasi.2Author
Senior
January 19, 2026

Hello FBL

any news about the ticket 223015?

 

thank you

 

best regards

Technical Moderator
January 20, 2026

Hi @ABasi.2 

Thanks a lot for your patience and for raising these detailed points.

Following up on ticket 223015, I checked internally with our USBX team. Unfortunately, at this stage, there is no plan to provide an MSC example implementing multi‑LUN.

I found something interesting that may help you. 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL