USBX Host Class Mass Storage in Synergy S3 UX_MEMORY_INSUFFICIENT

Hi

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.

Hanton

  • Hi Hanton-
    Have you looked over the DK-S3A7 version of this same project?
    www.renesas.com/.../D6001961.html

    It's in a separate zip file in the above download. You could check your configurations and stack sizes against it. This might be a better project to use as a comparison than the S5D9 one.. (but pay close attention to the larger Flash and SRAM available on the A7 vs the A6).

    Let me know what you find out.

    Warren
  • In reply to WarrenM:

    Hi WarrenM

    I have tried to do the similar configuration but it is not possible because the memory of the S3A7 is quite superior.
    The question is whether the FileX class with USBX Host Class Mass Storage is really possible with the S3A6 micro, I begin to think that it is not possible.

    Thanks
    Hanton
  • In reply to Hanton:

    Hi Hanton-
    I will ask Express Logic about this. What compiler error are you getting when the memory poll is larger than 17000?

    Thanx,
    Warren
  • In reply to WarrenM:

    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.
    Hanton
  • In reply to Hanton:

    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?

    Warren
  • In reply to WarrenM:

    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.

    Hanton
  • In reply to Hanton:

    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.

    Warren

  • In reply to WarrenM:

    Thanks WarrenM for your help.

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

    Thanks
    Hanton
  • In reply to Hanton:

    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.

    Regards
  • In reply to Renesas Karol:

    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.

    Thanks
    Hanton

  • In reply to Hanton:

    Hi Hanton,

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

    * UX_HOST_SIDE_ONLY
    * 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. 

    Regards

  • In reply to Renesas Karol:

    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.

    Regards
    Hanton
  • In reply to Hanton:

    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.

    Regards
  • In reply to Renesas Karol:

    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.

    Regards
  • In reply to Hanton:

    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.

    Regards