v2.6.1 (and 2.6.0) Kernel Panic in sysworkq

Code runs fine in v2.53 but when running in v2.6, we get a kernel panic at the exit of a delayable workqueue function. 

Tracing the code and line number, it dies in Zephyr. No idea where to go from here so any help would be appreciated.

ASSERTION FAIL @ WEST_TOPDIR/zephyr/include/zephyr/drivers/gpio.h:883
[00:00:17.195,861] <err> os: r0/a1: 0x00000004 r1/a2: 0x00000373 r2/a3: 0x00000000
[00:00:17.196,380] <err> os: r3/a4: 0x20010060 r12/ip: 0x000002ee r14/lr: 0x00045d0b
[00:00:17.196,899] <err> os: xpsr: 0x41000000
[00:00:17.197,265] <err> os: Faulting instruction address (r15/pc): 0x000668c2
[00:00:17.197,723] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
[00:00:17.198,211] <err> os: Current thread: 0x2000fb38 (sysworkq)
[00:00:17.203,582] <err> os: Halting system

CONFIG_HW_STACK_PROTECTION=y
CONFIG_DYNAMIC_OBJECTS=y
CONFIG_HEAP_MEM_POOL_SIZE=98304
#131072
CONFIG_NRF_MODEM_LIB_HEAP_SIZE=4096
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
#CONFIG_IDLE_STACK_SIZE=2048
CONFIG_AT_MONITOR_HEAP_SIZE=1024

Parents
  • Hello, 

    Could you please provide the output C:\ncs\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-addr2line.exe -e /build/zephyr/zephyr.elf 0x2000fb38 in command line ? Make sure to point to correct path of your toolchain folder cf2149caf2.

    If this does not work, please try with address 0x00045d0b

    This should give some indication of what is causing this fatal error. What happens if you remove the build folder completely?

    Kind regards,
    Øyvind

  • Deleted all build folders and rebuilt the application.

    D:\ncs\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-addr2line.exe -e .\build\zephyr\zephyr.elf 0x000668c2
    D:/ncs/v2.6.1/zephyr/lib/os/assert.c:44

  • ASSERTION FAIL @ WEST_TOPDIR/zephyr/include/zephyr/drivers/gpio.h:883

    The line it is referring to in this file is: 

        __ASSERT((flags & (GPIO_INT_DISABLE | GPIO_INT_ENABLE)) != 0U,
             "Must either enable or disable interrupts");
    Line 44 in assert.c does not provide any good information, other than k_panic()

    Could you run addr2line on address 0x00045d0b as well?
Reply
  • ASSERTION FAIL @ WEST_TOPDIR/zephyr/include/zephyr/drivers/gpio.h:883

    The line it is referring to in this file is: 

        __ASSERT((flags & (GPIO_INT_DISABLE | GPIO_INT_ENABLE)) != 0U,
             "Must either enable or disable interrupts");
    Line 44 in assert.c does not provide any good information, other than k_panic()

    Could you run addr2line on address 0x00045d0b as well?
Children
  • > D:\ncs\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-addr2line.exe -e .\build\zephyr\zephyr.elf 0x00045d93
    D:/ncs/v2.6.1/zephyr/include/zephyr/drivers/gpio.h:883

  • How are you calling gpio_pin_interrupt_configure() i.e. what flags are you setting. This seems to be due to given function not having either GPIO_INT_DISABLE or GPIO_INT_ENABLE. 

    Kind regards,
    Øyvind

  • int ret = gpio_pin_interrupt_configure_dt(&status, GPIO_INT_EDGE_BOTH);

  • Thanks for sharing. 

    From \zephyr\include\zephyr\drivers\gpio.h

    /**
     * @brief Configure pin interrupts from a @p gpio_dt_spec.
     *
     * This is equivalent to:
     *
     *     gpio_pin_interrupt_configure(spec->port, spec->pin, flags);
     *
     * The <tt>spec->dt_flags</tt> value is not used.
     *
     * @param spec GPIO specification from devicetree
     * @param flags interrupt configuration flags
     * @return a value from gpio_pin_interrupt_configure()
     */
    static inline int gpio_pin_interrupt_configure_dt(const struct gpio_dt_spec *spec,
    						  gpio_flags_t flags)
    {
    	return gpio_pin_interrupt_configure(spec->port, spec->pin, flags);
    }

    NautDesigner said:
    int ret = gpio_pin_interrupt_configure_dt(&status, GPIO_INT_EDGE_BOTH);

    What is &status pointing to in your case?

    Are you able to share more of your code around the interrupt configuration?

    Thanks.

    -Øyvind

  • static const struct gpio_dt_spec status = GPIO_DT_SPEC_GET_OR(SW3_NODE, gpios, {0});
    gpio_pin_configure_dt(&status, GPIO_INPUT);
    
    void statusCallback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) {
    
    //printk("*****\nCallback\n*****\n");
       if (gpio_pin_get_dt(&status)) {
          setStatusLED(true);
          //printk("** Status LED On **\n");
       } else {
          setStatusLED(false);
          //printk("** Status LED Off **\n");
       }
    //printk("* Leaving callback *\n");
    }
    
       int ret = gpio_pin_interrupt_configure_dt(&status, GPIO_INT_EDGE_BOTH); // edge falling is just an example.. you should set it what you need it to be
       if (ret != 0) {
          printk("Error %d: failed to configure interrupt pin %d\n", ret, status.pin);
       } else {
          gpio_init_callback(&fix_cb, statusCallback, BIT(status.pin));
          gpio_add_callback(status.port, &fix_cb);
       }

Related