From 02af80ed4e5c6e6ac0f775ae09372fa3163ddbdb Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Thu, 13 Apr 2023 20:20:21 +0200 Subject: [PATCH] rpi camera: support running on 32-bit OS with 64-bit kernel (#1644) (#1700) --- internal/rpicamera/rpicamera.go | 39 ++++----------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/internal/rpicamera/rpicamera.go b/internal/rpicamera/rpicamera.go index 879cf0bf..0215bacf 100644 --- a/internal/rpicamera/rpicamera.go +++ b/internal/rpicamera/rpicamera.go @@ -26,17 +26,6 @@ const ( //go:embed exe/exe var exeContent []byte -func getKernelArch() (string, error) { - cmd := exec.Command("uname", "-m") - - byts, err := cmd.Output() - if err != nil { - return "", err - } - - return string(byts[:len(byts)-1]), nil -} - func startEmbeddedExe(content []byte, env []string) (*exec.Cmd, error) { tempPath := tempPathPrefix + strconv.FormatInt(time.Now().UnixNano(), 10) @@ -103,6 +92,9 @@ func findLibrary(name string) (string, error) { for _, line := range strings.Split(string(byts), "\n") { f := strings.Split(line, " => ") if len(f) == 2 && strings.Contains(f[1], name+".so") { + if runtime.GOARCH == "arm" && !strings.Contains(f[1], "arm-linux-gnueabihf") { + return "", fmt.Errorf("libcamera is 64-bit, you need the 64-bit server version") + } return f[1], nil } } @@ -121,24 +113,6 @@ func setupSymlink(name string) error { return os.Symlink(lib, "/dev/shm/"+name+".so.x.x.x") } -// 32-bit embedded executables can't run on 64-bit. -func checkArch() error { - if runtime.GOARCH != "arm" { - return nil - } - - arch, err := getKernelArch() - if err != nil { - return err - } - - if arch == "aarch64" { - return fmt.Errorf("OS is 64-bit, you need the arm64 server version") - } - - return nil -} - var ( mutex sync.Mutex setupped bool @@ -149,12 +123,7 @@ func setupLibcameraOnce() error { defer mutex.Unlock() if !setupped { - err := checkArch() - if err != nil { - return err - } - - err = setupSymlink("libcamera") + err := setupSymlink("libcamera") if err != nil { return err }