Skip to content

Commit

Permalink
host/pine64: improve detection
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
flokli authored and maruel committed Dec 29, 2020
1 parent 0053935 commit fc8f190
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pine64/pine64.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ 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.
//
// 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
}
Expand Down

0 comments on commit fc8f190

Please sign in to comment.