cancel
Showing results for 
Search instead for 
Did you mean: 

How to deal with 'FX_MEDIA' in standalone HOST (not device) MSC with USBX and FILEX

NotMark
Associate

I am on an H573 and trying to rd/wr a file on a fat32-formatted USB memory stick using the mass storage controller. 

To jump right into the problem (details further below), I am trying to understand what to do about this block when I am running in standalone mode. This snip comes from the example code which is in RTOS mode. I want standalone mode.

NotMark_0-1727763297639.png

 

--Background--

As a starting point, I grabbed the Ux_MSC_Host example, and got that working with no difficulties on the H573 dev kit MB1677. That demo uses FileX, UsbX, ThreadX, and some power delivery peripherals.

 

Then I started some changes:

  1. I now have hardware that does not have power delivery. There is a 5v rail turned on and powering the memory stick.
  2. For various reasons I do not want ThreadX enabled; so: 
    1. I setup FileX and UsbX, and added some short snips in main.c, to finish initialization and loop on _ux_host_stack_tasks_run.
    2. With this, I am able to enumerate and get into the ux_host_event_callback.

 

But... 

When I tried to implement something meaningful in UX_DEVICE_INSERTION status, it turns out that the expression

 media = &storage_media->ux_host_class_storage_media;

fails to compile because the type "FX_MEDIA" is undefined. I need FX_MEDIA so I can use functions like fx_file_open or fx_file_read.

 

Apart from the undefined type, the field itself is if-def'ed away within ux_host_class_storage.h:

typedef struct UX_HOST_CLASS_STORAGE_MEDIA_STRUCT
{
#if !defined(UX_HOST_CLASS_STORAGE_NO_FILEX)
    UX_MEDIA ux_host_class_storage_media;
    ULONG ux_host_class_storage_media_partition_start;
    VOID *ux_host_class_storage_media_memory;
    ULONG ux_host_class_storage_media_status;
    ULONG ux_host_class_storage_media_lun;
    ULONG ux_host_class_storage_media_sector_size;
#else
    struct UX_HOST_CLASS_STORAGE_STRUCT
    *ux_host_class_storage_media_storage;
    ULONG ux_host_class_storage_media_number_sectors;
    USHORT ux_host_class_storage_media_sector_size;
    UCHAR ux_host_class_storage_media_lun;
    UCHAR ux_host_class_storage_media_status;
#endif
} UX_HOST_CLASS_STORAGE_MEDIA;

and the #defines are set earlier:

#if defined(UX_HOST_STANDALONE) && !defined(UX_HOST_CLASS_STORAGE_NO_FILEX)
#define UX_HOST_CLASS_STORAGE_NO_FILEX
#endif

 

I thought maybe I could tweak this vendor file (slightly queasy about that). But that's when I found statements like this littered throughout the library:

NotMark_1-1727764941448.png

 

I want FileX (and picked it in Cube), so this #define is confusing. I guess the question is: what is the proper configuration of #defines to bring all these pieces together properly? Or is standalone host msc not a supported feature? Are there lib tweaks I can make that will fake it?

 

I have found these informative - but they vary: 

 

Lastly, I attached the ioc and a pdf with recap/screenshots of what I changed. 

0 REPLIES 0