Skip to main content
Visitor II
October 20, 2019
Solved

Why is uart0 blocking uart1 ?

  • October 20, 2019
  • 2 replies
  • 1061 views

Hello,

I am running example "OpenAMP_TTY_echo" on the board "stm32mp157c-dk2"

I have modified the code a little bit so that channel0 (uart0) doesn't have to wait for a massage from linux side and transmit message every half second. It is sending the messages on every half second without problem.But the problem is now uart1 is not working. I mean on linux side if I write "echo "Hello Virtual UART1" >/dev/ttyRPMSG1" , I can not receive any callback message from the console. This means channel 1 is not working because channel 0 is blocking it. Is it normal ? Why normal ?

while (1)
 {
 
 OPENAMP_check_for_message();
 " "
 " "
 VIRT_UART_Transmit(&huart0, Data, size);
 HAL_Delay(500);
 
 if (VirtUart1RxMsg) {
 VirtUart1RxMsg = RESET;
 VIRT_UART_Transmit(&huart1, VirtUart1ChannelBuffRx, VirtUart1ChannelRxSize);
 }
 
 }

    This topic has been closed for replies.
    Best answer by Calvin Ageneau

    Hello,

    I managed to reproduce and i found an issue in the MAILBOX_Poll function in OpenAPM_TTY_echo/Src/mbox_ipcc.c.

    This function treats either a buffer free or a new message event but not both. As a buffer free event is received each time a rpmsg is sent from Cortex-M4, the message received event is never considered and the variable is never set. It will be fixed in a future version but if you want to fix it in your code you can replace the MAILBOX_Poll function by this one : 

    /**
     * @brief Initialize MAILBOX with IPCC peripheral
     * @param virtio device
     * @retval : Operation result
     */
    int MAILBOX_Poll(struct virtio_device *vdev)
    {
     /* If we got an interrupt, ask for the corresponding virtqueue processing */
    	int ret = -1;
     if (msg_received_ch1 == RX_BUF_FREE) {
     OPENAMP_log_dbg("Running virt0 (ch_1 buf free)\r\n");
     rproc_virtio_notified(vdev, VRING0_ID);
     msg_received_ch1 = RX_NO_MSG;
     ret = 0;
     }
     
     if (msg_received_ch2 == RX_NEW_MSG) {
     OPENAMP_log_dbg("Running virt1 (ch_2 new msg)\r\n");
     rproc_virtio_notified(vdev, VRING1_ID);
     msg_received_ch2 = RX_NO_MSG;
     
     /* The OpenAMP framework does not notify for free buf: do it here */
     rproc_virtio_notified(NULL, VRING1_ID);
     ret = 0;
     }
     
     return ret;
    }

    BR,

    Calvin

    2 replies

    Visitor II
    October 25, 2019

    Hello,

    I managed to reproduce and i found an issue in the MAILBOX_Poll function in OpenAPM_TTY_echo/Src/mbox_ipcc.c.

    This function treats either a buffer free or a new message event but not both. As a buffer free event is received each time a rpmsg is sent from Cortex-M4, the message received event is never considered and the variable is never set. It will be fixed in a future version but if you want to fix it in your code you can replace the MAILBOX_Poll function by this one : 

    /**
     * @brief Initialize MAILBOX with IPCC peripheral
     * @param virtio device
     * @retval : Operation result
     */
    int MAILBOX_Poll(struct virtio_device *vdev)
    {
     /* If we got an interrupt, ask for the corresponding virtqueue processing */
    	int ret = -1;
     if (msg_received_ch1 == RX_BUF_FREE) {
     OPENAMP_log_dbg("Running virt0 (ch_1 buf free)\r\n");
     rproc_virtio_notified(vdev, VRING0_ID);
     msg_received_ch1 = RX_NO_MSG;
     ret = 0;
     }
     
     if (msg_received_ch2 == RX_NEW_MSG) {
     OPENAMP_log_dbg("Running virt1 (ch_2 new msg)\r\n");
     rproc_virtio_notified(vdev, VRING1_ID);
     msg_received_ch2 = RX_NO_MSG;
     
     /* The OpenAMP framework does not notify for free buf: do it here */
     rproc_virtio_notified(NULL, VRING1_ID);
     ret = 0;
     }
     
     return ret;
    }

    BR,

    Calvin

    IYetkAuthor
    Visitor II
    October 25, 2019

    Thank you very much