USBX Host Class Mass Storage in Synergy S3 UX_MEMORY_INSUFFICIENT


I have successfully opened and executed the example program USBX Host Class Mass Storage with the Module Guide R11AN0173EU0101.

I have successfully executed this program in a S5D9 PK with the SSP 1.4.0 and it works well.

Now I'm trying to do the same on a proprietary electronic board with the micro Synergy S3 R7FS3A6783A01CFM.

I create the thread and add the FileX module in USB Mass Storage correctly. As it is an S3 I can only use USB Controller Selection USBFS.

I configure all the modules in a manner as similar as possible to the project with the S5D9, except that the memory of USBX Pool Memory Size can only be a maximum of 17000, since if I put more it does not compile me because it does not enter RAM.

The problem is that in execution, in the "void ux_host_init0 (void)" function within the common_data.c source, the / ** Register to USB host controller. * /
     UINT status_g_ux_host_0 = ux_host_stack_hcd_register ((UCHAR *) "g_sf_el_ux_hcd_fs_0", g_sf_el_ux_hcd_fs_0_initialize, R_USBFS_BASE, UX_SYNERGY_CONTROLLER); returns error 0x12: UX_MEMORY_INSUFFICIENT.

How should I do the configuration to be able to work with the USB and be able to read and write files on a pendrive?

Thank in advance.


Parents Reply Children
  • Hi WarrenM

    In this project with more threads, if I put 17000 the compiler error is the next:

    c:/program files (x86)/gnu tools arm embedded/4.9 2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: MODULE_IO_S3.elf section `.stack_dummy' will not fit in region `RAM'
    c:/program files (x86)/gnu tools arm embedded/4.9 2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 1120 bytes
    collect2.exe: error: ld returned 1 exit status

    The RAM for the S3A6 is 32KBytes, so it may not be enough.

    Thanks for your help.
  • Hi Hanton-
    Thanx for the additional information.

    Have you looked to see where all the RAM use in your project is coming from? Do you use lots of space in other parts of your program or are USB and FileX the main ones?

  • Hi WarrenM

    USB and FileX are the main ones.
    In fact I deleted the rest of the program, and now I can go up from 17000 to 20000, with 21000 I get the error in compilation. But with 20000 I have the same problem in execution.

  • Hi Hanton-

    The response from Express Logic

    "USBX will have a hard time running on the host with less than 32k of RAM. there is just too much it needs.”

    Now that I know this, I looked at the SSP 1.5.0 release notes and see that the S3A6 isn't listed as supporting Host Frameworks.


     I should have checked there first. There isn't enough memory available for the framework and application code.


  • Thanks WarrenM for your help.

    Now we have to decide whether to change it for the S3A3 or the S3A7

  • Hi Hanton,

    What else is your application doing besides USBX Mass Storage Host? Do you require long file names under FAT or is 8.3 naming sufficient for your application? USBX Mass Storage Host + FileX can be shrunk to around 16kB of RAM which should leave a bit of memory for all other things in your application.

  • Hi Karol

    No, it does not require long names, with 8.3 it would be enough.
    How can I reduce USBX Mass Storage Host + FileX to 16KB of RAM?

    What's more, it would be useful if the file system only allows me to read, I do not need writing at the moment.


  • Hi Hanton,

    Please find attached a project for minimal USB Mass Storage Host implementation with FileX: It may be possible to reduce memory required even further. I've defined following preprocessor symbols:

    * UX_MAX_CLASS_DRIVER=2 (you can set this to 1, I intended for my project to support another class)

    Additionally, FileX Source has following settings modified:

    * Max Long Name Len = 13
    * Max Last Name Len = 13
    * Max Sector Cache = 2
    * Max Fat Cache = 8
    * Media Search Cache = Disabled
    * Media Statistics = Disabled

    USBX Source overrides default settings with following:

    * Maximum Host Controllers = 1
    * Maximum Devices = 1
    * Maximum TDs = 32
    * Maximum Isochronous TDs = 1

    And for USBX Host Class Mass Storage Source:

    * Maximum number of SCSI logical units = 1
    * Maximum number of storage media instance = 1
    * Storage memory size in bytes for FileX used for data transfer = 1024
    * Maximum transfer size in bytes in one BOT data-transport phase = 1024
    * Stack size for the Mass Storage Class internal thread = 512

    This allows project to successfully initialize and run with USBX Pool Memory Size set to 15360. Project is for DK-S3A7 (as it has a USB host port) but will easily migrate to S3A6 board. 


  • Hi Karol

    I have tried two things.

    First I configured my project with an S3A6 exactly like the one you have passed me.

    Then I modified the project that you have passed me by changing the microcontroller for the S3A6 and leaving the rest the same.

    The result of both things is the same.

    When I launch the Debug it stops at common_data.c line 214 / ** Initialize the USBX Host stack. * /
    status_ux_init = ux_host_stack_initialize (ux_system_host_change_function);
    status_ux_init has the value 0x16 (UX_THREAD_ERROR)

    I do not know what I'm doing wrong.

  • Hello Hanton,

    UX_THREAD_ERROR is returned in only two places: when error occurs in creating enum thread and HCD thread. After posting my project I noticed the USBX HCD Thread Priority is set to 512 (which isn't correct) however if you created a project from scratch and implemented my recommended settings it should work fine.

    By now you should have ThreadX and USBX Source in your project so stepping into ux_host_stack_initialize should be possible. You can place breakpoint on the line with ux_host_stack_initialize single step inside this function to pin-point the troublesome call.

  • Hello Karol

    Ok, I have entered in the function ux_host_stack_initialize and the error UX_THREAD_ERROR is returned in the line 245 because the function _ux_utility_thread_create about creation of the HDC Thread of USBX is not correct.
    The status value that is the return of this function is 15, I suppose UX_HCD_DESTROY_ENDPOINT.

    Now I changed the value of USBX HCD Thread Priority and I set the value to 5 (I do not know if it's correct).
    What I see is that after this function, in the line 245 in the ux_host_stack_initialize return the same UX_THREAD_ERROR.
    But now, the status value is 0, I can´t see the real return value.

  • Hello Hanton,

    Error code 15 is from the tx_thread_create called inside ux_utility_thread_create and means TX_PRIORITY_ERROR. It only occurs if specified priority value is greater than or equal to TX_MAX_PRIORITIES (which by default is 32).

    For your project you can leave this value blank and defaults will be used instead. I highly recommend using my project as starting point and amending the HCD priority selection.

  • Hi Karol

    I work with your project and leave HCD priority selection in blank.
    The question is a little strange now, because I get another error, one like the one I have in another project with USBX device CDC-ACM with the same micro S3A6 and for which I put a post yesterday:
    So now I have the same problem in the two projects.

  • Hello Hanton,

    This problem is probably related to the clock configuration. We can continue in the ticket you linked.