STMP3760 SigmaTel write to NAND Flash

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

STMP3760 SigmaTel write to NAND Flash

4,665 Views
ioan_harna
Contributor I

Hello,

I am working with a SigmaTel STMP3760 and I need to read/write the values to an array to the NAND Flash. I have a NAND Flash Daughtercard (STMP36xx NAND Flash Rev. C).
I have the SDK Framework - SDK OS Media and the Nand Drivers in \drivers\media\nand. I've read the information in the developersguide_3700_1001_002.pdf about NAND and chapter 14 about GPMI from the datasheet.

I found the files *nand*test.c like nand_media_test.c and nand_stress_test.c that are using the functions from the drivers but when I call the function NANDMediaInit or NandHalInit the system stops.

Can anybody find give me a simple example that initialises the NAND flash communication and makes some read/write operations?

Thank you for your help,
Ioan Harna

0 Kudos
Reply
12 Replies

1,318 Views
ioan_harna
Contributor I
Hello,
 
It appears that the problem is only half solved.
 

I am using Fopen from fsapi.h.

 

I am always able to create the files I need when this function is called from a widget; meaning when I press a button and I treat this inside a widget similar with the about widget.

 

The problem is that I am not able to create files from a cyclic task (triggered by a timer).

 

I would like to mention that cmi_cm_StorMediaInitComp(CMI_INTERNAL_MEDIA) returns true meaning that the nand media is initialized.

 

I also tried to use cmi_dai_NewMediaHandle but this also does not work.

 

Does anybody know if there is any difference between calling Fopen from a widget and from a timer?

 

Thank you,

Ioan Harna

0 Kudos
Reply

1,318 Views
ioan_harna
Contributor I
Thank you !!!
Thank you !!!
Thank you !!!
 
My last day in the company and the problem got solved
 
Thank you !!!
Thank you !!!
Thank you !!!
 
 
0 Kudos
Reply

1,318 Views
JonathanL_Nesbi
Contributor I

Ioan Harna, Here's some helpful info from our SW architect. It depends what kind of timer you use. If you mean either a TX_TIMER callback, or a IRQ handler for a timer, then neither of those can access OS objects (like wait on a semaphore), and hence the whole filesystem stack would fail if trying to use fsapi calls from one of those timer event handlers.

If you need something cyclic, and the UI is up, then you can put it in the widget heartbeat function.

0 Kudos
Reply

1,318 Views
ioan_harna
Contributor I

Hello everybody,

 

The problem was that the storage media initialization was not complete at the time I tried to create the file.

I was trying to create a file after ~300ms after power-up and at that point the function cmi_cm_StorMediaInitComp(CMI_INTERNAL_MEDIA) returns FALSE meaning that the storage media initialization was not yet complete. After waiting a little bit more one call to Mkdir creates a directory and one call to Fopen opens/creates a file.

 

Thank you Jonathan for being the only one who tried to help :smileyhappy:

Please check your PM.

 

            If anybody will ever have questions related to this thread one can contact me at ioan.harna@gmail.com

 

0 Kudos
Reply

1,318 Views
JonathanL_Nesbi
Contributor I
See fsapi.h to use the FS calls fcreate, fopen, fwrite, fread with data drive 0 which is the nand data drive. I assume you are initializing the file system as the SDK5 for STMP37xx does. You can search your code for something like fsinit. The init sequence done by the SDK involves calls such as NandMediaInit, nandMediaDiscover, NandDriveInit,  fsDriveInit.
-JLN, STMP3xxx SDK SW engineer since 2002

0 Kudos
Reply

1,318 Views
ioan_harna
Contributor I

Hello Jonathan,

 

Thank you very much for your help, I made one small step forward.

 

Here is a sample of the code I am using:

 

   int32_t iFileHandle;
  
const uint8_t uHandle[]= "A:/recordings/FM/Test.txt";

    iFileHandle=Fopen((uint8_t *)uHandle,"w+");
   
if(iFileHandle >0)
  
{
               DEBUG_15
= 1;
   
}         
    
else
   
{
               DEBUG_15
= 2;
   
}

The values for DEBUG_15 is 2 and iFileHandle has the value 0xF0305014 meaning ERROR_OS_FILESYSTEM_INVALID_DIR_PATH.

This code runs ~300 ms after power-on from a function called at the end of UI_Init(). I do not know if any other initializations have to be made before fopen is called (maybe in order to initialize the NAND module) …

 

The same results were noticed with and without the file in recordings/FM/Test.txt. Fopen was called with “r” and “w+” with same result.

 

 

One more thing related to the initialization sequence: the function IsExternalDriveFsReady returns 0 meaning that “an external media and its drive are not present”.

 

I see that in my project the FSDriveInit function is called only in the file updater\src\updater_live.c that I think updates the firmware.

 

 

When I call FSDriveInit(0); the following error number is retuned:

0xF0208000 meaning ERROR_DDI_LDL_GENERAL.

 

Does anybody know the reason for this error?

 

Thank you very much for your help,

Ioan Harna

0 Kudos
Reply

1,318 Views
JonathanL_Nesbi
Contributor I
And after before using the nand data drive at the fsapi level, a call to ComputeFreeCluster is needed but the SDK does that for you already if you use the SDK framework that includes SDK OS Media or beyond.
0 Kudos
Reply

1,318 Views
ioan_harna
Contributor I
Here are some further steps I made:
 

The following functions are called prior to calling fopen:

InitialMediaInit

MediaInit( DATA_DRIVE_ID_INTERNAL ) returned SUCCESS in sdk_os_media_init.c

MediaDiscoverAllocation( DATA_DRIVE_ID_INTERNAL ) returned SUCCESS

MediaFindDriveWithTag(DRIVE_TAG_BOOTMANAGER_S) returned 5 and

DriveInit(5) returned SUCCESS

MediaFindDriveWithTag(DRIVE_TAG_BOOTMANAGER2_S) returned 6 and

DriveInit(6) returned SUCCESS

In the end the function InitialMediaInit returns SUCCESS and only afterwards Fopen is called.

 

Fopen returns error 0xf0305014 meaning INVALID_DIR_PATH.

 

0 Kudos
Reply

1,318 Views
ioan_harna
Contributor I

FSInit in sdk_os_media_init.c is also called and returns SUCCESS

When calling NandMediaInit(g_MediaDescriptor) just before calling Fopen the return result is also 0xf0305014 meaning INVALID_DIR_PATH.

Do I need to define NAND_IMAGER_UTILITY or this has no impact on my sw?

When calling FSDriveInit(DATA_DRIVE_ID_INTERNAL); just before calling Fopen it returns ERROR_DDI_LDL_LDRIVE_NOT_INITIALIZED.

 

How do I initialize the drive? :smileysad: Can I find somewhere these functions? (FSDriveInit... ) in order to understand why they return these error messages?

 

thank you in advance for your help,

Ioan Harna

0 Kudos
Reply

1,318 Views
JonathanL_Nesbi
Contributor I

You shouldn't have to add a call to FsDriveInit since it is already called in specific sdk5 frameworks that include the file system. Which application framework directory are you using? Sdk os media player framework is used by most STMP37xx SDK5 customers.


0 Kudos
Reply

1,318 Views
JonathanL_Nesbi
Contributor I
Refer to the STMP3xxx SDK developer's guide and contact the normal customer support channels for more info on file creation which varies depending on if your application includes our content management interface (CMI) library or not.

0 Kudos
Reply

1,318 Views
ioan_harna
Contributor I

Hello Mr. Nesbitt,

 

I am using the framework sdk_os_media_player. I have made a service request on freescale’s technical support centre 10 days ago but I did not get an answer yet.

 

In the directory components I have the folder CMI. Cmi_dai_* functions are called in my project. cmi_dai_GetProperty is called in   sdk_os_media_player\player\src\asi\mediaengine_control_api.c and therefore I think that my project uses CMI.

 

I will read the chapter 4. Media Management and take a close look at Content Management Interface.

 

I think I should use cmi_dai_NewMediaHandle() in order to create a file instead of fopen.

 

Thank you very much for your help and have a nice evening,

Ioan Harna

0 Kudos
Reply