Problem in writing data into flash

Hi,

I tried to write databytes into flash using adl_flashwrite function.
Flash subscribe success. i am getting error like

10/06/10,10:38:54:265 ADL 1 Binary header at 6E6161A0
10/06/10,10:38:55:312 ADL 16 [ADL PORT] subs (6E609FE0) : 0
10/06/10,10:38:56:328 ADL 16 [ADL PORT] subs (6E603B80) : 1
10/06/10,10:38:56:343 ADL 22 [ADL] flash subs 2 : -4
10/06/10,10:38:56:359 ADL 22 Flh Obj 0000 Len : 4
10/06/10,10:38:56:375 ADL 22 Read Flh Obj 0000 (4) : 0
10/06/10,10:38:56:437 ADL 16 [ADL PORT] event : 0 (port 80 ; state 0)
10/06/10,10:38:56:703 ADL 16 [ADL PORT] event : 0 (port 70 ; state 0)
10/06/10,10:38:56:718 ADL 16 [ADL PORT] event : 0 (port 01 ; state 0)
10/06/10,10:38:57:0 ADL 22 Flh Obj 0000 Len : 4
10/06/10,10:38:57:15 ADL 16 [ADL PORT] unsubs (1) : 0
10/06/10,10:38:58:140 ADL 1 Embedded : Appli Init 6
10/06/10,10:38:58:281 ADL 22 [ADL] flash subs 111 : 0
10/06/10,10:38:58:296 ADL 1 Embedded : Flash Subscribe Success
10/06/10,10:38:58:312 ADL 22 ID count : 111
10/06/10,10:38:58:328 ADL 1 Subscribed IdCount: 111
10/06/10,10:38:58:406 ADL 1 Embedded : Appli is started
10/06/10,10:38:58:421 ADL 22 Write Flh Obj 006F (24) : -23 ; 130217
10/06/10,10:38:58:437 ADL 1 Flash Write return value is: -23
10/06/10,10:38:58:453 ADL 22 Flh Obj 006F Len : 0
10/06/10,10:38:58:468 ADL 1 Length : -23
10/06/10,10:38:58:484 ADL 22 Read Flh Obj 006F (65513) : -23

i am able to write 0th ID OBJECT but i am unable to write other ID OBJECTS (1-2000) into flash.

where is the problem could any one know this let me know please?

thanks in advance
Nagendra

Hiya,

Unfortunately, the traces don’t tell us much.

Can you cut down your app to the bare minimum and then post both the Code and the Traces your code produces.

ciao, Dave

Hi,

i written code is like

#define FLHID_COUNT    111
#define FLH_HANDLE   "Nagtest2"


    // Subscribe to the  flash object
FlashRetVal = adl_flhSubscribe ( FLH_HANDLE, FLHID_COUNT );
if (FlashRetVal == OK )
{
    TRACE (( 1, "Embedded : Flash Subscribe Success " ));

    // Check object count
    IdCount = adl_flhGetIDCount ( FLH_HANDLE );
    TRACE (( 1, "Subscribed IdCount: %d", IdCount ));
    if ( IdCount != FLHID_COUNT )
    {
        adl_atSendResponse ( ADL_AT_UNS, "\r\nInit error: please reset flash objects (AT+WOPEN=3)\r\n" );
        TRACE (( 1, "Embedded: Appli flash init error" ));
    }
    else
    {
        adl_atSendResponse ( ADL_AT_UNS, "\r\n Application started \r\n" );
        TRACE (( 1, "Embedded : Appli is started" ));


    }

   wm_strcpy(ParamStr,"Hello Nagendra test");

  
    retval = adl_flhWrite ( FLH_HANDLE, FLHID_COUNT, 24, ParamStr);
    TRACE (( 1, "Flash Write return value is: %d", retval ));

    s32 Length = adl_flhExist ( FLH_HANDLE, FLHID_COUNT );

    TRACE (( 1, "Length    : %d", Length ));

    retval = adl_flhRead(FLH_HANDLE,FLHID_COUNT,Length,(u8*)buff);

    if(retval == OK)
    {
    	TRACE (( 2, "Embedded : Flash Read Success " ));
    }


        TRACE (( 2, buff));

}
else
{
	TRACE (( 1, "Embedded : Flash Subscribe Failed " ));
}

could any one please help regarding this?
where is the problem and solution?

Hiya,

You haven’t posted enough code to see what’s going on. How are all the variables defined?

Also, one thing I did note is that have appeared mis-understand about writing strings to the FLASH. FLASH takes an array of unsigned bytes (u8) to write - it neither knows or cares if the data is a text string or a float or whatever. It’s up to YOU to put the data back together correctly and then display/use it.

So:

here you’ve copied a string ( 20 bytes) into a variable, and then attempted to write 24 bytes to the flash. This is (at least) a buffer overrun issue - and probably a crash.

Later:

you then read back 24 bytes of which the first 20 are your data bytes - then dump it to a function that expects a nul terminated buffer…which your data probably (not reliably, anyway) is not.

Finally, have you checked what the return values from your flash functions means? (hint, look up what the return code -23 means)

Again, post up a bit of working code (not a fragment) and we might be able to help you some more.

ciao, Dave

Hi,

given full flash sample code

/********************************************************************************************/
/*  Hello_World.c   -  Copyright Wavecom S.A. (c) 2002										*/
/*																							*/
/*																							*/
/* DISCLAIMER OF WARRANTY																    */
/* ======================																    */
/* This Software is provided free of charge on an 'as is' basis. No warranty is given       */
/* by Wavecom S.A. in relation to the Software of the uses to which it may be put by you,   */
/* the user, or its merchantability, fitness or suitability for any particular purpose      */
/* or conditions; and/or that the use of the Software and all documentation relating        */
/* thereto by the Licensee will not infringe any third party copyright or other             */
/* intellectual property rights. Wavecom S.A. shall furthermore be under no obligation      */
/* to provide support of any nature for the Software and the Documentation.				    */
/*																						    */
/* LIMIT OF LIABILITY																	    */
/* ==================																		*/
/* In no event shall Wavecom S.A. be liable for any loss or damages whatsoever or howsoever	*/
/* caused arising directly or indirectly in connection with this licence, the Software,		*/
/* its use or otherwise except to the extent that such liability may not be lawfully		*/
/* excluded. Notwithstanding the generality of the foregoing, Wavecom S.A. expressly		*/
/* excludes liability for indirect, special, incidental or consequential loss or damage		*/
/* which may arise in respect of the Software or its use, or in respect of other equipment	*/
/* or property, or for loss of profit, business, revenue, goodwill or anticipated savings.	*/
/*																						    */
/********************************************************************************************/

/***************************************************************************/
/*  File       : Hello_World.c                                             */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application                                      */
/*                                                                         */
/*  contents   : Customer main procedures                                  */
/*                                                                         */
/*  Change     :                                                           */
/***************************************************************************/
/*
    $LogWavecom: G:\projet\mmi\pvcsarch\archives\open-mmi\SAMPLES\adl\Hello_World\src\hello_world.c-arc $
 * --------------------------------------------------------------------------
 *  Date     | Author | Revision       | Description
 * ----------+--------+----------------+-------------------------------------
 *  25.10.05 | DPO    | 1.2            | * New V4 interface
 * ----------+--------+----------------+-------------------------------------
 *  11.12.02 | dpo    | 1.1            | * Timer subscription update
 * ----------+--------+----------------+-------------------------------------
 *  06.11.02 | dpo    | 1.0            | Initial revision.
 * ----------+--------+----------------+-------------------------------------
*/

#include "adl_global.h"


/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;


#define FLHID_COUNT    117

//static const ascii * FLH_HANDLE = "Wmtest";

#define FLH_HANDLE   "Nagtest4"


/***************************************************************************/
/*  Function   : adl_main                                                  */
/*-------------------------------------------------------------------------*/
/*  Object     : Customer application initialisation                       */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  Variable Name     |IN |OUT|GLB|  Utilisation                           */
/*--------------------+---+---+---+----------------------------------------*/
/*  InitType          |   |   |   |  Application start mode reason         */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e  InitType )
{
    s32 IdCount;
    ascii ParamStr[25];
    s8 FlashRetVal;
    s8 retval;
    ascii buff[50];
    u8 m;


	TRACE (( 1, "Embedded : Appli Init 6 " ));

    // Subscribe to the  flash object
	FlashRetVal = adl_flhSubscribe ( FLH_HANDLE, FLHID_COUNT );
	if (FlashRetVal == OK )
	{
		TRACE (( 1, "Embedded : Flash Subscribe Success " ));


	    // Check object count
	    IdCount = adl_flhGetIDCount ( FLH_HANDLE );
	    TRACE (( 1, "Subscribed IdCount: %d", IdCount ));
	    if ( IdCount != FLHID_COUNT )
	    {
	        adl_atSendResponse ( ADL_AT_UNS, "\r\nInit error: please reset flash objects (AT+WOPEN=3)\r\n" );
	        TRACE (( 1, "Embedded: Appli flash init error" ));
	    }
	    else
	    {
	        adl_atSendResponse ( ADL_AT_UNS, "\r\n Application started \r\n" );
	        TRACE (( 1, "Embedded : Appli is started" ));


	    }

	   wm_strcpy(ParamStr,"Hello Nagendra test");


	    //retval = adl_flhErase(FLH_HANDLE,1 );
	    //TRACE (( 1, "Flash Erase return value is: %d", retval ));

	    retval = adl_flhWrite ( FLH_HANDLE, FLHID_COUNT, 24, ParamStr);
	    TRACE (( 1, "Flash Write return value is: %d", retval ));

	    s32 Length = adl_flhExist ( FLH_HANDLE, FLHID_COUNT );

	    TRACE (( 1, "Length    : %d", Length ));

	    retval = adl_flhRead(FLH_HANDLE,FLHID_COUNT,Length,(u8*)buff);

	    if(retval == OK)
	    {
	    	TRACE (( 2, "Embedded : Flash Read Success " ));
	    }

	    TRACE (( 2, buff));


	}
	else
	{
		TRACE (( 1, "Embedded : Flash Subscribe Failed " ));
	}


}

and trace results like

10/06/10,12:52:35:390 ADL 1 Binary header at 6E616180
10/06/10,12:52:36:437 ADL 16 [ADL PORT] subs (6E609F60) : 0
10/06/10,12:52:37:421 ADL 16 [ADL PORT] subs (6E603B00) : 1
10/06/10,12:52:37:437 ADL 22 [ADL] flash subs 2 : -4
10/06/10,12:52:37:453 ADL 22 Flh Obj 0000 Len : 4
10/06/10,12:52:37:468 ADL 22 Read Flh Obj 0000 (4) : 0
10/06/10,12:52:37:531 ADL 16 [ADL PORT] event : 0 (port 80 ; state 0)
10/06/10,12:52:37:796 ADL 16 [ADL PORT] event : 0 (port 70 ; state 0)
10/06/10,12:52:37:812 ADL 16 [ADL PORT] event : 0 (port 01 ; state 0)
10/06/10,12:52:37:828 ADL 16 [ADL PORT] event : 0 (port 02 ; state 0)
10/06/10,12:52:38:93 ADL 22 Flh Obj 0000 Len : 4
10/06/10,12:52:38:109 ADL 16 [ADL PORT] unsubs (1) : 0
10/06/10,12:52:39:203 ADL 1 Embedded : Appli Init 6
10/06/10,12:52:39:296 ADL 22 [ADL] flash subs 117 : 0
10/06/10,12:52:39:312 ADL 1 Embedded : Flash Subscribe Success
10/06/10,12:52:39:328 ADL 22 ID count : 117
10/06/10,12:52:39:343 ADL 1 Subscribed IdCount: 117
10/06/10,12:52:39:437 ADL 1 Embedded : Appli is started
10/06/10,12:52:39:468 ADL 22 Write Flh Obj 0075 (24) : -23 ; 130189
10/06/10,12:52:39:484 ADL 1 Flash Write return value is: -23
10/06/10,12:52:39:500 ADL 22 Flh Obj 0075 Len : 0
10/06/10,12:52:39:515 ADL 1 Length : -23
10/06/10,12:52:39:531 ADL 22 Read Flh Obj 0075 (65513) : -23

here iam getting error code -23

where do we get error code meanings ?
is there any documents please let me know?

RTFM! 8)

Yes - they are in ADL User Guide!

  • The documentation for each API function lists its possible return values, with descriptions;
  • The is a whole chapter at the end of the document titled, “Error Codes”

Hi awniel,

what to do remove the error? how to solve this problem error ?

could you please help e regarding this ?
why am i getting error like this?

thanks in advance

Hiya,

First look - here’s a BIG problem:

#define statements are dealt with by the pre-processor - and are essential done using a text substitution algorithm (think find and replace of defined items with the contents.

If you look at the wavecom sample code you see that they used a const ascii * construct to allocate the flash handle.

Basic C: #define “string” != const char * “string”

Also looks like you are not counting from zero in your flash allocation ID’s. Allocating 117 flash id’s gives you ID’s numbered from 0 to 116. Again, basic C.

Finally, check the return values and see if the function returns an error or not. In general, a negative return value indicates some sort of error. Unfortunately you will have to look up the ADL guide to work out which the error values correspond to the error codes detailed in the doco.

Try these fixes and let us know how you get on.

ciao, Dave

Hi davidc,

Thank you very much.

i fixed the problems as what you said.
working fine.

thanks Again