Flash API - PowerPoint PPT Presentation

About This Presentation
Title:

Flash API

Description:

Sector erase status is retrieved through the 'status' argument. ... Full sector write - Writes new data to the sector without first erasing the sector. ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 20
Provided by: jac81
Category:
Tags: api | erasing | flash

less

Transcript and Presenter's Notes

Title: Flash API


1
Flash API
  • Multiple flash memory bank support
  • New Flash API introduction
  • Detailed Flash API Function presentation
  • Supporting custom flash configurations
  • Flash API example application

NETOS Software Group
2
Multiple Flash Memory Banks
  • Multiple flash memory banks must be continuously
    addressable
  • NETARM 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 NETARM board
    must be set accordingly

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

4
NAFlashBase()
  • unsigned short NAFlashBase()
  • Retrieves the flash memory base address

5
NAFlashEnable()
  • void NAFlashEnable()
  • Enables flash memory so it can be read.

6
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.

7
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.

8
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.

9
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).

10
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.

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

12
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.

13
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 status5),
    and the erase status of sector "firstSectorNumber"
    is stored in status0.
  • If a char array of 19 elements (i.e. char
    status19) is used, and the erase status of
    sectors 3 to 7 is needed, do NAFlashEraseStatus(3,
    7, status3), and the erase status of sector
    "firstSectorNumber" is stored in
    statusfirstSectorNumber.

14
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.

15
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

16
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.

17
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.

18
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.

19
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.
Write a Comment
User Comments (0)
About PowerShow.com