Stack overflow during boot when both WiFi and USB stack (CDC_ACM) are enabled

Hello,

We are in the final stages of development with a board that combines the nRF5340 with the nRF7002. This board also requires native USB support and we are routing the Zephyr console to the  USB CDC_ACM interface. USB has been working fine until we brought WiFi into the mix. Now there's a fault during boot due to a stack overflow. After quite some research we are still unable to increase the stack size of the task where the problem occurs. Please see the UART console output below:

*** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***

*** Using Zephyr OS v3.7.99-ca954a6216c9 ***

[00:00:00.207,336] <inf> net_config: Initializing network

[00:00:00.215,332] <inf> net_config: Waiting interface 1 (0x20001d90) to be up...

[00:00:00.225,616] <inf> net_config: IPv4 address: 192.168.1.99

[00:00:00.234,191] <inf> net_config: Running dhcpv4 client...

[00:00:00.243,347] <inf> udc_nrf: Initialized

[00:00:00.250,305] <inf> usbd_init: interface 0 alternate 0

[00:00:00.258,483] <inf> usbd_init:     ep 0x81 mps 0x0010 interface ep-bm 0x00020000

[00:00:00.268,646] <inf> usbd_init: interface 1 alternate 0

[00:00:00.276,855] <inf> usbd_init:     ep 0x82 mps 0x0040 interface ep-bm 0x00040000

[00:00:00.287,048] <inf> usbd_init:     ep 0x01 mps 0x0040 interface ep-bm 0x00040002

[00:00:00.297,180] <inf> usbd_init: Instance iface-bm 0x00000003 ep-bm 0x00060002

[00:00:00.307,281] <inf> usbd_init: Init class node 0x20000454, descriptor length 66

[00:00:00.317,626] <inf> usbd_init: bNumInterfaces 2 wTotalLength 75

[00:00:00.326,568] <inf> usbd_init: FS bNumConfigurations 1

[00:00:00.334,869] <inf> usbd_cdc_acm: rx_en: trigger rx_fifo_work

[00:00:00.343,780] <err> os: ***** USAGE FAULT *****

[00:00:00.351,776] <err> os:   Stack overflow (context area not valid)

[00:00:00.361,175] <err> os: r0/a1:  0x2002b864  r1/a2:  0x2002b8cc  r2/a3:  0x00000002

[00:00:00.372,039] <err> os: r3/a4:  0xffffffff r12/ip:  0x00000000 r14/lr:  0x00000064

[00:00:00.382,873] <err> os:  xpsr:  0x0005ce00

[00:00:00.390,319] <err> os: s[ 0]:  0x00000003  s[ 1]:  0x00001683  s[ 2]:  0x2002b87d  s[ 3]:  0xaaaaaaaa

[00:00:00.402,923] <err> os: s[ 4]:  0xaaaaaaaa  s[ 5]:  0x00075d40  s[ 6]:  0x00000000  s[ 7]:  0x0007e3d2

[00:00:00.415,527] <err> os: s[ 8]:  0x00000080  s[ 9]:  0xaaaaaaaa  s[10]:  0xaaaaaaaa  s[11]:  0xaaaaaaaa

[00:00:00.428,131] <err> os: s[12]:  0xaaaaaaaa  s[13]:  0xaaaaaaaa  s[14]:  0xaaaaaaaa  s[15]:  0xaaaaaaaa

[00:00:00.440,704] <err> os: fpscr:  0x0007e3d1

[00:00:00.448,120] <err> os: Faulting instruction address (r15/pc): 0x00000000

[00:00:00.458,221] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0

[00:00:00.468,292] <err> os: Current thread: 0x20003770 (udc_nrfx)

[00:00:00.477,325] <err> os: Halting system

uart:~$

Is this something that can be fixed by config settings? Or requires a patch directly in the NCS source code?

Best regards,

Daniel Campora

Parents
  • Hi, 

    You could try increasing the stack size of the USB_WORKQUEUE_STACK_SIZE parameter to a larger value and see if it solves the situation.

    The default should be 1024 bytes. Try larger values like 2048 or 4096 and see if it works better:

    CONFIG_USB_WORKQUEUE_STACK_SIZE=4096
    Regards,
    Amanda H.
  • I already tried that. And even set to 8912. Same result. I tried all the following configurations:

    CONFIG_MAIN_STACK_SIZE=16384
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192
    CONFIG_USB_NRFX_WORK_QUEUE_STACK_SIZE=8192
    CONFIG_USB_WORKQUEUE_STACK_SIZE=8192
    CONFIG_BT_RX_STACK_SIZE=4096
    CONFIG_BT_HCI_TX_STACK_SIZE=4096
  • So far increasing all those stack sizes made no difference. Any other ideas?

  • Try to increase CONFIG_UDC_NRF_THREAD_STACK_SIZE. 

  • Thanks. I increased that value to 16384. And things are not a bit different. This is now the behaviour during boot:

    [00:00:00.057,556] <inf> wifi_nrf: Management buffer offload enabled

    *** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***

    *** Using Zephyr OS v3.7.99-ca954a6216c9 ***

    [00:00:00.208,862] <inf> net_config: Initializing network

    [00:00:00.216,857] <inf> net_config: Waiting interface 1 (0x20001d90) to be up...

    [00:00:00.227,172] <inf> net_config: IPv4 address: 192.168.1.99

    [00:00:00.235,748] <inf> net_config: Running dhcpv4 client...

    [00:00:00.244,903] <inf> udc_nrf: Initialized

    [00:00:00.251,861] <inf> usbd_init: interface 0 alternate 0

    [00:00:00.260,070] <inf> usbd_init:     ep 0x81 mps 0x0010 interface ep-bm 0x00020000

    [00:00:00.270,233] <inf> usbd_init: interface 1 alternate 0

    [00:00:00.278,442] <inf> usbd_init:     ep 0x82 mps 0x0040 interface ep-bm 0x00040000

    [00:00:00.288,635] <inf> usbd_init:     ep 0x01 mps 0x0040 interface ep-bm 0x00040002

    [00:00:00.298,797] <inf> usbd_init: Instance iface-bm 0x00000003 ep-bm 0x00060002

    [00:00:00.308,898] <inf> usbd_init: Init class node 0x20000454, descriptor length 66

    [00:00:00.319,274] <inf> usbd_init: bNumInterfaces 2 wTotalLength 75

    [00:00:00.328,216] <inf> usbd_init: FS bNumConfigurations 1

    [00:00:00.336,517] <inf> usbd_cdc_acm: rx_en: trigger rx_fifo_work

    [00:00:00.340,637] <inf> udc_nrf: SUSPEND state detected

    [00:00:00.353,393] <inf> usbd_cdc_acm: USB configuration is not enabled or suspended

    [00:00:00.364,776] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.373,535] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1023

    [00:00:00.383,972] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.392,700] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1022

    [00:00:00.403,137] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.411,895] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1021

    [00:00:00.422,332] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.431,060] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1020

    [00:00:00.441,497] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.450,225] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1019

    [00:00:00.460,662] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.469,421] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1018

    [00:00:00.479,858] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.488,586] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1017

    [00:00:00.499,023] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.507,781] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1016

    [00:00:00.517,242] <inf> udc_nrf: Reset

    uart:~$ [00:00:00.524,475] <inf> udc_nrf: RESUMING from suspend

    [00:00:00.532,348] <inf> udc: ep 0x80 is not halted|disabled

    [00:00:00.540,649] <inf> usbd_core: Actual device speed 1

    [00:00:00.548,767] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.557,739] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1015

    [00:00:00.568,328] <inf> udc: Sequence 3 not completed

    [00:00:00.576,141] <inf> usbd_ch9: Handle control 0x20057d10 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.586,975] <inf> usbd_ch9: Handle control 0x20057d58 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.597,839] <err> udc: Cannot determine the next stage

    [00:00:00.606,506] <inf> usbd_ch9: Handle control 0x20057d34 ep 0x80, len 0, s:0 d:0 s:1

    [00:00:00.617,187] <inf> usbd_ch9: s-(out)-status finished

    [00:00:00.625,427] <inf> udc: Sequence 6 not completed

    [00:00:00.633,300] <inf> usbd_ch9: Handle control 0x20057d34 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.644,287] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.646,789] <inf> usbd_ch9: Handle control 0x20057d58 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.664,184] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1014

    [00:00:00.674,774] <inf> usbd_ch9: Handle control 0x20057d34 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.685,821] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.686,157] <inf> usbd_ch9: Handle control 0x20057d58 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.705,657] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1013

    [00:00:00.716,217] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.716,552] <inf> usbd_ch9: Handle control 0x20057d34 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.736,145] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1012

    [00:00:00.746,734] <inf> usbd_ch9: Handle control 0x20057d58 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.757,781] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.758,148] <inf> usbd_ch9: Handle control 0x20057d34 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.777,679] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1011

    [00:00:00.788,238] <inf> usbd_ch9: Handle control 0x20057d58 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.799,285] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.799,652] <inf> usbd_ch9: Handle control 0x20057d34 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.819,122] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1010

    [00:00:00.829,711] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.829,956] <inf> usbd_ch9: Handle control 0x20057d58 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.849,517] <inf> usbd_cdc_acm: UART dev 0x75154, len 1, remaining space 1009

    [00:00:00.860,107] <inf> usbd_cdc_acm: tx_en: trigger irq_cb_work

    [00:00:00.863,830] <inf> usbd_ch9: Handle control 0x20057d34 ep 0x00, len 8, s:1 d:0 s:0

    [00:00:00.879,791] <inf> usbd_ch9: Set Configuration Request value 1

    [00:00:00.889,526] <err> os: ***** USAGE FAULT *****

    [00:00:00.897,369] <err> os:   Stack overflow (context area not valid)

    [00:00:00.906,768] <err> os: r0/a1:  0x00000001  r1/a2:  0x00075828  r2/a3:  0x2001c9b7

    [00:00:00.917,633] <err> os: r3/a4:  0x00000000 r12/ip:  0x0005cc6b r14/lr:  0x00007ce7

    [00:00:00.928,497] <err> os:  xpsr:  0x00075800

    [00:00:00.935,913] <err> os: s[ 0]:  0x2001c9cf  s[ 1]:  0x00000000  s[ 2]:  0x0005cc6b  s[ 3]:  0x00007ce7

    [00:00:00.948,516] <err> os: s[ 4]:  0x00000001  s[ 5]:  0x2001ca4c  s[ 6]:  0x2001ca4d  s[ 7]:  0x0005c815

    [00:00:00.961,151] <err> os: s[ 8]:  0x00075d80  s[ 9]:  0x0005d4a3  s[10]:  0x2001ca4d  s[11]:  0x0005c829

    [00:00:00.973,754] <err> os: s[12]:  0x00000030  s[13]:  0x30075d80  s[14]:  0x2001ca4c  s[15]:  0x0005c06f

    [00:00:00.986,328] <err> os: fpscr:  0x2001ca9c

    [00:00:00.993,743] <err> os: Faulting instruction address (r15/pc): 0x00000001

    [00:00:01.003,845] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0

    [00:00:01.013,916] <err> os: Current thread: 0x20002748 (usbd)

    [00:00:01.022,613] <err> os: Halting system

  • Try to increase CONFIG_USB_DEVICE_STACK_SIZE for usbd. 

Reply Children
No Data
Related