mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fixes for cramium target
This commit is contained in:
parent
d3bbe54da7
commit
829ac28072
5 changed files with 33 additions and 29 deletions
|
|
@ -255,6 +255,8 @@ pub fn phase_2(cfg: &mut BootConfig, fs_prehash: &[u8; 64]) {
|
||||||
swap_spec.swap_base = desc.ram_offset;
|
swap_spec.swap_base = desc.ram_offset;
|
||||||
swap_spec.swap_len = desc.ram_size;
|
swap_spec.swap_len = desc.ram_size;
|
||||||
(swap_spec.mac_base, swap_spec.mac_len) = cfg.swap_hal.as_ref().unwrap().mac_base_bounds();
|
(swap_spec.mac_base, swap_spec.mac_len) = cfg.swap_hal.as_ref().unwrap().mac_base_bounds();
|
||||||
|
swap_spec.sram_start = cfg.sram_start as u32;
|
||||||
|
swap_spec.sram_size = cfg.sram_size as u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the RPT into PID 2
|
// copy the RPT into PID 2
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,8 @@ pub fn early_init() {
|
||||||
use cramium_hal::ifram::IframRange;
|
use cramium_hal::ifram::IframRange;
|
||||||
use cramium_hal::iox::*;
|
use cramium_hal::iox::*;
|
||||||
use cramium_hal::udma::*;
|
use cramium_hal::udma::*;
|
||||||
|
use loader::swap::SPIM_FLASH_IFRAM_ADDR;
|
||||||
|
use loader::swap::SPIM_RAM_IFRAM_ADDR;
|
||||||
|
|
||||||
fn setup_port(
|
fn setup_port(
|
||||||
iox: &mut Iox,
|
iox: &mut Iox,
|
||||||
|
|
@ -307,7 +309,7 @@ pub fn early_init() {
|
||||||
// setup the I/O pins
|
// setup the I/O pins
|
||||||
let mut iox = Iox::new(utralib::generated::HW_IOX_BASE as *mut u32);
|
let mut iox = Iox::new(utralib::generated::HW_IOX_BASE as *mut u32);
|
||||||
let mut udma_global = GlobalConfig::new(utralib::generated::HW_UDMA_CTRL_BASE as *mut u32);
|
let mut udma_global = GlobalConfig::new(utralib::generated::HW_UDMA_CTRL_BASE as *mut u32);
|
||||||
#[cfg(not(feature = "spi-alt-channel"))]
|
#[cfg(feature = "spi-alt-channel")]
|
||||||
let channel = {
|
let channel = {
|
||||||
// JQSPI1
|
// JQSPI1
|
||||||
// SPIM_CLK_A[0]
|
// SPIM_CLK_A[0]
|
||||||
|
|
@ -363,7 +365,7 @@ pub fn early_init() {
|
||||||
udma_global.clock_on(PeriphId::Spim0); // JQSPI1
|
udma_global.clock_on(PeriphId::Spim0); // JQSPI1
|
||||||
SpimChannel::Channel0
|
SpimChannel::Channel0
|
||||||
};
|
};
|
||||||
#[cfg(feature = "spi-alt-channel")]
|
#[cfg(not(feature = "spi-alt-channel"))]
|
||||||
let channel = {
|
let channel = {
|
||||||
// JPC7_13
|
// JPC7_13
|
||||||
// SPIM_CLK_A[1]
|
// SPIM_CLK_A[1]
|
||||||
|
|
|
||||||
|
|
@ -86,12 +86,12 @@ SECTIONS
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_edata = .;
|
_edata = .;
|
||||||
} > REGION_DATA AT > REGION_RODATA
|
} > REGION_DATA AT > REGION_RODATA
|
||||||
|
/*
|
||||||
.fonts : ALIGN(65536)
|
.fonts : ALIGN(65536)
|
||||||
{
|
{
|
||||||
KEEP(*(.fontdata));
|
KEEP(*(.fontdata));
|
||||||
} > FONTS
|
} > FONTS
|
||||||
|
*/
|
||||||
.bss (NOLOAD) :
|
.bss (NOLOAD) :
|
||||||
{
|
{
|
||||||
_sbss = .;
|
_sbss = .;
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ use cramium_hal::iox::*;
|
||||||
use cramium_hal::sce;
|
use cramium_hal::sce;
|
||||||
use cramium_hal::udma::*;
|
use cramium_hal::udma::*;
|
||||||
use loader::swap::SPIM_RAM_IFRAM_ADDR;
|
use loader::swap::SPIM_RAM_IFRAM_ADDR;
|
||||||
|
use loader::{APP_UART_IFRAM_ADDR, UART_IFRAM_ADDR};
|
||||||
use rand_chacha::rand_core::RngCore;
|
use rand_chacha::rand_core::RngCore;
|
||||||
use rand_chacha::rand_core::SeedableRng;
|
use rand_chacha::rand_core::SeedableRng;
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
|
||||||
use crate::bootconfig::BootConfig;
|
use crate::bootconfig::BootConfig;
|
||||||
use crate::platform::{SPIM_FLASH_IFRAM_ADDR, SPIM_RAM_IFRAM_ADDR};
|
|
||||||
use crate::swap::*;
|
use crate::swap::*;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
|
@ -28,10 +28,6 @@ pub struct SwapHal {
|
||||||
src_cipher: Aes256GcmSiv,
|
src_cipher: Aes256GcmSiv,
|
||||||
flash_spim: Spim,
|
flash_spim: Spim,
|
||||||
ram_spim: Spim,
|
ram_spim: Spim,
|
||||||
iox: Iox,
|
|
||||||
udma_global: GlobalConfig,
|
|
||||||
swap_start: usize,
|
|
||||||
swap_len: usize,
|
|
||||||
swap_mac_start: usize,
|
swap_mac_start: usize,
|
||||||
swap_mac_len: usize,
|
swap_mac_len: usize,
|
||||||
dst_cipher: Aes256GcmSiv,
|
dst_cipher: Aes256GcmSiv,
|
||||||
|
|
@ -77,6 +73,8 @@ impl SwapHal {
|
||||||
// sanity check this structure
|
// sanity check this structure
|
||||||
assert_eq!(core::mem::size_of::<SwapSourceHeader>(), 4096);
|
assert_eq!(core::mem::size_of::<SwapSourceHeader>(), 4096);
|
||||||
|
|
||||||
|
let mut udma_global = GlobalConfig::new(utralib::generated::HW_UDMA_CTRL_BASE as *mut u32);
|
||||||
|
|
||||||
// setup the I/O pins
|
// setup the I/O pins
|
||||||
let mut iox = Iox::new(utralib::generated::HW_IOX_BASE as *mut u32);
|
let mut iox = Iox::new(utralib::generated::HW_IOX_BASE as *mut u32);
|
||||||
#[cfg(feature = "spi-alt-channel")]
|
#[cfg(feature = "spi-alt-channel")]
|
||||||
|
|
@ -192,10 +190,6 @@ impl SwapHal {
|
||||||
SpimChannel::Channel1
|
SpimChannel::Channel1
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut udma_global = GlobalConfig::new(utralib::generated::HW_UDMA_CTRL_BASE as *mut u32);
|
|
||||||
udma_global.clock_on(PeriphId::Spim0); // JQSPI1
|
|
||||||
// udma_global.clock_on(PeriphId::Spim1); // JPC7_13
|
|
||||||
|
|
||||||
// safety: this is safe because clocks have been set up
|
// safety: this is safe because clocks have been set up
|
||||||
let mut flash_spim = unsafe {
|
let mut flash_spim = unsafe {
|
||||||
Spim::new_with_ifram(
|
Spim::new_with_ifram(
|
||||||
|
|
@ -320,10 +314,6 @@ impl SwapHal {
|
||||||
src_cipher: Aes256GcmSiv::new((&swap.key).into()),
|
src_cipher: Aes256GcmSiv::new((&swap.key).into()),
|
||||||
flash_spim,
|
flash_spim,
|
||||||
ram_spim,
|
ram_spim,
|
||||||
iox,
|
|
||||||
udma_global,
|
|
||||||
swap_start: 0,
|
|
||||||
swap_len: ram_size_actual,
|
|
||||||
swap_mac_start: ram_size_actual,
|
swap_mac_start: ram_size_actual,
|
||||||
swap_mac_len: mac_size,
|
swap_mac_len: mac_size,
|
||||||
dst_cipher: Aes256GcmSiv::new((&dest_key).into()),
|
dst_cipher: Aes256GcmSiv::new((&dest_key).into()),
|
||||||
|
|
@ -456,7 +446,7 @@ pub fn userspace_maps(cfg: &mut BootConfig) {
|
||||||
SWAPPER_PID,
|
SWAPPER_PID,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
|
let mut iox = Iox::new(utralib::utra::iox::HW_IOX_BASE as *mut u32);
|
||||||
iox.set_alternate_function(IoxPort::PD, 2, IoxFunction::AF2);
|
iox.set_alternate_function(IoxPort::PD, 2, IoxFunction::AF2);
|
||||||
iox.set_alternate_function(IoxPort::PD, 3, IoxFunction::AF2);
|
iox.set_alternate_function(IoxPort::PD, 3, IoxFunction::AF2);
|
||||||
// rx as input, with pull-up
|
// rx as input, with pull-up
|
||||||
|
|
@ -466,29 +456,35 @@ pub fn userspace_maps(cfg: &mut BootConfig) {
|
||||||
iox.set_gpio_dir(IoxPort::PD, 3, IoxDir::Output);
|
iox.set_gpio_dir(IoxPort::PD, 3, IoxDir::Output);
|
||||||
|
|
||||||
// Set up the UDMA_UART block to the correct baud rate and enable status
|
// Set up the UDMA_UART block to the correct baud rate and enable status
|
||||||
let mut udma_global = udma::GlobalConfig::new(utra::udma_ctrl::HW_UDMA_CTRL_BASE as *mut u32);
|
let mut udma_global =
|
||||||
udma_global.clock_on(udma::PeriphId::Uart0);
|
cramium_hal::udma::GlobalConfig::new(utralib::utra::udma_ctrl::HW_UDMA_CTRL_BASE as *mut u32);
|
||||||
|
udma_global.clock_on(cramium_hal::udma::PeriphId::Uart0);
|
||||||
udma_global.map_event(
|
udma_global.map_event(
|
||||||
udma::PeriphId::Uart0,
|
cramium_hal::udma::PeriphId::Uart0,
|
||||||
udma::PeriphEventType::Uart(udma::EventUartOffset::Rx),
|
cramium_hal::udma::PeriphEventType::Uart(cramium_hal::udma::EventUartOffset::Rx),
|
||||||
udma::EventChannel::Channel2,
|
cramium_hal::udma::EventChannel::Channel2,
|
||||||
);
|
);
|
||||||
udma_global.map_event(
|
udma_global.map_event(
|
||||||
udma::PeriphId::Uart0,
|
cramium_hal::udma::PeriphId::Uart0,
|
||||||
udma::PeriphEventType::Uart(udma::EventUartOffset::Tx),
|
cramium_hal::udma::PeriphEventType::Uart(cramium_hal::udma::EventUartOffset::Tx),
|
||||||
udma::EventChannel::Channel3,
|
cramium_hal::udma::EventChannel::Channel3,
|
||||||
);
|
);
|
||||||
|
|
||||||
let baudrate: u32 = 115200;
|
let baudrate: u32 = 115200;
|
||||||
|
let perclk = 100_000_000; // TODO: turn this into a symbolic const, or better yet, pass in from the loader
|
||||||
let freq: u32 = perclk / 2;
|
let freq: u32 = perclk / 2;
|
||||||
|
|
||||||
// the address of the UART buffer is "hard-allocated" at an offset one page from the top of
|
// the address of the UART buffer is "hard-allocated" at an offset one page from the top of
|
||||||
// IFRAM0. This is a convention that must be respected by the UDMA UART library implementation
|
// IFRAM0. This is a convention that must be respected by the UDMA UART library implementation
|
||||||
// for things to work.
|
// for things to work.
|
||||||
let uart_buf_addr = UART_IFRAM_ADDR;
|
let uart_buf_addr = UART_IFRAM_ADDR;
|
||||||
let mut udma_uart = unsafe {
|
let udma_uart = unsafe {
|
||||||
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
// safety: this is safe to call, because we set up clock and events prior to calling new.
|
||||||
udma::Uart::get_handle(utra::udma_uart_0::HW_UDMA_UART_0_BASE, uart_buf_addr, uart_buf_addr)
|
cramium_hal::udma::Uart::get_handle(
|
||||||
|
utralib::utra::udma_uart_0::HW_UDMA_UART_0_BASE,
|
||||||
|
uart_buf_addr,
|
||||||
|
uart_buf_addr,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
crate::println!("Baud freq is {} Hz, baudrate is {}", freq, baudrate);
|
crate::println!("Baud freq is {} Hz, baudrate is {}", freq, baudrate);
|
||||||
udma_uart.set_baud(baudrate, freq);
|
udma_uart.set_baud(baudrate, freq);
|
||||||
|
|
@ -497,7 +493,7 @@ pub fn userspace_maps(cfg: &mut BootConfig) {
|
||||||
cfg.map_page_32(
|
cfg.map_page_32(
|
||||||
root,
|
root,
|
||||||
// TODO: use PD2/3 AF2 for this UART; set up the IOs for this
|
// TODO: use PD2/3 AF2 for this UART; set up the IOs for this
|
||||||
utra::udma_uart_0::HW_UDMA_UART_0_BASE,
|
utralib::utra::udma_uart_0::HW_UDMA_UART_0_BASE,
|
||||||
SWAP_APP_UART_VADDR,
|
SWAP_APP_UART_VADDR,
|
||||||
FLG_R | FLG_W | FLG_U | FLG_VALID,
|
FLG_R | FLG_W | FLG_U | FLG_VALID,
|
||||||
SWAPPER_PID,
|
SWAPPER_PID,
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,10 @@ pub struct SwapSpec {
|
||||||
pub mac_base: u32,
|
pub mac_base: u32,
|
||||||
/// Length of the MAC region in bytes
|
/// Length of the MAC region in bytes
|
||||||
pub mac_len: u32,
|
pub mac_len: u32,
|
||||||
|
/// Start of the main memory
|
||||||
|
pub sram_start: u32,
|
||||||
|
/// Size of the main memory
|
||||||
|
pub sram_size: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// RAM needs two buffers of 1k + 16 bytes = 2048 + 16 = 2064 bytes; round up to one page
|
// RAM needs two buffers of 1k + 16 bytes = 2048 + 16 = 2064 bytes; round up to one page
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue