Flipper-XFW / Xtreme-Firmware

The Dom amongst the Flipper Zero Firmware. Give your Flipper the power and freedom it is really craving. Let it show you its true form. Dont delay, switch to the one and only true Master today!
https://flipper-xtre.me
GNU General Public License v3.0
9.15k stars 651 forks source link

Apps: Geiger Counter: Fix furi_hal_gpio crash #549

Open braw opened 4 months ago

braw commented 4 months ago

Describe the bug.

Geiger Counter app crashes Flipper. Using FlippenHeimer board. Worked in XFW-0052_09122023, but appears broken in XFW-0053_02022024. Rolled back to XFW-0052_09122023 and have no issues.

Screen shows this after reboot:

Flipper crashed but has been rebooted targets/f7/furi_hal/furi_hal_gpio.c

Reproduction

  1. Plug in FlippenHeimer board.
  2. Launch Geiger Counter app.
  3. System crashes and reboots.

Target

targets/f7/furi_hal/furi_hal_gpio.c

Logs

No response

Anything else?

No response

Willy-JL commented 4 months ago

Can you try on latest development build? I have a feeling that the expansion related changes fixed this, as I cannot reproduce it

braw commented 4 months ago

I tried building Dev and installing. Both the Geiger Counter app and the Geiger Dice Roll still crash and reboot the Flipper. No issues when rolling back to XFW-0052_09122023. I tried formatting the SD and installing, rolling back to stock OS then to Dev XFW and it still crashes for me.

braw commented 4 months ago

I also tried the build here, and get the same results. It crashes if I have the FlippenHeimer board plugged in or not.

Willy-JL commented 4 months ago

managed to reproduce it, will have a fix soon. its related to the expansion stuff as i thought, but its just that its not been adapted to support them existing

Willy-JL commented 4 months ago

for now can just set Settings > Expansion Modules > Listen UART = None

Willy-JL commented 4 months ago

this is quite confusing... it crashes at

furi_hal_gpio_add_int_callback(&gpio_ext_pa7, gpiocallback, event_queue);

which looks fine as code... the reason it crashes i see in debugger is that &gpio_ext_pa7 already has a callback configured, but that doesnt make much sense... ill keep investigating

braw commented 4 months ago

I appreciate you looking into it. Just wanted to report it.

Willy-JL commented 4 months ago

this seems to be a problem with gpio pins callback from ofw. it stores interrupt callbacks based on pin index but not port. so pin 7 of right half of gpio had a callback, and setting a callback for pin 7 of left half conflicted, even though it should not have. for now, i can simply disable expansion modules in this app, but i mentioned this to ofw, hope it will get a proper fix

Willy-JL commented 4 months ago

temporarily fixed via b9594f9b4fe92752d6bb8ed2235a395c9b6a53bf, lets hope we get a proper fix from upstream

Willy-JL commented 4 months ago

drzlo and skotopes explained the issue, seems like it cannot be fixed properly. gpio pin interrupts are done via exti lines, which are shared between gpio ports, so pin 7 of port a will share the interrupt with pin 7 of port b and all other ports... so yeah disabling expansion module is the only option, this is a hardware limitation of the cpu of flipper.