Content originally posted in LPCWare by efiLabs on Sat May 10 22:49:36 MST 2014
hi Fernando :
i'm not quite sure if i follow all your details, but regardless of it, there are a few rules.
1) while writing the internal flash, regardless of the method and there is only one, IAP, the flash can not be used. period.
2) what this means is that the code fetching the image, wherever it comes from and the code making the IAP calls to write it, can not reside in the internal flash you are writing. also any constant data or whatever you use can not be in this internal flash.
3) options for the code space for handling the operation in item 2 will most likely be internal ram or other resources if the 1778 allows external memory execution access.
as long as you don't split your binary image into 2 parts i.e. boot loader and application program, the process of fetching the image (in small portions) and writing into flash can not be interrupted, otherwise you might need to re-image with ISP.
so what you do is, have the program portion which will execute in ram be placed in your flash image, have it compiled for the ram execution space, or in relocatable fashion if your compiler supports it ... and when you're ready to flash your new image, move this flash-loader from flash to ram and call it and once the flashing is done reset the cpu or jump to the reset vector. or wherever you want to jump (call) to in the new image.
have your interrupts disabled or the vector table access also relocated to a ram based ivect table
hopefully this short description helps ... think it over and envision, while writing, or erasing the internal flash you can not access it ... ergo execute the flash write portion, whatever it entails from a different memory address space ... where does this not flash resident portion of the code come from, most likely as an image embedded in the flash where you move it into ram before using (executing) it.
cheers, efiLabs