DolphinV4 API  1.6.1.0
Flash architecture

The flash memory size is 64kB and it can used for both program and data storage. The flash is organised in pages of 512 bytes which results in 128 pages. The smallest block that can be erased is 1 page = 512 bytes. A freshly erased page contains all their bytes initialised to 0xFF. Any location within the page can be written. However, once one bit has been written (either to 1 or 0), only the erasure of the whole page enables the possibility of writing the same bit location again. Failing to do so the data consistency of the the flash can't be ensured!

The flash memory is organised into two parts:

  • Program Area: code 0x0000 - 0x0xFBFF (126 pages - 64 512 bytes)
    Flash area containing program and data information.
  • Smart Ack Data: code 0x0xFA00 - 0x0xFBFF (1 page - 512 bytes)
    Flash area containing non volatile information about smart ack data.
  • Configuration area (CFG): code 0x0xFC00 - 0x0xFDFF (1 page - 512 bytes)
    Flash area containing the application configuration parameters. For more information about this area read the Configuration area (CFG) chapter.
  • Software information area (SWI)): code 0x0xFE00 - 0x0xFFFF (1 page - 512 bytes)
    Flash area containing the SW version number and application name. For more information about this area read the Software information area (SWI) chapter.
  • Chip information area (INF)): xdata 0x0xFC00 - 0x0xFDFF (1 page - 512 bytes)
    Flash area containing the chip specific information like the chip ID, testing lot, etc. For more information about this area read the Module configuration area (MOD) chapter.
  • Module configuration area (MOD)): xdata 0x0xFE00 - 0xFFFF (1 page - 512 bytes)
    Flash area containing the chip calibration values from the chip factory. For more information about this area read the Module configuration area (MOD) chapter.
flash_architecture.png
FLASH architecture

Flash Build In Self Test (BIST)
The Dolphin platform contains a Flash Built In Self Test (BIST) logic. It is useful to verify the program and static data integrity in the flash. The FLASH region on which the BIST integrity check is executed is defined by the user upon compilation time. It is recommended to exclude parts of the flash where dynamic data is stored - i.e. data that keeps changing during application execution. The BIST CRC value is stored as the last byte of the last page of the BIST region. EOPX2 Postbuild Tool saves the program size in pages to the u8PrgSize variable in SWI_AREA.val.u8PrgSize. The following figure shows how is the BIST structured in the flash.

flash_bist.PNG

To calculate the program BIST the compiled hex file generated with Keil has to be patched using the EOPX2 postbuild tool. For this purpose the following steps have to be executed:

  • Put the setBist command to the postbuild.txt file
  • The setBist command aligns the program area hex file to the 256 page boundary and adds as the last byte a CRC value to the hex file and stores the program size value to the CFG file
  • To activate a BIST from the application use the function mem_flashBist
  • For more information read the DolphinStudio manual EOPX2 section, see References

If you the application have predefined constants in your data area (specified by the BL51 linker and a constant object file) the IntelHex file contains these values. In such case the EOPX2 postbuild tool needs to differentiate between the program and data part in the IntelHex file. This can be done by defining the object of the constant in the postbuild.txt. Use the setBist FLASH_DATA2_MOD - where FLASH_DATA2_MOD is the object where the constants are stored. EOPX2 postbuild will parse the MAP file of the linker to determine where the data starts and program finishes. As an example see the TCM300 source code.

The following example explains how the <setBist> operates:

  • if the compiled program size is 256 byte - after patching it with EOPX2 postbuild tool - it will require 512 bytes (2 pages) in the flash (from 0x0000 - 0x01FF)
  • the last byte of the downloaded code will be the CRC value (at address 0x01FF) used for the BIST
  • the reason to increase the program size to 512 byte is to store the CRC in the last byte of the last used page without overwriting any program code. Therefore EOPX2 postbuild tool reserves another page
  • the flash area beyond the program can be used for data storage.
flash_bist_example.PNG

Code Protection Bit
The Program and Data area can be protected against readout with the Codeprotection bit (CFG_AREA is not affected by code protection bit and can always be read). When this bit is set the FLASH program can't be read with an extern programmer. To delete this bit the Program-Data area has to be erased. For more information about the Codeprotection bit please read the DolphinStudio manual.

Note:
You can access the FLASH memory using the mem module functions.
Read chapter Setting up Keil uVision for DolphinV4 Suite DolphinV4APIConfigurator and EOPX2 to see how to configure the Postbuild tools to work with Keil uVision.