software_dfu #46

Merged
sb10q merged 8 commits from software_dfu into master 2021-01-13 11:59:06 +08:00
2 changed files with 3 additions and 37 deletions
Showing only changes of commit e41415f82c - Show all commits

View File

@ -6,7 +6,7 @@ const DFU_MSG_ADDR: usize = 0x2001BC00;
/// DFU trigger message /// DFU trigger message
const DFU_TRIG_MSG: usize = 0xDECAFBAD; const DFU_TRIG_MSG: usize = 0xDECAFBAD;
/// Set DFU trigger message /// Set DFU trigger
pub unsafe fn trig_dfu() { pub unsafe fn trig_dfu() {
let dfu_msg_addr = DFU_MSG_ADDR as *mut usize; let dfu_msg_addr = DFU_MSG_ADDR as *mut usize;
*dfu_msg_addr = DFU_TRIG_MSG; *dfu_msg_addr = DFU_TRIG_MSG;

View File

@ -13,7 +13,7 @@ use log::{error, info, warn};
use core::fmt::Write; use core::fmt::Write;
use cortex_m::asm::wfi; use cortex_m::asm::wfi;
use cortex_m_rt::{entry}; use cortex_m_rt::entry;
use stm32f4xx_hal::{ use stm32f4xx_hal::{
hal::watchdog::{WatchdogEnable, Watchdog}, hal::watchdog::{WatchdogEnable, Watchdog},
rcc::RccExt, rcc::RccExt,
@ -482,37 +482,3 @@ fn main() -> ! {
unreachable!() unreachable!()
} }
// #[pre_init]
// #[no_mangle]
// unsafe fn __pre_init() {
// let dfu_msg_addr = DFU_MSG_ADDR as *mut usize;
// if *dfu_msg_addr == DFU_TRIG_MSG{
// *dfu_msg_addr = 0x00000000;
// const RCC_APB2ENR: *mut u32 = 0xE000_ED88 as *mut u32;
// const RCC_APB2ENR_ENABLE_SYSCFG_CLOCK: u32 = 0x00004000;
// core::ptr::write_volatile(
// RCC_APB2ENR,
// *RCC_APB2ENR | RCC_APB2ENR_ENABLE_SYSCFG_CLOCK,
// );
// const SYSCFG_MEMRMP: *mut u32 = 0x40013800 as *mut u32;
// const SYSCFG_MEMRMP_MAP_ROM: u32 = 0x00000001;
// core::ptr::write_volatile(
// SYSCFG_MEMRMP,
// *SYSCFG_MEMRMP | SYSCFG_MEMRMP_MAP_ROM,
// );
// asm!("LDR R0, =0x1FFF0000");
// asm!("LDR SP,[R0, #0]");
// asm!("LDR R0,[R0, #4]");
// asm!("BX R0");
// }
// }