Presentation is loading. Please wait.

Presentation is loading. Please wait.

1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting.

Similar presentations


Presentation on theme: "1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting."— Presentation transcript:

1

2 1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting custom flash configurations Flash API example application

3 Multiple Flash Memory Banks Multiple flash memory banks must be “continuously addressable” NET+ARM board has 2 banks of flash memory Modify the BSP_FLASH_BANKS constant in bspconf.h to inform flash driver of the configured flash memory banks. FBANK1 and FBANK2 switches on the NET+ARM board must be set accordingly

4 New Flash API NAFlashBase() NAFlashEnable() NAFlashInit() NAFlashCreateSemaphores() NAFlashSectors() NAFlashSectorSizes() NAFlashSectorOffsets() NAFlashErase() NAFlashEraseStatus() NAFlashRead() NAFlashWrite()

5 NAFlashBase() unsigned short * NAFlashBase(); Retrieves the flash memory base address

6 NAFlashEnable() void NAFlashEnable(); Enables flash memory so it can be read.

7 NAFlashInit() int NAFlashInit(unsigned long flashBanks); Enables the flash memory so it can be read. Sets the number of flash memory banks. Called by the startup or initialization code ONCE after power up.

8 NAFlashCreateSemaphores() int NAFlashCreateSemaphores(); Creates the semaphores to synchronize access to the flash driver API functions. Called by the user application ONCE after power up. NAFlashWrite(), NAFlashRead(), NAFlashErase(), NAFlashEraseStatus() are semaphore protected.

9 NAFlashSectors() int NAFlashSectors(); Retrieves the number of physical sectors for the flash memory configuration. In single bank 16 or 32 bit configurations, the number of physical sectors returned is identical. In multiple bank configurations, the number of sectors returned is a multiple of the physical sectors for the flash memory part.

10 NAFlashSectorSizes() int NAFlashSectorSizes (unsigned long * sectorSizeArray); Retrieves the physical sector sizes for the flash memory configuration. Should be called after NAFlashSectors(), so an appropriately sized array is passed to the function to store the sector size data. In 16 bit mode, the sector sizes are the sector sizes of one flash part. In 32 bit mode, the sector sizes are twice the sector sizes of one flash part (since two flash parts are accessed per I/O cycle).

11 NAFlashSectorOffsets() int NAFlashSectorOffsets (unsigned long * sectorOffsetArray); Retrieves the flash “sector offsets” from flash “base address” in bytes. Should be called after NAFlashSectors(), so an appropriately sized array is passed to the function to store the sector offset data.

12 NAFlashErase() int NAFlashErase(unsigned long firstSectorNumber, unsigned long lastSectorNumber); Erases the specified range of flash sectors.

13 NAFlashEraseStatus() int NAFlashEraseStatus (unsigned long firstSectorNumber, unsigned long lastSectorNumber, char * status); Checks the erase status of the specified range of flash sectors. Sector erase status is retrieved through the "status" argument. If the array element accessed through “status” is 0, the corresponding sector is not erased; otherwise, if the array element accessed through “status” is 1, the corresponding sector is erased.

14 NAFlashEraseStatus() (continued) For example, a flash part with 19 sectors is indexed from 0 to 18. To check the status of sectors 3 to 7, do NAFlashEraseStatus(3, 7, status) where "status" is an array of 5 elements (i.e. char status[5]), and the erase status of sector "firstSectorNumber" is stored in status[0]. If a char array of 19 elements (i.e. char status[19]) is used, and the erase status of sectors 3 to 7 is needed, do NAFlashEraseStatus(3, 7, &status[3]), and the erase status of sector "firstSectorNumber" is stored in status[firstSectorNumber].

15 NAFlashRead() int NAFlashRead(unsigned long sectorNumber, unsigned long sectorOffset, unsigned long bytesToRead, char * buffer); Reads data starting from a specified sector number and offset location and stores it in a buffer. This routine allows reading: One or more consecutive sectors (including the entire flash memory). Partial sectors. Any combination of the above.

16 NAFlashWrite() int NAFlashWrite(unsigned long sectorNumber, unsigned long sectorOffset, unsigned long bytesToWrite, char * buffer, char options); Writes data starting from a specified sector number and offset location. This routine allows writing: One or more consecutive sectors (including the entire flash memory) Partial sectors Any combination of the above

17 NAFlashWrite() (continued) The “options” argument specifies the advanced write options: ERASE_AS_NEEDED Full sector write - Erases the sector (if it is not erased) before writing new data. Partial sector write - Updates new data to the sector, but does not destroy the rest of the sector data. ALWAYS_ERASE Full sector write - Erases the sector before writing new data.

18 NAFlashWrite() (continued) Partial sector write - Updates new data to the sector, but erases the rest of the sector data. DO_NOT_ERASE Full sector write - Writes new data to the sector without first erasing the sector. If writing to the sector changes a bit from 0 to 1, the function returns an error. Partial sector write - Writes new data to the sector without first erasing the sector. If writing to the sector changes a bit from 0 to 1, the function returns an error.

19 Custom Flash Configurations Modify 3 constants in flash.h MAX_SECTORS - Maximum number of flash sectors supported. Increase value to support flash parts with a larger sector count. MAX_SECTOR_SIZE - Maximum sector size supported. Increase value to support flash parts with a larger sector size. MAX_FLASH_BANKS - Maximum flash memory banks supported. Increase value to support a larger number of flash banks.

20 Flash Example Application \netosx\src\examples\naflash Allows accessing up to 4MB in 32 bit mode on the standard NET50 board. Automatically adjusts MASK bits on CS0 option register to access amount of flash memory configured. Allows reading / writing entire flash memory 1 byte per NAFlashRead() / NAFlashWrite() call to reading / writing 4MB with one NAFlashRead() / NAFlashWrite() call.


Download ppt "1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting."

Similar presentations


Ads by Google