Skip to content

Commit b29ee3f

Browse files
authored
Merge pull request #203 from lurch/pi5_fix
Fix Build HAT library to work on Raspberry Pi 5
2 parents eeffd9d + 4f0ac08 commit b29ee3f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

buildhat/serinterface.py

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import tempfile
66
import threading
77
import time
8+
import os
89
from enum import Enum
910
from threading import Condition, Timer
1011

@@ -105,6 +106,11 @@ def __init__(self, firmware, signature, version, device="/dev/serial0", debug=Fa
105106
self.rampftr.append([])
106107
self.motorqueue.append(queue.Queue())
107108

109+
# On a Pi 5 /dev/serial0 will point to /dev/ttyAMA10 (which *only*
110+
# exists on a Pi 5, and is the 3-pin debug UART connector)
111+
# The UART on the Pi 5 GPIO header is /dev/ttyAMA0
112+
if device == "/dev/serial0" and os.readlink(device) == "ttyAMA10":
113+
device = "/dev/ttyAMA0"
108114
self.ser = serial.Serial(device, 115200, timeout=5)
109115
# Check if we're in the bootloader or the firmware
110116
self.write(b"version\r")

0 commit comments

Comments
 (0)