1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[standard]= AMD and Intel CPUs microcode updates
12 SPKGS[standard]= single
14 OPTIONS_AVAILABLE= none
15 OPTIONS_STANDARD= none
17 RUN_DEPENDS= devcpu-data-intel:single:standard
18 devcpu-data-amd:single:standard
20 FPC_EQUIVALENT= sysutils/devcpu-data
25 RC_SUBR= microcode_update:single
26 SUB_FILES= pkg-message-single
27 SUB_LIST= DATADIR="{{PREFIX}}/share/cpucontrol"
29 [FILE:154:descriptions/desc.single]
30 This port supplies microcode updates for use with cpuctl(4) microcode
31 update facility. These could be used to keep your processor's firmware
35 [FILE:2458:files/microcode_update.in]
38 # PROVIDE: microcode_update
39 # REQUIRE: root mountcritlocal
44 # Add the following line to /etc/rc.conf to enable flow-capture:
45 # microcode_update_enable (bool): Set it to "YES" to update microcode on startup
46 # Set to "NO" by default.
47 # microcode_update_datadir (str): Directory, microcode updates stored in.
48 # Default is "%%DATADIR%%"
49 # microcode_update_cpus (str): A list of cpus to update on startup, or "ALL" for all.
50 # Example: microcode_update_cpus="0 1"
51 # Set to "ALL" by default.
52 # microcode_update_flags (str): Flags for cpucontrol(8).
56 name="microcode_update"
57 rcvar=microcode_update_enable
59 start_precmd="microcode_update_prepare"
60 start_cmd="microcode_update_start"
61 requires_modules="cpuctl"
63 CMT="/usr/sbin/cpucontrol"
65 microcode_update_prepare()
67 if ! kldstat -q -m cpuctl; then
68 if ! kldload cpuctl > /dev/null 2>&1; then
69 warn "Can't load cpuctl module."
75 microcode_update_start()
77 echo "Updating CPU Microcode..."
78 if [ "${microcode_update_cpus}" = "ALL" ]; then
79 ncpu=`/sbin/sysctl -n hw.ncpu`
82 cpus=${microcode_update_cpus}
85 ${CMT} -u ${microcode_update_flags} \
86 -d "${microcode_update_datadir}" /dev/cpuctl${i} 2>&1 | \
87 logger -p daemon.notice -t microcode_update || \
88 (echo "Microcode Update Failed." && exit 1)
90 if [ "${microcode_update_cpus}" = "ALL" ]; then
91 CPUCONTROL_UPDATED=$(cpucontrol -h 2>&1 | grep -q -- -e; echo $?)
92 if [ ${CPUCONTROL_UPDATED} -ne 0 ]; then
93 echo "Please update your system in order to update CPU microcode."
95 ${CMT} -e /dev/cpuctl0 >/dev/null 2>&1
97 echo "Re-evalulation of CPU flags Failed."
108 if [ -n "${microcode_cpus}" ]; then
109 if [ -n "${microcode_update_cpus}" ]; then
110 echo "Warning: Ignoring deprecated rc variable, microcode_cpus."
112 echo "Warning: rc variable microcode_cpus is deprecated.
113 Warning: Set microcode_udpate_cpus instead."
114 microcode_update_cpus="${microcode_cpus}"
118 : ${microcode_update_enable="NO"}
119 : ${microcode_update_datadir="%%DATADIR%%"}
120 : ${microcode_update_cpus="ALL"}
121 : ${microcode_update_flags=""}
126 [FILE:1638:files/pkg-message-single.in]
127 This port includes an RC script, which is one of two methods to update the
128 CPU microcode on a FreeBSD system.
130 1. The first method, which does not require the RC script included in this
131 port is currently only supported on FreeBSD 12.0 or later and Intel i386
132 and amd64 processors. It is the preferred method when available because
133 it ensures that any CPU features introduced by a microcode update are
134 visible to the kernel by applying the update before the kernel performs
135 CPU feature detection.
137 To enable updates using the first method, add the following lines to
140 cpu_microcode_load="YES"
141 cpu_microcode_name="/boot/firmware/intel-ucode.bin"
143 The microcode update will be loaded when the system is rebooted.
146 2. The second method, which uses the RC script included in this port can
147 be enabled by adding the following line to /etc/rc.conf:
149 microcode_update_enable="YES"
151 The microcode update is then applied upon reboot or when the microcode
152 update service is run via:
154 # service microcode_update start
156 If the CPU requires a microcode update, a console message such as the
157 following will appear:
159 Updating CPU Microcode...
160 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl0 from rev 0x17 to rev 0x22... done.
161 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl2 from rev 0x17 to rev 0x22... done.
162 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl4 from rev 0x17 to rev 0x22... done.
163 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl6 from rev 0x17 to rev 0x22... done.
166 It is safe to enable both methods.