Programmatically load device tree overlay in Go


I am having a hard time understanding the nature of the “echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots”

I have written the following program in Go:

package bbbdevtreeovly

import (
// “io”
// “bytes”
// “fmt”
// “os/exec”
// “strings”

const (
slotsDir string = /sys/devices/ // Find BBB’s slots

func Load_dto(dtoFileName string, dtoFilePath string) (err error) {

log.SetPrefix(BBB Device Tree Overlay: )

slotFiles := make([]os.FileInfo, 100)

slotFiles, err = ioutil.ReadDir(slotsDir)

var i int

for i = 0; i < len(slotFiles); i++ {
found, _ := filepath.Match(bone_capemgr.*, slotFiles[i].Name())
if found {

log.Println(“This is the new program…”, “\n”)

slotsLoc := filepath.Join(slotsDir, slotFiles[i].Name(), slots)

log.Println("DTO File: ", dtoFileName, “\n”)

slots, err := os.Open(slotsLoc)
if err != nil {
return err
defer slots.Close()

log.Println("Slots location: ", slots.Name(), “\n”)


// slots.Write([]byte(“cape_bone_iio”))

return nil



Do you perhaps need a newline terminator for the line you’re writing to the slots “file”?

Thanks, Thorsten, but that didn’t see to help, unfortunately… It doesn’t generate any errors, it just doesn’t actually load the dto… Any other ideas?


What does dmesg say? That’s where you’d find any error messages.