Hi,
I would like to use the USB port to connect a memory stick and use it read/write files.
I have a old example here which uses "g_fx_media0 FileX on USB Mass Storage".
I am currently using SSP 1.2.1 and I am not finding this framework to add to my project.
Which framework should I use to achieve what I need?
Hi adboc, I inserted the stack as you indicated. Tried to compile it and got these errors: ../src/synergy_gen/common_data.c: In function 'ux_host_init0': ../src/synergy_gen/common_data.c:299:59: error: 'SYNERGY_NOT_DEFINED_initialize' undeclared (first use in this function) SYNERGY_NOT_DEFINED_initialize, SYNERGY_NOT_DEFINED, ^ ../src/synergy_gen/common_data.c:299:91: error: 'SYNERGY_NOT_DEFINED' undeclared (first use in this function) SYNERGY_NOT_DEFINED_initialize, SYNERGY_NOT_DEFINED, ^ ../src/synergy_gen/common_data.c:300:59: error: 'UX_SYNERGY_CONTROLLER' undeclared (first use in this function)
The function is that one: void ux_host_init0(void) { /** Register a USB host controller. */ UINT status_g_ux_host_0 = ux_host_stack_hcd_register ((UCHAR*) "SYNERGY_NOT_DEFINED", SYNERGY_NOT_DEFINED_initialize, SYNERGY_NOT_DEFINED, UX_SYNERGY_CONTROLLER); if (UX_SUCCESS != status_g_ux_host_0) { g_ux_host_0_err_callback (NULL, &status_g_ux_host_0); } } What should I create to replace SYNERGY_NOT_DEFINED_initialize, SYNERGY_NOT_DEFINED and UX_SYNERGY_CONTROLLER?
EDIT:
I saw this is new content from 1.2.1.
The only examples I could find are using 1.2.0.
Is there any examples of how to use the FX on USB in the new 1.2.1? (Or at least how to compile the auto-generated code)
I tried to replace:
/** Register a USB host controller. */ UINT status_g_ux_host_0 = ux_host_stack_hcd_register ((UCHAR*) "SYNERGY_NOT_DEFINED", SYNERGY_NOT_DEFINED_initialize, SYNERGY_NOT_DEFINED, UX_SYNERGY_CONTROLLER);
for:
/** Register a USB host controller. */ UINT status_g_ux_host_0 = ux_host_stack_hcd_register ((UCHAR*) "Anything",ux_hcd_synergy_initialize, UX_SYNERGY_CONTROLLER,UX_SYNERGY_CONTROLLER_S3A7);
But the e2studio undo my changes when I compile the code! The code goes back to its original content (which doesn't compile!).
So, the Synergy generate a file that doesn't compile and I can't edit that file.
Now, what can I do?
Hi Mad River,
The SYNERGY_NOT_DEFINED is a place holder because you have not selected a required module and configured it.
Please verify your configuration is correct. You can not edit files in the synergy or the synergy_gen folders because they are auto-generated when you build. You must change your configuration in the Synergy Configurator to fix these files.
Here is an example of properly configured USB mass storage host configuration:
-Gary
HI Mad River,
As Gary indicated, your SSP configuration is incomplete so some parameters are missing from the Synergy_cfg, etc. I attached USBX_Mass_Storage_Host_PKS5D9.zip as an example to show how to configure and setup in the SSP1.2.1. The pool memory size is dependent on your selected device and USB classes. The SSP User Manual lists recommended pool sizes for these combinations. Please let me know if you have any questions. Thanks
Joe
Hi everyone, Thanks to your help I was able to compile the generated code. Now, I am trying to run it. As soon I resume the application, my program goes to: void g_fx_media0_err_callback_failed_to_get_fx_media_internal(void * p_instance, void * p_data) { /** Suppress compiler warning for not using parameters. */ SSP_PARAMETER_NOT_USED (p_instance); SSP_PARAMETER_NOT_USED (p_data); /** A FileX media control block for a USB mass storage device was not found. */ BSP_CFG_HANDLE_UNRECOVERABLE_ERROR (0); } Am I missing some initialization?
Deeper debug indicates that the problem occurs here:
void fx_media_init_function0(void){ /** Suspend the thread until a USB Mass Storage Device inserted. */ UINT err_g_fx_media0_semaphore_get = tx_semaphore_get (&ux_host_storage_semaphore_insertion, 1000); if (TX_SUCCESS != err_g_fx_media0_semaphore_get) { g_fx_media0_err_callback_failed_to_get_fx_media (&ux_host_storage_semaphore_insertion, &err_g_fx_media0_semaphore_get); }
I am confused about this comment "/** Suspend the thread until a USB Mass Storage Device inserted. */"
In my application the USB memory stick is not inserted at startup time.
The user can eventually insert the USB memory stick while the application is already running.
The USB memory stick may even never be inserted.
Mad River,
Here is an example of using the host change call back & event flags to init the media when its inserted.
SK_S7_USB_MSC_Host_Example.zip
Hello Mad River,
You can disable auto initialization and perform it yourself after the USB stick has been inserted. Please refer to the following example project for SK-S7 and SSP 1.2.0: s7_sk_ux_mass_host_1_2_0.zip. On SSP 1.2.0, you cannot call initialization from the insertion callback (init will block waiting for a semaphore that's placed only after the callback) so you'll need to use another semaphore to signal a thread to perform initialization.
Regards
Hi everyone,
I ran the example "USBX_Mass_Storage_Host_DK-S3A7" here.
It worked, but not 100%. I repeatly inserted and removed the memory stick, and after some time it stop detecting the insertion.
Anyway, I copied the thread shown in the example to my application.
Not changed anything. Copied it as it is.
The problem is that in my application the memory stick insertion is NEVER detected.
In other words, the following code is never called:
static UINT ux_system_host_change_function(ULONG event, UX_HOST_CLASS * host_class, VOID * instance) // THIS FUNCTION IS NEVER CALLED!{ UINT status = UX_SUCCESS; SSP_PARAMETER_NOT_USED (event); SSP_PARAMETER_NOT_USED (host_class); SSP_PARAMETER_NOT_USED (instance);
#if !defined(usb_host_plug_event_notification) /* Call user function back for USBX Host Class event notification. */ status = usb_host_plug_event_notification (event, host_class, instance); // CALLS MY NOTIFICATION FUNCTION! }
As I said, the example is based in the SSP 1.2.0 and I am using SSP 1.2.1. Is this change causing the problem I am facing?
Or maybe something related to the DK-S3A7M2.0 or the DK-S3A7Bv2.0 (expansion board)? I am using the USB connector presented in the expansion board (DK-S3A7Bv2.0). Is any known issue with it?
More info about the problem.
When I insert the memory stick, program goes to:
void NMI_Handler (void){
if (1 == R_ICU->NMISR_b.SPEST) { /** MPU Stack Error interrupt is requested. */ bsp_group_irq_call(BSP_GRP_IRQ_MPU_STACK);
/** Clear MPU Stack error flag. */ R_ICU->NMICLR_b.SPECLR = 1U; }
}
EDIT 2:
I found the problem, but not the solution.
In my project I have added the ThreadX Source component in order to alter the parameter "Timer Ticks Per Second".
The memory stick detection (ux_system_host_change_function ()) is only called if I remove the ThreadX Source component from the project.
Once I add the ThreadX Source component the ux_system_host_change_function() stop being called.
Is it a known bug?
Hi!
Have you double-checked that in Thread-X Source component properties you have Notify Callback property set to Enabled? By default, it is disabled, so it needs to be changed.
Hi everyone,I discovered the cause of the problem.
The USB doesn't work when setting the Optimization Level to None (-O0).
I tested it in my own application and in the example provided by Renesas.
Once I set the Optimization Level to None the USB stop working.
The problem is that I need the Optimization Level set to None to my application work properly.
What can I do?