This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simultaneous File I/O access to SD Drive using FAT and USB Msc device

Hello

I have the following setup 1)Hardware - a STM32F4xx Keil dev board type circuit 2)Middleware RL-USB with a composite configuration - Msc and Cdc connected to a Windows computer and 3:) RL-FLash FS (using a SD card running in native mode). It all running under RL RTX.

Everthing just about works... but when i use File I/O routines such as fcheck, ffind etc - (via the Usb Cdc interface) - it does not work. I tried fcheck - it comes back with a 1 - an error.

I did have this all working - I patched the ST USB device firmware together to make a composite driver, reworked the various ST routines and using the RL-Flash FS and got it all to work. When I say it worked - I don't mean having simultaneous access to files. The idea was to copy a file across using windows and then using a hyperterminal CLI interface to (with the Cdc interface) re-program the STM32Fxx flash. Ok so if was working why did I change it - well I was really hopping to use the Keil middleware in the project and then there is a very good chance there wont be any funny stuff. I had "funny stuff" on my ST code - sometimes - when hooked up to certain HP laptops.

I have tried variation on this theme - but it's not working.

....


FAT_VI      *mc0;
Media_INFO  info;


__task void init (void)
{
        CreateMailboxes();

        t_TerminalTask          = os_tsk_create (TerminalTask,5);
        t_LedTickTask           = os_tsk_create (LedTickTask,5);
        os_evt_set(EVENT_BOOTUP_COMPLETE,t_LedTickTask);

        t_I2C1Task              = os_tsk_create (I2C1Task,5);
        t_PowerManagmentTask    = os_tsk_create (PowerManagmentTask,2);
        t_ADCTask               = os_tsk_create (ADCTask, 2);
        os_evt_set(EVENT_BOOTUP_COMPLETE,t_PowerManagmentTask);


        usbd_init  ();

        mc0 = ioc_getcb (NULL);
        if (ioc_init (mc0) == 0)
                {
                ioc_read_info (&info, mc0);
                usbd_msc_init ();
                }
        usbd_connect(__TRUE);
        while (!usbd_configured ());


        os_tsk_delete_self ();
}

Any ideas? Does the RL-FS work with either the USB Msc or using the File I/O routines like fopen, fclose etc - but not both. There is a polling mechanism in the the Usb Msc to check if the drive is ready/available so it would seem to me that this is a viable possibility?

Many Thanks
Peter

Parents
  • Thanks for that Ken - I figured that out - the the Keil RL File system is "MSDOS like" and does not support "simultaneous" access like the big daddy OS's like Windows,Linux etc. My work around was to have 3x separate standalone programs all residing on the STM32 flash - 1.the main app - 2. the flash loader (that used the USB Cdc interface for the CLI and the SD Flash Card running in FAT mode) - and 3..... a standard USB Msc interface to the SD card (using the SCSI interface?)- and using windows to copy flash images and so on. It works fine... but I guess that's the trade of for a small operating system (RTX) - having to reboot between the 3x apps - fortunately that is only for firmware upgrades - and shortly I will have the whole GSM/3G connection running to remotely do this. But thanks for your insight :)

Reply
  • Thanks for that Ken - I figured that out - the the Keil RL File system is "MSDOS like" and does not support "simultaneous" access like the big daddy OS's like Windows,Linux etc. My work around was to have 3x separate standalone programs all residing on the STM32 flash - 1.the main app - 2. the flash loader (that used the USB Cdc interface for the CLI and the SD Flash Card running in FAT mode) - and 3..... a standard USB Msc interface to the SD card (using the SCSI interface?)- and using windows to copy flash images and so on. It works fine... but I guess that's the trade of for a small operating system (RTX) - having to reboot between the 3x apps - fortunately that is only for firmware upgrades - and shortly I will have the whole GSM/3G connection running to remotely do this. But thanks for your insight :)

Children
  • 1) Windows allow write-back cache to be turned on/off as the user decides. So it depends if removable media requires any 'safe removal' or not - at least as long as people doesn't try to remove the device/card while the access light is flashing.

    2) Linux doesn't allow two masters either. There might be some variant of more or less cooperative file locking involved. But for this specific situation it would be solved by networking the file system. I.e the Windows machine knows it doesn't own the file system and that it can't just read in everything and cache the original data and any potential changes in memory. And the Windows machine sends the commands about what changes to do, and let the Linux machine perform the changes - which means the Linux machine has 100% knowledge of all changes.