Problem with rtems_event_send crashing from interrupt routine

Mr. Andrei Chichak groups at chichak.ca
Mon Jun 15 17:46:50 UTC 2015


> On 2015-June-13, at 8:50 AM, Sebastian Huber <sebastian.huber at embedded-brains.de <mailto:sebastian.huber at embedded-brains.de>> wrote:
> 
> Halloo Andrei,
> 
> I checked in a patch that hopefully helps to debug this problem.  Please update the RTEMS sources and build the BSP with the --enable-rtems-debug configure option.  This will define RTEMS_DEBUG and enables a lot of assertions that detect incorrect states in the operating system.  Set a break point to __assert_func().  In case you hit this break point, then it would be helpful to send the stack trace to the mailing list.

V-gates Sebastian (wie geitz),


I did a git pull and rebuild and the results ARE different, and interesting I believe.

I’m still working on a striped down version of the program but it looks to be an interrupt related issue, so I’ll give you an idea of what is going on here.

I hook the ADC DMA half and full transfer complete interrupts using:

	status = rtems_interrupt_handler_install((rtems_vector_number) DMA2_Stream0_IRQn,
			ADC1handlerName, RTEMS_INTERRUPT_UNIQUE,
			(rtems_interrupt_handler) DMA2_Stream0_IRQHandler, NULL);
	if (status != RTEMS_SUCCESSFUL) {
		printk("interrupt handler install 1 failed with %d\n", status);
	}

	status = rtems_interrupt_handler_install((rtems_vector_number) DMA2_Stream2_IRQn,
			ADC2handlerName, RTEMS_INTERRUPT_UNIQUE,
			(rtems_interrupt_handler) DMA2_Stream2_IRQHandler, NULL);
	if (status != RTEMS_SUCCESSFUL) {
		printk("interrupt handler install 2 failed with %d\n", status);
	}


From the traceback, the half complete callback (DMA2_Stream0_IRQHandler, supplied by ST as a part of the CubeMX HAL, calls HAL_DMA_IRQHandler which figures out the reason for the interrupt and calls HAL_ADC_ConvHalfCpltCallback) which:

void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc) {
	LEDOff(LED_NAMES_RED);
	rtems_status_code status;
	status = rtems_event_send( ADCTaskId, RTEMS_EVENT_1);
	if (status != RTEMS_SUCCESSFUL) {
		printk("half complete callback failed with %d",status);
	}
}

Which generates:




assertion "_ISR_Get_level() != 0" failed: file "../../cpukit/../../../stm32f4/lib/include/rtems/score/threadimpl.h", line 990, function: _Thread_Lock_acquire_default_critical





#0  0x0001d57c in _Terminate (the_source=the_source at entry=RTEMS_FATAL_SOURCE_ASSERT, is_internal=is_internal at entry=false, the_error=the_error at entry=536875264) at ../../../../../../rtems/c/src/../../cpukit/score/src/interr.c:52
#1  0x0001c7c6 in rtems_fatal (source=source at entry=RTEMS_FATAL_SOURCE_ASSERT, error=error at entry=536875264) at ../../../../../../rtems/c/src/../../cpukit/sapi/src/fatal2.c:34
#2  0x00018dbc in __assert_func (file=file at entry=0x2423c "../../cpukit/../../../stm32f4/lib/include/rtems/score/threadimpl.h", line=128, line at entry=990, func=func at entry=0x24214 <__FUNCTION__.7604> "_Thread_Lock_acquire_default_critical", failedexpr=failedexpr at entry=0x24280 "_ISR_Get_level() != 0") at ../../../../../../rtems/c/src/../../cpukit/libcsupport/src/__assert.c:52
#3  0x0001bdd2 in _Thread_Lock_acquire_default_critical (the_thread=0x0 <bsp_start_vector_table_begin>, lock_context=0x2000113c, lock_context at entry=0x2000111c) at ../../cpukit/../../../stm32f4/lib/include/rtems/score/threadimpl.h:990
#4  _Event_Surrender (the_thread=0x0 <bsp_start_vector_table_begin>, event_in=event_in at entry=2, event=0x80 <bsp_start_vector_table_begin+128>, wait_class=wait_class at entry=256, lock_context=lock_context at entry=0x2000113c) at ../../../../../../rtems/c/src/../../cpukit/rtems/src/eventsurrender.c:67
#5  0x0001bcf6 in rtems_event_send (id=<optimized out>, event_in=event_in at entry=2) at ../../../../../../rtems/c/src/../../cpukit/rtems/src/eventsend.c:40
#6  0x0000058e in HAL_ADC_ConvHalfCpltCallback (hadc=<optimized out>) at ../src/adctask.c:258
#7  0x00007704 in HAL_DMA_IRQHandler (hdma=0x20002560 <hdma_adc1>) at ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c:763
#8  0x00018766 in bsp_interrupt_handler_dispatch (vector=<optimized out>) at ../../../../../.././stm32f4/lib/include/bsp/irq-generic.h:266
#9  _ARMV7M_NVIC_Interrupt_dispatch () at ../../../../../../../../rtems/c/src/lib/libbsp/arm/stm32f4/../shared/armv7m/irq/armv7m-irq-dispatch.c:28
#10 <signal handler called>
#11 0x00000000 in bsp_start_vector_table_begin ()

A


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20150615/0fdb1383/attachment-0001.html>


More information about the users mailing list