micro-ros zephyr - Fault during interrupt handling
Hello,
I am developing an app that has 4 GPIO input interrupts for turbine flow sensors. I started developing It on pure Zephyr and everything worked fine. When I added Micro-ROS to the software stack, the interrupts started causing the halting error below when the first interrupt is triggered. BTW, the app has 3 low-frequency sensor threads running in parallel beside the Micro-ROS tasks. I've tried without the additional threads and the issue is still. So, just Micro-ROS with the interrupts is enough to cause the halting. I've tried with ROS Foxy and Galactic.
[00:04:31.528,000] <err> os: ***** BUS FAULT *****
[00:04:31.528,000] <err> os: Instruction bus error
[00:04:31.528,000] <err> os: r0/a1: 0x2000144c r1/a2: 0x08018ebf r2/a3: 0x0
[00:04:31.528,000] <err> os: r3/a4: 0x00b15046 r12/ip: 0x00000030 r14/lr: 0xb
[00:04:31.528,000] <err> os: xpsr: 0x000d0027
[00:04:31.528,000] <err> os: Faulting instruction address (r15/pc): 0x00b15046
[00:04:31.528,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:04:31.528,000] <err> os: Fault during interrupt handling
[00:04:31.528,000] <err> os: Current thread: 0x20001a58 (unknown)
[00:04:31.529,000] <err> os: Halting system
I did some experiments and dug a bit on the internet, but didn't find anything related. Does anyone know which measures I have to adopt in order to use GPIO interrupts together with Micro-ROS?
Hi @Jefecito, great
user_name
btw, I am not sure if you have check this tutorial: https://github.com/maksimdrachov/zeph...Hi, @osilva. Yes, I saw this tutorial. BTW, it's a very good initiative. But, I am not using any of these types of interrupt. I am using GPIO interrupts, like this code below.
Yes you were clear it's for GPIO. Sorry I missed that. I don't have much experience in this area but it's something it's in my list to do to learn. Hopefully you find an answer soon, pls make sure to document so others may benefit as well.
Thank you. Yes, I will do it.
Maybe it is related to stack? a micro-ROS task uses a considerable amount of stack memory. It highly depends on the case. How long is the stack assigned to the Zephyr micro-ROS task?
No, the stack wasn't the problem. I just discovered what was happening. It seems my mistake while using the GPIO API. It turns out that Instead of using the functions
gpio_pin_configure_dt(const struct gpio_dt_spec *spec, gpio_flags_t extra_flags)
andgpio_pin_interrupt_configure_dt(const struct gpio_dt_spec *spec, gpio_flags_t flags)
, I decided to usegpio_pin_configure(const struct device * port, gpio_pin_t pin, gpio_flags_t flags)
andgpio_pin_interrupt_configure(const struct device * port, gpio_pin_t pin, gpio_flags_t flags)
. The last ones receive a device struct as the first parameter instead of a gpio spec struct. It worked fine in Zephyr only but messed everything while working together with micro-ROS. Maybe it has caused some memory misallocation only reproduced when more memory is in use.Anyway, thank you, Guys!