eclipse-threadx / usbx

Eclipse ThreadX - USBX is a high-performance USB host, device, and on-the-go (OTG) embedded stack, that is fully integrated with Eclipse ThreadX RTOS
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/usbx/index.md
MIT License
154 stars 89 forks source link

Multi storage media creation #15

Closed FreeOxygen closed 3 years ago

FreeOxygen commented 3 years ago

In the ux_host_class_storage_device_initialize.c file, after defining the UX_HOST_CLASS_STORAGE_NO_FILEX macro, when creating storage_media, traversing ux_host_class_media will create multiple storage_media!, which should break at line 209.

#if defined(UX_HOST_CLASS_STORAGE_NO_FILEX)

        /* Find a free media slot for inserted media.  */
        storage_media =  (UX_HOST_CLASS_STORAGE_MEDIA *) class_inst -> ux_host_class_media;
        for (inst_index = 0; inst_index < UX_HOST_CLASS_STORAGE_MAX_MEDIA;
            storage_media ++, inst_index++)
        {

            /* Skip used storage media slots.  */
            if (storage_media -> ux_host_class_storage_media_storage != UX_NULL)
                continue;

            /* Use this free storage media slot.  */
            storage_media -> ux_host_class_storage_media_storage = storage;

            /* Save media information.  */
            storage_media -> ux_host_class_storage_media_lun = (UCHAR)storage -> ux_host_class_storage_lun;
            storage_media -> ux_host_class_storage_media_sector_size = (USHORT)storage -> ux_host_class_storage_sector_size;
            storage_media -> ux_host_class_storage_media_number_sectors = storage -> ux_host_class_storage_last_sector_number + 1;

            /* Invoke callback for media insertion.  */
            if (_ux_system_host -> ux_system_host_change_function != UX_NULL)
            {

                /* Call system change function.  */
                _ux_system_host ->  ux_system_host_change_function(UX_STORAGE_MEDIA_INSERTION,
                                    storage -> ux_host_class_storage_class, (VOID *) storage_media);
            }
        }
#endif
xiaocq2001 commented 3 years ago

Thank you for the feedback. We will update the file.

xiaocq2001 commented 3 years ago

Fixed in 6.1.8