Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: MPW-evb bringup #587

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cb466c2
recognize more flash chip types
bunnie Oct 1, 2024
19741d3
add new flash IDs to swap routine as well
bunnie Oct 1, 2024
f7c33c9
move a comment that was displaced
bunnie Oct 1, 2024
6f0ab9a
add flash write test routine to mbox
bunnie Oct 1, 2024
c7bdc1a
refactor iox to have a setup_pin() trait
bunnie Oct 1, 2024
1dbfb21
add some stand-in code for board definitions on the cramium platform
bunnie Oct 1, 2024
45d9487
add board module to the project
bunnie Oct 1, 2024
81637f1
add helper to translate return values from io setup to udma clock cha…
bunnie Oct 1, 2024
c0ddf5f
add board feature placeholders
bunnie Oct 1, 2024
76e88eb
absorb setup_pin trait into the cramium-hal service
bunnie Oct 1, 2024
6eca732
cleanup a warning
bunnie Oct 1, 2024
59b1554
add stubs for lifecycle management and update checking in loader
bunnie Oct 1, 2024
a66cd1c
add modules from previous commit
bunnie Oct 1, 2024
482b815
convert to using the new setup_pin trait
bunnie Oct 1, 2024
cddd971
remap to the setup_pin() trait
bunnie Oct 1, 2024
0733b65
firmware updater strategy and thoughts jotted into a file
bunnie Oct 1, 2024
20dd9b2
consolidate spi pin setup routines
bunnie Oct 1, 2024
2e086f4
consolidate spi pin setup
bunnie Oct 1, 2024
728fab3
consolidate spi pin setup
bunnie Oct 1, 2024
d679048
migrate more board parameters to board files
bunnie Oct 1, 2024
1eb1a1a
migrate loader board parameters to board files
bunnie Oct 1, 2024
d3691a5
extract reserved pages from board files
bunnie Oct 1, 2024
972a314
configure xous-log to point to board files
bunnie Oct 1, 2024
84f88e9
configure xous-swapper to point to board files
bunnie Oct 1, 2024
e581eb0
add board selector to build args
bunnie Oct 1, 2024
412a762
fix formatting
bunnie Oct 1, 2024
b2f8166
fix formatting
bunnie Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libs/cramium-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ bitfield = "0.13.2"
xous = { version = "0.9.64", features = ["v2p"] }

[features]
board-baosec = [] # USB form factor token
board-baosor = [] # Precursor form factor
board-dabao = [] # Dev board form factor

compress-entropy = []
magic-manual = []
std = ["log", "xous-api-names", "usb-device"]
derive-rkyv = ["rkyv"]
default = []
default = ["board-baosec"]
127 changes: 127 additions & 0 deletions libs/cramium-hal/src/board/baosec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Constants that define pin locations, RAM offsets, etc. for the BaoSec board
use crate::iox;
use crate::iox::IoSetup;
use crate::iox::*;

// console uart buffer
pub const UART_DMA_TX_BUF_PHYS: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 4096;

// RAM needs two buffers of 1k + 16 bytes = 2048 + 16 = 2064 bytes; round up to one page
pub const SPIM_RAM_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 2 * 4096;

// app uart buffer
pub const APP_UART_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 3 * 4096;

// display buffer: 1 page for double-buffering, rounded up to 1 page for commands
pub const DISPLAY_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 5 * 4096;

// Flash needs 4096 bytes for Rx, and 0 bytes for Tx + 16 bytes for cmd for 2 pages total. This is released
// after boot.
pub const SPIM_FLASH_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 7 * 4096;

// USB pages - USB subsystem is a hog, needs a lot of pages
pub const CRG_IFRAM_PAGES: usize = 22;
pub const CRG_UDC_MEMBASE: usize =
utralib::HW_IFRAM1_MEM + utralib::HW_IFRAM1_MEM_LEN - CRG_IFRAM_PAGES * 0x1000;

// MANUALLY SYNCED TO ALLOCATIONS ABOVE
// inclusive numbering - we allocate pages from the top-down, so the last number should generally be 31
pub const IFRAM0_RESERVED_PAGE_RANGE: [usize; 2] = [31 - 7, 31];
pub const IFRAM1_RESERVED_PAGE_RANGE: [usize; 2] = [31 - CRG_IFRAM_PAGES, 31];

/// Setup pins for the baosec display
pub fn setup_display_pins(iox: &dyn IoSetup) -> crate::udma::SpimChannel {
const SPI_CS_PIN: u8 = 5;
const SPI_CLK_PIN: u8 = 4;
const SPI_DAT_PIN: u8 = 0;
const SPI_PORT: iox::IoxPort = iox::IoxPort::PD;

// SPIM_CLK_A[0]
iox.setup_pin(
SPI_PORT,
SPI_CLK_PIN,
Some(iox::IoxDir::Output),
Some(iox::IoxFunction::AF1),
None,
None,
Some(iox::IoxEnable::Enable),
Some(iox::IoxDriveStrength::Drive2mA),
);
// SPIM_SD0_A[0]
iox.setup_pin(
SPI_PORT,
SPI_DAT_PIN,
Some(iox::IoxDir::Output),
Some(iox::IoxFunction::AF1),
None,
None,
Some(iox::IoxEnable::Enable),
Some(iox::IoxDriveStrength::Drive2mA),
);
// SPIM_CSN0_A[0]
// chip select toggle by UDMA has ~6 cycles setup and 1 cycles hold time, which
// meets the requirements for the display.
iox.setup_pin(
SPI_PORT,
SPI_CS_PIN,
Some(iox::IoxDir::Output),
Some(iox::IoxFunction::AF1),
None,
Some(iox::IoxEnable::Enable),
Some(iox::IoxEnable::Enable),
Some(iox::IoxDriveStrength::Drive2mA),
);
// using bank SPIM_B[1]
crate::udma::SpimChannel::Channel0
}

pub fn setup_memory_pins(iox: &dyn IoSetup) -> crate::udma::SpimChannel {
// JPC7_13
// SPIM_CLK_A[1]
iox.setup_pin(
IoxPort::PC,
11,
Some(IoxDir::Output),
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive4mA),
);
// SPIM_SD[0-3]_A[1]
for i in 7..11 {
iox.setup_pin(
IoxPort::PC,
i,
None,
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive2mA),
);
}
// SPIM_CSN0_A[1]
iox.setup_pin(
IoxPort::PC,
12,
Some(IoxDir::Output),
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive2mA),
);
// SPIM_CSN0_A[1]
iox.setup_pin(
IoxPort::PC,
13,
Some(IoxDir::Output),
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive2mA),
);
crate::udma::SpimChannel::Channel1
}
123 changes: 123 additions & 0 deletions libs/cramium-hal/src/board/baosor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Constants that define pin locations, RAM offsets, etc. for the BaoSec board
use crate::iox;
use crate::iox::IoSetup;

// console uart buffer
pub const UART_DMA_TX_BUF_PHYS: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 4096;

// RAM needs two buffers of 1k + 16 bytes = 2048 + 16 = 2064 bytes; round up to one page
pub const SPIM_RAM_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 2 * 4096;

// app uart buffer
pub const APP_UART_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 3 * 4096;

// Flash needs 4096 bytes for Rx, and 0 bytes for Tx + 16 bytes for cmd for 2 pages total. This is released
// after boot.
pub const SPIM_FLASH_IFRAM_ADDR: usize = utralib::HW_IFRAM0_MEM + utralib::HW_IFRAM0_MEM_LEN - 5 * 4096;

// USB pages - USB subsystem is a hog, needs a lot of pages
pub const CRG_IFRAM_PAGES: usize = 22;
pub const CRG_UDC_MEMBASE: usize =
utralib::HW_IFRAM1_MEM + utralib::HW_IFRAM1_MEM_LEN - CRG_IFRAM_PAGES * 0x1000;

// MANUALLY SYNCED TO ALLOCATIONS ABOVE
// inclusive numbering - we allocate pages from the top-down, so the last number should generally be 31
pub const IFRAM0_RESERVED_PAGE_RANGE: [usize; 2] = [31 - 5, 31];
pub const IFRAM1_RESERVED_PAGE_RANGE: [usize; 2] = [31 - CRG_IFRAM_PAGES, 31];

/// Setup pins for the baosor display (Precursor memory LCD target)
pub fn setup_display_pins(iox: &dyn IoSetup) -> crate::udma::SpimChannel {
const SPI_CS_PIN: u8 = 5;
const SPI_CLK_PIN: u8 = 4;
const SPI_DAT_PIN: u8 = 0;
const SPI_PORT: iox::IoxPort = iox::IoxPort::PD;

// SPIM_CLK_A[0]
iox.setup_pin(
SPI_PORT,
SPI_CLK_PIN,
Some(iox::IoxDir::Output),
Some(iox::IoxFunction::AF1),
None,
None,
Some(iox::IoxEnable::Enable),
Some(iox::IoxDriveStrength::Drive2mA),
);
// SPIM_SD0_A[0]
iox.setup_pin(
SPI_PORT,
SPI_DAT_PIN,
Some(iox::IoxDir::Output),
Some(iox::IoxFunction::AF1),
None,
None,
Some(iox::IoxEnable::Enable),
Some(iox::IoxDriveStrength::Drive2mA),
);
// SPIM_CSN0_A[0]
// chip select toggle by UDMA has ~6 cycles setup and 1 cycles hold time, which
// meets the requirements for the display.
iox.setup_pin(
SPI_PORT,
SPI_CS_PIN,
Some(iox::IoxDir::Output),
Some(iox::IoxFunction::AF1),
None,
Some(iox::IoxEnable::Enable),
Some(iox::IoxEnable::Enable),
Some(iox::IoxDriveStrength::Drive2mA),
);
// using bank SPIM_B[1]
crate::udma::SpimChannel::Channel0
}

pub fn setup_memory_pins(iox: &dyn IoSetup) -> crate::udma::SpimChannel {
// JPC7_13
// SPIM_CLK_A[1]
iox.setup_pin(
IoxPort::PC,
11,
Some(IoxDir::Output),
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive4mA),
);
// SPIM_SD[0-3]_A[1]
for i in 7..11 {
iox.setup_pin(
IoxPort::PC,
i,
None,
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive2mA),
);
}
// SPIM_CSN0_A[1]
iox.setup_pin(
IoxPort::PC,
12,
Some(IoxDir::Output),
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive2mA),
);
// SPIM_CSN0_A[1]
iox.setup_pin(
IoxPort::PC,
13,
Some(IoxDir::Output),
Some(IoxFunction::AF1),
None,
None,
Some(IoxEnable::Enable),
Some(IoxDriveStrength::Drive2mA),
);
crate::udma::SpimChannel::Channel1
}
8 changes: 8 additions & 0 deletions libs/cramium-hal/src/board/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[cfg(feature = "board-baosec")]
pub mod baosec;
#[cfg(feature = "board-baosec")]
pub use baosec::*;
#[cfg(feature = "board-baosor")]
pub mod baosor;
#[cfg(feature = "board-baosor")]
pub use baosor::*;
Loading