From fc8f190099535c8d772e9f9831e6b3fca501f496 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 29 Dec 2020 03:23:53 +0100 Subject: [PATCH] host/pine64: improve detection Read the model name from /proc/device-tree/model (via distro.DTModel()) instead of probing for /boot/pine64.dtb to be present. There's various distros out there that don't have a /boot/pine64.dtb, and /proc/device-tree/model is a much nicer way to do this. --- pine64/pine64.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pine64/pine64.go b/pine64/pine64.go index ee225f2a..1584d9dc 100644 --- a/pine64/pine64.go +++ b/pine64/pine64.go @@ -6,12 +6,13 @@ package pine64 import ( "errors" - "os" + "strings" "periph.io/x/conn/driver/driverreg" "periph.io/x/conn/pin" "periph.io/x/conn/pin/pinreg" "periph.io/x/host/allwinner" + "periph.io/x/host/distro" ) // Present returns true if running on a Pine64 board. @@ -19,9 +20,7 @@ import ( // https://www.pine64.org/ func Present() bool { if isArm { - // This is iffy at best. - _, err := os.Stat("/boot/pine64.dtb") - return err == nil + return strings.HasPrefix(distro.DTModel(), "Pine64") } return false }