1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 12:50:19 +01:00

add minimal support for NextThing CHIP

This commit is contained in:
Thorsten von Eicken 2016-08-26 23:00:39 -07:00
parent bfcd1345fe
commit d9dd4b51a9

View File

@ -31,6 +31,9 @@ const (
// HostRadxa represents the Radxa board. // HostRadxa represents the Radxa board.
HostRadxa = "Radxa" HostRadxa = "Radxa"
// HostCHIP represents the NextThing C.H.I.P.
HostCHIP = "CHIP"
) )
func execOutput(name string, arg ...string) (output string, err error) { func execOutput(name string, arg ...string) (output string, err error) {
@ -92,7 +95,7 @@ func cpuInfo() (model, hardware string, revision int, err error) {
} }
revision = int(rev) revision = int(rev)
case strings.HasPrefix(fields[0], "Hardware"): case strings.HasPrefix(fields[0], "Hardware"):
hardware = fields[1] hardware = strings.TrimSpace(fields[1])
case strings.HasPrefix(fields[0], "model name"): case strings.HasPrefix(fields[0], "model name"):
model = fields[1] model = fields[1]
} }
@ -108,7 +111,9 @@ func DetectHost() (host Host, rev int, err error) {
} }
if major < 3 || (major == 3 && minor < 8) { if major < 3 || (major == 3 && minor < 8) {
return HostNull, 0, fmt.Errorf("embd: linux kernel versions lower than 3.8 are not supported. you have %v.%v.%v", major, minor, patch) return HostNull, 0, fmt.Errorf(
"embd: linux kernel versions lower than 3.8 are not supported, "+
"you have %v.%v.%v", major, minor, patch)
} }
model, hardware, rev, err := cpuInfo() model, hardware, rev, err := cpuInfo()
@ -121,6 +126,13 @@ func DetectHost() (host Host, rev int, err error) {
return HostBBB, rev, nil return HostBBB, rev, nil
case strings.Contains(hardware, "BCM2708") || strings.Contains(hardware, "BCM2709"): case strings.Contains(hardware, "BCM2708") || strings.Contains(hardware, "BCM2709"):
return HostRPi, rev, nil return HostRPi, rev, nil
case hardware == "Allwinner sun4i/sun5i Families":
if major < 4 || (major == 4 && minor < 4) {
return HostNull, 0, fmt.Errorf(
"embd: linux kernel version 4.4+ required, you have %v.%v",
major, minor)
}
return HostCHIP, rev, nil
default: default:
return HostNull, 0, fmt.Errorf(`embd: your host "%v:%v" is not supported at this moment. request support at https://github.com/kidoman/embd/issues`, host, model) return HostNull, 0, fmt.Errorf(`embd: your host "%v:%v" is not supported at this moment. request support at https://github.com/kidoman/embd/issues`, host, model)
} }