Can somebody help me with documentation about IAP? I want to replace program on chip flash without botstrap mode. Microcontroller is connected with external device by data link and will receive programing data by it. I've read in Infineon Insider's Guide that "It is also possible for a program to reprogram itself, i.e. receive a new version of itself and blow it into FLASH. This requires a specially written C function, which can be downloaded from the Infineon website" but havn't found it. How to make IAP?
What is the name of file that you are looking for? I would contend it is not a file but a separate program that you are looking for. You generally create separate "boot" program which is responsible to bring up the device and contains the flash/communication routines. You perform a checksum (CRC) over the application sectors and if valid then jump to the application code. If the result is invalid then you enter a diagnostic/limp mode. Depending on the security level you want then you would allow to change the application code. Generally the "boot" program is programmed at your manufacturing site and is never allowed to be programmed in the field. Only the application code is allowed to be changed in the field. This strategy would prevent the module from becoming brain dead if there is a problem to update the application code (power loss while updating for example).
I want to use PSRAM to execute small part of the program which will get data by SPI from master device and program it to Flash. But I can't find clear indtructions how to do it.
Here is a link to XC16x In-Application On-Chip Flash Programming. http://www.keil.com/download/docs/275.asp Once you receive a command via the SPI to update your application memory. You need to follow the example to load the code in PSRAM and then call the functions to perform the flash updates. I would recommend that you add a check to make sure you don't allow reprogramming of your boot sector (or protect it). Also consider while updating the Flash… If you want to allow SPI communication If you want to allow interrupts (if so then vector location) Verification after each flash operation to make sure you had no errors Software reset when finished to restart the application.
Can I do it without boot program? I want only to replace my old program with new HEX file at all (like JTAG programming - only to place it in FLASH). I think to replace it with routines previously loaded into PSRAM from FLASH (current program which will be replaced next).
Yes, this is possible as it is up to you to implement it.
In Application Programming Reference: XC16X_IAP-FLASH.ZIP Hex file loads to RAM OK Checksum OK Programming Routines for PFlash copy to RAM OK Jump to RAM OK (CSP Register reports that program is running from RAM) Erase Program Flash Sector 0xC00000 causes program to stop! This code was working, but is not now. Other functions were added to another section of code, making it larger, but can not find anything that is being over-written. I can erase unused PFlash without error so I know the flash routines are good. Any ideas?
Never Mind! As usual, 5 minutes after posting a question here I figure it out for myself. I had left an interrupt timer on!
But can I decline of using PSRAM? And replace only part of my program in FLASH(I wrote about it in other topic..but didn't get an answer). My idea is to separate my program into 2 HEX files - mathematic and service function - to provide in-application reprogramming only of mathematic functions (separatly compiled) with service function. Can I do it within one project? Are there any examples of such applications? I'm not so big connoisseur in programming yet)
The XC16x family does not support reprogramming of the flash while executing out of the flash (there is only one flash module). This means the routines to change the flash must execute from another type of memory. This leaves the PSRAM, JTAG or external memory (no other choice). Yes, I believe it is possible to do what you want. You could use section or class controls to locate the code in the expected address ranges. Then you could use the "SAVE" command in uVision to split your hex files into different address ranges (as an example).
The XC16x family does not support reprogramming of the flash while executing out of the flash (there is only one flash module). This means the routines to change the flash must execute from another type of memory. This leaves the PSRAM, JTAG or external memory (no other choice). But I can reprogram 128 bytes in flash while executing from another sector of same flash. Or I not correctly understand what you mean? I think that it is possible to reprogram part of flash with new code. But I not understand entirely how to manage two HEX files and function calls between them if they will be compiled separetly. May be there is some examples about it?
My statement is incorrect; as you stated you can program out of the flash but during the actual execution of the program/erase algorithm flash read accesses are stalled. Maybe I miss what you are trying to do or why? Since I don't know really what your goal is to know all of the caveats, one idea is that you could make a function pointer table at the start of your math code or at an absolute address (which the structure is known to your other code, basically you need to know what is valid). Then your other code would read the data at the absolute address to fill its structure and then make a call using this information. Does this help you?
Thanks for help a lot! My goal is to separate my application into two HEX files which will be separetly downloaded to target. But first program must to know pointers to functions (to call math functions) which are in second HEX file. So, you said that idea is to store pointers in second HEX file and to read it from first. I thought that it is not so uncommon task.