API Documentation

enum SPIFlashMode

Values:

enumerator MODE_QIO
enumerator MODE_QOUT
enumerator MODE_DIO
enumerator MODE_DOUT
enumerator MODE_FAST_READ
enumerator MODE_SLOW_READ
enumerator MODE_QIO
enumerator MODE_QOUT
enumerator MODE_DIO
enumerator MODE_DOUT
enumerator MODE_SLOW_READ

Not supported.

enumerator MODE_FAST_READ

Not supported.

enumerator MODE_QIO
enumerator MODE_QOUT
enumerator MODE_DIO
enumerator MODE_DOUT
enumerator MODE_SLOW_READ

Not supported.

enumerator MODE_FAST_READ

Not supported.

enum SPIFlashSpeed

Values:

enumerator SPEED_40MHZ
enumerator SPEED_26MHZ
enumerator SPEED_20MHZ
enumerator SPEED_80MHZ
enumerator SPEED_40MHZ
enumerator SPEED_26MHZ
enumerator SPEED_20MHZ
enumerator SPEED_80MHZ
enumerator SPEED_40MHZ
enumerator SPEED_26MHZ
enumerator SPEED_20MHZ
enumerator SPEED_80MHZ
enum SPIFlashSize

Values:

enumerator SIZE_1MBIT
enumerator SIZE_2MBIT
enumerator SIZE_4MBIT
enumerator SIZE_8MBIT
enumerator SIZE_16MBIT
enumerator SIZE_32MBIT

Not listed.

enumerator SIZE_4MBIT
enumerator SIZE_2MBIT
enumerator SIZE_8MBIT
enumerator SIZE_16MBIT
enumerator SIZE_32MBIT
enumerator SIZE_1MBIT

Not supported.

enumerator SIZE_4MBIT
enumerator SIZE_2MBIT
enumerator SIZE_8MBIT
enumerator SIZE_16MBIT
enumerator SIZE_32MBIT
enumerator SIZE_1MBIT

Not supported.

uint32_t flashmem_write_internal(const void *from, uint32_t toaddr, uint32_t size)

write to flash memory

Note

All parameters MUST be aligned to 4-byte word boundaries, including the RAM pointer

Parameters:
  • from – Buffer to read data from - MUST be word-aligned

  • toaddr – Flash address (offset) to write to - MUST be word-aligned

  • size – Number of bytes to write - MUST be word-aligned

Return values:

uint32_t – Number of bytes actually written

uint32_t flashmem_read_internal(void *to, uint32_t fromaddr, uint32_t size)

Read from flash memory.

Note

All parameters MUST be aligned to 4-byte word boundaries, including the RAM pointer

Parameters:
  • to – Buffer to store data - MUST be word-aligned

  • fromaddr – Flash address (offset) to read from - MUST be word-aligned

  • size – Number of bytes to read - MUST be word-aligned

Return values:

uint32_t – Number of bytes actually read

flash_addr_t flashmem_get_address(const void *memptr)

Obtain the flash memory address for a memory pointer.

Note

If memptr is not in valid flash memory it will return an offset which exceeds the internal flash memory size.

Note

The flash location is dependent on where rBoot has mapped the firmware.

Parameters:

memptr

Return values:

flash_addr_t – Offset from start of flash memory

uint32_t flashmem_write(const void *from, flash_addr_t toaddr, uint32_t size)

Write a block of data to flash.

Note

None of the parameters need to be aligned

Parameters:
  • from – Buffer to obtain data from

  • toaddr – Flash location to start writing

  • size – Number of bytes to write

Return values:

uint32_t – Number of bytes written

uint32_t flashmem_read(void *to, flash_addr_t fromaddr, uint32_t size)

Read a block of data from flash.

Note

none of the parameters need to be aligned

Parameters:
  • to – Buffer to store data

  • fromaddr – Flash location to start reading

  • size – Number of bytes to read

Return values:

uint32_t – Number of bytes written

bool flashmem_erase_sector(flash_sector_t sector_id)

Erase a single flash sector.

Parameters:

sector_id – the sector to erase

Return values:

true – on success

SPIFlashInfo flashmem_get_info(void)

Get flash memory information block.

Return values:

SPIFlashInfo – Information block

SPIFlashSize flashmem_get_size_type(void)

Returns a number indicating the size of flash memory chip.

Return values:

SPIFlashSize

flash_addr_t flashmem_get_size_bytes(void)

get the total flash memory size

Return values:

flash_addr_t – Size in bytes

flash_sector_t flashmem_get_size_sectors(void)

Get the total number of flash sectors.

Return values:

uint16_t – Sector count

flash_sector_t flashmem_find_sector(flash_addr_t address, flash_addr_t *pstart, flash_addr_t *pend)

Helper function: find the flash sector in which an address resides.

Note

Optional parameters may be null

Parameters:
  • address

  • pstart – OUT/OPTIONAL: Start of sector containing the given address

  • pend – OUT/OPTIONAL: Last address in sector

Return values:

flash_sector_t – Sector number for the given address

flash_sector_t flashmem_get_sector_of_address(flash_addr_t addr)

Get sector number containing the given address.

Parameters:

addr

Return values:

flash_sector_t – sector number

inline uint32_t flashmem_get_first_free_block_address(void)
uint32_t spi_flash_get_id(void)
INTERNAL_FLASH_SECTOR_SIZE
INTERNAL_FLASH_START_ADDRESS
INTERNAL_FLASH_WRITE_UNIT_SIZE
INTERNAL_FLASH_READ_UNIT_SIZE
FLASH_TOTAL_SEC_COUNT
struct SPIFlashInfo
#include <flashmem.h>

SPI Flash memory information block.