Web server with usb mass storage class in 1.2.0

Dear Forum,

When setting up a new project in the new 1.2.0 ssp I was wondering where to find the user manual that describes building up a webserver using the usb mass storage host as the filesystem.  Maybe some examples.  I have this working in a older version of the ssp but was not able to get it to port properly and needed to add the net duo stuff to it anyway. 

When naming the Name of Request Notify Callback function, where do I place this function?  Since the function call to the nx_server_create is located in the new_thread0.c file which is synergy_gen, I cant place it with in there.  I have tried placing it with in the new_thread0_entry.c but the (IAR)linker fails to locate it.

Which function is called when there is a web page problem, like the requested page does not exist?  404 error for example?  Or how is that done.  

Thanks

Matt

  • Hi rupertm,

    In Synergy Gallery at Synergy Software Package > Release Archive you may find "Application Projects for SSP v1.2.0" zip file that consists of several examples, including NetX Duo Webserver. The project should work in both e2 Studio and IAR Workbench.

    Regards,
    adboc

  • In reply to adboc:

    Thank you Adboc,

    Going though the example I did notice one thing I found weird with the example NetX_Duo_WebServer_V120_SK_S7G2. I was setting a break point when the usb is removed or inserted. I found that the insert breakpoints were hit when the device booted. However when I go to remove the device I dont get the UX_DEVICE_REMOVAL == event and end up not hitting those break points, nor do I get to the insert breakpoints when I reinsert the usb drive. Any thoughts on this? I do see that the auto media initialization is enabled. In the ssp user manual, under USBX Host Mass Storage User Code Sample-->Use-case scenario 2 looks more like what is being done here, and it does not have the auto media initialization enabled. I did notice that when booting without the usb drive inserted I find myself in g_fx_media0_err_callback_failed_to_get_fx_media_internal. Is this cause of the auto media initialization and a timeout being reached with no media being found? But could that have anything to do with my first issues where I dont see the device removals.

    On the threads setup for the project, two packet pools are created. What is the reason for the second packet pool to be created?

    Thanks again.
    Matt
  • In reply to rupertm:

    Hi rupertm,

    I confirm that I'm observing this issue and trying to figure out why the callback isn't called. You're right, the g_fx_media0_err_callback_failed_to_get_fx_media_internal callback is fired after a timeout being reached with no USB media attached, this is expected behaviour, but it can be overwritten by implementing the g_fx_media0_err_callback_failed_to_get_fx_media function.

    As you noticed, he primary packet pool from IP instance can be reused. You may want to use a separate packet pool if you'd like to isolate RAM space between different components.

    Regards,
    adboc
  • In reply to adboc:

    Hi adboc,

    Thank you for the help!
    When you say I can overwrite that timeout but implementing the g_fx_media0_err_callback_failed_to_get_fx_media function. Is that already predefined somewhere where or will I need to create it within my usb_thread_entry.c block of code? Does the compiler/linker automatically know to look for g_fx_media0_err_callback_failed_to_get_fx_media in my usb_thread_entry.c file for that subroutine, or do I tell the compiler/linker the code is located in there. If I do where and how do I do that?

    Thanks
    Matt
  • In reply to rupertm:

    Hi Matt,

    The compiler/linker will automatically know that this function is located in your file, because it's declaration uses weak attribute (gcc.gnu.org/.../Function-Attributes.html). Here's an extract from synergy_gen/common_data.c:

     

    #if defined(__ICCARM__)
    #define g_fx_media0_err_callback_failed_to_get_fx_media_WEAK_ATTRIBUTE
    #pragma weak g_fx_media0_err_callback_failed_to_get_fx_media  = g_fx_media0_err_callback_failed_to_get_fx_media_internal
    #elif defined(__GNUC__)
    #define g_fx_media0_err_callback_failed_to_get_fx_media_WEAK_ATTRIBUTE __attribute__ ((weak, alias("g_fx_media0_err_callback_failed_to_get_fx_media_internal")))
    #endif
    void g_fx_media0_err_callback_failed_to_get_fx_media(void * p_instance, void * p_data)
    g_fx_media0_err_callback_failed_to_get_fx_media_WEAK_ATTRIBUTE;

     

    If there is no definition of this callback, then the default one (g_fx_media0_err_callback_failed_to_get_fx_media_internal) will be used.

     

    Regards,

    adboc

  • In reply to adboc:

    Hi adboc,

    That explains a few things. So as long as I have basically a redefined of the callback anywhere in the code the linker connects it instead of the weak one.

    Any further ideas at this point on what maybe going on with the usb issues earlier in this thread?

    Thank you adboc!!
    Matt

  • In reply to rupertm:

    Hi Matt,

    I removed all "Thread n" threads and made necessary changes in code in order to successfully compile the project. Now the callback is being received also when the USB disk is removed. You can also try changing thread priorites, but I haven't tested it.

    Regards,
    adboc