Skip to content

Commit 6557c1e

Browse files
committed
Add note for flash size to example
1 parent d21ca7c commit 6557c1e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/flash_read_write.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ use crate::hal::{
1313
use cortex_m_rt::entry;
1414
use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
1515

16+
/// # NOTE
17+
/// This example assumes a flash size of more than 16K. If your MCU has less or equal than 16K Bytes
18+
/// of flash memory, adjust the `memory.x` file and `OFFSET_START` + `OFFSET_END` constants accordingly.
1619
#[entry]
1720
fn main() -> ! {
1821
if let Some(mut p) = pac::Peripherals::take() {
1922
let _ = p.RCC.configure().freeze(&mut p.FLASH);
2023

24+
// Check that flash is big enough for this example
25+
assert!(p.FLASH.len() > 16 * 1024);
26+
2127
// All examples use the first 16K of flash for the program so we use the first page after that
2228
const OFFSET_START: u32 = 16 * 1024;
2329
const OFFSET_END: u32 = OFFSET_START + 1024;

0 commit comments

Comments
 (0)