SV#8 during concurrence of two adjacent ISR

Discussions and support about ChibiOS/RT, the free embedded RTOS.
User avatar
Cesare
Posts: 36
Joined: Tue Jul 11, 2017 11:51 am
Location: Milan, Italy
Has thanked: 3 times
Been thanked: 3 times

SV#8 during concurrence of two adjacent ISR

Postby Cesare » Tue Dec 13, 2022 8:57 pm

Good evening to everyone,
I am developing along STM32F407VGT on STM32F4-Discovery board.
I have one thread which continuously fills a double DMA buffer where the DMA moves data from memory to a GPIO peripheral at very high frequency. I have a DMA ISR every 570 uS.

I have another function, called from the shell, which uses chprintf() and writes characters to a stream managed by the SERIAL driver (SD3).
If I execute this function, very soon the OS gets stuck at SV#8 error. This happens during the DMA ISR at the state check __dbg_check_enter_isr().

Code: Select all

/**
 * @brief   DMA2 stream 1 shared interrupt handler.
 */
OSAL_IRQ_HANDLER(STM32_DMA2_CH1_HANDLER) {
  uint32_t flags;

  OSAL_IRQ_PROLOGUE();         <===== OS GET STUCK HERE =====

  flags = (DMA2->LISR >> 6U) & STM32_DMA_ISR_MASK;
  DMA2->LIFCR = flags << 6U;
  if (dma.streams[9].func)
    dma.streams[9].func(dma.streams[9].param, flags);

  OSAL_IRQ_EPILOGUE();
}


This is the stack trace:

Thread #1 (Suspended : Signal : SIGINT:Interrupt)
chSysHalt() at chsys.c:232 0x80015ae
__dbg_check_enter_isr() at chdebug.c:220 0x8001940
Vector124() at stm32_dma.c:329 0x8003c9e
<signal handler called>() at 0xfffffffd
chSchGoSleepS() at chschd.c:313 0x800231c
chSchGoSleepTimeoutS() at chschd.c:374 0x80023c2
chThdEnqueueTimeoutS() at chthreads.c:879 0x8002418
osalThreadEnqueueTimeoutS() at osal.h:895 0x800453e
oqPutTimeout() at hal_queues.c:546 0x800453e
_put() at hal_serial.c:64 0x80045cc
chvprintf() at chprintf.c:329 0x800279a
chprintf() at chprintf.c:371 0x800279a
render_dump() at eeprom_shell.c:65 0x8002f22
do_dump() at eeprom_shell.c:88 0x8002f22
argparse_getvalue() at argparse.c:149 0x8003172
parse_short_opt() at argparse.c:181 0x80031d2
ARGPARSE_Parse() at argparse.c:313 0x8003274
EEPROM_Shell() at eeprom_shell.c:126 0x8003460
cmdexec() at shell.c:106 0x80051ae
shellThread() at shell.c:405 0x80051ae
__port_thread_start() at chcoreasm.S:203 0x80002fe


I had to manage this error already several times, all those times when I forgot to use the I-class API. But this time I can't figure out what I am doing wrong.
If I get SV#8 it probably means I am missing some chSysLock() during the chprintf(), but I supposed this was already managed in the stream object.

Thanks in advance for any hint.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: SV#8 during concurrence of two adjacent ISR

Postby Giovanni » Tue Dec 13, 2022 9:04 pm

Hi,

It is also possible that you are using an invalid priority for that IRQ, use values 3...15. 0...2 could cause that error because those can preempt the kernel critical sections.

Giovanni

User avatar
Cesare
Posts: 36
Joined: Tue Jul 11, 2017 11:51 am
Location: Milan, Italy
Has thanked: 3 times
Been thanked: 3 times

Re: SV#8 during concurrence of two adjacent ISR

Postby Cesare » Wed Dec 14, 2022 7:07 pm

Giovanni,
you are always the MCU 'Professor' :D

My issue was very simple, the DMA IRQ priority in the NVIC register was erroneously set to 0. Changing it in the range 3-15 made it working perfectly.

Thank you so much.


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 43 guests