Merge #1139
1139: Wdt config changes r=lulf a=huntc Per commits: * By passing WDT config around we can control it more easily and promote sharing it between files. * The memory layout of the s140 crept into a number of memory files, which can cause confusion (well, it did for me!). * Obtaining the current WDT config is useful so that we do not have to duplicate configurations around the place. A constructor method has been introduced that attempts to return the current running WDT config from the WDT peripheral. The bootloader example has also been updated to show how the watchdog can be obtained and used. Co-authored-by: huntc <huntchr@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ MEMORY
|
||||
BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K
|
||||
ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K
|
||||
DFU : ORIGIN = 0x00017000, LENGTH = 68K
|
||||
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
__bootloader_state_start = ORIGIN(BOOTLOADER_STATE);
|
||||
|
@@ -5,7 +5,7 @@ MEMORY
|
||||
BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K
|
||||
ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K
|
||||
DFU : ORIGIN = 0x00017000, LENGTH = 68K
|
||||
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
__bootloader_state_start = ORIGIN(BOOTLOADER_STATE);
|
||||
|
@@ -6,6 +6,7 @@ use cortex_m_rt::{entry, exception};
|
||||
use defmt_rtt as _;
|
||||
use embassy_boot_nrf::*;
|
||||
use embassy_nrf::nvmc::Nvmc;
|
||||
use embassy_nrf::wdt;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
@@ -20,8 +21,14 @@ fn main() -> ! {
|
||||
*/
|
||||
|
||||
let mut bl = BootLoader::default();
|
||||
|
||||
let mut wdt_config = wdt::Config::default();
|
||||
wdt_config.timeout_ticks = 32768 * 5; // timeout seconds
|
||||
wdt_config.run_during_sleep = true;
|
||||
wdt_config.run_during_debug_halt = false;
|
||||
|
||||
let start = bl.prepare(&mut SingleFlashConfig::new(&mut BootFlash::<_, 4096>::new(
|
||||
WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, 5),
|
||||
WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config),
|
||||
)));
|
||||
unsafe { bl.load(start) }
|
||||
}
|
||||
|
Reference in New Issue
Block a user