[LEDE-DEV] [PATCH 4/5] firmware: add microcode package for Intel

Zoltan HERPAI wigyori at uid0.hu
Wed Jan 17 11:41:05 PST 2018


Compiling the Intel microcode package results in a
microcode.bin and a microcode-64.bin. As we can
decide based on the subtarget which should be used,
we'll only split the required .bin file with
iucode-tool.

Instead of using the large microcode.bin/microcode-64.bin, the
splitted ucode files (separate for CPU families) will be
installed.
 
The microcodes are updated from preinit - that's the
earliest place where we can do it.

Signed-off-by: Zoltan HERPAI <wigyori at uid0.hu>
---
 package/firmware/intel-microcode/Makefile          | 51 ++++++++++++++++++++++
 .../intel-microcode/files/intel-microcode.preinit  |  8 ++++
 2 files changed, 59 insertions(+)
 create mode 100644 package/firmware/intel-microcode/Makefile
 create mode 100644 package/firmware/intel-microcode/files/intel-microcode.preinit

diff --git a/package/firmware/intel-microcode/Makefile b/package/firmware/intel-microcode/Makefile
new file mode 100644
index 0000000..0af900c
--- /dev/null
+++ b/package/firmware/intel-microcode/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2018 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=intel-microcode
+PKG_VERSION:=20171215
+PKG_RELEASE:=1
+
+PKG_SOURCE:=intel-microcode_3.$(PKG_VERSION).$(PKG_RELEASE).tar.xz
+PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/non-free/i/intel-microcode/
+PKG_HASH:=eca8efc0a6dc456a8723204477e229577c1079fa5c1a10b6ba95d11e261ffa4d
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-3.$(PKG_VERSION).$(PKG_RELEASE)
+
+PKG_BUILD_DEPENDS:=iucode-tool/host
+
+ifdef CONFIG_TARGET_x86_64
+	MICROCODE:="intel-microcode-64"
+else
+	MICROCODE:="intel-microcode"
+endif
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/intel-microcode
+  SECTION:=firmware
+  CATEGORY:=Firmware
+  URL:=$(PKG_SOURCE_URL)
+  DEPENDS:=@TARGET_x86 +iucode-tool
+  TITLE:=Intel x86 CPU microcode
+endef
+
+define Build/Compile
+	IUCODE_TOOL=$(STAGING_DIR)/../host/bin/iucode_tool $(MAKE) -C $(PKG_BUILD_DIR)
+	mkdir $(PKG_BUILD_DIR)/intel-ucode
+	$(STAGING_DIR)/../host/bin/iucode_tool -q \
+		--write-firmware=$(PKG_BUILD_DIR)/intel-ucode $(PKG_BUILD_DIR)/$(MICROCODE).bin
+endef
+
+define Package/intel-microcode/install
+	$(INSTALL_DIR) $(1)/lib/firmware/intel-ucode
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/intel-ucode/* $(1)/lib/firmware/intel-ucode
+	$(INSTALL_DIR) $(1)/lib/preinit
+	$(INSTALL_BIN) ./files/intel-microcode.preinit $(1)/lib/preinit/02_load_intel_ucode
+endef
+
+$(eval $(call BuildPackage,intel-microcode))
diff --git a/package/firmware/intel-microcode/files/intel-microcode.preinit b/package/firmware/intel-microcode/files/intel-microcode.preinit
new file mode 100644
index 0000000..7f9279c
--- /dev/null
+++ b/package/firmware/intel-microcode/files/intel-microcode.preinit
@@ -0,0 +1,8 @@
+#!/bin/sh
+# Copyright (C) 2018 OpenWrt.org
+
+do_load_intel_ucode() {
+	echo 1 > /sys/devices/system/cpu/microcode/reload
+}
+
+boot_hook_add preinit_main do_load_intel_ucode
-- 
1.9.1




More information about the Lede-dev mailing list