csanchezdll opened a new issue, #16668:
URL: https://github.com/apache/nuttx/issues/16668

   ### Description / Steps to reproduce the issue
   
   Error interrupts from CAN peripheral CAN flood the system.
   
   ### How to reproduce
   You need a STM32 board with CAN interfaces enabled. This has been observed 
in a custom board using STM32H7.
   
   Use the following program:
   ```
   #include <net/if.h>
   #include <netpacket/can.h>
   #include <nuttx/can.h>
   #include <stdio.h>
   #include <sys/ioctl.h>
   #include <sys/socket.h>
   #include <unistd.h>
   
   int
   main (int argc, char *argv[])
   {
     int s;
     struct sockaddr_can addr;
     struct ifreq ifr;
     struct can_frame frame;
     int i;
   
     s = socket (PF_CAN, SOCK_RAW, CAN_RAW);
   
     strcpy(ifr.ifr_name, "can_6_14");
     ioctl(s, SIOCGIFINDEX, &ifr);
   
     addr.can_family = AF_CAN;
     addr.can_ifindex = ifr.ifr_ifindex;
   
     bind (s, (struct sockaddr *) &addr, sizeof (addr));
   
     ifr.ifr_flags |= IFF_UP;
     ioctl(s, SIOCSIFFLAGS, &ifr);
   
     frame.can_id = 123;
     frame.can_dlc = 1;
     frame.data[0] = 42;
   
     for (i = 0;; ++i)
       {
         printf ("%d\n", i);
         if (i > 4)
        write (s, &frame, sizeof (struct can_frame));
         sleep (1);
       }
   
     return 0;
   }
   ```
   
   When run on a system with *unconnected* CAN interface (so no ACKs are 
received) expected output would be the count to go on forever, but instead I 
get only count until 6 (so just one can frame was written).
   
   Using gdb, I can see the `fdcan_interrupt` is triggering continuously.
   
   ```
   (gdb) break fdcan_interrupt 
   Breakpoint 1 at 0x8012950: file 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c,
 line 1422.
   Note: automatically using hardware breakpoints for read-only addresses.
   (gdb) break fdcan_error_work 
   Breakpoint 2 at 0x8012c88: file 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c,
 line 2691.
   (gdb) c
   Continuing.
   
   Thread 1 "Idle Task" hit Breakpoint 1, fdcan_interrupt (irq=36, 
context=0x24005cdc <idle_stack+784>, arg=0x24001af0 <g_fdcan1>)
       at 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c:1422
   1422 {
   (gdb) c
   Continuing.
   [Switching to Thread 805307840]
   
   Thread 2 "hpwork" hit Breakpoint 2, fdcan_error_work (arg=0x24001af0 
<g_fdcan1>) at 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c:2691
   2691 {
   (gdb) c
   Continuing.
   [Switching to Thread 603987560]
   
   Thread 1 "Idle Task" hit Breakpoint 1, fdcan_interrupt (irq=36, 
context=0x24005cdc <idle_stack+784>, arg=0x24001af0 <g_fdcan1>)
       at 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c:1422
   1422 {
   (gdb) c
   Continuing.
   [Switching to Thread 805307840]
   
   Thread 2 "hpwork" hit Breakpoint 2, fdcan_error_work (arg=0x24001af0 
<g_fdcan1>) at 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c:2691
   2691 {
   (gdb) c
   Continuing.
   [Switching to Thread 603987560]
   
   Thread 1 "Idle Task" hit Breakpoint 1, fdcan_interrupt (irq=36, 
context=0x24005cdc <idle_stack+784>, arg=0x24001af0 <g_fdcan1>)
       at 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c:1422
   1422 {
   (gdb) c
   Continuing.
   [Switching to Thread 805307840]
   
   Thread 2 "hpwork" hit Breakpoint 2, fdcan_error_work (arg=0x24001af0 
<g_fdcan1>) at 
/home/carlossanchez/prj/godevice.3/patched/nuttx/arch/arm/src/chip/stm32_fdcan_sock.c:2691
   2691 {
   (gdb) 
   
   ```
   
   This is caused by a fail to disable error interrupts on error conditions. 
There is code and comments to disable such interrupts, but a final call to 
`fdcan_errint(priv, true)` enables all the interrupts back regardless of prior 
considerations.
   
   This has been detected on 12.1.0. I can not test on master right away (our 
custom platform requires some porting) but code inspection shows the problem is 
present in master as well.
   
   Affected platforms: stm32, stm32f0l0g0, stm32h7
   
   
   
   
   ### On which OS does this issue occur?
   
   [OS: Linux]
   
   ### What is the version of your OS?
   
   Ubuntu 20.04.6 LTS
   
   ### NuttX Version
   
   12.1.0
   
   ### Issue Architecture
   
   [Arch: arm]
   
   ### Issue Area
   
   [Area: Specific Peripheral]
   
   ### Host information
   
   _No response_
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to