From 868a1f280b25ad2f3273b4d47c0b08cbf8017aa1 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 5 May 2025 01:47:50 +0800 Subject: [PATCH] move SPINOR params into board definition this makes a lot more sense that defining it at the chip level --- libs/cramium-hal/src/board/baosec.rs | 9 +++++++++ libs/cramium-hal/src/udma/spim.rs | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/cramium-hal/src/board/baosec.rs b/libs/cramium-hal/src/board/baosec.rs index db564338c..438dc719c 100644 --- a/libs/cramium-hal/src/board/baosec.rs +++ b/libs/cramium-hal/src/board/baosec.rs @@ -5,6 +5,15 @@ pub const I2C_AXP2101_ADR: u8 = 0x34; pub const I2C_TUSB320_ADR: u8 = 0x47; pub const I2C_BQ27427_ADR: u8 = 0x55; +// location and organization of SPINOR should be board-specific +pub const SPINOR_PAGE_LEN: u32 = 0x100; +pub const SPINOR_ERASE_SIZE: u32 = 0x1000; // this is the smallest sector size. +pub const SPINOR_BULK_ERASE_SIZE: u32 = 0x1_0000; // this is the bulk erase size. +pub const SPINOR_LEN: u32 = 16384 * 1024; +pub const PDDB_LOC: u32 = 4096 * 1024; // located 4MiB in, after the swap image +pub const PDDB_LEN: u32 = 4096 * 1024; // 4MiB data for the PDDB total +// top 8 megs are reserved for staging updates, backups, etc. + // console uart buffer pub const UART_DMA_TX_BUF_PHYS: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 4096; diff --git a/libs/cramium-hal/src/udma/spim.rs b/libs/cramium-hal/src/udma/spim.rs index e425febe1..9d180a301 100644 --- a/libs/cramium-hal/src/udma/spim.rs +++ b/libs/cramium-hal/src/udma/spim.rs @@ -4,9 +4,9 @@ use utralib::*; use crate::ifram::IframRange; use crate::udma::*; -pub const FLASH_PAGE_LEN: usize = 256; -pub const FLASH_SECTOR_LEN: usize = 4096; -pub const BLOCK_ERASE_LEN: usize = 65536; +pub const FLASH_PAGE_LEN: usize = crate::board::SPINOR_PAGE_LEN as usize; +pub const FLASH_SECTOR_LEN: usize = crate::board::SPINOR_ERASE_SIZE as usize; +pub const BLOCK_ERASE_LEN: usize = crate::board::SPINOR_BULK_ERASE_SIZE as usize; // ----------------------------------- SPIM ------------------------------------