Problem writng flash


#1

Hi,
After reading the docs and searching in the forum, i have come up with this:

#define FLASH_LOCATION					3
static const ascii* flash_test_var = "some_flash";
u8 char_array[10];
...

	adl_flhSubscribe( flash_test_var, 10 );

	rc = adl_flhWrite(
			flash_test_var,			//ascii name
			FLASH_LOCATION,			//ID (int)
			10,//sizeof( char_array ),		//size in bytes
			&char_array					//reference
			);
	switch ( rc )
	{
	case OK:
			echo_u( "\r\nflash write rc = OK" );
			break;
	case ADL_RET_ERR_PARAM:
			echo_u( "\r\nflash write rc = ADL_RET_ERR_PARAM" );
			break;
	case ADL_RET_ERR_UNKNOWN_HDL:
			echo_u( "\r\nflash write rc = ADL_RET_ERR_UNKNOWN_HDL" );
			break;
	case ADL_FLH_RET_ERR_ID_OUT_OF_RANGE:
			echo_u( "\r\nflash write rc = ADL_FLH_RET_ERR_ID_OUT_OF_RANGE" );
			break;
	case ADL_RET_ERR_FATAL:
			echo_u( "\r\nflash write rc = ADL_RET_ERR_FATAL" );
			break;
	case ADL_FLH_RET_ERR_MEM_FULL:
			echo_u( "\r\nflash write rc = ADL_FLH_RET_ERR_MEM_FULL" );
			break;
	case ADL_FLH_RET_ERR_NO_ENOUGH_IDS:
			echo_u( "\r\nflash write rc = ADL_FLH_RET_ERR_NO_ENOUGH_IDS" );
			break;
	default:
			echo_u( "\r\nflash write rc = default" );
	}

now i have tried some different ways of using the adl_flhSubscribe() & adl_flhWrite() routines, but i keep getting the ’ ADL_FLH_RET_ERR_ID_OUT_OF_RANGE’ case.

could someone please show me how to write an array of bytes to flash?

thx


#2

What is the return value from adl_flhSubscribe ?


#3

with this code added:

rc = adl_flhSubscribe( flash_test_var, 10 );

	switch ( rc )
	{
	case OK:
			echo_u( "\r\nflash subscribe rc = OK" );
			break;
	case ADL_RET_ERR_PARAM:
			echo_u( "\r\nflash subscribe rc = ADL_RET_ERR_PARAM" );
			break;
	case ADL_FLH_RET_ERR_NO_ENOUGH_IDS:
			echo_u( "\r\nflash subscribe rc = ADL_FLH_RET_ERR_NO_ENOUGH_IDS" );
			break;
	case ADL_RET_ERR_ALREADY_SUBSCRIBED:
			echo_u( "\r\nflash subscribe rc = ADL_RET_ERR_ALREADY_SUBSCRIBED" );
			break;
	default:
			echo_u( "\r\nflash subscribe rc = default" );
	}

I am getting the ‘ADL_RET_ERR_ALREADY_SUBSCRIBED’ case.


#4

That’s good :slight_smile:

It’s not really an “error” - it’s just telling you that the Handle (set of Objects) already existed, and a new one hasn’t been created.
You have a valid subscription to the Handle.


#5

My mistake, but i should have also added the error that follows when writing to flash in the adl_flhWrite() routine, which follows immediately after the subscription.

So, the return codes are:

flash subscribe rc = ADL_RET_ERR_ALREADY_SUBSCRIBED
flash write rc = ADL_FLH_RET_ERR_ID_OUT_OF_RANGE

I guess the important thing here is to understand what the ‘ADL_FLH_RET_ERR_ID_OUT_OF_RANGE’ means. I have read the docs and i connot get a clear understanding?

I am getting a hunch that you cannot read/write an array of bytes, just one byte at a time?


#6

No, it’s not that - you certainly can write arrays and other multi-byte objects

Code: 

#define FLASH_LOCATION               3 
static const ascii* flash_test_var = "some_flash"; 
u8 char_array[10]; 
... 

   adl_flhSubscribe( flash_test_var, 10 ); 

   rc = adl_flhWrite( 
         flash_test_var,             // Handle 
         FLASH_LOCATION,             // ID (int) 
         10,//sizeof( char_array ),  // size in bytes 
         &char_array                 // address
         );

Note that you don’t actually need the ‘&’ operator with ‘char_array’
In ‘C’, the name of an array gives the address of the start of the array directly…

If you do use the ‘&’ operator, you would more usually write:

&char_array[0]

#7

hi ,
U just try by replacing your code “&char_array” with "char_array.
I think u can get da soln