[riot-notifications] [RIOT-OS/RIOT] drivers/dose: make use of start condition received interrupt (#16506)

Juergen Fitschen notifications at github.com
Wed Jul 28 11:43:06 CEST 2021


@jue89 requested changes on this pull request.

I think, I found the problem.

GDB to the rescue:
```
(gdb) info threads
  Id   Target Id                                 Frame 
  1    Thread 1 (Name: main, Pending)            __ISB () at /home/jue/Projects/RIOT/cpu/cortexm_common/include/vendor/cmsis_gcc.h:868
  2    Thread 2 (Name: pktdump, Blocked receive) __ISB () at /home/jue/Projects/RIOT/cpu/cortexm_common/include/vendor/cmsis_gcc.h:868
  3    Thread 3 (Name: ipv6, Pending)            __ISB () at /home/jue/Projects/RIOT/cpu/cortexm_common/include/vendor/cmsis_gcc.h:868
  4    Thread 4 (Name: udp, Blocked receive)     __ISB () at /home/jue/Projects/RIOT/cpu/cortexm_common/include/vendor/cmsis_gcc.h:868
* 5    Thread 5 (Name: dose, Running)            uart_write (uart=<optimized out>, data=0x20001438 <_netdev_eth_stack+663> "\340\026", data at entry=0x20001437 <_netdev_eth_stack+662> "", len=len at entry=1) at /home/jue/Projects/RIOT/cpu/sam0_common/periph/uart.c:69
(gdb) bt
#0  uart_write (uart=<optimized out>, data=0x20001438 <_netdev_eth_stack+663> "\340\026", data at entry=0x20001437 <_netdev_eth_stack+662> "", len=len at entry=1) at /home/jue/Projects/RIOT/cpu/sam0_common/periph/uart.c:69
#1  0x0000137e in send_octet (ctx=ctx at entry=0x200016e0 <dose>, c=<optimized out>, c at entry=0 '\000') at /home/jue/Projects/RIOT/drivers/dose/dose.c:389
#2  0x000013b6 in send_data_octet (ctx=ctx at entry=0x200016e0 <dose>, c=<optimized out>) at /home/jue/Projects/RIOT/drivers/dose/dose.c:420
#3  0x00001700 in _send (dev=0x200016e0 <dose>, iolist=0x2000148c <_netdev_eth_stack+747>) at /home/jue/Projects/RIOT/drivers/dose/dose.c:449
#4  0x00005ca2 in _send (netif=0x200015a4 <_netif>, pkt=0x20001d30 <_pktbuf_buf>) at /home/jue/Projects/RIOT/sys/net/gnrc/netif/ethernet/gnrc_netif_ethernet.c:163
#5  0x000061b0 in _send (push_back=false, pkt=<optimized out>, netif=0x200015a4 <_netif>) at /home/jue/Projects/RIOT/sys/net/gnrc/netif/gnrc_netif.c:1578
#6  _gnrc_netif_thread (args=0x200015a4 <_netif>) at /home/jue/Projects/RIOT/sys/net/gnrc/netif/gnrc_netif.c:1702
#7  0x00000af8 in sched_switch (other_prio=5856) at /home/jue/Projects/RIOT/core/sched.c:263
```

The `dose` thread is hanging during `uart_write()` and don't move forward. Looking in the code reveals the only end-less loop that might trigger such a behaviour:

```c
    for (const void* end = data + len; data != end; ++data) {
        while (!dev(uart)->INTFLAG.bit.DRE) {}
        dev(uart)->DATA.reg = *data;
    }
    while (!dev(uart)->INTFLAG.bit.TXC) {}
```

I guess that clearing all IRQ flags during ISR might steal the DRE or the TCX IRQ!

>      uint32_t status = dev(uartnum)->INTFLAG.reg;
+    dev(uartnum)->INTFLAG.reg = status;

This part clears IRQ flags that aren't handled by this ISR. We should mask-out those flags.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16506#pullrequestreview-716794857
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210728/ab5a2417/attachment-0001.htm>


More information about the notifications mailing list