1
NXPTM M522XX, KINETIS and i.MX RT / FLASH blocks
« on: July 20, 2007, 08:32:22 PM »
I have just one more piece of the puzzle to understand: writing data to the flash.
As I understand it, if I wanted to write just 1 byte to flash I first need to erase the entire block in-which that 1 byte is found. How large is the size of the block that must be erased? So to write 1 byte would require me to save and entire block to RAM, modify the 1 byte in RAM, erase the entire block on FLASH, then write the entire block from RAM to FLASH, right?
I've so far been looking at fnEraseFlashSector() and fnWriteBytesFlash(). These are great, but I'll need to know the block size in order to use them correctly. I'm guessing uTasker probably has some functions and/or defines that make this easier?
Looking at uTasker's fnEraseFlashSector() it would appear that 1 flash block is 0x1000 bytes (given that the address is ANDed with ~0x3. But looking through the code that comes with Freescale's dBUG program there is a define in cfm_flash.h that appears as though the block size is 0x800. I guess there's a fair amount of confusion because different texts refer to "block page size", "block sector size", "flash block size", "flash logical block size", ...and several more permutations on what may or may not be the same concept.
I've been playing around with fnEraseFlashSector() and fnWriteBytesFlash() and can see that I can modify bytes of FLASH, but without understanding everything that is going on I can't use them effectively.
As I understand it, if I wanted to write just 1 byte to flash I first need to erase the entire block in-which that 1 byte is found. How large is the size of the block that must be erased? So to write 1 byte would require me to save and entire block to RAM, modify the 1 byte in RAM, erase the entire block on FLASH, then write the entire block from RAM to FLASH, right?
I've so far been looking at fnEraseFlashSector() and fnWriteBytesFlash(). These are great, but I'll need to know the block size in order to use them correctly. I'm guessing uTasker probably has some functions and/or defines that make this easier?
Looking at uTasker's fnEraseFlashSector() it would appear that 1 flash block is 0x1000 bytes (given that the address is ANDed with ~0x3. But looking through the code that comes with Freescale's dBUG program there is a define in cfm_flash.h that appears as though the block size is 0x800. I guess there's a fair amount of confusion because different texts refer to "block page size", "block sector size", "flash block size", "flash logical block size", ...and several more permutations on what may or may not be the same concept.
I've been playing around with fnEraseFlashSector() and fnWriteBytesFlash() and can see that I can modify bytes of FLASH, but without understanding everything that is going on I can't use them effectively.