KrawallKurt
Posts: 3
Joined: Fri Feb 26, 2016 12:51 pm

Pi2 CPU stalls

Fri Feb 26, 2016 1:02 pm

Hi,
Short version: I attached a push button to GPIO #18 and want to detect the edges. Unfortunately after a few edge detections the CPU stalls.

Code:

Code: Select all

$ sudo python3
>>> import time
>>> import RPi.GPIO as GPIO
>>> GPIO.setwarnings(False)
>>> GPIO.setmode(GPIO.BCM)
>>> 
>>> GPIO.setup(18, GPIO.IN)
>>> 
>>> i = 0
>>> 
>>> def callback(channel):
...   global i
...   if GPIO.input(channel):
...     print("Rising edge " + str(i))
...     i += 1
...   else:
...     print("Falling edge")
... 
>>> GPIO.add_event_detect(18, GPIO.RISING, callback = callback)
The output then looks like the following after I press the button a few times:
>>> Rising edge 0
Rising edge 1
Rising edge 2
Rising edge 3
Rising edge 4
Rising edge 5
Long time no response
Falling edge
After this I checked the syslog and found the following.

Code: Select all

Feb 26 01:43:37 Pi2 kernel: [217723.959100] gpiomem-bcm2835 3f200000.gpiomem: gpiomem device opened.
Feb 26 01:44:16 Pi2 kernel: [217762.335545] INFO: rcu_sched detected stalls on CPUs/tasks:
Feb 26 01:44:16 Pi2 kernel: [217762.335575]     0: (2 GPs behind) idle=855/2/0 softirq=3584625/3584625 fqs=2102
Feb 26 01:44:16 Pi2 kernel: [217762.335583]     (detected by 2, t=2102 jiffies, g=2665498, c=2665497, q=1597)
Feb 26 01:44:16 Pi2 kernel: [217762.335595] Task dump for CPU 0:
Feb 26 01:44:16 Pi2 kernel: [217762.335602] swapper/0       R running      0     0      0 0x00000002
Something like this always happens, the messages vary slightly, but everytime it says "detected stalls".

Does anyone have a clue why this could happen?

Code: Select all

$ uname -a
Linux Pi2 4.1.17-v7+ #838 SMP Tue Feb 9 13:15:09 GMT 2016 armv7l GNU/Linux
If you need more information, let me know

Thanks in advance


PS: The same thing works perfectly on a Pi B Rev. 2 with kernel 4.1.13+

KrawallKurt
Posts: 3
Joined: Fri Feb 26, 2016 12:51 pm

Re: Pi2 CPU stalls

Fri Feb 26, 2016 7:09 pm

Okay, here is some more information I could gather. Normally I have a HD44780 display attached which shows some stuff, including the temperature of a OneWire thermometer (DS18B20). It seems, that when I do not request the temperature, everything works fine. For testing this behaviour I disconnected the display and ran the following code.

Code: Select all

import threading
import time
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

GPIO.setup(18, GPIO.IN)

i = 0

def callback(channel):
  global i
  if GPIO.input(channel):
    print("Rising Edge " + str(i))
    i += 1
  else:
    print("Falling Edge")

GPIO.add_event_detect(18, GPIO.RISING, callback = callback)

def roomtemp():
        while True:
                temperaturefile = open("/sys/bus/w1/devices/28-000005b309f1/w1_slave", "r").read()
                time.sleep(2)

roomTempThread = threading.Thread(target = roomtemp, name = "roomTempThread")
roomTempThread.daemon = True
roomTempThread.start()
The error persists on my Pi2. So I checked my Pi B Rev2, attached the OneWire thermometer to it and the code runs perfectly fine. It seems the Pi2 can't handle simultaneous GPIO interrupts and I am not sure whether that has something to do with the kernel or the Pi2 itself.

KrawallKurt
Posts: 3
Joined: Fri Feb 26, 2016 12:51 pm

Re: Pi2 CPU stalls

Fri Feb 26, 2016 10:15 pm

Since it works on my Pi B with kernel 4.1.13 I figured, I just update my Pi2 to 4.1.13. Unfortunately this did not help. Can anyone reproduce the error? I bet there are some people here who have a DS18B20

fregger
Posts: 1
Joined: Sun Nov 12, 2017 2:11 am

Re: Pi2 CPU stalls

Sun Nov 12, 2017 2:28 am

Did you find a solution for this? It appears i am having a similar problem.

Return to “Raspberry Pi OS”