This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Moving data within Flash

Hi,

Looking at pstorage related code, it appears that it handles data copy from RAM to Flash.

Can I use pstorage functions to move data within Flash? I want to implement an array of structures such that if an in between entry is deleted, the subsequent entries are shifted up to remove the hole within the array.

If the answer is yes, can I use the pstorage functions to move data within a Flash page (ie. pSrc and pDest lie in the same Flash page)?

If no, can you suggest how I can do that? I do not want to use RAM while shifting data within Flash.

Thanks, Sam

  • I can't see any reason you cannot copy flash to flash.

    The flash writes stall the CPU, but that does not matter.

    The ARM cores cannot write directly from any memory to any memory, they load the data into a register first.

    ie.

    a = b

    becomes

    load a into register

    store register into b

    This means all flash writes ultimately become a store command and it really does not matter where the data comes from.

    ie. it should be just the same to store the data from RAM, flash, serial port,...

  • Hi Charles,

    Thanks a lot for the information. I agree that moving data within Flash is possible.

    My question is mostly about if/how pstorage functions can be used to achieve that especially if the data size is large (spanning multiple pages)? If I look at pstorage_update(), it doesn't seem to consider the possibility of pSrc lying in Flash and of data size spanning multiple pages. If pSrc lies in Flash, the swap page usage could get tricky if pDest and pSrc lie within the same page. In that case, one may need to maintain 2 swap pages for tracking the data source and data destination locations during the copy procedure.

    Is there an easy way to move large chunk of data from one location in Flash to another location within Flash?

    Your insights are most welcome!

    Thanks, Sam

Related