fireinfo: Import latest fixes for ARM

This commit is contained in:
Michael Tremer
2014-11-04 23:52:02 +01:00
parent c172d453c1
commit bfb421f1bb
3 changed files with 136 additions and 0 deletions

View File

@@ -71,6 +71,9 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
@$(PREBUILD)
@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/0001-bogomips-Don-t-crash-when-no-bogomips-are-available.patch
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/fireinfo/0002-ARM-Read-board-model-from-device-tree-in-proc.patch
cd $(DIR_APP) && [ -x "configure" ] || sh ./autogen.sh
cd $(DIR_APP) && ./configure --prefix=/usr
cd $(DIR_APP) && make $(MAKETUNING)

View File

@@ -0,0 +1,61 @@
From a9401d9542fae575d9ce2bb534cd4e598e9c7b8e Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Tue, 28 Oct 2014 21:14:41 +0100
Subject: [PATCH 1/2] bogomips: Don't crash when no bogomips are available
The RPi doesn't provide bogomips in /proc/cpuinfo any more
and fireinfo crashed when trying to read that file
---
src/fireinfo/cpu.py | 14 +++++++++-----
src/fireinfo/system.py | 4 +++-
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/fireinfo/cpu.py b/src/fireinfo/cpu.py
index 32d885db8124..541575af6bbb 100644
--- a/src/fireinfo/cpu.py
+++ b/src/fireinfo/cpu.py
@@ -80,12 +80,16 @@ class CPU(object):
"""
Return the bogomips of this CPU.
"""
- try:
- bogomips = self.__cpuinfo["bogomips"]
- except KeyError:
- bogomips = self.__cpuinfo["BogoMIPS"]
+ bogomips = None
+
+ for key in ("bogomips", "BogoMIPS"):
+ try:
+ bogomips = self.__cpuinfo[key]
+ except KeyError:
+ continue
- return float(bogomips)
+ if bogomips:
+ return float(bogomips)
@property
def model(self):
diff --git a/src/fireinfo/system.py b/src/fireinfo/system.py
index 8e903e8e3449..890f58c05027 100644
--- a/src/fireinfo/system.py
+++ b/src/fireinfo/system.py
@@ -144,12 +144,14 @@ class System(object):
"model_string" : self.cpu.model_string,
"stepping" : self.cpu.stepping,
"flags" : self.cpu.flags,
- "bogomips" : self.cpu.bogomips,
"speed" : self.cpu.speed,
"family" : self.cpu.family,
"count" : self.cpu.count
}
+ if self.cpu.bogomips:
+ p["bogomips"] = self.cpu.bogomips
+
p["network"] = {
"green" : self.network.has_green(),
"blue" : self.network.has_blue(),
--
1.9.3

View File

@@ -0,0 +1,72 @@
From b9a068e26261007d4a0592fcb47f82658af2c775 Mon Sep 17 00:00:00 2001
From: Michael Tremer <michael.tremer@ipfire.org>
Date: Mon, 3 Nov 2014 21:33:45 +0100
Subject: [PATCH 2/2] ARM: Read board model from device-tree in /proc
---
src/fireinfo/system.py | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/src/fireinfo/system.py b/src/fireinfo/system.py
index 890f58c05027..195832e9f7eb 100644
--- a/src/fireinfo/system.py
+++ b/src/fireinfo/system.py
@@ -304,27 +304,6 @@ class System(object):
"""
return read_from_file("/sys/class/dmi/id/bios_vendor")
- def vendor_model_tuple(self):
- try:
- s = self.__cpuinfo["Hardware"]
- except KeyError:
- return (None, None)
-
- if s.startswith("ARM-Versatile"):
- return ("ARM", s)
-
- try:
- v, m = s.split(" ", 1)
- except ValueError:
- if s.startswith("BCM"):
- v = "Broadcom"
- m = s
- else:
- v = None
- m = s
-
- return v, m
-
@property
def vendor(self):
"""
@@ -337,8 +316,10 @@ class System(object):
break
if ret is None:
- v, m = self.vendor_model_tuple()
- ret = v
+ try:
+ return self.__cpuinfo["Hardware"]
+ except KeyError:
+ pass
return ret
@@ -353,9 +334,11 @@ class System(object):
if ret:
break
- if ret is None:
- v, m = self.vendor_model_tuple()
- ret = m
+ # Read device-tree model if available
+ ret = read_from_file("/proc/device-tree/model")
+ if ret:
+ # replace the NULL byte with which the DT string ends
+ ret = ret.replace(u"\u0000", "")
return ret
--
1.9.3