amd64-microcode: create early load microcode image
[openwrt/staging/zorun.git] / package / firmware / amd64-microcode / Makefile
1 #
2 # Copyright (C) 2018 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=amd64-microcode
11 PKG_VERSION:=20180524
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=amd64-microcode_3.$(PKG_VERSION).$(PKG_RELEASE).tar.xz
15 PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/non-free/a/amd64-microcode/
16 PKG_HASH:=7c389c357c242e7161f6872bf4e12011a71e4c0683f06fb1bcfad650a78bf0a9
17 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-3.$(PKG_VERSION).$(PKG_RELEASE)
18
19 PKG_LICENSE_FILE:=LICENSE.amd-ucode
20
21 include $(INCLUDE_DIR)/package.mk
22
23 define Package/amd64-microcode
24 SECTION:=firmware
25 CATEGORY:=Firmware
26 URL:=$(PKG_SOURCE_URL)
27 DEPENDS:=@TARGET_x86
28 TITLE:=AMD64 CPU microcode
29 endef
30
31 define Build/Prepare
32 rm -rf $(PKG_BUILD_DIR)
33 mkdir -p $(PKG_BUILD_DIR)
34 $(TAR) -C $(BUILD_DIR) -xJf $(DL_DIR)/$(PKG_SOURCE)
35 endef
36
37 define Build/Compile
38 mkdir -p $(PKG_BUILD_DIR)/kernel/x86/microcode/
39 cat $(PKG_BUILD_DIR)/microcode_amd*.bin \
40 > $(PKG_BUILD_DIR)/kernel/x86/microcode/AuthenticAMD.bin
41 (cd $(PKG_BUILD_DIR); \
42 echo "kernel/x86/microcode/AuthenticAMD.bin" \
43 | cpio -o -H newc --reproducible > amd-ucode.cpio)
44 endef
45
46 define Package/amd64-microcode/install
47 $(INSTALL_DIR) $(1)/boot
48 $(INSTALL_DATA) $(PKG_BUILD_DIR)/amd-ucode.cpio $(1)/boot/amd-ucode.img
49 endef
50
51 $(eval $(call BuildPackage,amd64-microcode))