API referencestd/embedded

std/embedded/chip/rp_flash

Public declarations, types, methods, and source contracts for std/embedded/chip/rp_flash.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/embedded/chip/rp_flash"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
hal std/embedded/hal rp_flash.dodo
ptr core/ptr rp_flash.dodo
rp_multicore std/embedded/chip/rp_multicore rp_flash.dodo

XIP_BASE

Constant · Source

Where the flash appears in the address space.

pub const XIP_BASE: usize = 0x1000_0000

SECTOR_BYTES

Constant · Source

The flash’s erase size.

pub const SECTOR_BYTES: u32 = 4096

PAGE_BYTES

Constant · Source

The flash’s program size.

pub const PAGE_BYTES: u32 = 256

MAX_REGIONS

Constant · Source

Regions out at once.

pub const MAX_REGIONS: u32 = 4

Flash

Struct · Source

The program flash, from the chip’s take().

pub struct Flash {
    // Private implementation fields omitted.
}

Flash.take

Function · Source

The flash, sized from the board’s flash size. SAFETY: call once, from the chip’s take(), so that the regions handed out are the only handles that erase and write the flash.

pub unsafe fn take() -> Flash

Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.

Flash.capacity

Function · Source

The board’s flash size in bytes.

pub fn capacity(&self) -> u32

Flash.program_end

Function · Source

The first sector after the program: the flash below it holds the program, the flash from it on is free for regions.

pub fn program_end(&self) -> u32

Flash.read

Function · Source

Copy buffer.len bytes from offset into buffer, anywhere in the flash, the program included. InvalidInput past its end.

pub fn read(&self, offset: u32, buffer: &mut[u8]) -> void!hal.Error

Flash.region

Function · Source

The length bytes of flash from start, both multiples of SECTOR_BYTES, to erase and write. InvalidInput unless the region is nonempty, at or above program_end(), and inside the flash; Busy if it overlaps a region that is out, or MAX_REGIONS are.

pub fn region(&mut self, start: u32, length: u32) -> Region!hal.Error

Flash.last

Function · Source

The last length bytes of the flash, as region.

pub fn last(&mut self, length: u32) -> Region!hal.Error

Flash.free

Function · Source

All the free flash, from program_end() to the end, as region.

pub fn free(&mut self) -> Region!hal.Error

Flash.release

Function · Source

Give back a region; its flash keeps its contents.

pub fn release(&mut self, region: Region)

Region

Struct · Source

Part of the program flash, from Flash.region, with the std/embedded/hal Flash protocol. Offsets count from its start.

pub struct Region: hal.Flash {
    // Private implementation fields omitted.
}

Region.start

Function · Source

Where the region starts in the flash.

pub fn start(&self) -> u32

Region.capacity

Function · Source

pub fn capacity(&self) -> u32

Region.erase_size

Function · Source

pub fn erase_size(&self) -> u32

Region.write_size

Function · Source

1: any byte can be written.

pub fn write_size(&self) -> u32

Region.read

Function · Source

pub fn read(&mut self, offset: u32, buffer: &mut[u8]) -> void!hal.Error

Region.erase

Function · Source

pub fn erase(&mut self, offset: u32, length: u32) -> void!hal.Error

Region.write

Function · Source

pub fn write(&mut self, offset: u32, bytes: &[u8]) -> void!hal.Error

Search every guide, reference page, and API declaration.