rtems_binary_semaphore_post from IRQ handler
jameszxj at gmail.com
Mon May 6 04:21:30 UTC 2019
From the document c-user.pdf 25.6.6，the funciton may be called from interrupt context. I have used rtems_semaphore_xxx API in UART drivers, it works fine.
RTEMS_FATAL_SOURCE_EXCEPTION should print the PC,LR ...
I think you can trace the PC pointer to see what makes the FATAL.
------------------ Original ------------------
From: "Ярослав Лещински"<midniwalker at gmail.com>;
Date: Sun, May 5, 2019 11:55 PM
To: "users"<users at rtems.org>;
Subject: Re: rtems_binary_semaphore_post from IRQ handler
still have some troubles with post/wait binary semaphore sequence. Could someone suggest what is a right way when you're working with semaphore inside interrupts.
I have sys call via spidev which is waiting for the binary semaphore. Semaphore released inside the interrupt. In some cases after several transmission I'm getting fatal: RTEMS_FATAL_SOURCE_EXCEPTION.
I'll be really appreciate for any suggestions.
On Wed, 17 Apr 2019 at 16:25, Ярослав Лещинский <midniwalker at gmail.com> wrote:
I wrote spidev driver for stm32l4 mcu.
spi_trasfer function looks like:
static int spi_transfer(
const spi_ioc_transfer *msgs,
struct stm32l4_spi_bus *bus = (struct stm32l4_spi_bus *)base;
SPI_TypeDef *spix = (SPI_TypeDef *)bus->driver.spix;
enum spi_major_num num = get_spi_major_number(spix);
bus->msg = &msgs;
spi_bus_table[num] = bus;
spi_bus_table[num]->msg_count = msg_count;
spi_bus_table[num]->messages_left = msg_count;
int msg_error = spi_setup_trasfer(
return (msg_error == 0)? 0 : -EINVAL;
Transmission proceeded via SPI IRQ + DMA IRQ. In DMA IRQ handler after dma successfully transmitted all data I'm using rtems_binary_semaphore_post for corresponding semaphore.
bool bus_is_broken = (bus == NULL) ||
(msg_count < bus->messages_left) ||
(msg_count == 0);
int ret = 0;
if(bus_is_broken == true)
if(msgs->cs_change == true)
if(bus->messages_left > 0)
const size_t msg_idx = msg_count - bus->messages_left;
ret = spi_do_transfer(bus, msgs, msg_idx);
if(ret != 0)
Currently I see that semaphore was successfully posted but control was not returned to spi_transfer.
As I know there are can be some issues with a context switching. Does rtems_binary_semaphore_post know about where control should be returned?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the users