nRF5340 CDC + SDCard generate Stack Overflow

Hello,

I am working with a nRF5340 and need to use both CDC and mass storage on SD Card. I started my application based on the CDC example and it has worked fine.

Now I need to implement the SD Card. Using the mass storage example from zephyr, it has kind of worked. The file system is started OK and the card is detected and read. But when the USB is started, an Stack Overflow occurs.

Nevertheless, I merged the SD Card functions into my app. It has performed better, as the USB can start and the removable disk can be accessed in windows. But, in order to have it working, it is necessary to disable the CDC initialization, otherwise it will also genarate an Stack overflow. My questions are:

  1. Why does the CDC API utilizes a physical UART port? I found that the UARTE0 is being initialized when CDC is enabled and some of the chosen pins are the ones I use in my SPI  interface with the SD Card.
  2. Wasn't the mass storage example supposed to work without problems in the nRF5340?
  3. What could be the cause for the Stack Overflow? I have incresed the reserved stack (CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE and CONFIG_MAIN_STACK_SIZE) up to 256kB and didn't had any improvements.
  4. Is there any known example on zephyr runnig both CDC and SD Card?

I have attached my overlay file and a log  of the error.

My environment is:

Windows 11, VSCode and NCS v1.9.

Any help would be really appreciated.

Thanks in advance,

Eduardo Carletti

00> *** Booting Zephyr OS build v2.7.99-ncs1  ***
00> 
00> [00:00:00.562,103] <inf> sdmmc_spi: Found a ~3781 MiB SDHC card.
00> [00:00:00.563,446] <inf> sdmmc_spi: Manufacturer ID=3 OEM='SD' Name='SS04G' Revision=0x80 Serial=0x2183f89f
00> [00:00:00.563,537] <inf> BATTERY: Setup AIN2 got 0
00> [00:00:00.563,537] <inf> BATTERY: Battery setup: 0 1
00> [00:00:36.035,095] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
00> [00:00:36.035,125] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
00> [00:00:36.035,125] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 14.50663 Build 1008232294
00> [00:00:36.038,940] <inf> bt_hci_core: Identity: C1:89:0C:B2:C3:A8 (random)
00> [00:00:36.038,970] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x22fe, manufacturer 0x0059
00> [00:00:36.038,970] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x22fe
00> Set up button at GPIO_1 pin 1
00> 
00> Set up button at GPIO_0 pin 24
00> 
00> Set up button at GPIO_0 pin 25
00> 
00> Set up button at GPIO_0 pin 5
00> 
00> [00:00:36.107,177] <inf> sdmmc_spi: Found a ~3781 MiB SDHC card.
00> [00:00:36.108,551] <inf> sdmmc_spi: Manufacturer ID=3 OEM='SD' Name='SS04G' Revision=0x80 Serial=0x2183f89f
00>   D 0 SYSTEM~1
00> 
00> --- 3 messages dropped ---
00>   D 0 FOLDER~1
00> 
00>   F 3015 MAIN.C
00> 
00>   F 5976390 MAPA_LPC.RAR
00> 
00> End of files
00> 
00> [00:00:36.733,673] <inf> main: Status 2
00> [00:00:36.736,755] <inf> usb_cdc_acm: Device suspended
00> [00:00:36.736,755] <inf> usb_cdc_acm: Device suspended
00> [00:00:36.736,785] <inf> main: Status 5
00> [00:00:36.888,610] <inf> usb_cdc_acm: Device resumed
00> [00:00:36.888,641] <inf> usb_cdc_acm: from suspend
00> [00:00:36.888,641] <inf> usb_cdc_acm: Device resumed
00> [00:00:36.888,641] <inf> usb_cdc_acm: from suspend
00> [00:00:36.888,641] <inf> main: Status 6
00> [00:00:36.888,702] <inf> main: Status 1
00> [00:00:36.990,661] <inf> main: Status 1
00> [00:00:37.076,843] <inf> usb_cdc_acm: Device configured
00> [00:00:37.076,873] <inf> usb_cdc_acm: Device configured
00> [00:00:37.076,904] <inf> main: Status 3
00> 
00> [00:00:37.155,090] <err> os: ***** USAGE FAULT *****
00> [00:00:37.155,090] <err> os:   Stack overflow (context area not valid)
00> [00:00:37.155,090] <err> os: r0/a1:  0x00000000  r1/a2:  0x0012ad74  r2/a3:  0x0002d666
00> [00:00:37.155,120] <err> os: r3/a4:  0x81000000 r12/ip:  0x00000000 r14/lr:  0x00000000
00> [00:00:37.155,120] <err> os:  xpsr:  0x00000000
00> [00:00:37.155,120] <err> os: Faulting instruction address (r15/pc): 0x00000000
00> [00:00:37.155,120] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
00> [00:00:37.155,151] <err> os: Current thread: 0x200017f8 (usb_mass)
00> [00:00:37.746,002] <err> fatal_error: Resetting system[0m
00> *** Booting Zephyr OS build v2.7.99-ncs1  ***

Parents Reply Children
No Data
Related