Skip to content

Commit

Permalink
Fix raspberry pi zero cpu variant recognition
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Stolcman <[email protected]>
  • Loading branch information
lstolcman committed Aug 9, 2023
1 parent 3fb4223 commit 5cd4ddc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/pkg/platform/platform_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/containers/image/v5/types"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)

Expand Down Expand Up @@ -82,9 +83,25 @@ func getCPUVariantWindows(arch string) string {
func getCPUVariantArm() string {
variant, err := getCPUInfo("Cpu architecture")
if err != nil {
logrus.Errorf("Couldn't get cpu architecture")
return ""
}
// TODO handle RPi Zero mismatch (https://github.com/moby/moby/pull/36121#issuecomment-398328286)

// handle RPi Zero variant mismatch due to wrong variant from kernel
// https://github.com/containerd/containerd/pull/4530
// https://www.raspberrypi.org/forums/viewtopic.php?t=12614
// https://github.com/moby/moby/pull/36121#issuecomment-398328286
if runtime.GOARCH == "arm" && variant == "7" {
model, err := getCPUInfo("model name")
if err != nil {
logrus.Errorf("Couldn't get cpu model name, it may be the corner case where variant is 6")
return ""
}
if strings.HasPrefix(strings.ToLower(model), "armv6-compatible") {
logrus.Debugf("Detected corner case, setting cpu variant to 6")
variant = "6"
}
}

switch strings.ToLower(variant) {
case "8", "aarch64":
Expand Down

0 comments on commit 5cd4ddc

Please sign in to comment.