Add RPi1/RPi0 workaround

On the very popular Raspberry Pi 1 and Zero devices, the CPU is actually ARMv6, but the chip happens to support the feature bit the kernel uses to differentiate v6/v7, so it gets reported as "CPU architecture: 7" and thus fails to run many of the images that get pulled.

To account for this very popular edge case, this also checks "model name" which on these chips will begin with "ARMv6-compatible" -- we could also check uname, but getCPUInfo is already handy, low overhead, and mirrors the code before this.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
This commit is contained in:
Tianon Gravi 2020-09-04 14:12:04 -07:00
parent d4e78200d6
commit 2055e12953

View File

@ -96,6 +96,15 @@ func getCPUVariant() string {
return "" return ""
} }
// handle edge case for Raspberry Pi ARMv6 devices (which due to a kernel quirk, report "CPU architecture: 7")
// https://www.raspberrypi.org/forums/viewtopic.php?t=12614
if runtime.GOARCH == "arm" && variant == "7" {
model, err := getCPUInfo("model name")
if err == nil && strings.HasPrefix(strings.ToLower(model), "armv6-compatible") {
variant = "6"
}
}
switch strings.ToLower(variant) { switch strings.ToLower(variant) {
case "8", "aarch64": case "8", "aarch64":
// special case: if running a 32-bit userspace on aarch64, the variant should be "v7" // special case: if running a 32-bit userspace on aarch64, the variant should be "v7"