IAP and variable memory mapping

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

IAP and variable memory mapping

439 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sweetalk on Thu Mar 13 15:00:31 MST 2014
Hi!, I'm trying to use the IAP (In Application Programming) functions to update some variables from my code for the next power up cicle (mostly some configuration data that the user can change). I've read the application note AN11388 and got the functions for writing the flash, and erasing it.

My question is how can I identify an specific variable memory address for uptdating it with the IAP functions or how can I read from an specific memory address to write it on a variable on my code.
Labels (1)
0 Kudos
6 Replies

372 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by salamlora1 on Tue Mar 18 00:24:49 MST 2014
thx for your answer I most study more   :)
0 Kudos

372 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Mar 17 03:44:40 MST 2014
"&" is the address-of operator and it can only appear on the right-hand side of an assignment.

I suggest that you learn C - read about pointers.
0 Kudos

372 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by salamlora1 on Sun Mar 16 23:19:34 MST 2014
Anyone hear me PLZZZZ help???
:((
0 Kudos

372 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by salamlora1 on Sun Mar 16 01:32:07 MST 2014
Hi I write this program and have some trouble with  
&res = (unsigned long)0x00001800;
The lpc exprresso say: lvalue required as left operand of assignment make


#define IAP_LOCATION 0x1fff1ff1;
    char iap[256]; // the data moust be write in flash
    char res[256]; // the data read frome flash and store in res
    int cunterst=0;
    for (cunterst=0;cunterst<256;cunterst++)
    iap[cunterst]=cunterst;
    unsigned int command[5];
    unsigned int result[2];
    typedef void (*IAP)(unsigned int[],unsigned int[]);
    IAP iap_entry;
    iap_entry = (IAP)IAP_LOCATION;
    command[0]=50;
    command[1]=6;
    command[2]=6;
    iap_entry (command, result);

    command[0]=52;
    command[1]=6;
    command[2]=6;
    command[3]=12000;
    iap_entry (command, result);
  

    command[0]=50;
    command[1]=6;
    command[2]=6;
    iap_entry (command, result);

    iap_entry=(IAP) IAP_LOCATION;

    command[0]=51;
    command[1]=(unsigned long)0x00001800;
    command[2]=(unsigned long)&iap;
    command[3]=256;
    command[4]=8000;
    iap_entry (command, result);

    command[0]=53;
    command[1]=5;
    command[2]=5;//0x00027fff;
    command[3]=0;
    command[4]=0;
    iap_entry (command, result);

   &res = (unsigned long)0x00001800;


How can I read data from my flash memory?!
0 Kudos

372 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by salamlora1 on Fri Mar 14 21:58:28 MST 2014
Hi
I have the same problem and solve it in the lpc2138 you can check it in the address below  :-D
http://www.lpcware.com/content/forum/iap-problem-lpc2138
Also I have a project with lpc812 and I’m working on IAP wen its finish I will post it
0 Kudos

372 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Fri Mar 14 08:31:13 MST 2014
Difficult question.

First of all, FLASH write access must be done with the size and alignment of a page.

If by 'variable' you mean an initialized (by the startup code) variable - a variable deposited in the section .data - then there's no need to read the FLASH, as the startup code has already done for you before handing over control to your main() .

The initialization values of the .data section are stored in FLASH. You have to look into your linker script and find the start of the initialization data of the .data section. Let's assume, you find it named '__data_image'. You'll recognize it by a statement
__data_image = . ;
in the linker script.
Then you can pretend in C code...

extern char __data_image;

...that a char is located at __data_image. &__data_image is then the address of the .data section's initialization image.

You can do the same with the start of .data, something like __data_start will be defined somewhere in the linker script.

extern char __data_start;

If your variable is named 'var', then offset = (char*)&var - &__data_start is the (byte) offset of var inside .data what is the same as the offset of the initialization value for var in the initialization image. Hence, var's FLASH address is &__data_image + offset . This is the address you're interested in.
Depending on your compilation environment, the values for &__data_start and &__data_image (or similar names) are handed to you on a silver platter  ;-)

But to be honest, I would not do it that way. It's much easier to put all your state + a magic number in a structure called state and read that structure from FLASH at program startup (inside main()) and write that state structure to FLASH on demand. As address, choose a FLASH sector/page your program doesn't use so far. That way, you don't need to know such details as described above.

EDIT: added missing '&'
0 Kudos