SD Card access issue in other Tasks

Discussion to talk about software related topics only.
Post Reply
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

SD Card access issue in other Tasks

Post by sblair »

I'm using a MOD54415 and trying to make use of the SD Flash card on it using NNDK 2.6.7. I've played around with the EFFS-HTTP and EFFS-MultipleMMC examples and followed them closely. My issue is that I can't access the file system within other Tasks other than the one I init'd everything in.

I'm using the FileSystemUtils.cpp file from the EFFS-HTTP application with the changes needed to the Init from the MultipleMMC example (I wish the FileSystemUtils files were identical across all the examples so we could just treat them like a lib).

In the task (MAIN) I have initialized the file system in I'm able to access it and read/write with no issues. However when trying to access it from other tasks it doesn't work.

I have been careful at the top of UserMain() to call f_enterFS() for the various tasks prios.

Code: Select all

    	
        f_enterFS();
        OSChangePrio(MAIN_PRIO);
        f_enterFS();
        OSChangePrio( HTTP_PRIO );
        f_enterFS();
        OSChangePrio( TASK_PRIORITY_RDMNET_MAIN );
        f_enterFS();
        OSChangePrio(MAIN_PRIO);

  /*** Initialize Netburner Hardware ***/
    InitializeHardware();  /* I init the file system and do some read/write in here and it works fine.*/

    //Get an IP Address.....
    InitializeEthernet();


    //OSChangePrio(MAIN_PRIO);
    iprintf("EnableAutoUpdate\n");
    EnableAutoUpdate();
    StartHTTP();
    EnableTaskMonitor();
At this point the only file system calls I'm making after the InitExtFlash() are to:
DisplayEffsSpaceStats(); // Display file space usage
DumpDir(); // Display flash card files and directories

In main both of those work. However when I try calling from either the result of a submit action on a web form or just inside the top of another task the DumpDir() fails and if I try creating or checking for existence of a folder it fails too. The DisplayEffsSpaceStats() always works though.

So I'm a bit baffled here. I've tried following the instructions and examples closely about not doing anything with the file system calls until f_enterfs() has been called for all task priorities it will be used in (shown above).

Does it work properly if the tasks have not actually been started yet? I assume it does since that's what it looked like for the examples...

Anything else I'm missing here?

Thanks.
Scott
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: SD Card access issue in other Tasks

Post by pbreed »

My guess is that this is an order issue.
Your notes say you initalize the file system after the task priority fs_enter calls...
Try doing that after the other initialization.

I personally prefer to to put the fs_enterFS in the individual tasks that are trying to use the file system rather than swapping the task priority in main...
sblair
Posts: 162
Joined: Mon Sep 12, 2011 1:54 pm

Re: SD Card access issue in other Tasks

Post by sblair »

I take your point about putting the f_enterfs() in the startup of the individual tasks. That's how I normally do it. All the example projects were using the OSChangePrio() which I'm guessing was mostly because that was the only way to do it with the HTTP and FTP tasks since those are system libs.

I did find the issue after doing a code review on the plane the other night, I wasn't doing the f_chdrive( MMC_DRV_NUM ) in each of the other tasks. I thought that only had to get initialized once and not once per task. So that appears to have solved it.

One request I do have is, can you guys update the FileSystemUtils.cpp file to be the same across all the examples? The one in the MOD5441x is definitely different than the others so I had to go through and merge code. It would be nice for these to all be the same where we could just treat it the same as a lib file where I'm not modifying it and I can just pull it into my code from the examples and be able to take advantage of improvements that you guys make to it.
Post Reply