-
Notifications
You must be signed in to change notification settings - Fork 367
Initial support for ASSIST_DEBUG in ESP32-H2 #566
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
Merged
jessebraham
merged 8 commits into
esp-rs:main
from
SergioGasquez:feature/esp32h2-debug_assist
May 30, 2023
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e93d231
feat: ✨ Add debug_assist example
SergioGasquez 913bcc5
feat: ✨ Enable peripherals
SergioGasquez f32d51e
docs: 📝 Add RAM comments
SergioGasquez 16a0afe
feat: ⚡️ Update debug_assist example
SergioGasquez 259cbe7
docs: 📝 Update changelog
SergioGasquez 3eb1345
Merge branch 'main' into feature/esp32h2-debug_assist
SergioGasquez 9faa1d4
build: 📌 Update esp-pacs rev for h2
SergioGasquez 94cbd55
style: 🎨 Move assist_debug_region* and assist_debug_sp* to peripheral…
SergioGasquez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| //! This shows debug-assist | ||
| //! | ||
| //! Uncomment the functionality you want to test | ||
|
|
||
| #![no_std] | ||
| #![no_main] | ||
|
|
||
| use core::cell::RefCell; | ||
|
|
||
| use critical_section::Mutex; | ||
| use esp32h2_hal::{ | ||
| assist_debug::DebugAssist, | ||
| clock::ClockControl, | ||
| interrupt, | ||
| peripherals::{self, Peripherals}, | ||
| prelude::*, | ||
| riscv, | ||
| timer::TimerGroup, | ||
| Rtc, | ||
| }; | ||
| use esp_backtrace as _; | ||
| use esp_println::println; | ||
|
|
||
| static DA: Mutex<RefCell<Option<DebugAssist>>> = Mutex::new(RefCell::new(None)); | ||
|
|
||
| #[entry] | ||
| fn main() -> ! { | ||
| let peripherals = Peripherals::take(); | ||
| let mut system = peripherals.PCR.split(); | ||
| let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); | ||
|
|
||
| let mut rtc = Rtc::new(peripherals.LP_CLKRST); | ||
| let timer_group0 = TimerGroup::new( | ||
| peripherals.TIMG0, | ||
| &clocks, | ||
| &mut system.peripheral_clock_control, | ||
| ); | ||
| let mut wdt0 = timer_group0.wdt; | ||
| let timer_group1 = TimerGroup::new( | ||
| peripherals.TIMG1, | ||
| &clocks, | ||
| &mut system.peripheral_clock_control, | ||
| ); | ||
| let mut wdt1 = timer_group1.wdt; | ||
|
|
||
| // Disable watchdog timers | ||
| rtc.swd.disable(); | ||
| rtc.rwdt.disable(); | ||
| wdt0.disable(); | ||
| wdt1.disable(); | ||
|
|
||
| let mut da = DebugAssist::new( | ||
| peripherals.ASSIST_DEBUG, | ||
| &mut system.peripheral_clock_control, | ||
| ); | ||
|
|
||
| // Uncomment the functionality you want to test | ||
| // We use a 0x1200 wide SP and 0x100 regions, and RAM ends at 0x40850000 | ||
|
|
||
| // Monitor the SP so as to prevent stack overflow or erroneous push/pop. When | ||
| // the SP exceeds the minimum or maximum threshold, the module will record the | ||
| // PC pointer and generate an interrupt | ||
| // da.enable_sp_monitor(0x4084ee00, 0x40850000); | ||
|
|
||
| // Monitor reads/writes performed by the CPU over data bus and peripheral bus | ||
| // in a certain address space, i.e., memory region. Whenever the bus reads or | ||
| // writes in the specified address space, an interrupt will be triggered | ||
| // da.enable_region0_monitor(0x4084ee00, 0x4084ef00, true, true); | ||
| da.enable_region1_monitor(0x4084ee00, 0x4084ef00, true, true); | ||
|
|
||
| critical_section::with(|cs| DA.borrow_ref_mut(cs).replace(da)); | ||
|
|
||
| interrupt::enable( | ||
| peripherals::Interrupt::ASSIST_DEBUG, | ||
| interrupt::Priority::Priority3, | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| unsafe { | ||
| riscv::interrupt::enable(); | ||
| } | ||
|
|
||
| eat_up_stack(0); | ||
|
|
||
| loop {} | ||
| } | ||
|
|
||
| #[allow(unconditional_recursion)] | ||
| fn eat_up_stack(v: u32) { | ||
| println!("Iteration {v}"); | ||
| eat_up_stack(v + 1); | ||
| } | ||
|
|
||
| #[interrupt] | ||
| fn ASSIST_DEBUG() { | ||
| critical_section::with(|cs| { | ||
| println!("\n\nDEBUG_ASSIST interrupt"); | ||
| let mut da = DA.borrow_ref_mut(cs); | ||
| let da = da.as_mut().unwrap(); | ||
|
|
||
| if da.is_sp_monitor_interrupt_set() { | ||
| println!("SP MONITOR TRIGGERED"); | ||
| da.clear_sp_monitor_interrupt(); | ||
| let pc = da.get_sp_monitor_pc(); | ||
| println!("PC = 0x{:x}", pc); | ||
| } | ||
|
|
||
| if da.is_region0_monitor_interrupt_set() { | ||
| println!("REGION0 MONITOR TRIGGERED"); | ||
| da.clear_region0_monitor_interrupt(); | ||
| let pc = da.get_region_monitor_pc(); | ||
| println!("PC = 0x{:x}", pc); | ||
| } | ||
|
|
||
| if da.is_region1_monitor_interrupt_set() { | ||
| println!("REGION1 MONITOR TRIGGERED"); | ||
| da.clear_region1_monitor_interrupt(); | ||
| let pc = da.get_region_monitor_pc(); | ||
| println!("PC = 0x{:x}", pc); | ||
| } | ||
|
|
||
| loop {} | ||
| }); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.