<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dawid Wróbel on Medium]]></title>
        <description><![CDATA[Stories by Dawid Wróbel on Medium]]></description>
        <link>https://medium.com/@wrobelda?source=rss-d13d57ddfa07------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*C1_c9kjCJQBxGiHm.jpg</url>
            <title>Stories by Dawid Wróbel on Medium</title>
            <link>https://medium.com/@wrobelda?source=rss-d13d57ddfa07------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:23:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wrobelda/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Initializing an LTE modem using raw USB communication]]></title>
            <link>https://medium.com/@wrobelda/initializing-an-lte-modem-using-raw-usb-communication-f755aca1bcc9?source=rss-d13d57ddfa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/f755aca1bcc9</guid>
            <category><![CDATA[usbmon]]></category>
            <category><![CDATA[sniffing]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[freebsd]]></category>
            <category><![CDATA[usb]]></category>
            <dc:creator><![CDATA[Dawid Wróbel]]></dc:creator>
            <pubDate>Mon, 17 Mar 2025 23:08:37 GMT</pubDate>
            <atom:updated>2025-03-17T23:11:40.598Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s this Polish <a href="http://aero2.pl/">Aero2</a> mobile network provider that offers a free, unmetered 512 kbps data plan, which is perfect for use as a failover link for your home router/server. And while my rather obscure, $10 Huawei USB LTE modem works out-of-the-box with Linux and NetworkManager, I struggled for quite a while to get it running under the FreeBSD-based OPNsense firewall. Turns out the modem’s peculiarities required a deep dive into tracing USB communication and its protocols to eventually get it initialized with a one-line command sending a raw USB message to device.</p><h3>The LTE USB modem</h3><figure><img alt="A Huawei E3131 USB LTE modem" src="https://cdn-images-1.medium.com/max/680/0*RtuG-LPh2wgzloJs.jpg" /></figure><p>The LTE modem in question, the Huawei E3131, is a USB stick that was popular in the early to mid-2010s with local mobile operators in Europe and Asia. They can now be had for next to nothing and offer decent LTE speeds, especially considering that the free mobile service I mentioned is limited to just 512 kbps, perfectly fine for emergency purposes.</p><p>LTE modems typically offer two connectivity modes: a traditional, serial port-based PPP mode and a more modern NCM CDC Ethernet mode, which creates an Ethernet interface with DHCP support — marketed as “HiLink” by Huawei. The former is speed-limited, which is why manufacturers default to the second mode, as does NetworkManager under Linux when configuring the device. The modes exposed by the modem are changed using the AT^SETPORT command, which is well documented, so I’ll skip that part. For reference, I configured my modem as follows:</p><pre>AT^SETPORT?<br>^SETPORT:;2,3,16</pre><p>This translates to:</p><pre>AT^SETPORT=?<br>^SETPORT:A1: CDROM<br>^SETPORT:A2: SD<br>^SETPORT:A: BLUE TOOTH<br>^SETPORT:B: FINGER PRINT<br>^SETPORT:D: MMS<br>^SETPORT:E: PC VOICE<br>^SETPORT:1: MODEM<br>^SETPORT:2: PCUI<br>^SETPORT:3: DIAG<br>^SETPORT:4: PCSC<br>^SETPORT:5: GPS<br>^SETPORT:6: GPS CONTROL<br>^SETPORT:16: NCM</pre><p>Notable here is having serial-based PPP MODEM disabled, which I could not get working at all, not even under user-friendly Linux and NetworkManager combo.</p><p>The above results in following devices created under Linux:</p><pre>[ 1334.805515] option 1-6:1.0: GSM modem (1-port) converter detected<br>[ 1334.807113] usb 1-6: GSM modem (1-port) converter now attached to ttyUSB0<br>[ 1334.807367] option 1-6:1.1: GSM modem (1-port) converter detected<br>[ 1334.807532] usb 1-6: GSM modem (1-port) converter now attached to ttyUSB1<br>[ 1334.811642] usbcore: registered new interface driver cdc_ether<br>[ 1334.813193] usbcore: registered new interface driver cdc_ncm<br>[ 1334.814079] usbcore: registered new interface driver cdc_wdm<br>[ 1334.892354] huawei_cdc_ncm 1-6:1.2: MAC-Address: aa:bb:cc:dd:ee:ff<br>[ 1334.892555] huawei_cdc_ncm 1-6:1.2: setting rx_max = 16384<br>[ 1334.895359] huawei_cdc_ncm 1-6:1.2: setting tx_max = 16384<br>[ 1334.898360] huawei_cdc_ncm 1-6:1.2: NDP will be placed at end of frame for this device.<br>[ 1334.898524] huawei_cdc_ncm 1-6:1.2: cdc-wdm0: USB WDM device<br>[ 1334.898766] huawei_cdc_ncm 1-6:1.2 wwan0: register &#39;huawei_cdc_ncm&#39; at usb-0000:0c:00.0-6, Huawei CDC NCM device, aa:bb:cc:dd:ee:ff<br>[ 1334.898999] usbcore: registered new interface driver huawei_cdc_ncm<br>[ 1334.903013] huawei_cdc_ncm 1-6:1.2 wwx582c80139263: renamed from wwan0</pre><p>The wwan0 Ethernet interface is provided by huawei_cdc_ncm kernel module, which notably also creates cdc-wdm character device under /dev/cdc-wdm0. This will get important later on, so bear with me.</p><p>The ttyUSB0 and ttyUSB1 GSM modem serial ports correspond to the DIAG and PCUIinterfaces, the former of which supports AT communication:</p><pre>root@proxmox:~ # cu -l /dev/ttyUSB0<br>AT<br>OK</pre><h3>Initializing connection</h3><p>While Huawei typically uses some proprietary software for maintaining connectivity under Windows, presumably using the PCUI serial interface, it can also be used as a standard CDC NCM modem supporting the NDIS command set and can be initialized with a simple AT^NDISUP=1,1,&quot;APN&quot; command sent to one of its serial ports. This is evidenced by NetworkManager running in debug mode:</p><pre>ModemManager[4118]: &lt;debug&gt; [modem0] user request to connect modem<br>ModemManager[4118]: &lt;info&gt;  [modem0] simple connect started...<br>ModemManager[4118]: &lt;debug&gt; [modem0]    profile ID: unspecified<br>ModemManager[4118]: &lt;debug&gt; [modem0]    PIN: unspecified<br>ModemManager[4118]: &lt;debug&gt; [modem0]    operator ID: unspecified<br>ModemManager[4118]: &lt;debug&gt; [modem0]    allowed roaming: yes<br>ModemManager[4118]: &lt;debug&gt; [modem0]    APN: darmowy<br>ModemManager[4118]: &lt;debug&gt; [modem0]    APN type: unspecified<br>ModemManager[4118]: &lt;debug&gt; [modem0]    IP family: ipv4<br>ModemManager[4118]: &lt;debug&gt; [modem0]    allowed authentication: none, pap, chap, mschap, mschapv2, eap<br>ModemManager[4118]: &lt;debug&gt; [modem0]    user: unspecified<br>ModemManager[4118]: &lt;debug&gt; [modem0]    password: unspecified<br>ModemManager[4118]: &lt;debug&gt; [modem0]    multiplex: unspecified<br>ModemManager[4118]: &lt;info&gt;  [modem0] simple connect state (6/10): register<br>ModemManager[4118]: &lt;debug&gt; [modem0] already registered automatically in network &#39;26001&#39;, automatic registration not launched...<br>ModemManager[4118]: &lt;info&gt;  [modem0] simple connect state (7/10): wait to get packet service state attached<br>ModemManager[4118]: &lt;info&gt;  [modem0] simple connect state (8/10): bearer<br>ModemManager[4118]: &lt;debug&gt; [modem0] creating new bearer...<br>ModemManager[4118]: &lt;debug&gt; [modem0] (huawei) ^NDISDUP supported, creating huawei bearer...<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 2 (open)<br>ModemManager[4118]: &lt;info&gt;  [modem0] simple connect state (9/10): connect<br>ModemManager[4118]: &lt;debug&gt; [modem0/bearer1] connecting...<br>ModemManager[4118]: &lt;info&gt;  [modem0] state changed (registered -&gt; connecting)<br>ModemManager[4118]: &lt;debug&gt; [modem0/bearer1] launching 3GPP connection attempt<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 3 (open)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 2 (close)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] --&gt; &#39;AT^NDISDUP=1,1,&quot;darmowy&quot;&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 3 (open)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 2 (close)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] --&gt; &#39;AT^NDISSTATQRY?&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;^NDISSTATQRY: 0,,,&quot;IPV4&quot;&lt;CR&gt;&lt;LF&gt;&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 1 (close)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 2 (open)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] --&gt; &#39;AT^NDISSTATQRY?&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;^NDISSTATQRY: 0,,,&quot;IPV4&quot;&lt;CR&gt;&lt;LF&gt;&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 1 (close)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 2 (open)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] --&gt; &#39;AT^NDISSTATQRY?&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;^NDISSTATQRY: 0,,,&quot;IPV4&quot;&lt;CR&gt;&lt;LF&gt;&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 1 (close)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;^MODE: 5,9&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [modem0] access technology changed (umts -&gt; hspa-plus)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;^NDISSTAT:1,,,&quot;IPV4&quot;&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [modem0] (huawei) NDIS status: IPv4 connected, IPv6 not available<br>ModemManager[4118]: &lt;debug&gt; [modem0/bearer0] (huawei) received spontaneous ^NDISSTAT (connected)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 2 (open)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] --&gt; &#39;AT^NDISSTATQRY?&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;^NDISSTATQRY: 1,,,&quot;IPV4&quot;&lt;CR&gt;&lt;LF&gt;&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 3 (open)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] device open count is 2 (close)<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] --&gt; &#39;AT^DHCP?&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [cdc-wdm0/at] &lt;-- &#39;&lt;CR&gt;&lt;LF&gt;^DHCP: 8EF45121,FCFFFFFF,8DF45364,8DF45364,FE7F02D4,346002D4,21600000,21600000&lt;CR&gt;&lt;LF&gt;&lt;CR&gt;&lt;LF&gt;OK&lt;CR&gt;&lt;LF&gt;&#39;<br>ModemManager[4118]: &lt;debug&gt; [modem0/wwx582c80139263/net] port now connected<br>ModemManager[4118]: &lt;debug&gt; [modem0/bearer1] connected<br>ModemManager[4118]: &lt;info&gt;  [modem0] state changed (connecting -&gt; connected)</pre><p>The repeated AT^NDISSTATQRY? commands, which follow the AT^NDISDUP, query the ECM/NDIS connection status. The eventual ^NDISSTAT:1,,,&quot;IPV4&quot; response signifies the modem had successfully established a connection and IPV4 address is available for DHCP to obtain on CDC Ethernet interface, while the ^MODE: 5,9 callback message informs that modem connected to LTE network and activated data session.</p><p>Unfortunately, I spent days trying to replicate this <em>without</em> using NetworkManager automation, with bare network interface and AT communication only. My commands sent to ttyUSB0, while acknowledged by the modem exactly as when sent by NetworkManager in the excerpt above, were not getting the modem to connect, retuning ^NDISSTATQRY: 0,,,&quot;IPV4&quot; in perpetuity. I also tried enabling a regular MODEM functionality with AT^SETPORT and using its additional, dedicated serial port to initialize communication, to no avail.</p><p>The solution hint was in the debug log, after all: all the NDIS AT commands were actually sent to cdc-wdm0 interface, not the ttyUSBx, so simply issuing echo -e &#39;AT^NDISDUP=1,1,&quot;APN&quot;\r&#39; &gt; /dev/cdc-wdm0 made it connect within seconds. In my defense, this goes against all the <a href="https://man.freebsd.org/cgi/man.cgi?cdce(4)">instructions</a> or <a href="https://forum.netgate.com/post/805127">discussions</a> for the CDC modems <a href="https://www.linksysinfo.org/index.php?threads/current-usb-3g-modem-support.35574/post-272323">out there</a>, all of which suggest sending AT commands to diagnostics/modem serial port.</p><p>As a side note, in the process I also found out that either “APN”, “darmowy” or no APN at all (AT^NDISDUP=1,1) will get the modem connected.</p><h3>The USB CDC WDM interface</h3><p>WDM (WCM Device Management) provides an interface for controlling Wireless Mobile Communication (WCM) devices such as wireless modems and phones. Any such device connected to Linux box will have a /dev/cdc-wdmX character device created for it, which userspace software can then use to talk to using one of the protocols. Modern devices typically use dedicated protocols, like the Qualcomm’s proprietary QMI or the USB Implementers Forum’s standardized MBIM. Older models, like my Huawei E3131, rely on traditional AT commands — which is why sending a simple AT^NDISDUP command is enough to establish a connection.</p><p>The problem now is that FreeBSD, which the OPNSense is based on, does not implement WCM Device Management driver so there’s no way to send the AT^NDISDUPas easily as under Linux. The only devices created there are the two useless serial ports (u3g0) and the ue0 Ethernet interface:</p><pre>ugen8.2: &lt;HUAWEI HUAWEI Mobile&gt; at usbus8<br>u3g0 on uhub0<br>u3g0: &lt;HUAWEI HUAWEI Mobile, class 0/0, rev 2.00/1.02, addr 1&gt; on usbus8<br>u3g0: Found 2 ports.<br>cdce0 on uhub0<br>cdce0: &lt;HUAWEI HUAWEI Mobile, class 0/0, rev 2.00/1.02, addr 1&gt; on usbus8<br>cdce0: faking MAC address<br>ue0: &lt;USB Ethernet&gt; on cdce0<br>ue0: Ethernet address: gg:hh:ii:jj:kk:00</pre><h3>Sniffing up the USB communication</h3><p>The next step was to see if I could replicate sending the AT command to cdc-wdm0by addressing the USB device directly. To start with, I used an usbmon module under Linux to sniff on the communication on USB bus 1, where my modem sits (as inspected by lsusb -t):</p><pre>root@proxmox:~ # modprobe usbmon<br>root@proxmox:~ # cat /sys/kernel/debug/usb/usbmon/1u</pre><p>This opens the trace stream of URBs (USB Request Blocks) in the u format. Issuing an echo -e &#39;AT^NDISDUP=1,1,&quot;APN&quot;\r&#39; &gt; /dev/cdc-wdm0 will show in the trace as:</p><pre>ffff88e146b706c0 1616543058 S Ii:1:020:3 -115:16 64 &lt;<br>ffff88e146b70000 1616543085 S Co:1:020:0 s 21 00 0000 0002 0016 22 = 41545e4e 44495344 55503d31 2c312c22 41504e22 0d0a<br>ffff88e146b70000 1616545678 C Co:1:020:0 0 22 &gt;<br>ffff88e146b706c0 1616545996 C Ii:1:020:3 -2:16 0<br>ffff88e146b706c0 1634336245 S Ii:1:020:3 -115:16 64 &lt;</pre><p>The second line is one of interest and it breaks down to:</p><ul><li>ffff88e146b70000: URB tag,</li><li>1616543085: Timestamp in microseconds,</li><li>S: Event Type: S - submission, C - callback, E - submission error,</li><li>Co:1:020:0: “Address” word. Consists of four fields:<br>- Co: URB type and direction, in this case ‘Control output’, <br>- 1: Bus number,<br>-020: Device address,<br>- 0: Endpoint number,</li><li>s: a Setup Tag, expected here as this is a ‘Control’ type request,</li><li>21 00 0000 0002 0016: Setup packet, consisting of 5 hexadecimal words:<br>- 21: bmRequestType. 21 is in the reserved range, and belongs to Microsoft’s <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/network/control-channel-characteristics">RNDIS (Remote NDIS) specification</a>,<br>- 00: bRequest,<br>- 0000: wValue,<br>- 0002: wIndex,<br>- 0016: length of the data transferred (number of bytes). 0x16 equals 22 decimal. This may be <em>larger</em> than the actual number of bytes transferred, but not smaller than.</li><li>22 =: the actual length of the data transferred, this time in decimal,</li><li>41545e4e 44495344 55503d31 2c312c22 41504e22 0d0a: Data words in big endian hexadecimal format, i.e. the actual message content, which decodes to AT^NDISDUP=1,1,&quot;APN&quot;\r\n. Note the extra \n newline feed character — presumably appended by the echo — which is why the length of the data is 22, not 21.</li></ul><p>What’s interesting here is the usage of endpoint number 0, sitting at interface 0, explicitly reserved for USB Control communication. Both are mandaded by the USB spec as the bare minimum of any USB device, so when you use lsusb -v to query device’s interfaces and endpoints, it will <em>not</em> list them. However, the FreeBSD’s equivalent usbconfig dump_all_config_desc, <em>does</em>:</p><pre>root@gw:~ # usbconfig -d 8.2 dump_all_config_desc<br>ugen8.2: &lt;Modem/Networkcard Huawei Technologies Co., Ltd.&gt; at usbus8, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)<br><br>Configuration index 0<br>    bLength = 0x0009<br>    bDescriptorType = 0x0002<br>    wTotalLength = 0x00a8<br>    bNumInterfaces = 0x0003<br>    bConfigurationValue = 0x0001<br>    iConfiguration = 0x0000  &lt;no string&gt;<br>    bmAttributes = 0x0080<br>    bMaxPower = 0x00fa<br>    Interface 0<br>      bLength = 0x0009<br>      bDescriptorType = 0x0004<br>      bInterfaceNumber = 0x0000<br>      bAlternateSetting = 0x0000<br>      bNumEndpoints = 0x0002<br>      bInterfaceClass = 0x00ff  &lt;Vendor specific&gt;<br>      bInterfaceSubClass = 0x0002<br>      bInterfaceProtocol = 0x0002<br>      iInterface = 0x0000  &lt;no string&gt;<br>      (...)<br>     Endpoint 0<br>        bLength = 0x0007<br>        bDescriptorType = 0x0005<br>        bEndpointAddress = 0x0081  &lt;IN&gt;<br>        bmAttributes = 0x0002  &lt;BULK&gt;<br>        wMaxPacketSize = 0x0200<br>        bInterval = 0x0020<br>        bRefresh = 0x0000<br>        bSynchAddress = 0x0000</pre><h3>Replaying the command</h3><p>All the information above provided by the usbmon is enough to replay the command onto the device directly. I used a pyusb library, itself a wrapper around libusb, in a simple script:</p><pre>import usb.core<br>import usb.util<br><br># Find the USB device<br>dev = usb.core.find(idVendor=0x12d1, idProduct=0x1506)<br><br># Claim the interface 0 of device<br>usb.util.claim_interface(dev, 0)<br><br># Prepare the AT command as a control transfer<br>command = &#39;AT^NDISDUP=1,1,&quot;APN&quot;\r\n&#39;<br>command_bytes = command.encode(&#39;utf-8&#39;)<br><br># Send the command using a control transfer<br>dev.ctrl_transfer(<br>    bmRequestType=0x21,<br>    bRequest=0x00,<br>    wValue=0x0000,<br>    wIndex=0x0002,<br>    data_or_wLength=command_bytes<br>)<br><br># Release the interface<br>usb.util.release_interface(dev, 0)<br>usb.util.dispose_resources(dev)</pre><h3>Linux failure</h3><p>I first tried running the script under Linux to reduce number of variables. Before I could, though, the device needed to be unbound from the drivers in use, otherwise it resulted in usb.core.USBError: [Errno 16] Resource busy:</p><pre>echo -n &quot;1-6:1.1&quot; &gt; /sys/bus/usb/drivers/option/unbind<br>echo -n &quot;1-6:1.2&quot; &gt; /sys/bus/usb/drivers/huawei_cdc_ncm/unbind</pre><p>With that done, the command got issued to the device and appeared in usbmontrace:</p><pre>ffff8f9cca7b7680 1202174990 C Co:1:012:0 0 0<br>ffff8f9cca920b40 1206191657 S Co:1:012:0 s 21 00 0000 0002 0016 22 = 41545e4e 44495344 55503d31 2c312c22 41504e22 0d0a<br>ffff8f9cca920b40 1206194025 C Co:1:012:0 0 22 &gt;</pre><p>The control command itself is identical as if sent to /dev/cdc-wdm character device. Unfortunately, after re-binding the devices to their respective modules, I could not obtain a DHCP addres. I suspect this is because re-binding to modules has them re-do the device initialization, as indicated by substantial chatter on usbmon. If anyone has any idea how to get the command sent under Linux without unbinding the device, feel free to leave a commonet.</p><h3>FreeBSD success</h3><p>Running the above script under OPNSense would likely yield a similar result, but I couldn’t even confirm this as the default installation does not come with py311-pyusb package. Sideloding it from the FreeBSD’s repositories proved annoyingly problematic and time-consuming.</p><p>However, turns out FreeBSD comes with the usbconfig tool, capable of performing a synchronous control request on a given device <em>without</em> unbinding it from the modules:</p><pre>root@gw:~ # usbconfig -h<br>usbconfig - configure the USB subsystem<br>usage: usbconfig -d [ugen]&lt;busnum&gt;.&lt;devaddr&gt; [-i &lt;ifaceindex&gt;] [-v] [cmds...]<br>commands:<br>  (...)<br>  do_request &lt;bmReqTyp&gt; &lt;bReq&gt; &lt;wVal&gt; &lt;wIdx&gt; &lt;wLen&gt; &lt;data...&gt;</pre><p>All the fields are pretty self-explanatory in light of the previous findings, except maybe for the scarce documentation on how to pass the data — and the popular AI agents will totally throw you under a bus suggesting to use plain ASCII string:</p><pre>root@gw:~ # usbconfig -d 8.2 -i 0 do_request 0x21 0 0 2 16 &#39;AT^NDISDUP=1,1\r\n&#39;<br>usbconfig: request data missing: No error: 0</pre><p>The resulting error message is fairly ambigous (<em>“No error: 0”</em>) but cross-checking using a usbdump -d 8.2 -s 256 -vv, a tool more or less equivalent of Linux’s usbmon, would confirm that no request was being sent.</p><p>Looking into the sourcecode, it is clear the tool expects the data to be provided <a href="https://github.com/freebsd/freebsd-src/blob/7008b9fab5552fd6dcf5a00cd2c62144d54ef3a0/usr.sbin/usbconfig/usbconfig.c#L844">as separate bytes</a> in a <a href="https://github.com/freebsd/freebsd-src/blob/7008b9fab5552fd6dcf5a00cd2c62144d54ef3a0/usr.sbin/usbconfig/usbconfig.c#L234">format readable</a> by strtoul C function, so the correct syntax is actually:</p><pre>root@gw:~ # usbconfig -d 8.2 -i 0 do_request 0x21 0 0 2 16 0x41 0x54 0x5e 0x4e 0x44 0x49 0x53 0x44 0x55 0x50 0x3d 0x31 0x2c 0x31 0x0d 0x0a<br>REQUEST = &lt;OK&gt;</pre><p>The usbdump output reflects this as:</p><pre>C23:15:56.508476 usbus8.2 SUBM-CTRL-EP=00000000,SPD=HIGH,NFR=2,SLEN=24,IVAL=0<br> frame[0] WRITE 8 bytes<br> 0000  21 00 00 00 02 00 10 00  -- -- -- -- -- -- -- --  |!.......        |<br> frame[1] WRITE 16 bytes<br> 0000  41 54 5E 4E 44 49 53 44  55 50 3D 31 2C 31 0D 0A  |AT^NDISDUP=1,1..|<br> flags 0x2 &lt;SHORT_XFER_OK|0&gt;<br> status 0xca1a3 &lt;OPEN|TRANSFERRING|STARTED|CONTROL_XFR|CONTROL_HDR|BDMA_ENABLE|BDMA_SETUP|CAN_CANCEL_IMMED|DOING_CALLBACK|0&gt;<br>23:15:56.510703 usbus8.2 DONE-INTR-EP=00000083,SPD=HIGH,NFR=1,SLEN=8,IVAL=2,ERR=0<br> frame[0] READ 8 bytes<br> 0000  A1 01 00 00 02 00 00 00  -- -- -- -- -- -- -- --  |........        |<br> flags 0x8a &lt;SHORT_XFER_OK|PIPE_BOF|NO_PIPE_OK|0&gt;<br> status 0xeb021 &lt;OPEN|STARTED|SHORT_XFER_OK|BDMA_ENABLE|BDMA_SETUP|CURR_DMA_SET|CAN_CANCEL_IMMED|DOING_CALLBACK|0&gt;<br>23:15:56.510706 usbus8.2 SUBM-INTR-EP=00000083,SPD=HIGH,NFR=1,SLEN=0,IVAL=2<br> frame[0] READ 32 bytes<br> flags 0x8a &lt;SHORT_XFER_OK|PIPE_BOF|NO_PIPE_OK|0&gt;<br> status 0xcb023 &lt;OPEN|TRANSFERRING|STARTED|SHORT_XFER_OK|BDMA_ENABLE|BDMA_SETUP|CAN_CANCEL_IMMED|DOING_CALLBACK|0&gt;<br>23:15:56.511120 usbus8.2 DONE-CTRL-EP=00000000,SPD=HIGH,NFR=2,SLEN=0,IVAL=0,ERR=0<br> frame[0] WRITE 8 bytes<br> frame[1] WRITE 16 bytes<br> flags 0x2 &lt;SHORT_XFER_OK|0&gt;<br> status 0xca1a1 &lt;OPEN|STARTED|CONTROL_XFR|CONTROL_HDR|BDMA_ENABLE|BDMA_SETUP|CAN_CANCEL_IMMED|DOING_CALLBACK|0&gt;</pre><p>This made the modem establish communication, allowing DHCP to obtain the addresses:</p><pre>root@gw:~ # dhclient ue0<br>DHCPREQUEST on ue0 to 255.255.255.255 port 67<br>DHCPACK from 100.xx.yyy.zz<br>bound to 100.xx.yyy.zz -- renewal in 259200 seconds.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f755aca1bcc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive into HDMI Resolution Troubleshooting]]></title>
            <link>https://medium.com/@wrobelda/deep-dive-into-hdmi-resolution-troubleshooting-d8ba563441fe?source=rss-d13d57ddfa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8ba563441fe</guid>
            <category><![CDATA[vesa]]></category>
            <category><![CDATA[displayport]]></category>
            <category><![CDATA[edid]]></category>
            <category><![CDATA[hdmi]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Dawid Wróbel]]></dc:creator>
            <pubDate>Sun, 09 Jun 2024 00:00:45 GMT</pubDate>
            <atom:updated>2024-06-13T16:19:03.318Z</atom:updated>
            <content:encoded><![CDATA[<p>I ran into an issue with my <a href="https://dawidwrobel.com/journal/cost-effective-intel-w680-server/">server</a> where my Yamaha TSR-5810 (RX-V581) receiver connected to an Optoma projector would display a blank screen during the POST/BIOS phase. I immediately suspected that HP’s BIOS couldn’t handle the low resolution of 720x480 reported by the projector, with the main suspect being the vintage DisplayPort to HDMI 1080p converter I was using. The immeddiate diagnosis was that the HP’s BIOS couldn’t handle the low resolution of 720x480, as reported by the projector, and the main suspect was the vintage DisplayPort to HDMI 1080p converter I was using.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xntDdVj8CGHID6EP.png" /><figcaption>Author’s reproduction of HP’s generous idea for this Blank Page project</figcaption></figure><p>You can hardly blame HP for not handling the 720x480 (480p) resolution, considering any hardware of the last 20 years typically handles at least 1024 x 768. Nevertheless, the completely blank screen stumped me for an hour. The obvious initial suspect was the Displayport to HDMI converter, so I ordered a modern, 4k version, only to find that it produced the same issue. More head-scratching ensued.</p><h3>Yamaha Customer Support</h3><p>Eventually, by reducing the number of variables and connecting the PC directly to the projector, the BIOS menu showed at the princely 4k@60Hz resolution, to my sheer surprise. At this point, I assumed it was one of the not uncommon HDMI/EDID negotiation issues and hoped Yamaha Customer Service could offer a way to force and lock the displayed resolution — something I believed some of their models <a href="https://manual.yamaha.com/av/18/rxv685/en-US/3838781195.html">supported</a>, but which, as they later clarified, was actually a video upscaling feature.</p><p>Yamaha CS did respond promptly, albeit with the expected “it’s not us, it’s you”:</p><blockquote><em>The TSR-5810 only passes through video signals. It does not have the ability to change incoming video signals from one resolution to another. If you are seeing 720p on the projector, it’s because the PC is deciding to output that resolution.</em></blockquote><p>, which I couldn’t but retribute with:</p><blockquote><em>Frankly speaking, this cannot be true and is directly opposed to my experience. As I explained before, if I connect the projector directly to the PC, I am getting a 4k@60Hz right away. If I instead connect the PC via my receiver, I get 480p.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*lWJchSbMIs5Xdk6Hse9Y0g.jpeg" /><figcaption>Yamaha receiver also failed to infer anything meaningful from the PC signal</figcaption></figure><p>However, the conversation carried on and I played along the “have you tried with other hardware” spiel. I connected my Dell display (of a 3440x1440 resolution) directly to the PC, which worked unsurprisingly, but also via the receiver, which somehow also worked fine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*IcUSnFGQD27gYDJHoZexYA.jpeg" /><figcaption>Dell U3419W connected to PC (using the DisplayPort to HDMI 4K adapter)</figcaption></figure><p>So the conclusion was that the receiver had an issue specifically with my projector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*0dwTg3fTtbD1QuMIHqPuGg.jpeg" /><figcaption>Dell U3419W connected to PC via the Receiver (using the DisplayPort to HDMI 4K adapter). Notice the reduced refresh rate.</figcaption></figure><p>I also found out that if I booted into a Linux GUI, I was actually able to change from 480p to 4k@60Hz manually. So with that in mind, I had no doubts this was an EDID negotiation issue between the receiver and the projector and not an actual hardware issue.</p><h3>Debugging EDID</h3><p>For the actual debugging of the problem, I resorted to the EDID information, which can be dumped by the <a href="https://git.linuxtv.org/edid-decode.git/about">edid-decode tool</a> on the PC connected to a display.</p><blockquote><em>Extended Display Identification Data (EDID) and Enhanced EDID (E-EDID) are metadata formats for display devices to describe their capabilities to a video source (e.g., graphics card or set-top box). The data format is defined by a standard published by the Video Electronics Standards Association (VESA). — Wikipedia</em></blockquote><p>EDID structure was extended by VESA committee multiple times, and our particular interest is in CTA EDID Timing Extension Block, i.e. the , which provides support for all the advanced capabilities of the HDMI- or DisplayPort-equipped devices. This is, in essence, what makes all the modern devices automatically select optimal resolutions, color gamut and refresh rates, as well as the surround sound modes, without requiring any human intervention - when it works, that is. All this information is contained within several CTA Data Blocks, one of which is the (Video Data Block). VBD, in turn, contains a list of SVDs (Short Video Descriptors), which basically reference the resolution and timing combinations predefined by VESA as Video Identification Codes () and supported by the display. Importantly, SVDs/VICs are listed in order of device preference.</p><p>Here’s an excerpt from the edid-decode tool that shows the timings of my Optoma projector connected to the PC, with the offender 480p resolution listed second:</p><pre><strong>Block 1, CTA-861 Extension Block:</strong><br>  Revision: 3<br>  Underscans IT Video Formats by default<br>  Basic audio support<br>  Supports YCbCr 4:4:4<br>  Supports YCbCr 4:2:2<br>  Native detailed modes: 1<br><strong>  Video Data Block:</strong><br>    VIC  63:  1920x1080  120.000000 Hz  16:9    135.000 kHz    297.000000 MHz<br>    <strong>VIC   2:   720x480    59.940060 Hz   4:3     31.469 kHz     27.000000 MHz</strong><br>    VIC   5:  1920x1080i  60.000000 Hz  16:9     33.750 kHz     74.250000 MHz<br>    VIC  20:  1920x1080i  50.000000 Hz  16:9     28.125 kHz     74.250000 MHz<br>    VIC  16:  1920x1080   60.000000 Hz  16:9     67.500 kHz    148.500000 MHz<br>    VIC  31:  1920x1080   50.000000 Hz  16:9     56.250 kHz    148.500000 MHz<br>    VIC  32:  1920x1080   24.000000 Hz  16:9     27.000 kHz     74.250000 MHz<br>    VIC  93:  3840x2160   24.000000 Hz  16:9     54.000 kHz    297.000000 MHz<br>    VIC  94:  3840x2160   25.000000 Hz  16:9     56.250 kHz    297.000000 MHz<br>    VIC  95:  3840x2160   30.000000 Hz  16:9     67.500 kHz    297.000000 MHz<br>    VIC  96:  3840x2160   50.000000 Hz  16:9    112.500 kHz    594.000000 MHz<br>    VIC  97:  3840x2160   60.000000 Hz  16:9    135.000 kHz    594.000000 MHz<br>    VIC  98:  4096x2160   24.000000 Hz 256:135   54.000 kHz    297.000000 MHz<br>    VIC  99:  4096x2160   25.000000 Hz 256:135   56.250 kHz    297.000000 MHz<br>    VIC 100:  4096x2160   30.000000 Hz 256:135   67.500 kHz    297.000000 MHz<br>    VIC 101:  4096x2160   50.000000 Hz 256:135  112.500 kHz    594.000000 MHz<br>    VIC 102:  4096x2160   60.000000 Hz 256:135  135.000 kHz    594.000000 MHz<br>    VIC   3:   720x480    59.940060 Hz  16:9     31.469 kHz     27.000000 MHz<br>    VIC   4:  1280x720    60.000000 Hz  16:9     45.000 kHz     74.250000 MHz<br>    VIC  19:  1280x720    50.000000 Hz  16:9     37.500 kHz     74.250000 MHz<br>    VIC  18:   720x576    50.000000 Hz  16:9     31.250 kHz     27.000000 MHz</pre><p>As the plot thickened, I ran the edid-decode tool:</p><p>- with projector plugged in directly to PC (Linux framebuffer displays at 1080p),</p><p>- the projector plugged in via the receiver (Linux framebuffer displays at 480p),</p><p>- with projector disconnected but the receiver plugged in.</p><p>There were several interesting differences between these outputs, but most notably, between the Optoma plugged into the PC via the receiver and directly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pi-F6B75zbI3p_slYvWGWw.png" /><figcaption>A diff of EDID reports: Optoma projector plugged into PC via receiver (left) and directly (right).</figcaption></figure><p>The Detailed Timing Descriptors section shows the currently used resolution and timings (frequencies). Notably, there&#39;s a difference in the Monitor ranges reported by both configurations. My Optoma is a UHZ50 model, which supports frequencies as high as 240Hz at 1080p. When connected via the receiver, however, the monitor range gets reduced, which is expected since the receiver itself supports only up to 120Hz at 720p.</p><p>As mentioned, VICs in Video Data Block are listed in the order of preference. The first VIC reported as preferred by Optoma is 1080@120Hz. As established, the receiver cannot handle such high bitrate mode, so it decides to remove it from the list altogether. The next on the list of preferences reported by the projector is 480p, which is exactly why the devices settle on it. BINGO!</p><h3>Conclusion</h3><p>This primarily seems like Yamaha firmware bug: a better behavior than removing the VIC altogether would be swapping it with one that describes the same resolution but at the highest frequency supported by both devices. This is also an odd decision on Optoma end to make a very obscure 480p resolution the <em>second preferred</em> one. HP is also not without fault here, since their firmware should explicitly request a more suitable, reasonable 720p mode, instead of defaulting to first on the list, which they can’t even handle properly.</p><p>I reported all my findings to Yamaha CS, who in turn forwarded them to their design team, although this ~6 y/o device is unlikely to see an update fixing this somewhat unusual issue.</p><p><em>Originally published at </em><a href="https://dawidwrobel.com/journal/debugging-hdmi/"><em>https://dawidwrobel.com</em></a><em> on June 9, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8ba563441fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Applying CSS transitions to Hugo blog posts]]></title>
            <link>https://medium.com/@wrobelda/applying-css-transitions-to-hugo-blog-posts-c3738f4448f2?source=rss-d13d57ddfa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3738f4448f2</guid>
            <category><![CDATA[css-animation]]></category>
            <category><![CDATA[hugo]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[css-transforms]]></category>
            <dc:creator><![CDATA[Dawid Wróbel]]></dc:creator>
            <pubDate>Mon, 29 Apr 2024 00:00:54 GMT</pubDate>
            <atom:updated>2024-05-05T12:45:07.929Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using a simple JavaScript hack and a bit of CSS styling</h3><p>I wanted to include some on-scroll content transitions to blog posts on my Hugo-based website, which I was just finished porting over from the initial Wordpress + <a href="https://laytheme.com/">LayTheme</a> design. Turns out it’s fairly easy using JavaScript’s IntersectionObserver API and some Hugo magic.</p><h3>CSS transitions</h3><p>Consider this (slightly modified) <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions#multiple_animated_properties_example">“Multiple animated properties example”</a> from Mozilla Developer Docs, showing how <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions">CSS transitions</a> work:</p><p>A div element:</p><pre>&lt;div class=&quot;box&quot;&gt;Sample&lt;/div&gt;</pre><p>styled with this CSS:</p><pre>.box {<br>  color: white;<br>  border-style: solid;<br>  border-width: 1px;<br>  display: block;<br>  width: 100px;<br>  height: 100px;<br>  background-color: #0000ff;<br>  transition:<br>    width 2s,<br>    height 2s,<br>    background-color 2s,<br>    rotate 2s,<br>    color 2s;<br>}<br><br>.box:hover,<br>.box:active {<br>  color: black;<br>  background-color: #ffcccc;<br>  width: 200px;<br>  height: 200px;<br>  rotate: 180deg;<br>}</pre><p>will result in a box that transforms as soon as you hover over it or depress it (for use on smartphones):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WXZK2xH3lEWvMGgg-Uqeag.gif" /></figure><p>Simple. Two classes, one for the “default” state and another one to define the transition to be applied.</p><p>You could now use <a href="https://gohugo.io/content-management/markdown-attributes/">Markdown Attributes</a> to apply those CSS classes to any of your Markdown content in Hugo and be done.</p><h3>IntersectionObserver API</h3><p>However, the particular transition I am after is an ease-in transform, which looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*VKJ2P5cTAb_qJ4T3DMhD9Q.gif" /></figure><p>In case you got distracted: the photo slides in slightly from the bottom when scrolling. To make that happen we need to kick the transition off as soon as the photo starts showing on the screen — or, technically speaking, showing in <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Viewport_concepts">viewport</a>. To get that working, I can leverage <a href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver API</a>, as explained on <a href="https://stackoverflow.com/questions/27462306/css3-animate-elements-if-visible-in-viewport-page-scroll/27462500#27462500">Stack Overflow</a>:</p><pre>const inViewport = (entries, observer) =&gt; {<br>  entries.forEach(entry =&gt; {<br>    entry.target.classList.toggle(&quot;is-inViewport&quot;, entry.isIntersecting);<br>  });<br>};<br><br>const Obs = new IntersectionObserver(inViewport);<br>const obsOptions = {}; //See: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Intersection_observer_options<br><br>// Attach observer to every [data-inviewport] element:<br>document.querySelectorAll(&#39;[data-inviewport]&#39;).forEach(el =&gt; {<br>  Obs.observe(el, obsOptions);<br>});</pre><p>The code is pretty self-explanatory (reading from the bottom up):</p><ul><li>For each element matching [data-inviewport] selector, have it observed by the Obs (which is an object of IntersectionObserver class).</li><li>Whenever an observed element intersects with browser’s viewport, Obs invokes inViewport callback function.</li><li>inViewport, in turn, toggles the is-inViewport class on observed element.</li></ul><p>Since the elements intersect both when they <em>appear</em> in the viewport and <em>disappear</em> from it, the is-inViewport class effectively tells us whether or not any portion of an observed element is visible on the screen or not. Neat.</p><p>You could now define some classes for different transformations, e.g.</p><pre>[data-inviewport=&quot;scale-in&quot;] {<br>  transition: 2s;<br>  transform: scale(0.1);<br>}<br>[data-inviewport=&quot;scale-in&quot;].is-inViewport { <br>  transform: scale(1);<br>}</pre><p>and add a data-inviewport=&quot;scale-in&quot; attribute to every HTML element you wanted to apply the scale-in effect to. Unfortunately, in Hugo, this typically means you&#39;d have to modify the theme itself, e.g. its shortcodes for &lt;&lt;figure&gt;&gt; or &lt;&lt;highlight&gt;&gt;, and ideally you want to avoid that.</p><p>The alternative is to use a different selector in querySelectorAll, one that would capture elements by their other classes previously applied or by their type. For example: querySelectorAll(&#39;.highlight, .post-content img&#39;) would get is-inViewport class toggled on:</p><ul><li>any element that already has a .highlight class assigned, i.e. is a code block;</li><li>and on any &lt;img&gt; element that is a descendant of any element with .post-content class, such that only images added as posts content have that transition applied - otherwise the selector would capture all of the images on the website, including your logo, etc.</li></ul><p>CSS styling to accompany that could look like this:</p><pre>.highlight,<br>.post-content img {<br>  transition: 2s;<br>  transform: scale(0.1);<br>}<br><br>.highlight.is-inViewport,<br>img.is-inViewport {<br>  transform: scale(1);<br>}</pre><p>Notice that the second selector does not use .post-content class restriction, given that .is-inViewport already limits it to the elements of our interest.</p><p>To finish this off, you’d save the CSS above into assets/css/extended folder (under any file name, Hugo will include it automatically) plus the JavaScript piece above to e.g. static/js/viewportobserve.js. For the latter, you also need a corresponding &lt;script&gt; tag added to the HTML&#39;s body to have the script actually loaded together with your website:</p><pre>&lt;script src=&quot;{{ &quot;js/assets/js/viewportobserve.js&quot; | absURL }}&quot;&gt;&lt;/script&gt;</pre><p>This is typically added to layouts/partials/extend_footer.html or a similar partial file - there&#39;s no rule, as it&#39;s merely a convention adopted by Hugo theme authors.</p><h3>Templating perfection</h3><p>The last step of improvement is to avoid having to modify the .js file whenever you want to change the element selector. Preferably, we’d want it as a parameter in hugo.toml (or hugo.yml) config file:</p><pre>[params]<br>observeViewportSelectors = &quot;.highlight, .post-content img&#39;&quot;</pre><p>For that we need to convert the JavaScript code to incorporate Hugo templates and its Go functions:</p><pre>const inViewport = (entries, observer) =&gt; {<br>  entries.forEach(entry =&gt; {<br>    entry.target.classList.toggle(&quot;is-inViewport&quot;, entry.isIntersecting);<br>  });<br>};<br><br>const Obs = new IntersectionObserver(inViewport);<br>const obsOptions = {};<br><br>{{ if .Site.Params.observeViewportSelectors }}<br>const selector = &quot;{{ .Site.Params.observeViewportSelectors }}&quot;;<br>// Attach observer to every element requested:<br>document.querySelectorAll(selector).forEach(el =&gt; {<br>    Obs.observe(el, obsOptions);<br>});<br>{{ end }}</pre><p>Lastly, we change the script inclusion directive to have Hugo pre-process the now templated .js file using <a href="https://gohugo.io/hugo-pipes/resource-from-template">ExecuteAsTemplate</a> function:</p><pre>{{- $viewportobserve := resources.Get &quot;js/viewportobserve.js&quot; | resources.ExecuteAsTemplate &quot;viewportobserve_processed.js&quot; . | resources.Minify }}<br>&lt;script crossorigin=&quot;anonymous&quot; src=&quot;{{ $viewportobserve.RelPermalink }}&quot;&gt;&lt;/script&gt;</pre><p>A notable difference here is that the script file now needs to be placed inside assets/js/, since it no longer is just a static file, but instead a resource we retrieve using resources.Get for further processing.</p><p>Done. Now you can observe any elements getting in/out of the viewport and apply any changes to them using CSS styles.</p><p><em>Originally published at </em><a href="https://dawidwrobel.com/journal/content-css-transformations-in-hugo/"><em>https://dawidwrobel.com</em></a><em> on April 29, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3738f4448f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A cost-effective Intel W680 ECC server: repurposing an HP Z2 G9 Workstation motherboard]]></title>
            <link>https://medium.com/@wrobelda/a-cost-effective-intel-w680-ecc-server-repurposing-an-hp-z2-g9-workstation-motherboard-fd30878baaf1?source=rss-d13d57ddfa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd30878baaf1</guid>
            <category><![CDATA[power-saving]]></category>
            <category><![CDATA[home-server]]></category>
            <category><![CDATA[motherboard]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Dawid Wróbel]]></dc:creator>
            <pubDate>Fri, 12 Apr 2024 00:00:18 GMT</pubDate>
            <atom:updated>2024-06-13T16:20:28.895Z</atom:updated>
            <content:encoded><![CDATA[<h3>I bought a second-hand HP Z2 G9 W680 motherboard for less than USD 100 and within last 3 months I gained enough experience to share.</h3><p>Considering all other W680 motherboards cost upwards of USD 500 at this point, this turns out to be a fairly attractive solution to get a modern Intel system with low idle power consumption, PCIe Gen 5, and, most importantly, ECC memory support. Interestingly, I saw some recent eBay listings that sold those motherboards for as little as <a href="https://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p2334524.m570.l1313&amp;_nkw=hp+z2+g9+tower+motheboard+&amp;_sacat=0&amp;_odkw=M82213-601&amp;_osacat=0&amp;_sop=15&amp;LH_Complete=1">20–40 USD</a>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*963djeJAjOtRySsn.jpg" /></figure><p>A trade off, however, is that there are a few challenges running it, compared to your run-of-the-mill products.</p><h3>PSU</h3><p>HP, Dell, and Lenovo all use proprietary PSUs, which at least in case HP are actually conformant to ATX12VO. That means the PSUs themselves only deliver 12V to the board, which then handles the 5V supply by itself. This also means that using off-the-self PSU is very limited, especially because the board expects +12VSB (stand-by voltage), as opposed to the standard 5V. There are workarounds available (google it), but I resorted to using an HP power supply.​</p><figure><img alt="The G5 system 450W PSU I use, with three 18A 12V rails" src="https://cdn-images-1.medium.com/max/1024/0*URKqwoOpfwlyiBo1.jpeg" /><figcaption>The G5 system 450W PSU I use, with three 18A 12V rails</figcaption></figure><p>For the record, while the HP Z2 G9 can be configured with 3 different PSUs, you can use PSUs from other compatible systems. Notably, the PSU must have a 7-pin PWRCMD connector, as opposed to a 6-pin That is, however, not enough, as not all PSUs have enough wires in the connector, and my conclusion at this point is that any PSU with <em>black cabling</em> and a 7-pin PWRCMD connector will work with this system. I am myself using it with an HP G5 450W PSU, which has Gold certification — although Platinum ones are also available.​</p><figure><img alt="7-pin connector with 7 black wires plus three 12V connectors plus a disruptor" src="https://cdn-images-1.medium.com/max/1024/0*cXT8jf1uopd6CJK3.jpeg" /><figcaption>7-pin connector with 7 black wires plus three 12V connectors plus a disruptor</figcaption></figure><p>Also worth noting is that there isn’t anything proprietary about those PSUs outside of the connectors: all of the cabling is standard ATX. In fact, before they switched to using all-black cabling, all of the cable colors used matched the ATX standard.​ ​</p><h3>Fans</h3><p>Another proprietary solution is HP fan connectors. They are compatible with regular PWM fans, but the HP CPU fan comes with 5 pins, instead of regular 4. Pins 1–4 are the same as in the standard, pin number 5 is crucial to get the system to NOT report fan incompatibility upon POST.​ ​ Their fans come in at 65W and 125W TDP versions. So far, what I found, is that to emulate 125W, one needs to connect pins 3 and 5. Shorting pins 3, 4, and 5 will allow the system to not report when the fan is missing entirely. More on that later.​ ​ The system will also report a missing chassis fan, CHFAN2 (P9 in manual). This one is a regular, 4-pin one. The solution here is to short pins 3 and 4.​ ​ The problem, unfortunately, is that HP fan implementation is not exposed to the system, so lm-sensors is not able to control them. That wouldn’t be that bad if not for the fact that they tie the fan speed to the CPU usage, not the temperature. And this in itself wouldn’t be a problem if they didn’t tie them to a <em>single core</em> usage, which results in fans blasting as soon as the system sees even modest utilization, around 3–5%.​ ​ See this thread on HP forums for details: <a href="https://h30434.www3.hp.com/t5/Business-PCs-Workstations-and-Point-of-Sale-Systems/HP-Z2-G9-CPU-Fan-starts-spinning-at-full-speed-even-if-only/m-p/8935953#M44658">Re: HP Z2 G9 — CPU Fan starts spinning at full speed even if only one or two cores are at 100% usage​</a> ​ With that in mind, you need to resort to an external fan controller to take the control back. Some recommended options are Corsair and NZXT, which luckily come with Linux kernel support, together with liquidctl to control them. More here: <a href="https://github.com/liquidctl/liquidctl?tab=readme-ov-file#supported-devices">liquidctl​</a>. You’ll also need to short pins 3, 4, and 5, as explained above, to avoid the POST complaints. ​</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*i60arR_hd5bubi_-.png" /><figcaption>Motherboard diagram <a href="https://kaas.hpcloud.hp.com/pdf-public/pdf_5451169_en-US-1.pdf">(HP Z2 G9 Tower Service Manual)</a></figcaption></figure><h3><strong>Non-standard size</strong></h3><p>All of these HP/DELL/Lenovo motherboards come in non-standard sizes. They are Micro-ATX by lengths, but exceptionally wide. This has both pros and cons:​ You can’t use them in regular ATX cases, most likely. I don’t have a problem with it, since I have it installed in a custom IKEA shelving</p><p>Outside of the non-standard size mentioned above, the board has:</p><ol><li>Excellent IOMMU grouping. Pretty much every single device has its own group. No ACS overrides needed. No issues in passing GPU, Mellanox SRIOV VFs, or SATA controller to the VMs:</li></ol><pre>root@proxmox:~# for d in /sys/kernel/iommu_groups/*/devices/*; do n=${d#*/iommu_groups/*}; n=${n%%/*}; printf &#39;IOMMU group %s &#39; &quot;$n&quot;; lspci -nns &quot;${d##*/}&quot;; done<br>IOMMU group 0 00:02.0 Display controller [0380]: Intel Corporation Raptor Lake-S GT1 [UHD Graphics 770] [8086:a780] (rev 04)<br>IOMMU group 10 02:00.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 XL Downstream Port of PCI Express Switch [1002:1479]<br>IOMMU group 11 03:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 23 [Radeon RX 6600/6600 XT/6600M] [1002:73ff] (rev c1)<br>IOMMU group 12 03:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 21/23 HDMI/DP Audio Controller [1002:ab28]<br>IOMMU group 13 04:00.0 Non-Volatile memory controller [0108]: Shenzhen Longsys Electronics Co., Ltd. Device [1d97:1602] (rev 01)<br>IOMMU group 14 05:00.0 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx] [15b3:1015]<br>IOMMU group 15 05:00.1 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx] [15b3:1015]<br>IOMMU group 16 06:00.0 Non-Volatile memory controller [0108]: Shenzhen Longsys Electronics Co., Ltd. Device [1d97:1602] (rev 01)<br>IOMMU group 17 05:01.2 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 18 05:01.3 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 19 05:01.4 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 1 00:00.0 Host bridge [0600]: Intel Corporation Device [8086:a704] (rev 01)<br>IOMMU group 20 05:01.5 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 21 05:01.6 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 22 05:01.7 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 23 05:02.0 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 24 05:02.1 Ethernet controller [0200]: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] [15b3:1016]<br>IOMMU group 2 00:01.0 PCI bridge [0604]: Intel Corporation Device [8086:a70d] (rev 01)<br>IOMMU group 3 00:14.0 USB controller [0c03]: Intel Corporation Alder Lake-S PCH USB 3.2 Gen 2x2 XHCI Controller [8086:7ae0] (rev 11)<br>IOMMU group 3 00:14.2 RAM memory [0500]: Intel Corporation Alder Lake-S PCH Shared SRAM [8086:7aa7] (rev 11)<br>IOMMU group 4 00:17.0 SATA controller [0106]: Intel Corporation Alder Lake-S PCH SATA Controller [AHCI Mode] [8086:7ae2] (rev 11)<br>IOMMU group 5 00:1b.0 PCI bridge [0604]: Intel Corporation Device [8086:7ac4] (rev 11)<br>IOMMU group 6 00:1c.0 PCI bridge [0604]: Intel Corporation Alder Lake-S PCH PCI Express Root Port #1 [8086:7ab8] (rev 11)<br>IOMMU group 7 00:1d.0 PCI bridge [0604]: Intel Corporation Alder Lake-S PCH PCI Express Root Port #13 [8086:7ab4] (rev 11)<br>IOMMU group 8 00:1f.0 ISA bridge [0601]: Intel Corporation Device [8086:7a88] (rev 11)<br>IOMMU group 8 00:1f.4 SMBus [0c05]: Intel Corporation Alder Lake-S PCH SMBus Controller [8086:7aa3] (rev 11)<br>IOMMU group 8 00:1f.5 Serial bus controller [0c80]: Intel Corporation Alder Lake-S PCH SPI Controller [8086:7aa4] (rev 11)<br>IOMMU group 8 00:1f.6 Ethernet controller [0200]: Intel Corporation Ethernet Connection (17) I219-LM [8086:1a1c] (rev 11)<br>IOMMU group 9 01:00.0 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 XL Upstream Port of PCI Express Switch [1002:1478] (rev c1)</pre><ol><li>3 x NVMe PCIe4 x4 slots and 1 x m2 PCIe3 x1 slot</li><li>HP Flex IOv2 connector, so you can add an extra <a href="https://www.servethehome.com/hp-flex-io-v2-10gbase-t-module-56q71aa-for-1l-pcs-marvell/">10Gbit NIC</a> or a relatively inexpensive HP 3UU05AA Thunderbolt 3 extension card (which takes up PCI slot 4 as well).</li><li>I219-LM Gigabit Ethernet with vPro support.</li><li>Extra USB connectors on the other end of the board</li><li>Only 4 PCI slots. Slot 1 is PCIe5 x16. The rest are PCIe3 x1, x4, x4. A typical 2.5-width GPU card will leave you with a single PCI slot 4 free — unless you resort to some creative PCI ribbon risers.</li><li>4 SATA ports. You need a <a href="https://superuser.com/questions/1809823/hp-p160-sata-power-to-pcie-power">P160 HP cable</a> to power the disks, as the PSU being ATX12VO does not come with SATA power cabling.</li><li>An onboard USB header, used to connect the Media Card reader. Unfortunately it is non-standard, so you can’t use it to connect the Corsair/NZXT fan controller unless you figure out the pinout.</li></ol><h3><strong>Runtime issues</strong></h3><h4>13th gen “PCA not fully compatible” error</h4><p>After updating to the 13th gen, I am seeing a “PCA not fully compatible” error. This is actually <a href="https://forums.servethehome.com/index.php?threads/hp-z2-mini-g9-upgrade-cpu-to-raptor-lake-getting-pca-not-fully-compatible-warning.40139/page-2#post-420441">discussed on ServeTheHome</a> forums, affecting the HP Z2 G9 Mini system, without any definitive conclusion at the time of writing this. I myself have no clue what’s causing this: the fan is rather unlikely since you can disconnect it altogether and the SKU error still shows, followed by the “missing fan” error. The PSU is also unlikely, since AFIK there’s no way for the motherboard to know the model of the PSU connected. There is another revision of the motherboard, which is said was released to fix some 13/14th gen compatibility issues, but HP themselves have not confirmed that, and all of the posts on their forums that ask for help with the very same issue were left with no response from HP.</p><p>Unfortunately, the system will not post past this error unless you acknowledge it with a keyboard press. I did not notice any other compatibility issues with the 13th gen on top of the 12th gen. Goes without saying the firmware is up to date.</p><h4>Power consumption</h4><p>With no external devices connected and the system idling, 64GB (2 x 32 GB) ECC RAM, and 2 x Lexar NM 710 1 TB SSDs, the power consumption measured off the wall is 4.5–5.5W for 12600k and 5.0–6.5W with 13600k, which is astonishing. It could potentially get even lower with a Platinum PSU! AMD clearly cannot compete here at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZAECuC8x1kW99WEK.jpeg" /><figcaption>6.4W of peak consumption at the wall while idling</figcaption></figure><p>The C-States go all the way to C10 with 12600k, but only C8 with 13600k — I am not sure if that is expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wWTyVhtPTJOrTamE.jpeg" /><figcaption>The C8 levels observed with 13600k processor and no device in PCI slot 1</figcaption></figure><p>Unfortunately, some serious problems start as soon as I connect PCI devices. Specifically, with the AMD 6600 XT GPU connected to slot 1, the system will no longer enter deeper C-states, stopping at C2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s0n-dD0WbSb4_tSI.jpeg" /><figcaption>The C2 levels observed with 13600k processor and a GPU in PCI Slot 1</figcaption></figure><p>I believe this is because the PCIe5 slot 1 is connected directly to the CPU, which apparently limits the C states to 2, as reported by <a href="https://mattgadient.com/7-watts-idle-on-intel-12th-13th-gen-the-foundation-for-building-a-low-power-server-nas/">Matt Gadient</a>. So while the GPU is very efficient, idling at 4 W only, the system’s consumption spikes up to 40–55W. Combined with my Mellanox 4 LX and some USB devices + 4 x 2.5&quot; idling HDDs, the total idle consumption is 55W-70W. This is, unfortunately, on par with similarly configured, idling AM5, with regular, off-the-shelf components.</p><p>It’s worth noting that all of the devices have ASPM enabled, as reported by the lspci:</p><pre>root@proxmox:~# lspci -vv | awk &#39;/ASPM/{print $0}&#39; RS= | grep -P &#39;(^[a-z0-9:.]+|ASPM )&#39;<br>00:01.0 PCI bridge: Intel Corporation Device a70d (rev 01) (prog-if 00 [Normal decode])<br>    LnkCap: Port #2, Speed 32GT/s, Width x16, ASPM L1, Exit Latency L1 &lt;16us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>00:1b.0 PCI bridge: Intel Corporation Device 7ac4 (rev 11) (prog-if 00 [Normal decode])<br>    LnkCap: Port #21, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 &lt;64us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>00:1c.0 PCI bridge: Intel Corporation Alder Lake-S PCH PCI Express Root Port #1 (rev 11) (prog-if 00 [Normal decode])<br>    LnkCap: Port #1, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L1 &lt;64us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>00:1d.0 PCI bridge: Intel Corporation Alder Lake-S PCH PCI Express Root Port #13 (rev 11) (prog-if 00 [Normal decode])<br>    LnkCap: Port #13, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 &lt;64us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>01:00.0 PCI bridge: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 XL Upstream Port of PCI Express Switch (rev c1) (prog-if 00 [Normal decode])<br>    LnkCap: Port #0, Speed 16GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;64us<br>    LnkCtl: ASPM L1 Enabled; Disabled- CommClk+<br>02:00.0 PCI bridge: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 XL Downstream Port of PCI Express Switch (prog-if 00 [Normal decode])<br>    LnkCap: Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s &lt;64ns, L1 &lt;1us<br>    LnkCtl: ASPM L0s L1 Enabled; Disabled- CommClk+<br>03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 23 [Radeon RX 6600/6600 XT/6600M] (rev c1) (prog-if 00 [VGA controller])<br>    LnkCap: Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s &lt;64ns, L1 &lt;1us<br>    LnkCtl: ASPM L0s L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>03:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Navi 21/23 HDMI/DP Audio Controller<br>    LnkCap: Port #0, Speed 16GT/s, Width x16, ASPM L0s L1, Exit Latency L0s &lt;64ns, L1 &lt;1us<br>    LnkCtl: ASPM L0s L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>04:00.0 Non-Volatile memory controller: Shenzhen Longsys Electronics Co., Ltd. Device 1602 (rev 01) (prog-if 02 [NVM Express])<br>    LnkCap: Port #0, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 &lt;64us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>05:00.0 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>05:00.1 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+<br>05:01.2 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>05:01.3 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>05:01.4 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>05:01.5 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>05:01.6 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>05:01.7 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>05:02.0 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>05:02.1 Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function]<br>    LnkCap: Port #0, Speed 8GT/s, Width x8, ASPM L1, Exit Latency L1 &lt;4us<br>    LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk-<br>06:00.0 Non-Volatile memory controller: Shenzhen Longsys Electronics Co., Ltd. Device 1602 (rev 01) (prog-if 02 [NVM Express])<br>    LnkCap: Port #0, Speed 16GT/s, Width x4, ASPM L1, Exit Latency L1 &lt;64us<br>    LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+</pre><p>I am left without ideas here, I asked on HP forums, but I doubt I will be met with any help: <a href="https://h30434.www3.hp.com/t5/Desktop-Hardware-and-Upgrade-Questions/Z2-G9-unable-to-reach-C-state-above-2-with-GPU-installed-in/m-p/9042319">Z2 G9: unable to reach C-state above 2 with GPU installed in PCIe5 slot</a></p><p>Noteworthy, HP specs suggest a similarly specced system, i9 12900 with NVIDIA GPU, should idle at 22–24W in Windows. This is considering NVIDIA GPUs are actually worse than AMDs in idle. I have not tested the system with Windows yet, it would be interesting to see whether I can confirm those numbers — especially in light of what is reported on C2 levels enforced by occupying CPU-bound PCI slots.</p><h4>RAM issues with Intel x710 NIC</h4><p>Another weird issue is happening with an Intel x710 installed in PCI slot 4 in place of the Mellanox. I figured I would want to reduce the overall power consumption by using the Intel NIC, which is reported to be more power efficient. Unfortunately, with Intel NIC installed, the system POSTs with half of the memory, i.e. 32GB in my case. Super odd issue, I would need to have someone try to replicate it, otherwise it may sound like the motherboard is somehow broken. Although it’s interesting that I am not getting such an issue with the Mellanox installed.</p><h4>Turbo speeds</h4><p>I am convinced the motherboard doesn’t have good enough VRMs to support over 125W of consumption and, as a result, the CPU will hardly ever get close to the Turbo speeds, even if the thermals permit it. This is even with the High-Performance Mode enabled in BIOS, on both 12th Gen and 13th Gen CPU (so the [SKU issue](#13th-gen-PCA-not-fully-compatible” error is rather not at fault). This would be somehow expected, considering how the Mini version of the same system struggles with the same, as reported by <a href="https://youtu.be/2n2K9Jg_0fs?si=6MZZ2-MLano3tjw1&amp;t=557">Linus Tech Tips</a>. Just to make sure it wasn’t a kernel misconfiguration, I verified with turbostat that the package levels are as expected:</p><pre>cpu0: MSR_RAPL_POWER_UNIT: 0x000a0e03 (0.125000 Watts, 0.000061 Joules, 0.000977 sec.)<br>cpu0: MSR_PKG_POWER_INFO: 0x000003e8 (125 W TDP, RAPL 0 - 0 W, 0.000000 sec.)<br>cpu0: MSR_PKG_POWER_LIMIT: 0x4285a800e383e8 (UNlocked)<br>cpu0: PKG Limit #1: ENabled (125.000 Watts, 224.000000 sec, clamp ENabled)<br>cpu0: PKG Limit #2: ENabled (181.000 Watts, 0.002</pre><p>Double checking with powercap-info:</p><pre>root@proxmox:~# powercap-info<br>intel-rapl<br>  enabled: 1<br>  Zone 0<br>    name: package-0<br>    enabled: 1<br>    max_energy_range_uj: 262143328850<br>    energy_uj: 167777849357<br>    Constraint 0<br>      name: long_term<br>      power_limit_uw: 125000000<br>      time_window_us: 223870976<br>      max_power_uw: 125000000<br>    Constraint 1<br>      name: short_term<br>      power_limit_uw: 181000000<br>      time_window_us: 2440<br>      max_power_uw: 0<br>    Constraint 2<br>      name: peak_power<br>      power_limit_uw: 285000000<br>      max_power_uw: 0<br>    Zone 0:0<br>      name: core<br>      enabled: 0<br>      max_energy_range_uj: 262143328850<br>      energy_uj: 173515342054<br>      Constraint 0<br>        name: long_term<br>        power_limit_uw: 0<br>        time_window_us: 976<br>    Zone 0:1<br>      name: uncore<br>      enabled: 0<br>      max_energy_range_uj: 262143328850<br>      energy_uj: 53173753<br>      Constraint 0<br>        name: long_term<br>        power_limit_uw: 0<br>        time_window_us: 976</pre><h4>Undervolting</h4><p>Before the 12th generation of processors, you could simply use the <a href="https://github.com/georgewhewell/undervolt">undervolt</a> tool on Linux to reduce the power usage of the otherwise typically power-hungry Intel chips. Starting with 12th Gen, however, Intel added an MSR (Model-Specific Register) for “Undervolt Protection”, which does exactly what it says. Motherboard manufacturers can choose to enable undervolting nonetheless by disabling that register, but of course most ready-made systems disable it, since this inevitably reduces the number of “my system is unstable” customer support complaints. The Z2 G9, being a proprietary, for-business system means the chances of the register remaining unblocked were virtually nonexistent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/0*LkTXRaAgC4dce2LW.png" /><figcaption>The IA32_OVERCLOCKING_STATUS MSR specification <a href="https://cdrdv2-public.intel.com/671098/335592-sdm-vol-4.pdf">(Intel Volume 4: Model-Specific Registers manual)</a></figcaption></figure><p>To find out if your motherboard is affected, you can check the IA32_OVERCLOCKING_STATUS register, which is at 0x195 address, as shown in the excerpt. A single bitfield at position 1 corresponds to “Undervolt Protection”, so the command to use on Linux is:</p><pre>root@proxmox:~# rdmsr -f 1:1 0x195<br>1</pre><p>A result of 1 means protection is enabled, so this very system is indeed not undervoltable. Conversely, off-the-shelf ASUS WS W680 ACE motherboard is reported to have undervolting enabled. No surprise here.</p><h3><strong>Summary</strong></h3><p>Whether this is a viable platform depends on the issues above. Having to manually press “Enter” to boot with a 13th gen CPU can be worked around by resorting to a 12th gen CPU. However, if you want to use it with extra PCI devices, you need to consider the idle power consumption issues, which then make this system lose its advantages over the AMD AM5 platform. Other than that, the system has been very stable, not having crashed once in the lasts 3 months. Nevertheless, I’d go with a commerical W680 motherboard if I was doing this again and not bother getting my hands dirty like I did.</p><p><em>Originally published at </em><a href="https://dawidwrobel.com/journal/cost-effective-intel-w680-server/"><em>https://dawidwrobel.com</em></a><em> on April 12, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd30878baaf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>