periph / host

Go·Hardware·Lean - Host drivers
https://periph.io
Apache License 2.0
57 stars 32 forks source link

Drivers skipped #35

Closed ea7kir closed 1 year ago

ea7kir commented 1 year ago

Can't get you example code to work.

To Reproduce Copy your code into VsCode.

package main

import (
    "fmt"
    "log"

    "periph.io/x/host/v3"
)

func main() {
    // Make sure periph is initialized.
    state, err := host.Init()
    if err != nil {
        log.Fatalf("failed to initialize periph: %v", err)
    }

    // Prints the loaded driver.
    fmt.Printf("Using drivers:\n")
    for _, driver := range state.Loaded {
        fmt.Printf("- %s\n", driver)
    }

    // Prints the driver that were skipped as irrelevant on the platform.
    fmt.Printf("Drivers skipped:\n")
    for _, failure := range state.Skipped {
        fmt.Printf("- %s: %s\n", failure.D, failure.Err)
    }

    // Having drivers failing to load may not require process termination. It
    // is possible to continue to run in partial failure mode.
    fmt.Printf("Drivers failed to load:\n")
    for _, failure := range state.Failed {
        fmt.Printf("- %s: %v\n", failure.D, failure.Err)
    }

    // Use pins, buses, devices, etc.
}

and then...

go mod init example
go mod tidy
  1. Run it.
    go run .
  2. See error
    Using drivers:
    - bcm283x-gpio
    - rpi
    - sysfs-gpio
    - sysfs-i2c
    - sysfs-led
    - sysfs-thermal
    Drivers skipped:
    - allwinner-gpio-pl: no A64 CPU detected
    - allwinner-gpio: no Allwinner CPU detected
    - pine64: pine64 board not detected
    - sysfs-spi: no SPI port found
    Drivers failed to load:
    - bcm283x-dma: pmem: failed to open physical memory: open /dev/mem: permission denied

    Expected behavior No Drivers skipped and no Drivers failed to load.

Platform

Additional context This is after 3 days of trying to find proper documentation on how to install and get started. Please help.

maruel commented 1 year ago

Drivers that are not applicable are skipped.

Drivers that fail because the program is not running as root correctly fail to load. This is normal behavior.

ea7kir commented 1 year ago

OK. so why is it the same if I build and run it with sudo?

Just notice. Is this correct?

odule example

go 1.20

require periph.io/x/host/v3 v3.8.2

require periph.io/x/conn/v3 v3.7.0 // indirect
ea7kir commented 1 year ago

If I start with a clean Pi OS (64bit) with only oo1.20.6 installed, do I need to install anything new before writing code? If so, please could you write a getting started guide for dummies like me?

maruel commented 1 year ago

It's okay. You don't need the bcm283x-dma driver to use periph. You can go ahead and write code.