LevelX performance

Hello,
we are using LevelX+FileX+USBX Mass storage device based on Winbond W25Q64FV (8 megabyte) QSPI Flash.
The MCU is Renesas Synergy S5D9.
If we read 2 megabyte file (USBX mass storage device) without LevelX it takes for several seconds.
But if we add LevelX the speed drops dramatically, the same file reads for 4 minutes (It is very low speed for our application).
In our application we writes this file (from MCU side) in fragments of approximately 200 bytes.
The maximum size of used memory is our application is less than 3 megabytes.
Please look at thread stack settings attached.
Is it any way to speed up LevelX performance?

Thanks, dxwak.

 

  • In reply to Jeremy:

    Hi Jeremy and Janet.
    After applying Jeremy's fix the problem was solved, so now we could use LevelX and LX_DIRECT_READ in our product.
    Thank you for support provided.
    In our project Synergy device write data on QSPI based FileX system but for host PC the disk is read only.
    Also there is separate mode of operation of our equipment when we connect to the PC we don't write on FileX.
    so I hope we won't have further issues.
    We have no problems with opening USB mass storage on Windows PCs (tested with several PCs from W7 to W10), so we leave fault tolerance as it is.

    Regards, dxwak.
  • In reply to dxwak:

    Glad to hear Jeremy's fix worked out! I think we will likely post his program in the Knowledge Base as well as apply those fixes for the next release so the next LevelX user doesn't have to run into this. Thanks for bringing this to our attention.

    Regards,
    Janet
  • In reply to Jeremy:

    Hello Jeremy, Janet.
    It seems we found one more bug using Synergy with LevelX .
    If we delete file using fx_file_delete the file system corrupted
    and fx_media_open return FX_BOOT_ERROR.

    1. There is no error if we delete via USB MSC from windows explorer
    2. We got error from time to time if file size less than 1MB.
    3. If we delete file after fill test (2MB file) we always got error.
    Just press the TEST button, wait while test finished with 9991 records,
    after it delete the file, so the file system got corrupted.
    4. LX_DIRECT_READ doesn't matter.
    5. There is no problem if we do not use LevelX.

    I add delete file button to GUI, updated project attached.
    Please check.MediaTest NOR delete.zip

  • In reply to dxwak:

    Hi dxwak

    First, why are you trying to (are you trying to ) run FileX locally on a Synergy device concurrently with mass storage device g_ux_device_class_storage?

    I am not sure why LevelX makes a difference. But it would be good to understand what you are trying to do.

    Thanks,
    Janet
  • In reply to JanetC:

    Hi Janet,
    Thank you for your reply.
    I needn't to run FileX and MSC USBX concurrently.

    My device works on three independent modes
    1. Log the data using FileX LevelX QSPI storage
    2. View logged data on the device and delete the
    data if needed. So here I got the error. If
    I delete the file using fx_file_delete next
    time booting the device up with fx_media_open
    I got FX_BOOT_ERROR
    3. View and copy saved data on the PC while connect
    the device to the PC. The user cant delete the
    data from the PC. The disk runs as read-only device.

    In my test project it runs concurrently because it is
    just convinient to observe the disk after making some
    operations from FileX.
    I didn't connect the board to the USB while make the test.
    Moreover I delete USBX MSC stack from project and made the
    test again, the problem still exist.
    Hope it could be solved.

    Regards, dxwak.
  • In reply to dxwak:

    Hi dxwak,

    I am trying to reproduce your actions  on start up, but I'm afraid the details above are a bit ambiguous to me. I can see the files from the PC, and as you observed I cannot delete a file from the PC. 

    Here is how I am running it (no changes to your project except to turn off optimization, always a BAD idea during debugging):

    1. The device is connected to PC by the J5 connector. I  boot the project from the debugging. 

    2. Am I supposed to format the media? If I do the button changes to Wait...and eventually completes. 

    3. What is the purpose of "test". By the way, what records is the "test" counting? It too eventually completes with no error.  Anyway, when "test" is running, only the "Menu" button is visible. 

    4. Then I try to delete a file. But I don't see anything happening. I put a breakpoint in delete_file() and it errors out (0x04 which is file not found). I tried this test a dozen times so the exact details and order of are perhaps confused in my head.  

    Please clarify 

    "Log the data using FileX LevelX QSPI storage" - who where what is this data logged? 

    "View logged data on the device and delete the data if needed." Are you viewing the data from the PC /windows explorer or from the debugger? 

    "So here I got the error. " Please clarify which this error is, is it reported on the LCD or do you set a breakpoint in the debugger somewhere?

    "If I delete the file using fx_file_delete next time booting the device up with fx_media_open I got FX_BOOT_ERROR" Still trying to reproduce this

     

    Thanks, apologies if I seem obtuse.

     

    Janet

  • In reply to JanetC:

    Hi Janet,
    sorry for misunderstanding.
    For the first there are two projects, one is for our custom board and another one is uploaded example project for SK-S7G2 board where I could also reproduce the problem.
    Previously you asked me why need I to run FileX and MSC USBX concurrently, so I told that I needn't and described about my custom board project.
    Let's concetrate with SK-S7G2 current project because you have hardware to check.
    Regarding your questions:
    1. > The device is connected to PC by the J5 connector. I boot the project from the debugging.
    ok, but connectioan via J5 is optional, if you don't connect to PC via J5 connector, the problem still exist.
    2. > Am I supposed to format the media? If I do the button changes to Wait...and eventually completes.
    Yes, when you run first time you need to format the media. While media not formatted you couldn't observe disc or use FileX.
    Please press format media button and wait, I recorded a video:
    www.dropbox.com/.../format.mp4
    If you power cycle the board there are no errors and if you connect to PC you could observe disk with empty archive.txt file.
    3. > What is the purpose of "test".
    > By the way, what records is the "test" counting? It too eventually completes with no error.
    > Anyway, when "test" is running, only the "Menu" button is visible.
    Now I would like to fill archive.txt file with some data.
    It writes 200 bytes (from 0x00 till 0xc7) for 9991 times.
    Please wait while writes completes.
    If you power cycle the board everythigs seems to be okay, the number of records readed from FileX succesfully.
    If you connect the board to the PC you could observe the disk with about 2 Megabyte file.
    And if you look into the file (I used Fhred) you could see the file saved without any errors.
    I recorded videos:
    Start TEST:
    www.dropbox.com/.../test_start.mp4
    End TEST:
    www.dropbox.com/.../test_end.mp4
    4. > Then I try to delete a file. But I don't see anything happening. I put a breakpoint in delete_file() and it errors out (0x04 which is file not found).
    > I tried this test a dozen times so the exact details and order of are perhaps confused in my head.
    Now delete the file by pressing the DELETE FILE button.

    By default I do not put GUI messages out. 
    If you would like to see GUI output modify menu_window_handler by adding show_error() function in FILE_DELETE_BUTTON_EVENT:

    case GX_SIGNAL(FILE_DELETE_BUTTON_ID, GX_EVENT_CLICKED):
    if (current_status.code == NO_ERROR && !format_button_wait && !test_button_wait && !delete_button_wait)
    {
    delete_button_wait = true;
    current_status = delete_file();
    delete_button_wait = false;
    show_error();
    }
    break;

    For the first time fx_file_delete return SSP_SUCCESS, for the second time its return file not found.
    But if I power cycle the board to call fx_media_open, or open fx_media_open without power cycle it returns FX_BOOT_ERROR (Code 0x01).
    So the file system is broken, also I couldn't observe the file system on PC.
    Thats the problem after deleting testing file the file system is got corrupted.

    The video without error messages:

    https://www.dropbox.com/s/aty7ah0ziv5vg8o/delete_file_media_open_error.mp4?dl=0

    In the start of the video I power cycle the board and fx_media_open return FX_SUCCESS, but if I delete the file the file system is broken and fx_media_open return FX_BOOT_ERROR.

    And with error messages from delete button:

    www.dropbox.com/.../delete_file_status.mp4


    If you would like to retry the error please make steps 2-4 (format, write, delete) again.

    About clarifying questions I told about my custom board and project.


    If you have any other questions please do not hesistate to ask.
    Please inform me if you could reproduce the problem on your SK-S7G2 board.

    Regards, dxwak.

  • In reply to dxwak:

    Hi Dxwak,

    Thanks, that helps to clarify things. Appreciate the short 'cameo' videos. A picture is worth a thousand words.

    When I power cycle the device, or reboot in the debugger, the 'auto initialization' fx_media_open always fails with the FX_BOOT_ERROR. When I click on Format Media button it always succeeds. This is regardless if the previous session included deleteing the file or not:

    Format Media -> Test -> Delete File

    Do you call fx_media_flush before closing everything down?

    Also, is there any way to shorten the test? It takes a super long time to wait for the 9991 records. Is it necessary to generate 2mB test file or can we get by with something smaller? Would smaller tests have the same problem with LevelX enabled or only the larger files. This sounds reminiscent of your previous issue with LevelX where the QSPI/(or synergy driver) is limited an memory source locations it can process. But Jeremy's patch should have resolved that, right? So this is something different now.

    I'll work on it more tomorrow.
  • In reply to JanetC:

    Hi Janet,
    thank you for your patience.

    > When I power cycle the device, or reboot in the debugger, the 'auto initialization' fx_media_open always fails with the FX_BOOT_ERROR.
    > When I click on Format Media button it always succeeds.
    > This is regardless if the previous session included deleteing the file or not:
    This is very strange, if I don't delete the file or just create the file everything works well.

    > Do you call fx_media_flush before closing everything down?
    Yes I call fx_media_flush after checking, writing, or delete the file.

    > Also, is there any way to shorten the test? It takes a super long time to wait for the 9991 records. Is it necessary to >generate 2mB test file or can we get by with something smaller? Would smaller tests have the same problem with LevelX >enabled or only the larger files.

    Yes, you could make the test faster. If I make 10 records everything works well, but if I make 100 records the problem appeared.
    Please change the number of records in main_thread_entry() function to:
    if (test && count_records <= 99)

    > This sounds reminiscent of your previous issue with LevelX where the QSPI/(or synergy driver) is limited an memory
    > source locations it can process. But Jeremy's patch should have resolved that, right? So this is something different now.

    Yes these problem is alike but now unfortunately not the same.
    I used Jeremy's patch, without it writing is not reliable.

    I made a full test video, it started with Media open error, so I FORMAT_MEDIA, so I wait it done.
    Then I power down and up the system several times without any error, the file system is ok, and number of records is zero. After it I made test with 100 records. So again power cycle board several time, the file system is ok and shows 100 records. In the end I delete the file, FX_SUCCESS status received, and after power cycle the board I got FX_BOOT_ERROR from fx_media_open.
    Link to the video:
    www.dropbox.com/.../test_full.mp4

    Regards, dxwak.
  • In reply to dxwak:

    The issue occurs when FileX starts to release sectors after the file has been deleted by FileX. In sf_el_fx, the ioctl for sector release is called with the sector number (start_sector value is passed in) :-

            ret_val = p_block_media->p_api->ioctl(p_block_media->p_ctrl,
                                                  SSP_COMMAND_CTRL_SECTOR_RELEASE,
                                                  (void *) start_sector);

    However, in sf_block_media_lx_nor, the value passed in is used as a pointer :-

     

    and that pointer is used to call lx_nor_flash_sector_release():-

    so levelx releases the wrong sector.

    However, if in sf_el_fx, the ioctl for sector release is called passing the address of the variable holding the sector number to release :-

            ret_val = p_block_media->p_api->ioctl(p_block_media->p_ctrl,
                                                  SSP_COMMAND_CTRL_SECTOR_RELEASE,
                                                  (void *) &start_sector);

    then the correct sector is passed to lx_nor_flash_sector_release() and the filesystem is not corrupted. The attached project has this fix in src\sf_el_fx\sf_el_fx.c the original version should be excluded from the build.

    SSP_1_6_0_S7G2_SK_LevelX_Sector_Release.zip

  • In reply to Jeremy:

    Thanks Jeremy!
  • In reply to Jeremy:

    Dear Janet and Jeremy,
    after applying fix provided we do not see any problem now.
    Thank you for your support.
    Hope it could be helpful for other Synergy platfom users.

    Regards, dxwak.