firmware: add microcode package for Intel
authorZoltan HERPAI <wigyori@uid0.hu>
Wed, 17 Jan 2018 12:01:55 +0000 (13:01 +0100)
committerZoltan HERPAI <wigyori@uid0.hu>
Wed, 17 Jan 2018 13:06:37 +0000 (14:06 +0100)
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.

Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
package/firmware/intel-microcode/Makefile [new file with mode: 0644]
package/firmware/intel-microcode/files/intel-microcode.preinit [new file with mode: 0644]

diff --git a/package/firmware/intel-microcode/Makefile b/package/firmware/intel-microcode/Makefile
new file mode 100644 (file)
index 0000000..0af900c
--- /dev/null
@@ -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 (file)
index 0000000..b2bcd34
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh /etc/rc.common
+# (C) 2018 Zoltan HERPAI
+
+START=10
+IUCODE_BIN="/usr/bin/iucode_tool"
+
+load_intel_ucode() {
+       $IUCODE_BIN -S -k -v /lib/firmware/intel-ucode
+}
+
+boot_hook_add preinit_main load_intel_ucode