From 688e3b44325f814c854206608d96e3270f534b87 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 9 Jan 2020 22:13:04 +0100 Subject: [PATCH] libboard_zc706::boot: don't leave core1 stopped Fixes Gitea issue #7. --- experiments/src/main.rs | 2 +- libboard_zc706/src/boot.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/experiments/src/main.rs b/experiments/src/main.rs index d3da52f..86e3a6a 100644 --- a/experiments/src/main.rs +++ b/experiments/src/main.rs @@ -96,7 +96,7 @@ pub fn main_core0() { let x = { *SHARED.lock() }; println!("done shared: {:08X}", x); - core1.stop(); + core1.reset(); libcortex_a9::asm::dsb(); print!("Core1 stack [{:08X}..{:08X}]:", &core1.stack[0] as *const _ as u32, &core1.stack[core1.stack.len() - 1] as *const _ as u32); diff --git a/libboard_zc706/src/boot.rs b/libboard_zc706/src/boot.rs index 5690627..373341f 100644 --- a/libboard_zc706/src/boot.rs +++ b/libboard_zc706/src/boot.rs @@ -109,10 +109,13 @@ pub struct Core1> { } impl> Core1 { - pub fn stop(&self) { + pub fn reset(&self) { + unsafe { + CORE1_STACK.set(0); + } + slcr::RegisterBlock::unlocked(|slcr| { slcr.a9_cpu_rst_ctrl.modify(|_, w| w.a9_rst1(true)); - slcr.a9_cpu_rst_ctrl.modify(|_, w| w.a9_clkstop1(true)); slcr.a9_cpu_rst_ctrl.modify(|_, w| w.a9_rst1(false)); }); } @@ -125,7 +128,11 @@ impl> Core1 { let mut core = Core1 { stack }; // reset and stop (safe to repeat) - core.stop(); + slcr::RegisterBlock::unlocked(|slcr| { + slcr.a9_cpu_rst_ctrl.modify(|_, w| w.a9_rst1(true)); + slcr.a9_cpu_rst_ctrl.modify(|_, w| w.a9_clkstop1(true)); + slcr.a9_cpu_rst_ctrl.modify(|_, w| w.a9_rst1(false)); + }); let stack = core.stack.as_mut(); let stack_start = &mut stack[stack.len() - 1];