Cannot get SD Card to work in user created Task

Discussion to talk about software related topics only.
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: Cannot get SD Card to work in user created Task

Post by seulater »

I will work on getting you an example that works, hang on.
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Cannot get SD Card to work in user created Task

Post by dciliske »

Couple of things here. First off if you're trying to simply add a task to the http-effs example and it's failing, this seems odd.

Note for Tod and seulater, you are incorrect in your assumptions. It is perfectly valid to use the following code to set up the filesystem in a new task

Code: Select all

OSChangePrio( TASK_PRIO );
f_enterFS();
This is exactly how all the multitasking EFFS examples set it up. I've seen what is going on down in the bowels of the filesystem that uses the task registration magic (btw, filesystems are complicated...), and when you register a task the only thing the filesystem cares about is the task priority number.

Lachlanp, it would help to see your UserMain function in its entirety here. Somehow it feels as if you haven't initialized the SD card before making this call in your other task.

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: Cannot get SD Card to work in user created Task

Post by seulater »

First note, i am wondering if you are using "f_chdrive( MMC_DRV_NUM );" in your uCFG task.
Try that first and see if that helps.

I took the same EFFS-HTTP example and added another task called Task_1.
Here is what that looks like

Code: Select all

//*********************************************************************
//****************************  TASK 1  *******************************
//*********************************************************************
void Task_1( void *pd )
{
   /* The following call to f_enterFS() must be called in every task that accesses
      the file system.  This must only be called once in each task and must be done before 
      any other file system functions are used.  Up to 10 tasks can be assigned to use
      the file system. Any task may also be removed from accessing the file system with a 
      call to the function f_releaseFS(). */

	f_enterFS();

	while(1)
	{
		// Wait here until we are called, this ensures that all other f_enterFS() have been called first
                // We dont want to access the file system until everything else has been initialized. 
		OSSemPend(&PTask1_Wait,0);

		f_chdrive( MMC_DRV_NUM );

		iprintf("\r\n****************************************************\r\n");
		iprintf("Task 1, Showing SD Card Info\r\n");


		DisplayEffsSpaceStats();  // Display file space usage
		DumpDir();                // Display flash card files and directories

		iprintf("****************************************************\r\n");

		OSTimeDly( TICKS_PER_SECOND );
	}


}

Then in user main just before it calls " DisplayMenu();" i placed:

Code: Select all

   // Allow PTask1_Wait to run once
	OSSemPost(&PTask1_Wait);

Now when the program runs, Main displays the drive files, and just before it calls DisplayMenu it allows Task_1 to run, and also show the files.
NOTE: that if you do not use "f_chdrive( MMC_DRV_NUM );" in the new task it will not show the files which is why i am wondering if you have that in there, and this is causing the trouble for you.
Lachlanp
Posts: 91
Joined: Tue Jan 29, 2013 4:44 am

Re: Cannot get SD Card to work in user created Task

Post by Lachlanp »

Solved.
Thank you for you support.
Regards
Lachlan
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: Cannot get SD Card to work in user created Task

Post by seulater »

What was the culprit ?
Lachlanp
Posts: 91
Joined: Tue Jan 29, 2013 4:44 am

Re: Cannot get SD Card to work in user created Task

Post by Lachlanp »

The f_chdrive. As soon as I add that, all worked.

Thanks again or your help.
Regards
Lachlan
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Cannot get SD Card to work in user created Task

Post by tod »

Dan I think the mistake was all mine, I made incorrect assumptions about what seulater meant. Sorry about that, I should know better.
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Cannot get SD Card to work in user created Task

Post by dciliske »

Tod, I wasn't trying to admonish you or anything, just trying to make sure the correct information was available as well as the explanation as to why it was correct. Keep being awesome!
Dan Ciliske
Project Engineer
Netburner, Inc
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: Cannot get SD Card to work in user created Task

Post by seulater »

Just to clarify, you can do it either way. You can call f_enterFS() in the main task, or you can call it in the thread itself.
Without having enough of the original code to go on it was not clear to me where he was calling it, i figured the best way under the circumstances was to have him call it in the thread itself.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: Cannot get SD Card to work in user created Task

Post by tod »

Not to mention that doing it in the task itself avoids the potential problem of OSChangePrio returning error 40, indicating that the task priority is already in use.
Post Reply