API Documentation

enum spi_flash::SPIFlashMode

Values:

MODE_QIO = 0
MODE_QOUT = 1
MODE_DIO = 2
MODE_DOUT = 15
MODE_SLOW_READ = 0xFE

Not supported.

MODE_FAST_READ = 0xFF

Not supported.

MODE_QIO = ESP_IMAGE_SPI_MODE_QIO
MODE_QOUT = ESP_IMAGE_SPI_MODE_QOUT
MODE_DIO = ESP_IMAGE_SPI_MODE_DIO
MODE_DOUT = ESP_IMAGE_SPI_MODE_DOUT
MODE_FAST_READ = ESP_IMAGE_SPI_MODE_FAST_READ
MODE_SLOW_READ = ESP_IMAGE_SPI_MODE_SLOW_READ
enum spi_flash::SPIFlashSpeed

Values:

SPEED_40MHZ = 0
SPEED_26MHZ = 1
SPEED_20MHZ = 2
SPEED_80MHZ = 15
SPEED_40MHZ = ESP_IMAGE_SPI_SPEED_40M
SPEED_26MHZ = ESP_IMAGE_SPI_SPEED_26M
SPEED_20MHZ = ESP_IMAGE_SPI_SPEED_20M
SPEED_80MHZ = ESP_IMAGE_SPI_SPEED_80M
enum spi_flash::SPIFlashSize

Values:

SIZE_4MBIT = 0
SIZE_2MBIT = 1
SIZE_8MBIT = 2
SIZE_16MBIT = 3
SIZE_32MBIT = 4
SIZE_1MBIT = 0xFF

Not supported.

SIZE_1MBIT = ESP_IMAGE_FLASH_SIZE_1MB
SIZE_2MBIT = ESP_IMAGE_FLASH_SIZE_2MB
SIZE_4MBIT = ESP_IMAGE_FLASH_SIZE_4MB
SIZE_8MBIT = ESP_IMAGE_FLASH_SIZE_8MB
SIZE_16MBIT = ESP_IMAGE_FLASH_SIZE_16MB
SIZE_32MBIT = 0xFF

Not listed.

enum spi_flash::SPIFlashMode

Values:

MODE_QIO = 0
MODE_QOUT = 1
MODE_DIO = 2
MODE_DOUT = 15
MODE_SLOW_READ = 0xFE

Not supported.

MODE_FAST_READ = 0xFF

Not supported.

MODE_QIO = ESP_IMAGE_SPI_MODE_QIO
MODE_QOUT = ESP_IMAGE_SPI_MODE_QOUT
MODE_DIO = ESP_IMAGE_SPI_MODE_DIO
MODE_DOUT = ESP_IMAGE_SPI_MODE_DOUT
MODE_FAST_READ = ESP_IMAGE_SPI_MODE_FAST_READ
MODE_SLOW_READ = ESP_IMAGE_SPI_MODE_SLOW_READ
enum spi_flash::SPIFlashSpeed

Values:

SPEED_40MHZ = 0
SPEED_26MHZ = 1
SPEED_20MHZ = 2
SPEED_80MHZ = 15
SPEED_40MHZ = ESP_IMAGE_SPI_SPEED_40M
SPEED_26MHZ = ESP_IMAGE_SPI_SPEED_26M
SPEED_20MHZ = ESP_IMAGE_SPI_SPEED_20M
SPEED_80MHZ = ESP_IMAGE_SPI_SPEED_80M
enum spi_flash::SPIFlashSize

Values:

SIZE_4MBIT = 0
SIZE_2MBIT = 1
SIZE_8MBIT = 2
SIZE_16MBIT = 3
SIZE_32MBIT = 4
SIZE_1MBIT = 0xFF

Not supported.

SIZE_1MBIT = ESP_IMAGE_FLASH_SIZE_1MB
SIZE_2MBIT = ESP_IMAGE_FLASH_SIZE_2MB
SIZE_4MBIT = ESP_IMAGE_FLASH_SIZE_4MB
SIZE_8MBIT = ESP_IMAGE_FLASH_SIZE_8MB
SIZE_16MBIT = ESP_IMAGE_FLASH_SIZE_16MB
SIZE_32MBIT = 0xFF

Not listed.

uint32_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 Value
  • uint32_t: Offset from start of flash memory

uint32_t flashmem_write(const void *from, uint32_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 Value
  • uint32_t: Number of bytes written

uint32_t flashmem_read(void *to, uint32_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 Value
  • uint32_t: Number of bytes written

bool flashmem_erase_sector(uint32_t sector_id)

Erase a single flash sector.

Parameters
  • sector_id: the sector to erase

Return Value
  • true: on success

SPIFlashInfo flashmem_get_info()

Get flash memory information block.

Return Value

uint8_t flashmem_get_size_type()

Returns a number indicating the size of flash memory chip.

Return Value
  • uint8_t: See SpiFlashInfo.size field for possible values

uint32_t flashmem_get_size_bytes()

get the total flash memory size

Return Value
  • uint32_t: Size in bytes

uint16_t flashmem_get_size_sectors()

Get the total number of flash sectors.

Return Value
  • uint16_t: Sector count

uint32_t flashmem_find_sector(uint32_t address, uint32_t *pstart, uint32_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 Value
  • uint32_t: Sector number for the given address

uint32_t flashmem_get_sector_of_address(uint32_t addr)

Get sector number containing the given address.

Parameters
  • addr:

Return Value
  • uint32_t: sector number

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 Value
  • 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 Value
  • uint32_t: Number of bytes actually read

uint32_t flashmem_get_first_free_block_address()
INTERNAL_FLASH_WRITE_UNIT_SIZE

Flash memory access must be aligned and in multiples of 4-byte words.

INTERNAL_FLASH_READ_UNIT_SIZE
FLASH_TOTAL_SEC_COUNT
SYS_PARAM_SEC_COUNT

Number of flash sectors reserved for system parameters at start.

FLASH_WORK_SEC_COUNT
INTERNAL_FLASH_SECTOR_SIZE
INTERNAL_FLASH_SIZE
INTERNAL_FLASH_START_ADDRESS
SPI_FLASH_RESULT_OK
INTERNAL_FLASH_WRITE_UNIT_SIZE

Flash memory access must be aligned and in multiples of 4-byte words.

INTERNAL_FLASH_READ_UNIT_SIZE
FLASH_TOTAL_SEC_COUNT
SYS_PARAM_SEC_COUNT

Number of flash sectors reserved for system parameters at start.

FLASH_WORK_SEC_COUNT
INTERNAL_FLASH_SECTOR_SIZE
INTERNAL_FLASH_SIZE
struct STORE_TYPEDEF_ATTR
#include <esp_spi_flash.h>

SPI Flash memory information block. Stored at the beginning of flash memory.

struct SPIFlashInfo
#include <esp_spi_flash.h>

SPI Flash memory information block. Copied from bootloader header. See esp_image_header_t.