-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterating GPIOs crashes on Raspberry Pi 4B #104
Comments
Thanks for reporting this, are you using a 64bits OS and Swift 5.2.4-v4 on both? |
It should work now if you pull master/1.1.15 and use .RaspberryPi4 as board type on the Pi4. |
@uraimo thanks for such a quick response. Unfortunately, it's still crashing: ➜ PiTest sudo swift run
(key: SwiftyGPIO.GPIOName.P12, value: GPIO12<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P22, value: GPIO22<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P6, value: GPIO6<IN,NONE,true>: 1)
(key: SwiftyGPIO.GPIOName.P13, value: GPIO13<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P3, value: GPIO3<OUT,NONE,true>: 1)
(key: SwiftyGPIO.GPIOName.P4, value: GPIO4<IN,NONE,true>: 1)
(key: SwiftyGPIO.GPIOName.P9, value: GPIO9<OUT,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P14, value: GPIO14<OUT,NONE,true>: 1)
(key: SwiftyGPIO.GPIOName.P5, value: GPIO5<IN,NONE,true>: 1)
(key: SwiftyGPIO.GPIOName.P10, value: GPIO10<OUT,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P11, value: GPIO11<OUT,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P20, value: GPIO20<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P15, value: GPIO15<OUT,NONE,true>: 1)
(key: SwiftyGPIO.GPIOName.P17, value: GPIO17<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P26, value: GPIO26<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P24, value: GPIO24<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P19, value: GPIO19<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P23, value: GPIO23<IN,NONE,true>: 0)
(key: SwiftyGPIO.GPIOName.P27, value: GPIO27<IN,NONE,true>: 0)
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /home/ubuntu/Swift/PiTest/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift, line 73
Current stack trace:
0 libswiftCore.so 0x0000ffff8aa30e4c swift_reportError + 64
1 libswiftCore.so 0x0000ffff8aa960e4 _swift_stdlib_reportFatalErrorInFile + 128
2 libswiftCore.so 0x0000ffff8a7ea7b0 <unavailable> + 1439664
3 libswiftCore.so 0x0000ffff8a7e9a28 _assertionFailure(_:_:file:line:flags:) + 464
4 PiTest 0x0000aaaac39decd8 <unavailable> + 343256
5 PiTest 0x0000aaaac39e34b0 <unavailable> + 361648
6 PiTest 0x0000aaaac39e3628 <unavailable> + 362024
7 libswiftCore.so 0x0000ffff8a82f5e0 _debugPrint_unlocked<A, B>(_:_:) + 304
8 libswiftCore.so 0x0000ffff8a899120 <unavailable> + 2154784
9 libswiftCore.so 0x0000ffff8a82ecb4 _print_unlocked<A, B>(_:_:) + 740
10 libswiftCore.so 0x0000ffff8a89f5bc <unavailable> + 2180540
11 libswiftCore.so 0x0000ffff8a89e680 <unavailable> + 2176640
12 PiTest 0x0000aaaac39960a8 <unavailable> + 45224
13 PiTest 0x0000aaaac3996148 <unavailable> + 45384
14 PiTest 0x0000aaaac39961a8 <unavailable> + 45480
15 libswiftCore.so 0x0000ffff8a8b07b8 Sequence.forEach(_:) + 384
16 PiTest 0x0000aaaac3995d48 <unavailable> + 44360
17 libc.so.6 0x0000ffff89bd8fa8 __libc_start_main + 232
18 PiTest 0x0000aaaac39959cc <unavailable> + 43468
[1] 3010 trace trap sudo swift run This is after I pulled
One other thing: running 64bit on Ubuntu Server 20.04 |
Update: Appears it may be an Ubuntu Server 20.04 issue? I had a suspicion, and when I re-ran my script on RPI 4B w/Ubuntu Server 18.04, it worked. My apologies; I should restate my test rigs (for us both):
|
I'm getting the same error on a Pi4B Rev1.1 with 32bit debian buster (similar to 18.04), the issue seem to be consistently with the initialization of gpio 10,11 and 19. |
Those are all SPI/PWM pins, can you install wiringpi and run "gpio readall" on 18.04 and 20.04? |
|
@uraimo anything I can do to help with this? |
GPIOs 10,11 and 19 and not being exported correctly on Pi4, removing them temporarily until upstream fixes this. Have not verified if the alternate function on these pins still work correctly.
Excluded the gpio 10, 11 and 19 from the Pi4's list until Raspian fixes them upstream. |
Board Type
Operating System
Ubuntu Server 18.04
Swift Version
Swift 5.2.4 v4
Description
Wrote a program to iterate over GPIOs:
When I run this on RPi 3B+, it works without a problem:
When I run this on RPi 4, it iterates a few, then crashes with a
nil
exception:The text was updated successfully, but these errors were encountered: