EVM6418 Flash Module
The FLASH API provides functions to erase as well as read and write from the on-board Flash memory. Programming errors can be detected through use of a checksum function.
The Flash is divided into eight logical pages which must be erased before being re-programmed. After being erased, locations withing the page can be programmed in any order. However, each location can only be programmed once per erasure.
The following list summarizes the FLASH API in terms of its function calls:
Programs that use the FLASH API should include both the evm6418.h and the evm6418_flash.h BSL header files. evm6418_flash.h defines several constants that may be useful while programming:
| Name |
Typical Value |
Description |
| EVM6418_FLASH_BASE |
0x90000000 |
Address of start of Flash memory |
| EVM6418_FLASH_PAGESIZE |
0x8000 |
Size of Flash page |
| EVM6418_FLASH_PAGES |
8 |
Number of Flash pages |
| EVM6418_FLASH_SIZE |
0x40000 |
Total size of Flash |
| EVM6418_FLASH_SUPPORT |
1 |
1 if Flash is supported on this target, 0 if not |
EVM6418_FLASH_checksum()
Description
Calculate the checksum of a data range in Flash. The checksum is the unsigned sum of all 8-bit bytes in the range. If the sum is exceeds 0xFFFFFFFF it wraps around at 32-bits. The sum is returned as a single 32-bit value.
Required Headers
evm6418.h
evm6418_flash.h
Required Libraries
evm6418bsl.lib
Function Prototype
Uint32 EVM6418_FLASH_checksum( Uint32 start, Uint32 length )
Parameters
start - Beginning of region to checksum. Given as an integral number of 8-bit bytes.
length - Length of memory to checksum. Given as an integral number of 8-bit bytes.
Return Value
32-bit checksum that is generated by adding all the bytes in the Flash range
Example
Uint32 checksum;
/* Calculate checksum for first page sector of Flash */
checksum = EVM6418_FLASH_checksum(EVM6418_FLASH_BASE,
EVM6418_FLASH_SECTORSIZE);
EVM6418_FLASH_erase()
Description
Erase a range of Flash memory.
Required Headers
evm6418.h
evm6418_flash.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_FLASH_erase( Uint32 start, Uint32 length )
Parameters
start - Beginning of region to erase. Given as an integral number of 8-bit bytes.
length - Length of region to erase. Given as an integral number of 8-bit bytes.
Return Value
None
Example
/* Erase the first 2 sectors of the Flash */
EVM6418_FLASH_erase(EVM6418_FLASH_BASE,
(Uint32)(EVM6418_FLASH_SECTORSIZE * 2));
/* Erase the current Flash page */
EVM6418_FLASH_erase(EVM6418_FLASH_BASE,
EVM6418_FLASH_PAGESIZE);
EVM6418_FLASH_read()
Description
Read data from a range in Flash
Required Headers
evm6418.h
evm6418_flash.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_FLASH_read(Uint32 src, Uint32 dst, Uint32 length)
Parameters
src - Address of Flash to read from. Given as an integral number of 8-bit bytes.
dst - Address to memory to read to. Given as an integral number of 8-bit bytes.
length - Length of memory to read from. Given as an integral number of 8-bit bytes.
Return Value
None
Example
Uint8 buffer[256];
/* Copy 256 16-bit words from the
* beginning of the Flash to buf */
EVM6418_FLASH_read( EVM6418_FLASH_BASE, (Uint32)buffer, 256);
EVM6418_FLASH_write()
Description
Write data to a data range in Flash. The Flash must be erased first.
Required Headers
evm6418.h
evm6418_flash.h
Required Libraries
evm6418bsl.lib
Function Prototype
void EVM6418_FLASH_write(Uint32 src, Uint32 dst, Uint32 length)
Parameters
src - Address of memory to read from. Given as an integral number of 8-bit bytes.
dst - Address to Flash to write to. Given as an integral number of 8-bit bytes.
length – Length of memory to write to. Given as an integral number of 8-bit bytes.
Return Value
None
Example
Uint8 buffer[256];
/* Copy 256 8-bit bytes from buf
* to the beginning of Flash */
EVM6418_FLASH_write((Uint32)buffer, EVM6418_FLASH_BASE, 256);
|