[LEDE-DEV] [RFC v3 2/2] x86: use sysfs DMI information to populate sysinfo
Jo-Philipp Wich
jo at mein.io
Wed Jun 1 08:14:34 PDT 2016
Use the DMI data available in sysfs to extract manufacturer and model info
and write it to /tmp/sysinfo/.
The data will be picked up by board_detect and can be used by e.g. LuCI to
display a more appropriate model description.
On an APU board the files will contain the following values:
# cat /tmp/sysinfo/model
PC Engines APU
# cat /tmp/sysinfo/board_name
pc-engines-apu
Signed-off-by: Jo-Philipp Wich <jo at mein.io>
---
target/linux/x86/base-files/lib/preinit/20_sysinfo | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 target/linux/x86/base-files/lib/preinit/20_sysinfo
diff --git a/target/linux/x86/base-files/lib/preinit/20_sysinfo b/target/linux/x86/base-files/lib/preinit/20_sysinfo
new file mode 100644
index 0000000..0b836ce
--- /dev/null
+++ b/target/linux/x86/base-files/lib/preinit/20_sysinfo
@@ -0,0 +1,16 @@
+do_sysinfo_x86() {
+ local vendor product boardname
+
+ vendor="$(cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null)"
+ product="$(cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null)"
+
+ [ -n "$vendor" -a -n "$product" ] || return
+
+ boardname="$(printf "%s %s" "$vendor" "$product" | tr 'A-Z' 'a-z' | tr -cs 'a-z0-9_-' '-')"
+
+ mkdir -p /tmp/sysinfo
+ echo "$boardname" > /tmp/sysinfo/board_name
+ echo "$vendor $product" > /tmp/sysinfo/model
+}
+
+boot_hook_add preinit_main do_sysinfo_x86
--
2.1.4
More information about the Lede-dev
mailing list