Skip to content

Flash

The Flash module provides low-level access to flash memory partitions.

import flash from "embedded:storage/flash";

Instantiates a Flash Partition instance from a flash partition path name.

flash.open({ path, mode, format })

options

path - A string indicating the name of the flash partition path name to open.

mode - A string indicating the mode used to access the partition. Values are "r" and "r+". Defaults to "r+".

format - A string indicating the data format to use for read and write operations. The only supported value is "buffer".

Returns an object with information about the partition.

size - The total number of bytes in the partition.

blockLength - The number of bytes in a block (sector).

blocks - The number of blocks in the partition.

Erases one or more blocks in the partition.

Reads count bytes from the partition starting at offset.

Writes data to the partition starting at offset.

Releases all resources associated with the partition instance.

import flash from "embedded:storage/flash";
let partition = flash.open({ path: "ota-bootloader" });
let status = partition.status();
partition.eraseBlock(0);
partition.write(new Uint8Array([0x01, 0x02]), 0);
partition.close();

Flash