knurling-rs / app-template

Quickly set up a `probe-rs` + `defmt` + `flip-link` embedded project
Apache License 2.0
306 stars 28 forks source link

Hard fault crash after 1-2 minutes of running #76

Open itxs opened 9 months ago

itxs commented 9 months ago

I've written a simple button application based on the app-template. However, after some time of firmware being run on the STM32F027B-DISCO board, it stopped. I started to dig in and found HardFault occurred. The breakpoint in the HardFault handler in lib.rs never hit even if I press Run after the automatic stop caused by the debugger. The repo: https://github.com/itxs/embedded_rust_learning The screenshot of an issue: image

itxs commented 8 months ago

Hm, any activity here?

Urhengulas commented 7 months ago

Hi @itxs. That's odd. Unfortunately I do not have your board at hand, so you need to try a few things.

First can you please test if this problems also occurs with a very simple loop. The code is adapted from adapted from https://docs.rs/stm32f0xx-hal/latest/stm32f0xx_hal/delay/index.html, but I didn't test if it compiles, there might be some typo.

use helloworld1 as _; // global logger + panicking-behavior + memory layout

use stm32f0xx_hal as hal;

use crate::hal::pac;
use crate::hal::prelude::*;
use crate::hal::delay::Delay;
use cortex_m::peripheral::Peripherals;

#[cortex_m_rt::entry]
fn main() -> ! {
    let mut p = pac::Peripherals::take().unwrap();
    let mut cp = cortex_m::Peripherals::take().unwrap();

    let mut rcc = p.RCC.configure().freeze(&mut p.FLASH);
    let mut delay = Delay::new(cp.SYST, &rcc);
    loop {
        delay.delay_ms(1_000_u16);
        defmt::println!("Hello, world!");
    }

    helloworld1::exit()
}

Afterwards can you please test if the problem occurs with all your commits, or which commit introduced the bug.

When you have this please come back here with the results.

I assume this is an error on in the HAL, because I don't see which part of the template should be responsible for this, but let's see.

itxs commented 5 months ago

Sure, will check, sorry for delay