G120 - USB client - mounting SD / USB storage and formating

I our current design we use the USB client to get access to the storage on the custom PCB.
The basic approach is check the USB client state during the watchdog timer reset (every 3 seconds)

 USBClientController.State usbState = USBClientController.GetState();

next we close files, unmount SD or USB depending on a flag and attach + enable this to the USB client :

            // connect only once !
            if (usbState == USBClientController.State.Running && MyUSBClientLoaded == 0)
            {
                // only if SD is actually mounted !!
                if (SDStorage == 1)
                {
                    // flag 
                    MyUSBClientLoaded = 1;

                    // log naar syslog
                    SysLogFileWriteLine(RealDateTime + " : " + "USB Client connected");

                    // still mounted -> close all file handles
                    FreeSDcard();
                    Thread.Sleep(50);
                    MySD.UnmountFileSystem();

                    // connect the SD card
                    MyUSBClient.AttachLun(0, MySD, "Emrol", "IRC Controller SD");
                    MyUSBClient.EnableLun(0);
                }
                else
                { 
                //als FreedSD aangeroepen is de USB mounten inplaatst van SD
                    // flag 
                    MyUSBClientLoaded = 1;

                    // log naar syslog
                    SysLogFileWriteLine(RealDateTime + " : " + "USB Client connected");

                    MyUSB.UnmountFileSystem();

                    // connect the USB memory
                    MyUSBClient.AttachLun(0, MyUSB, "Emrol", "IRC Controller USB");
                    MyUSBClient.EnableLun(0);
                }
            }

Here comes my first question: At the connected pc i instant see a USB mass storage device popping up, but it takes 30-60 seconds before it’s accessible, is this normal timing?

Second question: today we tested formatting the connected storage from the USB client and for the USB mass storage it took more then one hour to format (not quick format) a 4Gb transcend (TSS112288M~~44GUFFM–H) module? is this normal timing?

Did we did something wrong or is this normal timing on GHI filesystem?

There is a lot of overhead involved in passing data back and forth plus this is a full-speed USB, 12mbps. Where it is 480mbps on card readers for example. That is significant difference, 40 times.

That said, it should not take that long to mount! Let us run some tests here to see how long it takes on our end.

We did some more test today and a “quick format” takes about 2 minutes, this is acceptable if you keep in mind that the G120 is actual running the main application with (depending on the loaded configuration) running 5-10 threads and 5-10 timer events at the same time. (all threads have the same priority but CAN bus load is about 50% on CAN1 125kbs and CAN2 500kbs)

The mounting is a bit odd but then again, who now’s tomorrow with the new SDK :smiley:

BTW, are there CAN changes in the new .10 release? (still have the 1000kbs problem on G120 in the test setup)

First custom PCB’s arrived today with a emergency 2 day production… 3 weeks to go live…
hope to show some pictures in the next day’s :slight_smile:

1 Like