cambus.net.atom.xml - sfeed_tests - sfeed tests and RSS and Atom files
 (HTM) git clone git://git.codemadness.org/sfeed_tests
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       cambus.net.atom.xml (234551B)
       ---
            1 <?xml version="1.0" encoding="utf-8"?>
            2 <feed xmlns="http://www.w3.org/2005/Atom">
            3         <title><![CDATA[Atom Feed - Cambus.net]]></title>
            4         <subtitle><![CDATA[Personal site and technical blog of Frederic Cambus]]></subtitle>
            5 
            6         <link href="https://www.cambus.net/atom.xml" rel="self" />
            7         <link href="https://www.cambus.net/" />
            8 
            9         <updated>2021-10-01T23:39:34Z</updated>
           10         <id>https://www.cambus.net/</id>
           11 
           12         <author>
           13                 <name><![CDATA[Frederic Cambus]]></name>
           14         </author>
           15 
           16         <generator uri="https://github.com/fcambus/motyl">Motyl</generator>
           17 
           18         <entry>
           19         <title><![CDATA[Toolchains adventures - Q3 2021]]></title>
           20                 <link href="https://www.cambus.net/toolchains-adventures-q3-2021/"/>
           21                 <id>https://www.cambus.net/toolchains-adventures-q3-2021/</id>
           22                 <published>2021-10-01T23:16:00Z</published>
           23                 <updated>2021-10-01T23:16:00Z</updated>
           24                 <content type="html"><![CDATA[<p>I've been keeping myself busy since I posted the "<a href="https://www.cambus.net/diving-into-toolchains/">Diving into toolchains</a>"
           25 article at the beginning of June, so here is an update detailing what I've
           26 been up to during the past couple of months.</p>
           27 
           28 <p>At the end of June, I went through the FSF copyright assignment process for
           29 both <strong>Binutils</strong> and <strong>GDB</strong>, which now allows me to contribute larger
           30 changes to these codebases. I thus updated the <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=77db4723ddda2a5eb20876e8a818f77ffa7dafc8">NetBSD system call table</a>
           31 in GDB, and added support to readelf for <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=98ca73afe51e1e921915c37f242c88d4d445841c">reading OpenBSD ELF core notes</a>.</p>
           32 
           33 <p>In Pkgsrc land, I packaged and imported <a href="https://github.com/rui314/mold">mold</a>, a new linker that is
           34 optimized for modern multi-core machines, and updated our binutils package
           35 to the latest version.</p>
           36 
           37 <p>At the end of August, I attended the <strong>OpenBSD k2k21 hackathon</strong>, and one of
           38 the goals I had was to get <a href="https://clang.llvm.org/docs/SourceBasedCodeCoverage.html">source-based code coverage</a> working in LLVM.
           39 The first part of this was to find how to allow the compiler driver to
           40 link against the <strong>libclang_rt.profile</strong> library when passing the
           41 <strong>-fprofile-instr-generate</strong> and <strong>-fcoverage-mapping</strong> options to Clang.
           42 Once I figured the <a href="https://www.freshbsd.org/openbsd/src/commit/uWsA4smmd2wX3UBC">magic incantation</a>, I committed my change to src
           43 and <a href="https://reviews.llvm.org/D109244">sent it upstream</a> where it got committed and backported to the
           44 LLVM 13 branch. With this part sorted, the next step was to build and ship
           45 the library in the base system. I added <a href="https://www.freshbsd.org/openbsd/src/commit/mQ6P5wL9QLzzIzbt">build infrastructure</a> for the
           46 library in base, and <a href="https://www.freshbsd.org/openbsd/src/commit/nVaOYoXmnskB2gez">linked it to the build</a>. It is now enabled on
           47 architectures where Clang is built.</p>
           48 
           49 <p>To illustrate what we can do with the source-based code coverage, let's
           50 take the following C program:</p>
           51 
           52 <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#include &lt;stdio.h&gt;
           53 </span>
           54 <span class="kt">int</span>
           55 <span class="nf">main</span><span class="p">()</span>
           56 <span class="p">{</span>
           57         <span class="n">printf</span><span class="p">(</span><span class="s">" &gt;o_/   &gt;o_/   &gt;o_/ </span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
           58         <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
           59 
           60         <span class="n">printf</span><span class="p">(</span><span class="s">"*PAN!* *PAN!* *PAN!*</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
           61 <span class="p">}</span>
           62 </code></pre></div></div>
           63 
           64 <p>Let's build and instrument it to emit profile data:</p>
           65 
           66 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>clang <span class="nt">-fprofile-instr-generate</span> <span class="nt">-fcoverage-mapping</span> ducks.c <span class="nt">-o</span> ducks
           67 </code></pre></div></div>
           68 
           69 <p>And we can now run it to collect and process profile data:</p>
           70 
           71 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">LLVM_PROFILE_FILE</span><span class="o">=</span><span class="s2">"ducks.profraw"</span> ./ducks
           72 llvm-profdata merge <span class="nt">-sparse</span> ducks.profraw <span class="nt">-o</span> ducks.profdata
           73 llvm-cov show ./ducks <span class="nt">-instr-profile</span><span class="o">=</span>ducks.profdata
           74 </code></pre></div></div>
           75 
           76 <p>We can see that no ducks were harmed during this experiment:</p>
           77 
           78 <p><img src="/content/2021/10/ducks.png" alt="Ducks profile" title="Ducks profiling" /></p>
           79 
           80 <p>Coverage reports can also be created by llvm-cov:</p>
           81 
           82 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>llvm-cov report ./ducks <span class="nt">-instr-profile</span><span class="o">=</span>ducks.profdata
           83 
           84 Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover
           85 <span class="nt">-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
           86 /home/f/ducks/ducks.c               2                 1    50.00%           1                 0   100.00%           6                 1    83.33%
           87 <span class="nt">-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
           88 TOTAL                               2                 1    50.00%           1                 0   100.00%           6                 1    83.33%
           89 </code></pre></div></div>
           90 
           91 <p>Using the <strong>LLVM_PROFILE_FILE</strong> environment variable, it is possible to
           92 do several runs with different options and/or input files and get a new
           93 <strong>.profraw</strong> file each time. All those files can then be merged using
           94 <strong>llvm-profdata</strong>, which is pretty useful for doing coverage reports from
           95 unit tests.</p>
           96 
           97 <p>On top of the OpenBSD related changes I've been contributing upstream to
           98 LLVM, I've been continuing my experiments with the build system. I've also
           99 been reading documentation about various parts of the toolchain, sending
          100 diffs when encountering mistakes or things which could be improved.</p>
          101 
          102 <p>binutils and GDB commits:</p>
          103 
          104 <ul>
          105   <li>2021-09-11 - <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=98ca73afe51e1e921915c37f242c88d4d445841c">98ca73a</a> - Add support to readelf for reading OpenBSD ELF core notes</li>
          106   <li>2021-07-14 - <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=77db4723ddda2a5eb20876e8a818f77ffa7dafc8">77db472</a> - Update the NetBSD system call table to match NetBSD-current</li>
          107 </ul>
          108 
          109 <p>Pkgsrc toolchains related commits:</p>
          110 
          111 <ul>
          112   <li>2021-09-27 - <a href="https://github.com/NetBSD/pkgsrc/commit/65675ea811f6d03c306ce7f7c0025b3a54c4d616">65675ea</a> - Update to mold 0.9.6</li>
          113   <li>2021-09-11 - <a href="https://github.com/NetBSD/pkgsrc/commit/871f328dd67d65399dd1c14fb9399facbee7e1ce">871f328</a> - Update to binutils 2.37</li>
          114   <li>2021-09-11 - <a href="https://github.com/NetBSD/pkgsrc/commit/053d0f2eb4be764d374dff859c8fe3f1d0e1b661">53d0f2e</a> - Update to mold 0.9.5</li>
          115   <li>2021-07-29 - <a href="https://github.com/NetBSD/pkgsrc/commit/1b5d5857ac970d79e15d7c766626956da3a65e68">1b5d585</a> - Import mold 0.9.3</li>
          116 </ul>
          117 
          118 <p>LLVM commits:</p>
          119 
          120 <ul>
          121   <li>2021-09-30 - <a href="https://github.com/llvm/llvm-project/commit/97a0ba475d105838bd9bb7ed8506f599210995c7">97a0ba4</a> - [clang] Update Clang version from 13 to 14 in scan-build.1</li>
          122   <li>2021-09-30 - <a href="https://github.com/llvm/llvm-project/commit/01641f665f5a3f94fc9e2bba598b5a65a6a7bd01">01641f6</a> - [clang] Fix sentence in the usage section of ThinLTO docs</li>
          123   <li>2021-09-29 - <a href="https://github.com/llvm/llvm-project/commit/7a7caf97012f53172743d650fd3c97bce99f86ef">7a7caf9</a> - [clang] Fix library name (libsupc++) in the admonition note</li>
          124   <li>2021-09-28 - <a href="https://github.com/llvm/llvm-project/commit/5b125a49ba9f52cb6b24767f3c98ce623a2d5207">5b125a4</a> - [CMake] Add detection for the mold linker in AddLLVM.cmake</li>
          125   <li>2021-09-24 - <a href="https://github.com/llvm/llvm-project/commit/626e2a6c6236d2fd7582928a0363d381c55eb43d">626e2a6</a> - [compiler-rt] Use portable "#!/usr/bin/env bash" shebang for tests</li>
          126   <li>2021-09-24 - <a href="https://github.com/llvm/llvm-project/commit/4ed05312a1557b2f2552298a3aac12c2e224d77e">4ed0531</a> - [docs] Document the –print-passes flag in opt</li>
          127   <li>2021-09-23 - <a href="https://github.com/llvm/llvm-project/commit/7f5ca8cc2158debe66663f09eb19b4613e75e124">7f5ca8c</a> - [clang] Use portable "#!/usr/bin/env bash" shebang for tools and utils</li>
          128   <li>2021-09-17 - <a href="https://github.com/llvm/llvm-project/commit/b588f5d665aa01fe88921fe2ffb7256fdedfbfb0">b588f5d</a> - [clang][scan-build] Use cc/c++ instead of gcc/g++ on OpenBSD</li>
          129   <li>2021-09-07 - <a href="https://github.com/llvm/llvm-project/commit/4787ef3d0f0abfdc041d418aba28a7e6473f0766">4787ef3</a> - [compiler-rt] Document that builtins is known to work on OpenBSD</li>
          130   <li>2021-09-03 - <a href="https://github.com/llvm/llvm-project/commit/466451c6616272d8c779618b92b0ae80f394a795">466451c</a> - [clang] Allow the OpenBSD driver to link the libclang_rt.profile library</li>
          131   <li>2021-07-27 - <a href="https://github.com/llvm/llvm-project/commit/1862ffe25a2e927ecae012f5f0c4cdf7c3fc1b67">1862ffe</a> - [clang] Fix a typo in the manual page: s/contraint/constraint</li>
          132   <li>2021-07-23 - <a href="https://github.com/llvm/llvm-project/commit/bc96aa9f2c9b25ae65a7e05dbbff8c28079db9c9">bc96aa9</a> - [clang] Fix typos in Options.td and regen ClangCommandLineReference.rst</li>
          133 </ul>
          134 
          135 ]]></content>
          136                 <summary type="html">
          137                         <![CDATA[My continuous journey into toolchains, in the third quarter of 2021]]>
          138                 </summary>
          139 
          140                 <category term="Toolchains" scheme="https://www.cambus.net/categories/toolchains"/>
          141         </entry>
          142         <entry>
          143         <title><![CDATA[OpenBSD on the Vortex86DX CPU]]></title>
          144                 <link href="https://www.cambus.net/openbsd-on-the-vortex86dx-cpu/"/>
          145                 <id>https://www.cambus.net/openbsd-on-the-vortex86dx-cpu/</id>
          146                 <published>2021-09-24T13:12:00Z</published>
          147                 <updated>2021-09-24T13:12:00Z</updated>
          148                 <content type="html"><![CDATA[<p>This is the OpenBSD counterpart of my article about running <a href="https://www.cambus.net/netbsd-on-the-vortex86dx-cpu/">NetBSD on
          149 the Vortex86DX CPU</a>, and its purpose is mostly to archive a <strong>dmesg</strong>
          150 entry and various benchmarks for this machine. I should note that with
          151 only 256MB of RAM, the machine is too constrained to do kernel and
          152 libraries relinking in a timely manner, due to swapping.</p>
          153 
          154 <p>For more information and background about the hardware, please refer to
          155 my other article.</p>
          156 
          157 <p>Here is the result of a quick <strong>md5 -t</strong> benchmark:</p>
          158 
          159 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>MD5 <span class="nb">time </span>trial.  Processing 10000 10000-byte blocks...
          160 Digest <span class="o">=</span> 52e5f9c9e6f656f3e1800dfa5579d089
          161 Time   <span class="o">=</span> 2.398437 seconds
          162 Speed  <span class="o">=</span> 41693819.766790 bytes/second
          163 </code></pre></div></div>
          164 
          165 <p>Here is the result of the <strong>sha1 -t</strong> benchmark:</p>
          166 
          167 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SHA1 <span class="nb">time </span>trial.  Processing 10000 10000-byte blocks...
          168 Digest <span class="o">=</span> 74a57b897cc581defa5b3a359fa762a1b83a60e8
          169 Time   <span class="o">=</span> 5.648437 seconds
          170 Speed  <span class="o">=</span> 17704012.632167 bytes/second
          171 </code></pre></div></div>
          172 
          173 <p>For the record, LibreSSL speed benchmark results are available <a href="/files/openbsd/openssl-speed-vortex.txt">here</a>.</p>
          174 
          175 <p>System message buffer (dmesg output):</p>
          176 
          177 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>OpenBSD 7.0 <span class="o">(</span>GENERIC<span class="o">)</span> <span class="c">#203: Wed Sep 22 19:24:38 MDT 2021</span>
          178     deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
          179 real mem  <span class="o">=</span> 267927552 <span class="o">(</span>255MB<span class="o">)</span>
          180 avail mem <span class="o">=</span> 246661120 <span class="o">(</span>235MB<span class="o">)</span>
          181 random: good seed from bootblocks
          182 mpath0 at root
          183 scsibus0 at mpath0: 256 targets
          184 mainbus0 at root
          185 bios0 at mainbus0: <span class="nb">date </span>10/29/10, BIOS32 rev. 0 @ 0xf0010
          186 pcibios0 at bios0: rev 3.0 @ 0xf0000/0x10000
          187 pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xf3a80/224 <span class="o">(</span>12 entries<span class="o">)</span>
          188 pcibios0: no compatible PCI ICU found: ICU vendor 0x17f3 product 0x6031
          189 pcibios0: Warning, unable to fix up PCI interrupt routing
          190 pcibios0: PCI bus <span class="c">#0 is the last bus</span>
          191 bios0: ROM list: 0xc0000/0x8000 0xe9400/0x200!
          192 cpu0 at mainbus0: <span class="o">(</span>uniprocessor<span class="o">)</span>
          193 cpu0: Vortex86 SoC  <span class="o">(</span>586-class<span class="o">)</span> 1.01 GHz, 05-02-02
          194 cpu0: FPU,TSC,CX8
          195 pci0 at mainbus0 bus 0: configuration mode 1 <span class="o">(</span>no bios<span class="o">)</span>
          196 pchb0 at pci0 dev 0 <span class="k">function </span>0 <span class="s2">"RDC R6021 Host"</span> rev 0x02
          197 vga1 at pci0 dev 3 <span class="k">function </span>0 <span class="s2">"XGI Technology Volari Z7"</span> rev 0x00
          198 wsdisplay0 at vga1 mux 1: console <span class="o">(</span>80x25, vt100 emulation<span class="o">)</span>
          199 wsdisplay0: screen 1-5 added <span class="o">(</span>80x25, vt100 emulation<span class="o">)</span>
          200 pcib0 at pci0 dev 7 <span class="k">function </span>0 <span class="s2">"RDC R6031 ISA"</span> rev 0x02
          201 vte0 at pci0 dev 8 <span class="k">function </span>0 <span class="s2">"RDC R6040 Ethernet"</span> rev 0x00: irq 10, address 00:1b:eb:22:16:5c
          202 rdcphy0 at vte0 phy 1: R6040 10/100 PHY, rev. 1
          203 ohci0 at pci0 dev 10 <span class="k">function </span>0 <span class="s2">"RDC R6060 USB"</span> rev 0x12: irq 11, version 1.0, legacy support
          204 ehci0 at pci0 dev 10 <span class="k">function </span>1 <span class="s2">"RDC R6061 USB2"</span> rev 0x03: irq 11
          205 usb0 at ehci0: USB revision 2.0
          206 uhub0 at usb0 configuration 1 interface 0 <span class="s2">"RDC EHCI root hub"</span> rev 2.00/1.00 addr 1
          207 ohci1 at pci0 dev 11 <span class="k">function </span>0 <span class="s2">"RDC R6060 USB"</span> rev 0x12: irq 11, version 1.0, legacy support
          208 ehci1 at pci0 dev 11 <span class="k">function </span>1 <span class="s2">"RDC R6061 USB2"</span> rev 0x03: irq 11
          209 usb1 at ehci1: USB revision 2.0
          210 uhub1 at usb1 configuration 1 interface 0 <span class="s2">"RDC EHCI root hub"</span> rev 2.00/1.00 addr 1
          211 pciide0 at pci0 dev 12 <span class="k">function </span>0 <span class="s2">"RDC R1011 IDE"</span> rev 0x01: DMA <span class="o">(</span>unsupported<span class="o">)</span>, channel 0 configured to compatibility, channel 1 configured to compatibility
          212 pciide0: channel 0 ignored <span class="o">(</span>not responding<span class="p">;</span> disabled or no drives?<span class="o">)</span>
          213 pciide0: channel 1 ignored <span class="o">(</span>not responding<span class="p">;</span> disabled or no drives?<span class="o">)</span>
          214 isa0 at pcib0
          215 isadma0 at isa0
          216 pckbc0 at isa0 port 0x60/5 irq 1 irq 12
          217 pckbd0 at pckbc0 <span class="o">(</span>kbd slot<span class="o">)</span>
          218 wskbd0 at pckbd0: console keyboard, using wsdisplay0
          219 pcppi0 at isa0 port 0x61
          220 spkr0 at pcppi0
          221 npx0 at isa0 port 0xf0/16: reported by CPUID<span class="p">;</span> using exception 16
          222 usb2 at ohci0: USB revision 1.0
          223 uhub2 at usb2 configuration 1 interface 0 <span class="s2">"RDC OHCI root hub"</span> rev 1.00/1.00 addr 1
          224 usb3 at ohci1: USB revision 1.0
          225 uhub3 at usb3 configuration 1 interface 0 <span class="s2">"RDC OHCI root hub"</span> rev 1.00/1.00 addr 1
          226 dt: 445 probes
          227 umass0 at uhub1 port 2 configuration 1 interface 0 <span class="s2">"SanDisk Cruzer Switch"</span> rev 2.00/1.27 addr 2
          228 umass0: using SCSI over Bulk-Only
          229 scsibus1 at umass0: 2 targets, initiator 0
          230 sd0 at scsibus1 targ 1 lun 0: &lt;SanDisk, Cruzer Switch, 1.27&gt; removable serial.07815572120302108502
          231 sd0: 7633MB, 512 bytes/sector, 15633408 sectors
          232 uhidev0 at uhub2 port 1 configuration 1 interface 0 <span class="s2">"Lenovo ThinkPad Compact USB Keyboard with TrackPoint"</span> rev 2.00/3.30 addr 2
          233 uhidev0: iclass 3/1
          234 ukbd0 at uhidev0: 8 variable keys, 6 key codes
          235 wskbd1 at ukbd0 mux 1
          236 wskbd1: connecting to wsdisplay0
          237 uhidev1 at uhub2 port 1 configuration 1 interface 1 <span class="s2">"Lenovo ThinkPad Compact USB Keyboard with TrackPoint"</span> rev 2.00/3.30 addr 2
          238 uhidev1: iclass 3/1, 22 report ids
          239 ums0 at uhidev1 reportid 1: 5 buttons, Z and W <span class="nb">dir
          240 </span>wsmouse0 at ums0 mux 0
          241 ucc0 at uhidev1 reportid 16: 573 usages, 18 keys, array
          242 wskbd2 at ucc0 mux 1
          243 wskbd2: connecting to wsdisplay0
          244 uhid0 at uhidev1 reportid 17: <span class="nv">input</span><span class="o">=</span>2, <span class="nv">output</span><span class="o">=</span>0, <span class="nv">feature</span><span class="o">=</span>0
          245 uhid1 at uhidev1 reportid 19: <span class="nv">input</span><span class="o">=</span>8, <span class="nv">output</span><span class="o">=</span>8, <span class="nv">feature</span><span class="o">=</span>8
          246 uhid2 at uhidev1 reportid 21: <span class="nv">input</span><span class="o">=</span>2, <span class="nv">output</span><span class="o">=</span>0, <span class="nv">feature</span><span class="o">=</span>0
          247 uhid3 at uhidev1 reportid 22: <span class="nv">input</span><span class="o">=</span>2, <span class="nv">output</span><span class="o">=</span>0, <span class="nv">feature</span><span class="o">=</span>0
          248 uaudio0 at uhub2 port 2 configuration 1 interface 1 <span class="s2">"ABC C-Media USB Audio Device"</span> rev 1.10/1.00 addr 3
          249 uaudio0: class v1, full-speed, <span class="nb">sync</span>, channels: 2 play, 1 rec, 8 ctls
          250 audio0 at uaudio0
          251 uhidev2 at uhub2 port 2 configuration 1 interface 3 <span class="s2">"ABC C-Media USB Audio Device"</span> rev 1.10/1.00 addr 3
          252 uhidev2: iclass 3/0
          253 ucc1 at uhidev2: 11 usages, 3 keys, enum
          254 wskbd3 at ucc1 mux 1
          255 wskbd3: connecting to wsdisplay0
          256 vscsi0 at root
          257 scsibus2 at vscsi0: 256 targets
          258 softraid0 at root
          259 scsibus3 at softraid0: 256 targets
          260 root on sd0a <span class="o">(</span>779fe8066eed6ce5.a<span class="o">)</span> swap on sd0b dump on sd0b
          261 </code></pre></div></div>
          262 
          263 <p>There are no sensors available on this machine.</p>
          264 
          265 <p>PCI device data:</p>
          266 
          267 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># pcidump</span>
          268 Domain /dev/pci0:
          269  0:0:0: RDC R6021 Host
          270  0:3:0: XGI Technology Volari Z7
          271  0:7:0: RDC R6031 ISA
          272  0:8:0: RDC R6040 Ethernet
          273  0:10:0: RDC R6060 USB
          274  0:10:1: RDC R6061 USB2
          275  0:11:0: RDC R6060 USB
          276  0:11:1: RDC R6061 USB2
          277  0:12:0: RDC R1011 IDE
          278 </code></pre></div></div>
          279 
          280 ]]></content>
          281                 <summary type="html">
          282                         <![CDATA[Running OpenBSD on the DMP EBOX 3300A-H with a Vortex86DX CPU]]>
          283                 </summary>
          284 
          285                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
          286         </entry>
          287         <entry>
          288         <title><![CDATA[Diving into toolchains]]></title>
          289                 <link href="https://www.cambus.net/diving-into-toolchains/"/>
          290                 <id>https://www.cambus.net/diving-into-toolchains/</id>
          291                 <published>2021-06-08T13:37:00Z</published>
          292                 <updated>2021-06-08T13:37:00Z</updated>
          293                 <content type="html"><![CDATA[<p>I've been wanting to learn more about compilers and toolchains in general
          294 for a while now. In June 2016, I asked about <a href="https://twitter.com/fcambus/status/744799252145070080">recommended readings on lexers
          295 and parsers</a> on Twitter. However, I have to confess that I didn't go
          296 forward with reading the Dragon Book.</p>
          297 
          298 <p>Instead, I got involved as a developer in the <a href="https://www.openbsd.org/">OpenBSD</a> and <a href="https://www.netbsd.org/">NetBSD</a>
          299 projects, and witnessing the evolution of toolchains within those systems
          300 played a big role in maintaining my interest and fascination in the topic.
          301 In retrospect, it now becomes apparent that the work I did on porting
          302 and packaging software for those systems really helped to put in perspective
          303 how the different parts of the toolchains interact together to produce
          304 binaries.</p>
          305 
          306 <p>Approximately one year ago, I asked again on Twitter whether I knew <a href="https://twitter.com/fcambus/status/1249468322883796994">anyone
          307 having worked on compilers and toolchains professionally</a> to get real
          308 world advice on how to gain expertise in the field. I got several interesting
          309 answers and started to collect and read more resources on the topic.
          310 Some of the links I collected ended up on <a href="https://www.toolchains.net/">toolchains.net</a>, a collection
          311 of toolchain resources which I put online in February.</p>
          312 
          313 <p>But the answer that resonate the most with me was <a href="https://twitter.com/hyc_symas/status/1249474322701451265">Howard's advice to
          314 learn by doing</a>. Because I seem to be the kind of person who need to
          315 see some concrete results in order to keep motivated, that's exactly what
          316 I decided to do.</p>
          317 
          318 <p>I started by doing some cleanups in the <a href="https://www.gnu.org/software/binutils/">binutils</a> package in NetBSD's
          319 pkgsrc, which resulted in a <a href="https://www.freshbsd.org/?q=binutils&amp;committer[]=fcambus">series of commits</a>:</p>
          320 
          321 <ul>
          322   <li>2020-12-20 - <a href="https://github.com/NetBSD/pkgsrc/commit/ca38479f6b0fcc13f14fefc86cc1739767f9bc39">ca38479</a> - Remove now unneeded OpenBSD specific checks in gold</li>
          323   <li>2020-12-15 - <a href="https://github.com/NetBSD/pkgsrc/commit/7263eeeda8ff66f7b3cd54b3a62743d52f98494b">7263eee</a> - Add missing TEST_DEPENDS on devel/dejagnu</li>
          324   <li>2020-12-14 - <a href="https://github.com/NetBSD/pkgsrc/commit/b1637da54ae4c3860352f1851cb570fca8af1d6f">b1637da</a> - Don't use hard-coded -ldl in the gold test suite.</li>
          325   <li>2020-12-13 - <a href="https://github.com/NetBSD/pkgsrc/commit/146def2d48eac2a72159ca4a40492a1f6f91e8c8">146def2</a> - Remove apparently unneeded patch for libiberty</li>
          326   <li>2020-12-12 - <a href="https://github.com/NetBSD/pkgsrc/commit/6b347a938fed8568337c818c669418729cefde5f">6b347a9</a> - Remove CFLAGS.OpenBSD+= -Wno-bounded directive</li>
          327   <li>2020-12-11 - <a href="https://github.com/NetBSD/pkgsrc/commit/f53b2d8ae2dd5747bdc29c0575ab8fcae26bd735">f53b2d8</a> - Remove now unneeded patch dropping hidden symbols warning</li>
          328   <li>2020-12-10 - <a href="https://github.com/NetBSD/pkgsrc/commit/b0373808d471e15967274264affbf8deac0a3022">b037380</a> - Enable building gold on Linux</li>
          329   <li>2020-12-03 - <a href="https://github.com/NetBSD/pkgsrc/commit/75d00bc3616276133b55e68d900e32b61fbfb23c">75d00bc</a> - Remove now unneeded workaround for binutils 2.24</li>
          330   <li>2020-12-03 - <a href="https://github.com/NetBSD/pkgsrc/commit/adfee3096ef0366c9dbda13be5074c1267ff022a">adfee30</a> - Drop all Bitrig related patches</li>
          331 </ul>
          332 
          333 <p>Meanwhile, I also got the opportunity to update our package and apply
          334 security fixes:</p>
          335 
          336 <ul>
          337   <li>2021-02-11 - <a href="https://github.com/NetBSD/pkgsrc/commit/761e000686bc37c9791ccc34f63ede3e32b49675">761e000</a> - Update to binutils 2.36.1</li>
          338   <li>2021-01-27 - <a href="https://github.com/NetBSD/pkgsrc/commit/ba983e5c5ee6ce131e7399200b7493b2f7efa726">ba983e5</a> - Update to binutils 2.36</li>
          339   <li>2021-01-07 - <a href="https://github.com/NetBSD/pkgsrc/commit/7aef5c0311e2d423ae3f985dec1009fef7b112f2">7aef5c0</a> - Add upstream fixes for CVE-2020-35448</li>
          340   <li>2020-12-06 - <a href="https://github.com/NetBSD/pkgsrc/commit/99fdf3900a96fca988b1eb8e3ee5031f7ffad11a">99fdf39</a> - Update to binutils 2.35.1</li>
          341 </ul>
          342 
          343 <p>I eventually took <a href="https://github.com/NetBSD/pkgsrc/commit/d7146b45a9b7e78524e14f493cd5835c3334f52c">maintainership</a> of binutils in Pkgsrc.</p>
          344 
          345 <p>Building it repeatedly with different compilers exposed different warnings,
          346 and I've also run builds through Clang's static analyzer.</p>
          347 
          348 <p>All of this resulted in the opportunity to contribute to <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=search;s=Frederic+Cambus;st=author">binutils</a> itself:</p>
          349 
          350 <ul>
          351   <li>2021-04-14 - <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=5f47741bf633596475bb8fbb0ed304be318362cd">5f47741</a> - Remove unneeded tests for definitions of NT_NETBSDCORE values</li>
          352   <li>2021-04-12 - <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=0fa29e2deea19a33fec7f1e5a5cf49b94f93b2f8">0fa29e2</a> - Remove now unneeded #ifdef check for NT_NETBSD_PAX</li>
          353   <li>2021-03-12 - <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=be3b926d8d2dde16a55e9e303fadf95164e13ebf">be3b926</a> - Add values for NetBSD .note.netbsd.ident notes (PaX)</li>
          354   <li>2021-01-26 - <a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=e37709f0901fe6f2410094151002bab3d123df85">e37709f</a> - Fix a double free in objcopy's memory freeing code</li>
          355 </ul>
          356 
          357 <p>Most recently, I also wrote a couple of blog posts on the topic:</p>
          358 
          359 <ul>
          360   <li><a href="https://www.cambus.net/the-state-of-toolchains-in-netbsd/">The state of toolchains in NetBSD</a></li>
          361   <li><a href="https://www.cambus.net/speedbuilding-llvm-clang-in-5-minutes/">Speedbuilding LLVM/Clang in 5 minutes</a></li>
          362   <li><a href="https://www.cambus.net/speedbuilding-llvm-clang-in-2-minutes-on-arm/">Speedbuilding LLVM/Clang in 2 minutes on ARM</a></li>
          363   <li><a href="https://www.cambus.net/the-state-of-toolchains-in-openbsd/">The state of toolchains in OpenBSD</a></li>
          364   <li><a href="https://www.cambus.net/playing-with-djgpp-and-gcc-10-on-dos/">Playing with DJGPP and GCC 10 on DOS</a></li>
          365 </ul>
          366 
          367 <p>And the journey continues. I'm following a different path from traditional
          368 compiler courses starting with lexers and parsers, and doing the opposite
          369 curriculum somehow, starting from binaries instead. I will be focusing on the
          370 final stages of the pipeline for now: compiling assembly to machine code
          371 and producing binaries.</p>
          372 
          373 <p>My next steps are to read the full <a href="https://refspecs.linuxfoundation.org/elf/elf.pdf">ELF specification</a>, followed by
          374 the <a href="https://linker.iecc.com">Linkers and Loader</a> book, and then refresh my ASM skills. My
          375 favorite course at university was the computer architecture one and
          376 especially its MIPS assembly part, so I'm looking to revisit the subject
          377 but with ARM64 assembly this time.</p>
          378 
          379 ]]></content>
          380                 <summary type="html">
          381                         <![CDATA[My journey into toolchains, through reading and practice]]>
          382                 </summary>
          383 
          384                 <category term="Toolchains" scheme="https://www.cambus.net/categories/toolchains"/>
          385         </entry>
          386         <entry>
          387         <title><![CDATA[NetBSD on the Vortex86DX CPU]]></title>
          388                 <link href="https://www.cambus.net/netbsd-on-the-vortex86dx-cpu/"/>
          389                 <id>https://www.cambus.net/netbsd-on-the-vortex86dx-cpu/</id>
          390                 <published>2021-06-03T18:40:00Z</published>
          391                 <updated>2021-06-03T18:40:00Z</updated>
          392                 <content type="html"><![CDATA[<p>I'm not exactly sure how I first heard about the <a href="https://www.vortex86.com">Vortex86</a> CPUs, I think
          393 it was either when seeing the demonstration video on <a href="https://kolibrios.org">KolibriOS</a> project
          394 site showcasing the system running on a <strong>DMP EBOX</strong> machine, or when skimming
          395 <strong>NetBSD</strong>'s <a href="https://github.com/NetBSD/src/blob/trunk/sys/arch/x86/x86/identcpu.c">identcpu.c</a> code. Or did the discovery of the machine prompted
          396 me to check if the CPU would be correctly probed by the NetBSD's kernel?</p>
          397 
          398 <p>For those interested, Wikipedia has an article retracing the <a href="https://en.wikipedia.org/wiki/Vortex86">history of the
          399 Vortex86</a> from its birth at <strong>Rise</strong> to our days.</p>
          400 
          401 <p>Several <strong>DMP EBOX</strong> machines are available for sale at various specialized
          402 vendors, but new devices cost several hundreds of dollars which is prohibitive
          403 for such low spec systems. However, I was recently able to acquire a boxed
          404 older model on a local auction site for about $25: the <strong>EBOX 3300A-H</strong>, with
          405 a 1GHz CPU and 256MB of RAM, no less.</p>
          406 
          407 <p>As I already mentioned, those machines are quite slow but they still do have
          408 a few things going for them:</p>
          409 
          410 <ul>
          411   <li>They are totally <strong>fanless</strong>, and the metal case finish is quite nice</li>
          412   <li>They are very <strong>low-power x86</strong> embedded devices, and still being produced</li>
          413 </ul>
          414 
          415 <p>I used a power meter to do measurements, and an idle system consumes 5.3W.
          416 Power consumption peaked at 6.4W when running the OpenSSL speed benchmark.</p>
          417 
          418 <p>There is space for a 2.5" hard drive in the enclosure, but I don't have any
          419 IDE drives anymore so I opted to use old CompactFlash cards I had laying
          420 around. As a side note, it's actually exquisite to use those cards like
          421 glorified floppies :-)</p>
          422 
          423 <p>For this post, I used a <strong>1GB CompactFlash</strong> card and selected a minimal
          424 installation in <strong>sysinst</strong>.</p>
          425 
          426 <p>The installed system takes 212M:</p>
          427 
          428 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Filesystem         Size       Used      Avail %Cap Mounted on
          429 /dev/wd0a          919M       212M       661M  24% /
          430 kernfs             1.0K       1.0K         0B 100% /kern
          431 ptyfs              1.0K       1.0K         0B 100% /dev/pts
          432 procfs             4.0K       4.0K         0B 100% /proc
          433 tmpfs               64M         0B        64M   0% /var/shm
          434 </code></pre></div></div>
          435 
          436 <p>On a freshly booted system, 15 processes are running and 26M of RAM are used:</p>
          437 
          438 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>load averages:  0.01,  0.00,  0.00<span class="p">;</span>               up 0+00:48:26        14:48:28
          439 16 processes: 15 sleeping, 1 on CPU
          440 CPU states:  0.0% user,  0.0% <span class="nb">nice</span>,  0.0% system,  0.0% interrupt,  100% idle
          441 Memory: 26M Act, 6460K Exec, 12M File, 195M Free
          442 Swap: 
          443 
          444   PID USERNAME PRI NICE   SIZE   RES STATE      TIME   WCPU    CPU COMMAND
          445     0 root      96    0     0K   26M usbevt     0:01  0.00%  0.00% <span class="o">[</span>system]
          446   795 root      43    0  6160K 1628K CPU        0:00  0.00%  0.00% top
          447   555 root      85    0    12M 3472K <span class="nb">wait       </span>0:00  0.00%  0.00% login
          448   630 postfix   85    0    13M 3220K kqueue     0:00  0.00%  0.00% qmgr
          449   599 postfix   85    0    12M 3172K kqueue     0:00  0.00%  0.00% pickup
          450   575 root      85    0    13M 2304K kqueue     0:00  0.00%  0.00% master
          451   196 root      85    0  9780K 1960K kqueue     0:00  0.00%  0.00% syslogd
          452   583 root      85    0  6788K 1824K <span class="nb">wait       </span>0:00  0.00%  0.00% sh
          453   710 root      85    0  6276K 1448K nanoslp    0:00  0.00%  0.00% cron
          454   733 root      85    0  6108K 1396K ttyraw     0:00  0.00%  0.00% getty
          455   730 root      85    0  5720K 1392K ttyraw     0:00  0.00%  0.00% getty
          456   633 root      85    0  6104K 1388K ttyraw     0:00  0.00%  0.00% getty
          457   211 root      85    0  7316K 1360K kqueue     0:00  0.00%  0.00% dhcpcd
          458     1 root      85    0  6600K 1340K <span class="nb">wait       </span>0:00  0.00%  0.00% init
          459   689 root      85    0  5700K 1184K kqueue     0:00  0.00%  0.00% inetd
          460   402 root      84    0  5920K 1140K kqueue     0:00  0.00%  0.00% powerd
          461 </code></pre></div></div>
          462 
          463 <p>Here is the result of running <strong>cat /proc/cpuinfo</strong> on this device:</p>
          464 
          465 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>processor        : 0
          466 vendor_id        : Vortex86 SoC
          467 cpu family        : 5
          468 model                : 2
          469 model name        : Vortex86DX
          470 stepping        : 2
          471 cpu MHz                : 1000.05
          472 apicid                : 0
          473 initial apicid        : 0
          474 fdiv_bug        : no
          475 fpu                : <span class="nb">yes
          476 </span>fpu_exception        : <span class="nb">yes
          477 </span>cpuid level        : 1
          478 wp                : <span class="nb">yes
          479 </span>flags                : fpu tsc cx8 
          480 clflush size        : 0
          481 </code></pre></div></div>
          482 
          483 <p>For the record, OpenSSL speed benchmark results are available <a href="/files/netbsd/openssl-speed-vortex86.txt">here</a>.</p>
          484 
          485 <p>System message buffer (dmesg output):</p>
          486 
          487 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>     1.000000] Copyright <span class="o">(</span>c<span class="o">)</span> 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
          488 <span class="o">[</span>     1.000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
          489 <span class="o">[</span>     1.000000]     2018, 2019, 2020 The NetBSD Foundation, Inc.  All rights reserved.
          490 <span class="o">[</span>     1.000000] Copyright <span class="o">(</span>c<span class="o">)</span> 1982, 1986, 1989, 1991, 1993
          491 <span class="o">[</span>     1.000000]     The Regents of the University of California.  All rights reserved.
          492 
          493 <span class="o">[</span>     1.000000] NetBSD 9.2 <span class="o">(</span>GENERIC<span class="o">)</span> <span class="c">#0: Wed May 12 13:15:55 UTC 2021</span>
          494 <span class="o">[</span>     1.000000]         mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/i386/compile/GENERIC
          495 <span class="o">[</span>     1.000000] total memory <span class="o">=</span> 255 MB
          496 <span class="o">[</span>     1.000000] avail memory <span class="o">=</span> 231 MB
          497 <span class="o">[</span>     1.000000] rnd: seeded with 66 bits
          498 <span class="o">[</span>     1.000000] timecounter: Timecounters tick every 10.000 msec
          499 <span class="o">[</span>     1.000000] Kernelized RAIDframe activated
          500 <span class="o">[</span>     1.000000] running cgd selftest aes-xts-256 aes-xts-512 <span class="k">done</span>
          501 <span class="o">[</span>     1.000000] timecounter: Timecounter <span class="s2">"i8254"</span> frequency 1193182 Hz quality 100
          502 <span class="o">[</span>     1.000003] Generic PC
          503 <span class="o">[</span>     1.000003] mainbus0 <span class="o">(</span>root<span class="o">)</span>
          504 <span class="o">[</span>     1.000003] Firmware Error <span class="o">(</span>ACPI<span class="o">)</span>: A valid RSDP was not found <span class="o">(</span>20190405/tbxfroot-261<span class="o">)</span>
          505 <span class="o">[</span>     1.000003] autoconfiguration error: acpi_probe: failed to initialize tables
          506 <span class="o">[</span>     1.000003] ACPI Error: Could not remove SCI handler <span class="o">(</span>20190405/evmisc-312<span class="o">)</span>
          507 <span class="o">[</span>     1.000003] cpu0 at mainbus0
          508 <span class="o">[</span>     1.000003] cpu0: Vortex86DX, <span class="nb">id </span>0x522
          509 <span class="o">[</span>     1.000003] cpu0: package 0, core 0, smt 0
          510 <span class="o">[</span>     1.000003] pci0 at mainbus0 bus 0: configuration mode 1
          511 <span class="o">[</span>     1.000003] pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
          512 <span class="o">[</span>     1.000003] pchb0 at pci0 dev 0 <span class="k">function </span>0: vendor 17f3 product 6021 <span class="o">(</span>rev. 0x02<span class="o">)</span>
          513 <span class="o">[</span>     1.000003] vga0 at pci0 dev 3 <span class="k">function </span>0: vendor 18ca product 0020 <span class="o">(</span>rev. 0x00<span class="o">)</span>
          514 <span class="o">[</span>     1.000003] wsdisplay0 at vga0 kbdmux 1: console <span class="o">(</span>80x25, vt100 emulation<span class="o">)</span>
          515 <span class="o">[</span>     1.000003] wsmux1: connecting to wsdisplay0
          516 <span class="o">[</span>     1.000003] drm at vga0 not configured
          517 <span class="o">[</span>     1.000003] rdcpcib0 at pci0 dev 7 <span class="k">function </span>0: vendor 17f3 product 6031 <span class="o">(</span>rev. 0x02<span class="o">)</span>
          518 <span class="o">[</span>     1.000003] rdcpcib0: watchdog timer configured.
          519 <span class="o">[</span>     1.000003] vte0 at pci0 dev 8 <span class="k">function </span>0: vendor 17f3 product 6040 <span class="o">(</span>rev. 0x00<span class="o">)</span>
          520 <span class="o">[</span>     1.000003] vte0: Ethernet address 00:1b:eb:22:16:5c
          521 <span class="o">[</span>     1.000003] vte0: interrupting at irq 10
          522 <span class="o">[</span>     1.000003] rdcphy0 at vte0 phy 1: R6040 10/100 media interface, rev. 1
          523 <span class="o">[</span>     1.000003] rdcphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
          524 <span class="o">[</span>     1.000003] ohci0 at pci0 dev 10 <span class="k">function </span>0: vendor 17f3 product 6060 <span class="o">(</span>rev. 0x12<span class="o">)</span>
          525 <span class="o">[</span>     1.000003] ohci0: interrupting at irq 11
          526 <span class="o">[</span>     1.000003] ohci0: OHCI version 1.0, legacy support
          527 <span class="o">[</span>     1.000003] usb0 at ohci0: USB revision 1.0
          528 <span class="o">[</span>     1.000003] ehci0 at pci0 dev 10 <span class="k">function </span>1: vendor 17f3 product 6061 <span class="o">(</span>rev. 0x03<span class="o">)</span>
          529 <span class="o">[</span>     1.000003] ehci0: interrupting at irq 11
          530 <span class="o">[</span>     1.000003] ehci0: BIOS has given up ownership
          531 <span class="o">[</span>     1.000003] ehci0: EHCI version 1.0
          532 <span class="o">[</span>     1.000003] ehci0: 1 companion controller, 2 ports: ohci0
          533 <span class="o">[</span>     1.000003] usb1 at ehci0: USB revision 2.0
          534 <span class="o">[</span>     1.000003] ohci1 at pci0 dev 11 <span class="k">function </span>0: vendor 17f3 product 6060 <span class="o">(</span>rev. 0x12<span class="o">)</span>
          535 <span class="o">[</span>     1.000003] ohci1: interrupting at irq 11
          536 <span class="o">[</span>     1.000003] ohci1: OHCI version 1.0, legacy support
          537 <span class="o">[</span>     1.000003] usb2 at ohci1: USB revision 1.0
          538 <span class="o">[</span>     1.000003] ehci1 at pci0 dev 11 <span class="k">function </span>1: vendor 17f3 product 6061 <span class="o">(</span>rev. 0x03<span class="o">)</span>
          539 <span class="o">[</span>     1.000003] ehci1: interrupting at irq 11
          540 <span class="o">[</span>     1.000003] ehci1: BIOS has given up ownership
          541 <span class="o">[</span>     1.000003] ehci1: EHCI version 1.0
          542 <span class="o">[</span>     1.000003] ehci1: 1 companion controller, 2 ports: ohci1
          543 <span class="o">[</span>     1.000003] usb3 at ehci1: USB revision 2.0
          544 <span class="o">[</span>     1.000003] rdcide0 at pci0 dev 12 <span class="k">function </span>0: RDC R1011 IDE controller <span class="o">(</span>rev. 0x01<span class="o">)</span>
          545 <span class="o">[</span>     1.000003] rdcide0: bus-master DMA support present
          546 <span class="o">[</span>     1.000003] rdcide0: primary channel configured to compatibility mode
          547 <span class="o">[</span>     1.000003] rdcide0: primary channel interrupting at irq 14
          548 <span class="o">[</span>     1.000003] atabus0 at rdcide0 channel 0
          549 <span class="o">[</span>     1.000003] rdcide0: secondary channel configured to compatibility mode
          550 <span class="o">[</span>     1.000003] rdcide0: secondary channel interrupting at irq 15
          551 <span class="o">[</span>     1.000003] atabus1 at rdcide0 channel 1
          552 <span class="o">[</span>     1.000003] isa0 at rdcpcib0
          553 <span class="o">[</span>     1.000003] pckbc0 at isa0 port 0x60-0x64
          554 <span class="o">[</span>     1.000003] attimer0 at isa0 port 0x40-0x43
          555 <span class="o">[</span>     1.000003] pcppi0 at isa0 port 0x61
          556 <span class="o">[</span>     1.000003] midi0 at pcppi0: PC speaker
          557 <span class="o">[</span>     1.000003] sysbeep0 at pcppi0
          558 <span class="o">[</span>     1.000003] isapnp0 at isa0 port 0x279
          559 <span class="o">[</span>     1.000003] attimer0: attached to pcppi0
          560 <span class="o">[</span>     1.000003] isapnp0: no ISA Plug <span class="s1">'n Play devices found
          561 [     1.000003] timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
          562 [     1.064509] uhub0 at usb1: NetBSD (0000) EHCI root hub (0000), class 9/0, rev 2.00/1.00, addr 1
          563 [     1.064509] uhub0: 2 ports with 2 removable, self powered
          564 [     1.064509] uhub1 at usb2: NetBSD (0000) OHCI root hub (0000), class 9/0, rev 1.00/1.00, addr 1
          565 [     1.064509] uhub1: 2 ports with 2 removable, self powered
          566 [     1.064509] uhub2 at usb3: NetBSD (0000) EHCI root hub (0000), class 9/0, rev 2.00/1.00, addr 1
          567 [     1.064509] uhub2: 2 ports with 2 removable, self powered
          568 [     1.064509] uhub3 at usb0: NetBSD (0000) OHCI root hub (0000), class 9/0, rev 1.00/1.00, addr 1
          569 [     1.064509] uhub3: 2 ports with 2 removable, self powered
          570 [     1.064509] IPsec: Initialized Security Association Processing.
          571 [     3.914550] uaudio0 at uhub3 port 2 configuration 1 interface 0
          572 [     3.914550] uaudio0: vendor 0d8c (0xd8c) C-Media USB Audio Device (0x08), rev 1.10/1.00, addr 2
          573 [     3.934546] uaudio0: audio rev 1.00
          574 [     3.934546] audio0 at uaudio0: playback, capture, full duplex, independent
          575 [     3.934546] audio0: slinear_le:16 2ch 48000Hz, blk 11520 bytes (60ms) for playback
          576 [     3.934546] audio0: slinear_le:16 1ch 48000Hz, blk 6000 bytes (62.5ms) for recording
          577 [     3.934546] uhidev0 at uhub3 port 2 configuration 1 interface 3
          578 [     3.934546] uhidev0: vendor 0d8c (0xd8c) C-Media USB Audio Device (0x08), rev 1.10/1.00, addr 2, iclass 3/0
          579 [     3.944550] uhid0 at uhidev0: input=4, output=4, feature=0
          580 [     4.054550] wd0 at atabus1 drive 0
          581 [     4.054550] wd0: &lt;Hitachi XX.V.3.5.0.0&gt;
          582 [     4.054550] wd0: drive supports 1-sector PIO transfers, LBA addressing
          583 [     4.054550] wd0: 977 MB, 1987 cyl, 16 head, 63 sec, 512 bytes/sect x 2002896 sectors
          584 [     4.064551] wd0: 32-bit data port
          585 [     4.064551] wd0: drive supports PIO mode 4
          586 [     4.064551] wd0(rdcide0:1:0): using PIO mode 4
          587 [     4.084559] WARNING: 1 error while detecting hardware; check system log.
          588 [     4.084559] boot device: wd0
          589 [     4.084559] root on wd0a dumps on wd0b
          590 [     4.094550] root file system type: ffs
          591 [     4.094550] kern.module.path=/stand/i386/9.2/modules
          592 [    20.764808] wsdisplay0: screen 1 added (80x25, vt100 emulation)
          593 [    20.784809] wsdisplay0: screen 2 added (80x25, vt100 emulation)
          594 [    20.794810] wsdisplay0: screen 3 added (80x25, vt100 emulation)
          595 [    20.804812] wsdisplay0: screen 4 added (80x25, vt100 emulation)
          596 </span></code></pre></div></div>
          597 
          598 ]]></content>
          599                 <summary type="html">
          600                         <![CDATA[Running NetBSD on the DMP EBOX 3300A-H with a Vortex86DX CPU]]>
          601                 </summary>
          602 
          603                 <category term="NetBSD" scheme="https://www.cambus.net/categories/netbsd"/>
          604         </entry>
          605         <entry>
          606         <title><![CDATA[Character and color cycling effect in C on DOS]]></title>
          607                 <link href="https://www.cambus.net/character-and-color-cycling-effect-in-c-on-dos/"/>
          608                 <id>https://www.cambus.net/character-and-color-cycling-effect-in-c-on-dos/</id>
          609                 <published>2021-05-27T23:21:00Z</published>
          610                 <updated>2021-05-27T23:21:00Z</updated>
          611                 <content type="html"><![CDATA[<p>As mentioned in my previous post about <a href="https://www.cambus.net/playing-with-djgpp-and-gcc-10-on-dos/">playing with DJGPP and GCC 10 on DOS</a>, I have been redoing my small character and color cycling effect in text
          612 mode. The original version in JavaScript can be seen <a href="https://www.cambus.net/character-and-color-cycling-effect-in-javascript/">here</a>.</p>
          613 
          614 <p><img src="/content/2021/05/cycling-effect.png" alt="Cycling effect" /></p>
          615 
          616 <p>To understand why we can't access video memory directly and need to use the
          617 DPMI service to create a selector to access the required real-mode segment
          618 address, please refer to <a href="https://www.delorie.com/djgpp/v2faq/faq18_4.html">section 18.4 of the DJGPP FAQ</a>.</p>
          619 
          620 <p>The effect can be downloaded <a href="/content/2021/05/cycling.exe">here</a>. Sadly, the resulting binary is quite
          621 large (104K stripped!), and it requires <a href="https://sandmann.dotster.com/cwsdpmi/">CWSDPMI</a> to run.</p>
          622 
          623 <p>Here is the code:</p>
          624 
          625 <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#include &lt;conio.h&gt;
          626 #include &lt;dpmi.h&gt;
          627 #include &lt;go32.h&gt;
          628 #include &lt;pc.h&gt;
          629 </span>
          630 <span class="kt">void</span>
          631 <span class="nf">wait_vbl</span><span class="p">()</span>
          632 <span class="p">{</span>
          633         <span class="k">while</span><span class="p">(</span><span class="n">inp</span><span class="p">(</span><span class="mh">0x3da</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0x08</span><span class="p">);</span>
          634         <span class="k">while</span><span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="n">inp</span><span class="p">(</span><span class="mh">0x3da</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0x08</span><span class="p">));</span>
          635 <span class="p">}</span>
          636 
          637 <span class="kt">int</span>
          638 <span class="nf">main</span><span class="p">()</span>
          639 <span class="p">{</span>
          640         <span class="kt">short</span> <span class="n">video</span> <span class="o">=</span> <span class="n">__dpmi_segment_to_descriptor</span><span class="p">(</span><span class="mh">0xb800</span><span class="p">);</span>
          641         <span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">buffer</span><span class="p">[</span><span class="mi">4000</span><span class="p">];</span>
          642 
          643         <span class="kt">int</span> <span class="n">character</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">color</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
          644 
          645         <span class="cm">/* Define character and color arrays */</span>
          646         <span class="kt">char</span> <span class="n">characters</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="mh">0x5c</span><span class="p">,</span> <span class="mh">0x7c</span><span class="p">,</span> <span class="mh">0x2f</span><span class="p">,</span> <span class="mh">0x2d</span> <span class="p">};</span>
          647         <span class="kt">char</span> <span class="n">colors</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="mh">0xf</span><span class="p">,</span> <span class="mh">0xb</span><span class="p">,</span> <span class="mh">0x9</span><span class="p">,</span> <span class="mh">0x1</span><span class="p">,</span> <span class="mh">0x9</span><span class="p">,</span> <span class="mh">0xb</span><span class="p">,</span> <span class="mh">0xf</span> <span class="p">};</span>
          648 
          649         <span class="k">while</span> <span class="p">(</span><span class="o">!</span><span class="n">kbhit</span><span class="p">())</span> <span class="p">{</span>
          650                 <span class="k">for</span> <span class="p">(</span><span class="kt">size_t</span> <span class="n">offset</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">offset</span> <span class="o">&lt;</span> <span class="mi">4000</span><span class="p">;</span> <span class="n">offset</span> <span class="o">+=</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
          651                         <span class="cm">/* Write character and color data */</span>
          652                         <span class="n">buffer</span><span class="p">[</span><span class="n">offset</span><span class="p">]</span> <span class="o">=</span> <span class="n">characters</span><span class="p">[</span><span class="n">character</span><span class="p">];</span>
          653                         <span class="n">buffer</span><span class="p">[</span><span class="n">offset</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">colors</span><span class="p">[</span><span class="n">color</span><span class="p">];</span>
          654 
          655                         <span class="cm">/* Increment the color index */</span>
          656                         <span class="n">color</span> <span class="o">=</span> <span class="n">color</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">&lt;</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">colors</span><span class="p">)</span> <span class="o">?</span> <span class="n">color</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
          657                 <span class="p">}</span>
          658 
          659                 <span class="cm">/* Increment the character index */</span>
          660                 <span class="n">character</span> <span class="o">=</span> <span class="n">character</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">&lt;</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">characters</span><span class="p">)</span> <span class="o">?</span>
          661                     <span class="n">character</span> <span class="o">+</span> <span class="mi">1</span> <span class="o">:</span> <span class="mi">0</span><span class="p">;</span>
          662 
          663                 <span class="cm">/* Copy the buffer into text mode video memory */</span>
          664                 <span class="n">movedata</span><span class="p">(</span><span class="n">_my_ds</span><span class="p">(),</span> <span class="p">(</span><span class="kt">unsigned</span><span class="p">)</span><span class="n">buffer</span><span class="p">,</span> <span class="n">video</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">4000</span><span class="p">);</span>
          665 
          666                 <span class="cm">/* Wait for VBL */</span>
          667                 <span class="n">wait_vbl</span><span class="p">();</span>
          668                 <span class="n">wait_vbl</span><span class="p">();</span>
          669                 <span class="n">wait_vbl</span><span class="p">();</span>
          670                 <span class="n">wait_vbl</span><span class="p">();</span>
          671                 <span class="n">wait_vbl</span><span class="p">();</span>
          672         <span class="p">}</span>
          673 <span class="p">}</span>
          674 </code></pre></div></div>
          675 
          676 ]]></content>
          677                 <summary type="html">
          678                         <![CDATA[Oldschool demoscene effect in C on DOS: a simple character and color cycling animation]]>
          679                 </summary>
          680 
          681                 <category term="C" scheme="https://www.cambus.net/categories/c"/>
          682                 <category term="DOS" scheme="https://www.cambus.net/categories/dos"/>
          683         </entry>
          684         <entry>
          685         <title><![CDATA[Playing with DJGPP and GCC 10 on DOS]]></title>
          686                 <link href="https://www.cambus.net/playing-with-djgpp-and-gcc-10-on-dos/"/>
          687                 <id>https://www.cambus.net/playing-with-djgpp-and-gcc-10-on-dos/</id>
          688                 <published>2021-05-23T00:36:00Z</published>
          689                 <updated>2021-05-23T00:36:00Z</updated>
          690                 <content type="html"><![CDATA[<p>I was recently amazed to discover that <a href="https://www.delorie.com/djgpp/">DJGPP</a> was still being maintained,
          691 and had very recent versions of GCC and binutils available. I have not been
          692 doing any C programming on DOS in a very long time now, so I think the timing
          693 is right.</p>
          694 
          695 <p>There is an installation program with an interface very similar to the good
          696 old <strong>Turbo Vision</strong>, which could be helpful in case one wants to install the
          697 full environment.</p>
          698 
          699 <p><img src="https://www.cambus.net/content/2021/05/djgpp-01.png" alt="DJGPP Installer" /></p>
          700 
          701 <p><img src="https://www.cambus.net/content/2021/05/djgpp-02.png" alt="DJGPP Installer" /></p>
          702 
          703 <p>I'm only interested in using the <strong>C</strong> frontend for now, so I will do a
          704 manual installation.</p>
          705 
          706 <p>We need the following components:</p>
          707 
          708 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>djdev205.zip    B  2,509,574  2015-10-18   DJGPP development kit 2.05
          709 bnu2351b.zip    B  6,230,009  2021-01-16   GNU Binutils 2.35.1 binaries <span class="k">for </span>DJGPP
          710 gcc1030b.zip    B 42,027,946  2021-04-18   GNU GCC C compiler 10.3.0 <span class="k">for </span>DJGPP V2
          711 csdpmi7b.zip    B     71,339  2010-01-29   CS<span class="s1">'s DPMI Provider r7 Binaries
          712 </span></code></pre></div></div>
          713 
          714 <p>The development environment can be bootstrapped as follows:</p>
          715 
          716 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> ~/dos/djgpp
          717 <span class="nb">cd</span> ~/dos/djgpp
          718 wget https://www.delorie.com/pub/djgpp/current/v2/djdev205.zip
          719 wget https://www.delorie.com/pub/djgpp/current/v2gnu/bnu2351b.zip
          720 wget https://www.delorie.com/pub/djgpp/current/v2gnu/gcc1030b.zip
          721 wget https://www.delorie.com/pub/djgpp/current/v2misc/csdpmi7b.zip
          722 unzip djdev205.zip
          723 unzip bnu2351b.zip
          724 unzip gcc1030b.zip
          725 unzip csdpmi7b.zip
          726 </code></pre></div></div>
          727 
          728 <p>When using <strong>FreeDOS</strong>, we need to add the following in <em>AUTOEXEC.BAT</em>:</p>
          729 
          730 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">set </span><span class="nv">DJGPP</span><span class="o">=</span>c:<span class="se">\d</span>jgpp<span class="se">\d</span>jgpp.env
          731 <span class="nb">set </span><span class="nv">PATH</span><span class="o">=</span>c:<span class="se">\d</span>jgpp<span class="se">\b</span><span class="k">in</span><span class="p">;</span>%PATH%
          732 </code></pre></div></div>
          733 
          734 <p>Alternatively, when using <strong>DOSBox</strong> instead, we need the following in
          735 <em>dosbox.conf</em>:</p>
          736 
          737 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>autoexec]
          738 mount c ~/dos
          739 <span class="nv">path</span><span class="o">=</span>c:<span class="se">\d</span>jgpp<span class="se">\b</span><span class="k">in
          740 </span><span class="nb">set </span><span class="nv">DJGPP</span><span class="o">=</span>c:<span class="se">\d</span>jgpp<span class="se">\d</span>jgpp.env
          741 c:
          742 </code></pre></div></div>
          743 
          744 <p>Once we are done installing, this gives us GCC 10.3.0 and ld 2.35.1:</p>
          745 
          746 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C:<span class="se">\&gt;</span>gcc <span class="nt">--version</span>
          747 gcc.exe <span class="o">(</span>GCC<span class="o">)</span> 10.3.0
          748 Copyright <span class="o">(</span>C<span class="o">)</span> 2020 Free Software Foundation, Inc.
          749 This is free software<span class="p">;</span> see the <span class="nb">source </span><span class="k">for </span>copying conditions.  There is NO
          750 warranty<span class="p">;</span> not even <span class="k">for </span>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
          751 
          752 C:<span class="se">\&gt;</span>ld <span class="nt">--version</span>
          753 GNU ld <span class="o">(</span>GNU Binutils<span class="o">)</span> 2.35.1
          754 Copyright <span class="o">(</span>C<span class="o">)</span> 2020 Free Software Foundation, Inc.
          755 This program is free software<span class="p">;</span> you may redistribute it under the terms of
          756 the GNU General Public License version 3 or <span class="o">(</span>at your option<span class="o">)</span> a later version.
          757 This program has absolutely no warranty.
          758 </code></pre></div></div>
          759 
          760 <p>To verify things are working properly, let's create a simple test program:</p>
          761 
          762 <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#include &lt;stdio.h&gt;
          763 </span>
          764 <span class="kt">int</span>
          765 <span class="nf">main</span><span class="p">()</span>
          766 <span class="p">{</span>
          767         <span class="n">puts</span><span class="p">(</span><span class="s">"Hello World!"</span><span class="p">);</span>
          768 
          769         <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
          770 <span class="p">}</span>
          771 </code></pre></div></div>
          772 
          773 <p>We then build and run it:</p>
          774 
          775 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C:<span class="se">\&gt;</span>gcc hello.c <span class="nt">-o</span> hello
          776 
          777 C:<span class="se">\&gt;</span>hello
          778 Hello World!
          779 </code></pre></div></div>
          780 
          781 <p>Here is the output of running <strong>file</strong> on the executable:</p>
          782 
          783 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>HELLO.EXE: MS-DOS executable, COFF <span class="k">for </span>MS-DOS, DJGPP go32 DOS extender
          784 </code></pre></div></div>
          785 
          786 <p>Let's build only an object file:</p>
          787 
          788 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C:<span class="se">\&gt;</span>gcc <span class="nt">-c</span> hello.c
          789 </code></pre></div></div>
          790 
          791 <p>We can run <strong>nm</strong> on it to list symbols:</p>
          792 
          793 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C:<span class="se">\&gt;</span>nm hello.o
          794 00000000 b .bss
          795 00000000 N .comment
          796 00000000 d .data
          797 00000000 t .text
          798 0000000d T _main
          799          U _puts
          800 </code></pre></div></div>
          801 
          802 <p>And run <strong>objdump</strong> to display its content:</p>
          803 
          804 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C:<span class="se">\&gt;</span>objdump <span class="nt">-s</span> hello.o
          805 
          806 HELLO.o:     file format coff-go32
          807 
          808 Contents of section .text:
          809  0000 48656c6c 6f20576f 726c6421 008d4c24  Hello World!..L<span class="err">$</span>
          810  0010 0483e4f0 ff71fc55 89e55183 ec0483ec  .....q.U..Q.....
          811  0020 0c680000 0000e8d5 ffffff83 c410b800  .h..............
          812  0030 0000008b 4dfc89ec 5d8d61fc c3909090  ....M...].a.....
          813 Contents of section .comment:
          814  0000 4743433a 2028474e 55292031 302e332e  GCC: <span class="o">(</span>GNU<span class="o">)</span> 10.3.
          815  0010 30000000                             0...            
          816 </code></pre></div></div>
          817 
          818 <p>We can also use <strong>objdump</strong> to disassemble the object file:</p>
          819 
          820 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C:<span class="se">\&gt;</span>objdump <span class="nt">-d</span> hello.o
          821 
          822 HELLO.o:     file format coff-go32
          823 
          824 Disassembly of section .text:
          825 
          826 00000000 &lt;.text&gt;:
          827    0:        48                      dec    %eax
          828    1:        65 6c                   gs insb <span class="o">(</span>%dx<span class="o">)</span>,%es:<span class="o">(</span>%edi<span class="o">)</span>
          829    3:        6c                      insb   <span class="o">(</span>%dx<span class="o">)</span>,%es:<span class="o">(</span>%edi<span class="o">)</span>
          830    4:        6f                      outsl  %ds:<span class="o">(</span>%esi<span class="o">)</span>,<span class="o">(</span>%dx<span class="o">)</span>
          831    5:        20 57 6f                and    %dl,0x6f<span class="o">(</span>%edi<span class="o">)</span>
          832    8:        72 6c                   jb     76 &lt;_main+0x69&gt;
          833    a:        64 21 00                and    %eax,%fs:<span class="o">(</span>%eax<span class="o">)</span>
          834 
          835 0000000d &lt;_main&gt;:
          836    d:        8d 4c 24 04             lea    0x4<span class="o">(</span>%esp<span class="o">)</span>,%ecx
          837   11:        83 e4 f0                and    <span class="nv">$0xfffffff0</span>,%esp
          838   14:        ff 71 <span class="nb">fc                </span>pushl  <span class="nt">-0x4</span><span class="o">(</span>%ecx<span class="o">)</span>
          839   17:        55                      push   %ebp
          840   18:        89 e5                   mov    %esp,%ebp
          841   1a:        51                      push   %ecx
          842   1b:        83 ec 04                sub    <span class="nv">$0x4</span>,%esp
          843   1e:        83 ec 0c                sub    <span class="nv">$0xc</span>,%esp
          844   21:        68 00 00 00 00          push   <span class="nv">$0x0</span>
          845   26:        e8 d5 ff ff ff          call   0 &lt;.text&gt;
          846   2b:        83 c4 10                add    <span class="nv">$0x10</span>,%esp
          847   2e:        b8 00 00 00 00          mov    <span class="nv">$0x0</span>,%eax
          848   33:        8b 4d <span class="nb">fc                </span>mov    <span class="nt">-0x4</span><span class="o">(</span>%ebp<span class="o">)</span>,%ecx
          849   36:        89 ec                   mov    %ebp,%esp
          850   38:        5d                      pop    %ebp
          851   39:        8d 61 <span class="nb">fc                </span>lea    <span class="nt">-0x4</span><span class="o">(</span>%ecx<span class="o">)</span>,%esp
          852   3c:        c3                      ret
          853   3d:        90                      nop
          854   3e:        90                      nop
          855   3f:        90                      nop
          856 </code></pre></div></div>
          857 
          858 <p>Besides the C frontend, the <strong>Ada</strong>, <strong>C++</strong>, <strong>Fortran</strong>, <strong>Objective C</strong>,
          859 and <strong>Pascal</strong> frontends are also available. While I used DOSBox to test the
          860 development environment and prepare this article, I've since moved to FreeDOS
          861 which I'm running natively on my ASUS Eee PC. I'm currently having a lot of
          862 fun redoing some small character and color cycling effects in text mode.</p>
          863 
          864 ]]></content>
          865                 <summary type="html">
          866                         <![CDATA[How to install a C developement environment on DOS with DJGPP and GCC 10]]>
          867                 </summary>
          868 
          869                 <category term="DOS" scheme="https://www.cambus.net/categories/dos"/>
          870                 <category term="Toolchains" scheme="https://www.cambus.net/categories/toolchains"/>
          871         </entry>
          872         <entry>
          873         <title><![CDATA[The state of toolchains in OpenBSD]]></title>
          874                 <link href="https://www.cambus.net/the-state-of-toolchains-in-openbsd/"/>
          875                 <id>https://www.cambus.net/the-state-of-toolchains-in-openbsd/</id>
          876                 <published>2021-05-19T12:08:00Z</published>
          877                 <updated>2021-05-19T12:08:00Z</updated>
          878                 <content type="html"><![CDATA[<p>For most of the 2010s, the OpenBSD base system has been stuck with GCC 4.2.1.
          879 It was <a href="https://gcc.gnu.org/gcc-4.2/">released</a> in July 2007, <a href="https://www.freshbsd.org/openbsd/src/commit/19ddffda9825e103cd4b730bf9bf733085d07375d0aa8aab757fcf7639d825cf">imported</a> into the OpenBSD source tree
          880 in October 2009, and became the default compiler on the amd64, i386, hppa,
          881 sparc64, socppc and macppc platforms in <a href="https://www.openbsd.org/48.html">OpenBSD 4.8</a>, released in November
          882 2010. As specified in the commit message during import, this is the last
          883 version released under the GPLv2 license.</p>
          884 
          885 <p>OpenBSD was not the only operating system sticking to GCC 4.2.1 for licensing
          886 reasons, FreeBSD did the same, and Mac OS X as well.</p>
          887 
          888 <p>As a general rule, and this is not OpenBSD specific, being stuck with old
          889 compilers is problematic for several reasons:</p>
          890 
          891 <ul>
          892   <li>The main reason has to be <strong>newer C and C++ standards support</strong>. While the
          893 C standards committee is conservative and the language evolves slowly, the
          894 pace at which new C++ standards appear has been accelerating, with a new
          895 version emerging every 3 years.</li>
          896   <li>Another major reason is <strong>new architectures support</strong>. Not only new ISAs
          897 like ARMv8 and RISC-V, but also x86-64 microarchitecture updates.</li>
          898   <li>They are not getting <strong>bugfixes</strong>, nor new optimizations or advances in
          899 diagnostic (better warnings) and security features.</li>
          900 </ul>
          901 
          902 <p>The latest point has been partially mitigated on OpenBSD, as several developers
          903 have worked on fixing OpenBSD related issues and backporting fixes, as
          904 detailed in Miod's excellent "<a href="https://marc.info/?l=openbsd-misc&amp;m=137530560232232&amp;w=2">Compilers in OpenBSD</a>" post from 2013.</p>
          905 
          906 <p>Regarding new architectures support, the more astute reader will know that
          907 all OpenBSD supported platforms are self-hosted and releases must be built
          908 using the base system compiler on real hardware. No cross-compilation, no
          909 emulators. The ARMv8 architecture was announced in 2011, a few years after
          910 GCC 4.2.1 was released. By the year 2016, 64-bit ARMv8 devices were getting
          911 widely available and more affordable. During the g2k16 hackathon, the
          912 Castle Inn pub had become a favorite meet-up point among OpenBSD developers,
          913 and the topic came up at one of the evening gatherings. I happened to be
          914 sitting nearby when patrick@ discussed with deraadt@ about the possibility
          915 of importing LLVM to make a future <a href="https://www.openbsd.org/arm64.html">OpenBSD/arm64</a> porting effort possible,
          916 and Theo said that there was nothing blocking it. The next day, pascal@
          917 mentioned he already had some Makefiles to replace the LLVM build system,
          918 and when someone then asked how long it would take to put them in shape for
          919 import, he said he didn't know, then smiled and said: "Let's find out! :-)".
          920 Before the end of the hackathon, he imported <a href="https://undeadly.org/cgi?action=article&amp;sid=20160904232020">LLVM 3.8.1 along with Clang</a>.
          921 Patrick's <a href="https://undeadly.org/cgi?action=article;sid=20160915232310">g2k16 hackathon report</a> retraces the events and gives more
          922 technical details.</p>
          923 
          924 <p>OpenBSD/arm64 became the first platform to use Clang as base system compiler
          925 and LLD as the default linker. Clang then became the <a href="https://undeadly.org/cgi?action=article;sid=20170727055820">default compiler on amd64
          926 and i386</a> in July 2017, on <a href="https://www.freshbsd.org/openbsd/src/commit/JmZz5xo7HtfbQVnr">armv7</a> in January 2018, on <a href="https://www.freshbsd.org/openbsd/src/commit/hiNW53dlIfQjhCxg">octeon</a> in
          927 July 2019, on <a href="https://www.freshbsd.org/openbsd/src/commit/VtKIfyX8XOXgGRfR">powerpc</a> in April 2020, and finally on <a href="https://www.freshbsd.org/openbsd/src/commit/dq6PbcfNzGraX0Li">loongson</a> in
          928 December 2020.</p>
          929 
          930 <p>LLVM was updated regularly along the way up to the 8.0.1 version, which
          931 was the latest version released under the NCSA license. From then all later
          932 LLVM versions have been released under the Apache 2.0 license, which couldn't
          933 be included in OpenBSD. The project's <a href="https://www.openbsd.org/policy.html">copyright policy</a> page details
          934 OpenBSD's stance on the license, and Mark Kettenis <a href="https://lists.llvm.org/pipermail/llvm-dev/2017-April/112300.html">objection</a> on the
          935 llvm-dev mailing list gives more background information.</p>
          936 
          937 <p>While staying with LLVM 8.0.1 would not have been an immediate problem for
          938 the OpenBSD kernel and the base system userland which uses C99, the project also
          939 includes 3rd party C++ codebases for parts of the graphics stack and of course
          940 LLVM itself. Jonathan Gray <a href="https://marc.info/?l=openbsd-misc&amp;m=159514079929237&amp;w=2">hinted</a> at the problem on the openbsd-misc
          941 mailing list, mentioning that not updating was becoming increasingly painful.
          942 The effect which can be observed in the 3rd party software ecosystem
          943 regarding newer C and C++ standards is that while C99 is still reigning
          944 supreme in C codebases, C++ codebases maintainers have been eager to adopt
          945 new C++ standards (and for good reasons). The recent RFC on cfe-dev about
          946 <a href="https://lists.llvm.org/pipermail/cfe-dev/2021-April/068058.html">bumping toolchain requirements for LLVM</a> to Clang 6.0 (released in March
          947 2018) proves that LLVM is no exception. A compromise was thus inevitable,
          948 and <a href="https://undeadly.org/cgi?action=article;sid=20200806001449">LLVM 10.0.0 was imported</a> into -current in August 2020.</p>
          949 
          950 <p>At the time the OpenBSD 6.9 branch was created, the CVS tree contained
          951 LLVM 10.0.1, GCC 4.2.1, and GCC 3.3.6. However, it's important to understand
          952 that not all compilers are built on all platforms:</p>
          953 
          954 <ul>
          955   <li><strong>Clang is the default compiler</strong> on amd64, arm64, armv7, i386, loongson,
          956 macppc, octeon, powerpc64, and riscv64.</li>
          957   <li>GCC 4.2.1 is still the default compiler on alpha, hppa, landisk, and sparc64.</li>
          958   <li>OpenBSD/luna88k is the only platform still using GCC 3.3.6, as <a href="https://gcc.gnu.org/legacy-ml/gcc-help/2005-12/msg00103.html">m88k support
          959 was removed in GCC 3.4</a>.</li>
          960 </ul>
          961 
          962 <p>Following the OpenBSD 6.9 release, OpenBSD-current has been updated to
          963 LLVM 11.1.0 and GCC 4.2.1 is <a href="https://www.freshbsd.org/openbsd/src/commit/wqgeXdfygt81WqdD">not built anymore on amd64</a>. GCC 8.4.0 
          964 (released in March 2020) is available in the ports collection.</p>
          965 
          966 <p>Among the remaining platforms still using GCC 4.2.1 as the default compiler,
          967 only sparc64 will be able to switch in the future. LLVM has a Sparc V9 backend
          968 and work has been done in OpenBSD to make the switch possible. For all the
          969 other remaining ones, there are no alpha, hppa, sh4, nor m88k backends in LLVM,
          970 and even if this changed in the future, the hardware is too slow to be able to
          971 self-host the compiler.</p>
          972 
          973 <p>Regarding linkers, <strong>LLD is the default linker</strong> on amd64, arm64, armv7, i386,
          974 powerpc64, and riscv64. All other platforms still use GNU ld from binutils
          975 2.17. Realistically, it should be possible to switch to LLD in the future
          976 on the following platforms: loongson, macppc, octeon, and sparc64.</p>
          977 
          978 <p>At this point, all relevant architectures have modern and up-to-date
          979 toolchains, and we can look ahead in confidence on that front.</p>
          980 
          981 ]]></content>
          982                 <summary type="html">
          983                         <![CDATA[The current state of LLVM and GNU toolchains in the OpenBSD project]]>
          984                 </summary>
          985 
          986                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
          987                 <category term="Toolchains" scheme="https://www.cambus.net/categories/toolchains"/>
          988         </entry>
          989         <entry>
          990         <title><![CDATA[Speedbuilding LLVM/Clang in 2 minutes on ARM]]></title>
          991                 <link href="https://www.cambus.net/speedbuilding-llvm-clang-in-2-minutes-on-arm/"/>
          992                 <id>https://www.cambus.net/speedbuilding-llvm-clang-in-2-minutes-on-arm/</id>
          993                 <published>2021-05-12T23:09:00Z</published>
          994                 <updated>2021-05-12T23:09:00Z</updated>
          995                 <content type="html"><![CDATA[<p>This post is the AArch64 counterpart of my "<a href="https://www.cambus.net/speedbuilding-llvm-clang-in-5-minutes/">Speedbuilding LLVM/Clang in 5
          996 minutes</a>" article.</p>
          997 
          998 <p>After publishing and sharing the previous post URL with some friends on IRC,
          999 I was asked if I wanted to try doing the same on a 160 cores ARM machine.
         1000 Finding out what my answer was is left as an exercise to the reader :-)</p>
         1001 
         1002 <p>The system I'm using for this experiment is a BM.Standard.A1.160 bare-metal
         1003 machine from Oracle Cloud, which has a dual-socket motherboard with two 80
         1004 cores <strong>Ampere Altra CPUs</strong>, for a total <strong>160 cores</strong>, and <strong>1024 GB of
         1005 RAM</strong>. This is to the best of my knowledge the fastest AArch64 server
         1006 machine available at this time.</p>
         1007 
         1008 <p>The system is running Oracle Linux Server 8.3 with up-to-date packages
         1009 and kernel.</p>
         1010 
         1011 <p>The full result of <em>cat /proc/cpuinfo</em> is available <a href="/content/2021/05/oracle-cloud-bm-standard-a1-160-proc-cpuinfo.txt">here</a>.</p>
         1012 
         1013 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">uname</span> <span class="nt">-a</span>
         1014 Linux benchmarks 5.4.17-2102.201.3.el8uek.aarch64 <span class="c">#2 SMP Fri Apr 23 09:42:46 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux</span>
         1015 </code></pre></div></div>
         1016 
         1017 <p>Let's start by installing required packages:</p>
         1018 
         1019 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="k">in </span>clang git lld
         1020 </code></pre></div></div>
         1021 
         1022 <p>Unfortunately the CMake version available in the packages repository (3.11.4)
         1023 is too old to build the main branch of the LLVM Git repository, and Ninja is
         1024 not available either.</p>
         1025 
         1026 <p>Let's bootstrap <a href="https://pkgsrc.org">Pkgsrc</a> to build and install them:</p>
         1027 
         1028 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/NetBSD/pkgsrc.git
         1029 <span class="nb">cd </span>pkgsrc/bootstrap
         1030 ./bootstrap <span class="nt">--make-jobs</span><span class="o">=</span>160 <span class="nt">--unprivileged</span>
         1031 
         1032 <span class="o">===&gt;</span> bootstrap started: Wed May 12 12:23:34 GMT 2021
         1033 <span class="o">===&gt;</span> bootstrap ended:   Wed May 12 12:26:08 GMT 2021
         1034 </code></pre></div></div>
         1035 
         1036 <p>We then need to add <em>~pkg/bin</em> and <em>~pkg/sbin</em> to the path:</p>
         1037 
         1038 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span><span class="nv">$PATH</span>:<span class="nv">$HOME</span>/pkg/bin:<span class="nv">$HOME</span>/pkg/sbin
         1039 </code></pre></div></div>
         1040 
         1041 <p>For faster Pkgsrc builds, we can edit <em>~/pkg/etc/mk.conf</em> and add:</p>
         1042 
         1043 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">MAKE_JOBS</span><span class="o">=</span>              160
         1044 </code></pre></div></div>
         1045 
         1046 <p>Let's build and install CMake and Ninja:</p>
         1047 
         1048 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> ~/pkgsrc/devel/cmake
         1049 bmake <span class="nb">install </span>package clean clean-depends
         1050 
         1051 <span class="nb">cd</span> ~/pkgsrc/devel/ninja-build
         1052 bmake <span class="nb">install </span>package clean clean-depends
         1053 </code></pre></div></div>
         1054 
         1055 <p>The compiler used for the builds is Clang 10.0.1:</p>
         1056 
         1057 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>clang <span class="nt">--version</span>
         1058 clang version 10.0.1 <span class="o">(</span>Red Hat 10.0.1-1.0.1.module+el8.3.0+7827+89335dbf<span class="o">)</span>
         1059 Target: aarch64-unknown-linux-gnu
         1060 Thread model: posix
         1061 InstalledDir: /bin
         1062 </code></pre></div></div>
         1063 
         1064 <p>Regarding linkers, we are using GNU ld and GNU Gold from binutils 2.30,
         1065 and LLD 10.0.1.</p>
         1066 
         1067 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>GNU ld version 2.30-79.0.1.el8
         1068 GNU gold <span class="o">(</span>version 2.30-79.0.1.el8<span class="o">)</span> 1.15
         1069 LLD 10.0.1 <span class="o">(</span>compatible with GNU linkers<span class="o">)</span>
         1070 </code></pre></div></div>
         1071 
         1072 <p>For all the following runs, I'm building from the Git repository main branch
         1073 commit <a href="https://github.com/llvm/llvm-project/commit/cf4610d27bbb5c3a744374440e2fdf77caa12040">cf4610d27bbb5c3a744374440e2fdf77caa12040</a>. The build directory is
         1074 of course fully erased between each run.</p>
         1075 
         1076 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>commit cf4610d27bbb5c3a744374440e2fdf77caa12040
         1077 Author: Victor Huang &lt;wei.huang@ibm.com&gt;
         1078 Date:   Wed May 12 10:56:54 2021 <span class="nt">-0500</span>
         1079 </code></pre></div></div>
         1080 
         1081 <p>I'm not sure what the underlying storage is, but with 1 TB of RAM there
         1082 is no reason not to use a ramdisk.</p>
         1083 
         1084 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> /mnt/ramdisk
         1085 mount <span class="nt">-t</span> tmpfs <span class="nt">-o</span> <span class="nv">size</span><span class="o">=</span>32g tmpfs /mnt/ramdisk
         1086 <span class="nb">cd</span> /mnt/ramdisk
         1087 </code></pre></div></div>
         1088 
         1089 <p>To get a baseline, let's do a full release build on this machine:</p>
         1090 
         1091 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd </span>llvm-project
         1092 <span class="nb">mkdir </span>build
         1093 <span class="nb">cd </span>build
         1094 
         1095 cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1096         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1097         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1098         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1099         ../llvm
         1100 
         1101 <span class="nb">time </span>make <span class="nt">-j160</span>
         1102 real    7m3.226s
         1103 user    403m28.362s
         1104 sys     6m41.331s
         1105 </code></pre></div></div>
         1106 
         1107 <p>By default, CMake generates Makefiles. As documented in the "<a href="https://llvm.org/docs/GettingStarted.html">Getting Started
         1108 with the LLVM System</a>" tutorial, most LLVM developers use Ninja.</p>
         1109 
         1110 <p>Let's switch to generating Ninja build files, and using ninja to build:</p>
         1111 
         1112 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1113         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1114         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1115         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1116         <span class="nt">-GNinja</span> ../llvm
         1117 
         1118 <span class="nb">time </span>ninja
         1119 <span class="o">[</span>4182/4182] Linking CXX executable bin/c-index-test
         1120 
         1121 real    4m20.403s
         1122 user    427m27.118s
         1123 sys     7m2.320s
         1124 </code></pre></div></div>
         1125 
         1126 <p><img src="/content/2021/05/llvm-clang-htop-arm.png" alt="htop" /></p>
         1127 
         1128 <p>By default, GNU ld is used for linking. Let's switch to using gold:</p>
         1129 
         1130 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1131         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1132         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1133         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1134         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>gold <span class="se">\</span>
         1135         <span class="nt">-GNinja</span> ../llvm
         1136 
         1137 <span class="nb">time </span>ninja
         1138 <span class="o">[</span>4182/4182] Linking CXX executable bin/c-index-test
         1139 
         1140 real    4m1.062s
         1141 user    427m1.648s
         1142 sys     6m58.282s
         1143 </code></pre></div></div>
         1144 
         1145 <p>LLD has been a viable option for some years now. Let's use it:</p>
         1146 
         1147 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1148         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1149         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1150         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1151         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1152         <span class="nt">-GNinja</span> ../llvm
         1153 
         1154 <span class="nb">time </span>ninja
         1155 <span class="o">[</span>4182/4182] Linking CXX executable bin/clang-scan-deps
         1156 
         1157 real    3m58.476s
         1158 user    428m3.807s
         1159 sys     7m14.418s
         1160 </code></pre></div></div>
         1161 
         1162 <p>Using GNU gold instead of GNU ld results in noticeably faster builds, and
         1163 switching to LLD shaves a few mores seconds from the build.</p>
         1164 
         1165 <p>If we want to build faster, we can make some compromises and start stripping
         1166 the build by removing some components.</p>
         1167 
         1168 <p>Let's start by disabling additional architecture support:</p>
         1169 
         1170 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1171         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1172         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1173         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1174         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1175         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"AArch64"</span> <span class="se">\</span>
         1176         <span class="nt">-GNinja</span> ../llvm
         1177 
         1178 <span class="nb">time </span>ninja
         1179 <span class="o">[</span>3195/3195] Linking CXX executable bin/c-index-test
         1180 
         1181 real    3m10.312s
         1182 user    326m54.898s
         1183 sys     5m24.770s
         1184 </code></pre></div></div>
         1185 
         1186 <p>We can verify the resulting Clang binary only supports AArch64 targets:</p>
         1187 
         1188 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>bin/clang <span class="nt">--print-targets</span>
         1189   Registered Targets:
         1190     aarch64    - AArch64 <span class="o">(</span>little endian<span class="o">)</span>
         1191     aarch64_32 - AArch64 <span class="o">(</span>little endian ILP32<span class="o">)</span>
         1192     aarch64_be - AArch64 <span class="o">(</span>big endian<span class="o">)</span>
         1193     arm64      - ARM64 <span class="o">(</span>little endian<span class="o">)</span>
         1194     arm64_32   - ARM64 <span class="o">(</span>little endian ILP32<span class="o">)</span>
         1195 </code></pre></div></div>
         1196 
         1197 <p>Let's go further and disable the static analyzer and the ARC Migration Tool:</p>
         1198 
         1199 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1200         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1201         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1202         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1203         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1204         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"AArch64"</span> <span class="se">\</span>
         1205         <span class="nt">-DCLANG_ENABLE_STATIC_ANALYZER</span><span class="o">=</span>OFF <span class="se">\</span>
         1206         <span class="nt">-DCLANG_ENABLE_ARCMT</span><span class="o">=</span>OFF <span class="se">\</span>
         1207         <span class="nt">-GNinja</span> ../llvm
         1208 
         1209 <span class="nb">time </span>ninja
         1210 <span class="o">[</span>3146/3146] Creating library symlink lib/libclang-cpp.so
         1211 
         1212 real    3m6.474s
         1213 user    319m25.914s
         1214 sys     5m20.924s
         1215 </code></pre></div></div>
         1216 
         1217 <p>Let's disable building some LLVM tools and utils:</p>
         1218 
         1219 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1220         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1221         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1222         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1223         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1224         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"AArch64"</span> <span class="se">\</span>
         1225         <span class="nt">-DCLANG_ENABLE_STATIC_ANALYZER</span><span class="o">=</span>OFF <span class="se">\</span>
         1226         <span class="nt">-DCLANG_ENABLE_ARCMT</span><span class="o">=</span>OFF <span class="se">\</span>
         1227         <span class="nt">-DLLVM_BUILD_TOOLS</span><span class="o">=</span>OFF <span class="se">\</span>
         1228         <span class="nt">-DLLVM_BUILD_UTILS</span><span class="o">=</span>OFF <span class="se">\</span>
         1229         <span class="nt">-GNinja</span> ../llvm
         1230 
         1231 <span class="nb">time </span>ninja
         1232 <span class="o">[</span>2879/2879] Creating library symlink lib/libclang-cpp.so
         1233 
         1234 real    2m59.659s
         1235 user    298m47.482s
         1236 sys     4m57.430s
         1237 </code></pre></div></div>
         1238 
         1239 <p>Compared to the previous build, the following binaries were not built:
         1240 <em>FileCheck</em>, <em>count</em>, <em>lli-child-target</em>, <em>llvm-jitlink-executor</em>,
         1241 <em>llvm-PerfectShuffle</em>, <em>not</em>, <em>obj2yaml</em>, <em>yaml2obj</em>, and <em>yaml-bench</em>.</p>
         1242 
         1243 <p>We are reaching the end of our journey here. At this point, we are done
         1244 stripping out things.</p>
         1245 
         1246 <p>Let's disable optimizations and do a last run:</p>
         1247 
         1248 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1249         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1250         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1251         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1252         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1253         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"AArch64"</span> <span class="se">\</span>
         1254         <span class="nt">-DCLANG_ENABLE_STATIC_ANALYZER</span><span class="o">=</span>OFF <span class="se">\</span>
         1255         <span class="nt">-DCLANG_ENABLE_ARCMT</span><span class="o">=</span>OFF <span class="se">\</span>
         1256         <span class="nt">-DLLVM_BUILD_TOOLS</span><span class="o">=</span>OFF <span class="se">\</span>
         1257         <span class="nt">-DLLVM_BUILD_UTILS</span><span class="o">=</span>OFF <span class="se">\</span>
         1258         <span class="nt">-DCMAKE_CXX_FLAGS_RELEASE</span><span class="o">=</span><span class="s2">"-O0"</span> <span class="se">\</span>
         1259         <span class="nt">-GNinja</span> ../llvm
         1260 
         1261 <span class="nb">time </span>ninja
         1262 <span class="o">[</span>2879/2879] Linking CXX executable bin/c-index-test
         1263 
         1264 real    2m37.003s
         1265 user    231m53.133s
         1266 sys     4m56.675s
         1267 </code></pre></div></div>
         1268 
         1269 <p>So this is it, this machine can build a full LLVM/Clang release build in
         1270 a bit less than four minutes, and a stripped down build with optimizations
         1271 disabled in two minutes. Two minutes. This is absolutely mind-blowing…
         1272 The future is now!</p>
         1273 
         1274 ]]></content>
         1275                 <summary type="html">
         1276                         <![CDATA[Speedbuilding LLVM/Clang in 2 minutes on a 160 cores ARM server]]>
         1277                 </summary>
         1278 
         1279                 <category term="Toolchains" scheme="https://www.cambus.net/categories/toolchains"/>
         1280         </entry>
         1281         <entry>
         1282         <title><![CDATA[Speedbuilding LLVM/Clang in 5 minutes]]></title>
         1283                 <link href="https://www.cambus.net/speedbuilding-llvm-clang-in-5-minutes/"/>
         1284                 <id>https://www.cambus.net/speedbuilding-llvm-clang-in-5-minutes/</id>
         1285                 <published>2021-05-11T21:21:00Z</published>
         1286                 <updated>2021-05-11T21:21:00Z</updated>
         1287                 <content type="html"><![CDATA[<p>This post is a spiritual successor to my "<a href="https://www.cambus.net/building-llvm-on-openbsd-loongson/">Building LLVM on OpenBSD/loongson</a>" article, in which I retraced my attempts to build LLVM 3.7.1 on
         1288 <strong>MIPS64</strong> in a RAM constrained environment.</p>
         1289 
         1290 <p>After reading the excellent "<a href="https://www.npopov.com/2020/05/10/Make-LLVM-fast-again.html">Make LLVM fast again</a>", I wanted to revisit
         1291 the topic, and see how fast I could build a recent version of <strong>LLVM</strong> and
         1292 <strong>Clang</strong> on modern x86 server hardware.</p>
         1293 
         1294 <p>The system I'm using for this experiment is a CCX62 instance from Hetzner,
         1295 which has <strong>48 dedicated vCPUs</strong> and <strong>192 GB of RAM</strong>. This is the fastest
         1296 machine available in their cloud offering at the moment.</p>
         1297 
         1298 <p>The system is running Fedora 34 with up-to-date packages and kernel.</p>
         1299 
         1300 <p>The full result of <em>cat /proc/cpuinfo</em> is available <a href="/content/2021/05/hetzner-ccx62-proc-cpuinfo.txt">here</a>.</p>
         1301 
         1302 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">uname</span> <span class="nt">-a</span>
         1303 Linux benchmarks 5.11.18-300.fc34.x86_64 <span class="c">#1 SMP Mon May 3 15:10:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux</span>
         1304 </code></pre></div></div>
         1305 
         1306 <p>Let's start by installing required packages:</p>
         1307 
         1308 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="k">in </span>clang cmake git lld ninja-build
         1309 </code></pre></div></div>
         1310 
         1311 <p>The compiler used for the builds is Clang 12.0.0:</p>
         1312 
         1313 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>clang <span class="nt">--version</span>
         1314 clang version 12.0.0 <span class="o">(</span>Fedora 12.0.0-0.3.rc1.fc34<span class="o">)</span>
         1315 Target: x86_64-unknown-linux-gnu
         1316 Thread model: posix
         1317 InstalledDir: /usr/bin
         1318 </code></pre></div></div>
         1319 
         1320 <p>Regarding linkers, we are using GNU ld and GNU Gold from binutils 2.35.1,
         1321 and LLD 12.0.0.</p>
         1322 
         1323 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>GNU ld version 2.35.1-41.fc34
         1324 GNU gold <span class="o">(</span>version 2.35.1-41.fc34<span class="o">)</span> 1.16
         1325 LLD 12.0.0 <span class="o">(</span>compatible with GNU linkers<span class="o">)</span>
         1326 </code></pre></div></div>
         1327 
         1328 <p>For all the following runs, I'm building from the Git repository main branch
         1329 commit <a href="https://github.com/llvm/llvm-project/commit/831cf15ca6892e2044447f8dc516d76b8a827f1e">831cf15ca6892e2044447f8dc516d76b8a827f1e</a>. The build directory is
         1330 of course fully erased between each run.</p>
         1331 
         1332 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>commit 831cf15ca6892e2044447f8dc516d76b8a827f1e
         1333 Author: David Spickett &lt;david.spickett@linaro.org&gt;
         1334 Date:   Wed May 5 11:49:35 2021 +0100
         1335 </code></pre></div></div>
         1336 
         1337 <p>To get a baseline, let's do a full release build on this machine:</p>
         1338 
         1339 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd </span>llvm-project
         1340 <span class="nb">mkdir </span>build
         1341 <span class="nb">cd </span>build
         1342 
         1343 cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1344         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1345         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1346         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1347         ../llvm
         1348 
         1349 <span class="nb">time </span>make <span class="nt">-j48</span>
         1350 real    11m19.852s
         1351 user    436m30.619s
         1352 sys     12m5.724s
         1353 </code></pre></div></div>
         1354 
         1355 <p>By default, CMake generates Makefiles. As documented in the "<a href="https://llvm.org/docs/GettingStarted.html">Getting Started
         1356 with the LLVM System</a>" tutorial, most LLVM developers use Ninja.</p>
         1357 
         1358 <p>Let's switch to generating Ninja build files, and using ninja to build:</p>
         1359 
         1360 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1361         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1362         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1363         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1364         <span class="nt">-GNinja</span> ../llvm
         1365 
         1366 <span class="nb">time </span>ninja
         1367 <span class="o">[</span>4182/4182] Generating ../../bin/llvm-readelf
         1368 
         1369 real    10m13.755s
         1370 user    452m16.034s
         1371 sys     12m7.584s
         1372 </code></pre></div></div>
         1373 
         1374 <p><img src="/content/2021/05/llvm-clang-htop.png" alt="htop" /></p>
         1375 
         1376 <p>By default, GNU ld is used for linking. Let's switch to using gold:</p>
         1377 
         1378 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1379         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1380         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1381         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1382         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>gold <span class="se">\</span>
         1383         <span class="nt">-GNinja</span> ../llvm
         1384 
         1385 <span class="nb">time </span>ninja
         1386 <span class="o">[</span>4182/4182] Generating ../../bin/llvm-readelf
         1387 
         1388 real    10m13.405s
         1389 user    451m35.029s
         1390 sys     11m57.649s
         1391 </code></pre></div></div>
         1392 
         1393 <p>LLD has been a viable option for some years now. Let's use it:</p>
         1394 
         1395 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1396         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1397         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1398         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1399         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1400         <span class="nt">-GNinja</span> ../llvm
         1401 
         1402 <span class="nb">time </span>ninja
         1403 <span class="o">[</span>4182/4182] Generating ../../bin/llvm-readelf
         1404 
         1405 real    10m12.710s
         1406 user    451m12.444s
         1407 sys     12m12.634s
         1408 </code></pre></div></div>
         1409 
         1410 <p>During tests on smaller build machines, I had observed that using GNU gold
         1411 or LLD instead of GNU ld resulted in noticeably faster builds. This doesn't
         1412 seem to be the case on this machine. We end up with a slightly faster build
         1413 by using LLD, but not by a large margin at all.</p>
         1414 
         1415 <p>If we want to build faster, we can make some compromises and start stripping
         1416 the build by removing some components.</p>
         1417 
         1418 <p>Let's start by disabling additional architecture support:</p>
         1419 
         1420 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1421         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1422         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1423         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1424         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1425         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"X86"</span> <span class="se">\</span>
         1426         <span class="nt">-GNinja</span> ../llvm 
         1427 
         1428 <span class="nb">time </span>ninja
         1429 <span class="o">[</span>3196/3196] Generating ../../bin/llvm-readelf
         1430 
         1431 real    7m55.531s
         1432 user    344m56.462s
         1433 sys     8m53.970s
         1434 </code></pre></div></div>
         1435 
         1436 <p>We can verify the resulting Clang binary only supports x86 targets:</p>
         1437 
         1438 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>bin/clang <span class="nt">--print-targets</span>
         1439   Registered Targets:
         1440     x86    - 32-bit X86: Pentium-Pro and above
         1441     x86-64 - 64-bit X86: EM64T and AMD64
         1442 </code></pre></div></div>
         1443 
         1444 <p>Let's go further and disable the static analyzer and the ARC Migration Tool:</p>
         1445 
         1446 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1447         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1448         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1449         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1450         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1451         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"X86"</span> <span class="se">\</span>
         1452         <span class="nt">-DCLANG_ENABLE_STATIC_ANALYZER</span><span class="o">=</span>OFF <span class="se">\</span>
         1453         <span class="nt">-DCLANG_ENABLE_ARCMT</span><span class="o">=</span>OFF <span class="se">\</span>
         1454         <span class="nt">-GNinja</span> ../llvm 
         1455 
         1456 <span class="nb">time </span>ninja
         1457 <span class="o">[</span>3147/3147] Generating ../../bin/llvm-readelf
         1458 
         1459 real    7m42.299s
         1460 user    334m47.916s
         1461 sys     8m44.704s
         1462 </code></pre></div></div>
         1463 
         1464 <p>Let's disable building some LLVM tools and utils:</p>
         1465 
         1466 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1467         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1468         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1469         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1470         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1471         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"X86"</span> <span class="se">\</span>
         1472         <span class="nt">-DCLANG_ENABLE_STATIC_ANALYZER</span><span class="o">=</span>OFF <span class="se">\</span>
         1473         <span class="nt">-DCLANG_ENABLE_ARCMT</span><span class="o">=</span>OFF <span class="se">\</span>
         1474         <span class="nt">-DLLVM_BUILD_TOOLS</span><span class="o">=</span>OFF <span class="se">\</span>
         1475         <span class="nt">-DLLVM_BUILD_UTILS</span><span class="o">=</span>OFF <span class="se">\</span>
         1476         <span class="nt">-GNinja</span> ../llvm
         1477 
         1478 <span class="nb">time </span>ninja
         1479 <span class="o">[</span>2880/2880] Generating ../../bin/llvm-readelf
         1480 
         1481 real    7m21.016s
         1482 user    315m42.127s
         1483 sys     8m9.377s
         1484 </code></pre></div></div>
         1485 
         1486 <p>Compared to the previous build, the following binaries were not built:
         1487 <em>FileCheck</em>, <em>count</em>, <em>lli-child-target</em>, <em>llvm-jitlink-executor</em>,
         1488 <em>llvm-PerfectShuffle</em>, <em>not</em>, <em>obj2yaml</em>, <em>yaml2obj</em>, and <em>yaml-bench</em>.</p>
         1489 
         1490 <p>We are reaching the end of our journey here. At this point, we are done
         1491 stripping out things.</p>
         1492 
         1493 <p>Let's disable optimizations and do a last run:</p>
         1494 
         1495 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cmake   <span class="nt">-DCMAKE_C_COMPILER</span><span class="o">=</span>clang <span class="se">\</span>
         1496         <span class="nt">-DCMAKE_CXX_COMPILER</span><span class="o">=</span>clang++ <span class="se">\</span>
         1497         <span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
         1498         <span class="nt">-DLLVM_ENABLE_PROJECTS</span><span class="o">=</span>clang <span class="se">\</span>
         1499         <span class="nt">-DLLVM_USE_LINKER</span><span class="o">=</span>lld <span class="se">\</span>
         1500         <span class="nt">-DLLVM_TARGETS_TO_BUILD</span><span class="o">=</span><span class="s2">"X86"</span> <span class="se">\</span>
         1501         <span class="nt">-DCLANG_ENABLE_STATIC_ANALYZER</span><span class="o">=</span>OFF <span class="se">\</span>
         1502         <span class="nt">-DCLANG_ENABLE_ARCMT</span><span class="o">=</span>OFF <span class="se">\</span>
         1503         <span class="nt">-DLLVM_BUILD_TOOLS</span><span class="o">=</span>OFF <span class="se">\</span>
         1504         <span class="nt">-DLLVM_BUILD_UTILS</span><span class="o">=</span>OFF <span class="se">\</span>
         1505         <span class="nt">-DCMAKE_CXX_FLAGS_RELEASE</span><span class="o">=</span><span class="s2">"-O0"</span> <span class="se">\</span>
         1506         <span class="nt">-GNinja</span> ../llvm 
         1507 
         1508 <span class="nb">time </span>ninja
         1509 <span class="o">[</span>2880/2880] Linking CXX executable bin/c-index-test
         1510 
         1511 real    5m37.225s
         1512 user    253m18.515s
         1513 sys     9m2.413s
         1514 </code></pre></div></div>
         1515 
         1516 <p>That's it. Five minutes. Don't try this at home :-)</p>
         1517 
         1518 ]]></content>
         1519                 <summary type="html">
         1520                         <![CDATA[Speedbuilding LLVM/Clang in 5 minutes on a 48 vCPUs machine using Ninja and LLD]]>
         1521                 </summary>
         1522 
         1523                 <category term="Toolchains" scheme="https://www.cambus.net/categories/toolchains"/>
         1524         </entry>
         1525         <entry>
         1526         <title><![CDATA[The state of toolchains in NetBSD]]></title>
         1527                 <link href="https://www.cambus.net/the-state-of-toolchains-in-netbsd/"/>
         1528                 <id>https://www.cambus.net/the-state-of-toolchains-in-netbsd/</id>
         1529                 <published>2021-04-09T22:42:00Z</published>
         1530                 <updated>2021-04-09T22:42:00Z</updated>
         1531                 <content type="html"><![CDATA[<p>While FreeBSD and OpenBSD both switched to using LLVM/Clang as their
         1532 base system compiler, NetBSD picked a different path and remained with
         1533 <strong>GCC</strong> and <strong>binutils</strong> regardless of the license change to GPLv3.
         1534 However, it doesn't mean that the NetBSD project endorses this license,
         1535 and the NetBSD Foundation's has issued a <a href="http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/README?rev=1.1">statement</a> about its position
         1536 on the subject.</p>
         1537 
         1538 <p>Realistically, NetBSD is more or less tied to GCC, as it supports more
         1539 architectures than the other BSDs, some of which will likely never be
         1540 supported in LLVM.</p>
         1541 
         1542 <p>As of <a href="https://www.netbsd.org/releases/formal-9/NetBSD-9.1.html">NetBSD 9.1</a>, the latest released version, all <a href="https://wiki.netbsd.org/ports/">supported
         1543 platforms</a> have recent versions of GCC (7.5.0) and binutils (2.31.1)
         1544 in the base system. Newer (and older!) versions of GCC can be installed
         1545 via Pkgsrc, and the following packages are available, going all the way
         1546 back to GCC 3.3.6:</p>
         1547 
         1548 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>+---------+------------+-------------------+
         1549 | Package | Version    |      Release <span class="nb">date</span> |
         1550 +---------+------------+-------------------+
         1551 | gcc10   | GCC 10.2.0 |     July 23, 2020 |
         1552 | gcc9    | GCC  9.3.0 |    March 12, 2020 |
         1553 | gcc8    | GCC  8.4.0 |     March 4, 2020 |
         1554 | gcc7    | GCC  7.5.0 | November 14, 2019 |
         1555 | gcc6    | GCC  6.5.0 |  October 26, 2018 |
         1556 | gcc5    | GCC  5.5.0 |  October 10, 2017 |
         1557 | gcc49   | GCC  4.9.4 |    August 3, 2016 |
         1558 | gcc48   | GCC  4.8.5 |     June 23, 2015 |
         1559 | gcc3    | GCC  3.3.6 |       May 3, 2005 |
         1560 +---------+------------+-------------------+
         1561 </code></pre></div></div>
         1562 
         1563 <p>The focus on GCC doesn't mean that the GNU and LLVM toolchains cannot coexist
         1564 within NetBSD, and work has in fact been done during the last decade to make
         1565 it happen.</p>
         1566 
         1567 <p>Despite currently not being built by default in official NetBSD releases,
         1568 <a href="https://www.freshbsd.org/netbsd/src/commit/EoXArQqbzjtXf3fx">LLVM has been imported</a> in the NetBSD source tree in 2013. Daily images
         1569 are built from NetBSD-current for selected platforms (at least amd64, i386
         1570 and evbarm) with the <em>MKLLVM</em> and <em>HAVE_LLVM</em> build options enabled, and
         1571 contain LLVM and Clang.</p>
         1572 
         1573 <p>Moreover, NetBSD has invested a lot of work on LLVM during the past few
         1574 years, including funding some developer contracts for Kamil Rytarowski
         1575 (kamil@) and MichaÅ‚ GĂ³rny (mgorny@), which allowed them to work on various
         1576 parts of the LLVM toolchain to add and enhance support for <strong>sanitizers</strong>,
         1577 and to improve <strong>LLDB</strong> support.</p>
         1578 
         1579 <p>They both published several dozen articles on the <a href="https://blog.netbsd.org/tnf/category/Development">NetBSD blog</a>
         1580 along the way, retracing their journey. Kamil's final report about
         1581 <a href="https://blog.netbsd.org/tnf/entry/the_process_of_upstreaming_support">upstreaming support to LLVM sanitizers</a> summarizes the work accomplished.
         1582 Thanks to this work, sanitizer support on NetBSD is mature and mostly on par
         1583 with Linux. As a result, because LLVM is upstream for GCC sanitizers, they
         1584 are also available in GCC on NetBSD.  Similarly, Michał's final report on
         1585 his <a href="https://blog.netbsd.org/tnf/entry/lldb_work_concluded">LLDB work</a> details the achievements on the debuggers front.</p>
         1586 
         1587 <p>As always, work continues towards keeping the toolchains up to date, and
         1588 upstreaming local changes whenever possible.</p>
         1589 
         1590 ]]></content>
         1591                 <summary type="html">
         1592                         <![CDATA[The current state of GNU and LLVM toolchains in the NetBSD project]]>
         1593                 </summary>
         1594 
         1595                 <category term="NetBSD" scheme="https://www.cambus.net/categories/netbsd"/>
         1596                 <category term="Toolchains" scheme="https://www.cambus.net/categories/toolchains"/>
         1597         </entry>
         1598         <entry>
         1599         <title><![CDATA[OpenBSD/loongson on the Lemote Fuloong]]></title>
         1600                 <link href="https://www.cambus.net/openbsd-loongson-on-the-lemote-fuloong/"/>
         1601                 <id>https://www.cambus.net/openbsd-loongson-on-the-lemote-fuloong/</id>
         1602                 <published>2021-03-04T23:10:00Z</published>
         1603                 <updated>2021-03-04T23:10:00Z</updated>
         1604                 <content type="html"><![CDATA[<p>In my article about running <a href="/openbsd-loongson-on-the-lemote-yeeloong-8101b/">OpenBSD/loongson on the Lemote Yeeloong</a> back
         1605 in 2016, I mentioned looking for a Fuloong. All hope seemed lost until the
         1606 Summer of 2017, when a fellow OpenBSD developer was contacted by a generous
         1607 user (Thanks again, Lars!) offering to donate two <strong>Lemote Fuloong</strong> machines,
         1608 and I was lucky enough to get one of those units.</p>
         1609 
         1610 <p>This machine uses the same CPU as the Yeeloong, a <strong>Loongson 2F</strong> which is
         1611 a single-core MIPS-III 64-bit processor running at 800/900 MHz.</p>
         1612 
         1613 <p>As hinted in my previous article, contrarily to the <strong>Yeeloong</strong>, the
         1614 <strong>Fuloong</strong> is less strict with the type of RAM it accepts, and my device is
         1615 happily running with a Kingston 2GB DDR2 SO-DIMM module (ASU256X64D2S800C6),
         1616 replacing the original 512MB module.</p>
         1617 
         1618 <p>Here is the result of a quick <strong>md5 -t</strong> benchmark:</p>
         1619 
         1620 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>MD5 <span class="nb">time </span>trial.  Processing 10000 10000-byte blocks...
         1621 Digest <span class="o">=</span> 52e5f9c9e6f656f3e1800dfa5579d089
         1622 Time   <span class="o">=</span> 1.726563 seconds
         1623 Speed  <span class="o">=</span> 57918535.263411 bytes/second
         1624 </code></pre></div></div>
         1625 
         1626 <p>For the record, LibreSSL speed benchmark results are available <a href="/files/openbsd/openssl-speed-fuloong.txt">here</a>.</p>
         1627 
         1628 <p>System message buffer (dmesg output):</p>
         1629 
         1630 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Copyright <span class="o">(</span>c<span class="o">)</span> 1982, 1986, 1989, 1991, 1993
         1631         The Regents of the University of California.  All rights reserved.
         1632 Copyright <span class="o">(</span>c<span class="o">)</span> 1995-2021 OpenBSD. All rights reserved.  https://www.OpenBSD.org
         1633 
         1634 OpenBSD 6.9-beta <span class="o">(</span>GENERIC<span class="o">)</span> <span class="c">#74: Fri Feb 26 08:02:25 MST 2021</span>
         1635     deraadt@loongson.openbsd.org:/usr/src/sys/arch/loongson/compile/GENERIC
         1636 real mem <span class="o">=</span> 2147483648 <span class="o">(</span>2048MB<span class="o">)</span>
         1637 avail mem <span class="o">=</span> 2116452352 <span class="o">(</span>2018MB<span class="o">)</span>
         1638 random: boothowto does not indicate good seed
         1639 mainbus0 at root: Lemote Fuloong
         1640 cpu0 at mainbus0: STC Loongson2F CPU 797 MHz, STC Loongson2F FPU
         1641 cpu0: cache L1-I 64KB D 64KB 4 way, L2 512KB 4 way
         1642 bonito0 at mainbus0: memory and PCI-X controller, rev 1
         1643 pci0 at bonito0 bus 0
         1644 re0 at pci0 dev 6 <span class="k">function </span>0 <span class="s2">"Realtek 8169"</span> rev 0x10: RTL8169/8110SCd <span class="o">(</span>0x1800<span class="o">)</span>, irq 4, address 00:23:9e:00:0f:71
         1645 rgephy0 at re0 phy 7: RTL8169S/8110S/8211 PHY, rev. 2
         1646 sisfb0 at pci0 dev 8 <span class="k">function </span>0 <span class="s2">"SiS 315 Pro VGA"</span> rev 0x00: 640x400, 8bpp
         1647 wsdisplay0 at sisfb0 mux 1: console <span class="o">(</span>std, vt100 emulation<span class="o">)</span>
         1648 glxpcib0 at pci0 dev 14 <span class="k">function </span>0 <span class="s2">"AMD CS5536 ISA"</span> rev 0x03: rev 3, 32-bit 3579545Hz timer, watchdog, gpio, i2c
         1649 isa0 at glxpcib0
         1650 com0 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
         1651 com1 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
         1652 mcclock0 at isa0 port 0x70/2: mc146818 or compatible
         1653 gpio1 at glxpcib0: 32 pins
         1654 iic at glxpcib0 not configured
         1655 glxclk0 at glxpcib0: clock, prof
         1656 pciide0 at pci0 dev 14 <span class="k">function </span>2 <span class="s2">"AMD CS5536 IDE"</span> rev 0x01: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility
         1657 wd0 at pciide0 channel 0 drive 0: &lt;WDC WD1600BEVS-00VAT0&gt;
         1658 wd0: 16-sector PIO, LBA48, 152627MB, 312581808 sectors
         1659 wd0<span class="o">(</span>pciide0:0:0<span class="o">)</span>: using PIO mode 4, Ultra-DMA mode 2
         1660 pciide0: channel 1 ignored <span class="o">(</span>disabled<span class="o">)</span>
         1661 auglx0 at pci0 dev 14 <span class="k">function </span>3 <span class="s2">"AMD CS5536 Audio"</span> rev 0x01: isa irq 9, CS5536 AC97
         1662 ac97: codec <span class="nb">id </span>0x414c4760 <span class="o">(</span>Avance Logic ALC655 rev 0<span class="o">)</span>
         1663 audio0 at auglx0
         1664 ohci0 at pci0 dev 14 <span class="k">function </span>4 <span class="s2">"AMD CS5536 USB"</span> rev 0x02: isa irq 11, version 1.0, legacy support
         1665 ehci0 at pci0 dev 14 <span class="k">function </span>5 <span class="s2">"AMD CS5536 USB"</span> rev 0x02: isa irq 11
         1666 usb0 at ehci0: USB revision 2.0
         1667 uhub0 at usb0 configuration 1 interface 0 <span class="s2">"AMD EHCI root hub"</span> rev 2.00/1.00 addr 1
         1668 usb1 at ohci0: USB revision 1.0
         1669 uhub1 at usb1 configuration 1 interface 0 <span class="s2">"AMD OHCI root hub"</span> rev 1.00/1.00 addr 1
         1670 apm0 at mainbus0
         1671 vscsi0 at root
         1672 scsibus0 at vscsi0: 256 targets
         1673 softraid0 at root
         1674 scsibus1 at softraid0: 256 targets
         1675 pmon bootpath: <span class="nv">bootduid</span><span class="o">=</span>53153d3cd8ddc482
         1676 root on wd0a <span class="o">(</span>53153d3cd8ddc482.a<span class="o">)</span> swap on wd0b dump on wd0b
         1677 </code></pre></div></div>
         1678 
         1679 <p>PCI device data:</p>
         1680 
         1681 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># pcidump</span>
         1682 Domain /dev/pci0:
         1683  0:6:0: Realtek 8169
         1684  0:8:0: SiS 315 Pro VGA
         1685  0:14:0: AMD CS5536 ISA
         1686  0:14:2: AMD CS5536 IDE
         1687  0:14:3: AMD CS5536 Audio
         1688  0:14:4: AMD CS5536 USB
         1689  0:14:5: AMD CS5536 USB
         1690 </code></pre></div></div>
         1691 
         1692 ]]></content>
         1693                 <summary type="html">
         1694                         <![CDATA[Running the OpenBSD/loongson port on a Lemote Fuloong]]>
         1695                 </summary>
         1696 
         1697                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         1698                 <category term="MIPS64" scheme="https://www.cambus.net/categories/mips64"/>
         1699         </entry>
         1700         <entry>
         1701         <title><![CDATA[NetBSD on the EdgeRouter Lite]]></title>
         1702                 <link href="https://www.cambus.net/netbsd-on-the-edgerouter-lite/"/>
         1703                 <id>https://www.cambus.net/netbsd-on-the-edgerouter-lite/</id>
         1704                 <published>2021-01-29T19:20:00Z</published>
         1705                 <updated>2021-01-29T19:20:00Z</updated>
         1706                 <content type="html"><![CDATA[<p>NetBSD-current now has pre-built <a href="https://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/latest/evbmips-mips64eb/binary/gzimg/">octeon bootable images</a> (which will
         1707 appear in NetBSD 10.0) for the <strong>evbmips</strong> port, so I decided to finally
         1708 give it a try. I've been happily running OpenBSD/octeon on my EdgeRouter
         1709 Lite for a few years now, and have previously published <a href="https://www.cambus.net/openbsd-octeon-on-the-edgerouter-lite/">some notes</a>
         1710 including more detail about the CPU.</p>
         1711 
         1712 <p>Contrary to the <a href="https://www.openbsd.org/octeon.html">OpenBSD/octeon</a> port which is very stable and runs SMP
         1713 kernels, things are a little less polished on the NetBSD side for this
         1714 platform. The system runs an uniprocessor kernel and there are still some
         1715 stability issues.</p>
         1716 
         1717 <p><img src="/content/2017/08/edgerouter-lite.jpg" alt="EdgeRouter Lite" /></p>
         1718 
         1719 <p>Here is the U-Boot configuration to boot the image:</p>
         1720 
         1721 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Octeon ubnt_e100# <span class="nb">set </span>bootcmd <span class="s1">'fatload usb 0 $loadaddr netbsd;bootoctlinux $loadaddr coremask=0x3 root=wedge:octeon-root'</span>
         1722 Octeon ubnt_e100# saveenv
         1723 Saving Environment to Flash...
         1724 Un-Protected 1 sectors
         1725 Erasing Flash...
         1726 <span class="nb">.</span> <span class="k">done
         1727 </span>Erased 1 sectors
         1728 Writing to Flash... 4....3....2....1....done
         1729 Protected 1 sectors
         1730 Octeon ubnt_e100#
         1731 </code></pre></div></div>
         1732 
         1733 <p>On first boot, the system automatically expands the filesystem:</p>
         1734 
         1735 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Resizing / <span class="o">(</span><span class="nv">NAME</span><span class="o">=</span>octeon-root<span class="o">)</span>
         1736 /dev/rdk1: grow cg |<span class="k">*************************************</span>                 |  69%
         1737 </code></pre></div></div>
         1738 
         1739 <p>Here is the login session, for posterity:</p>
         1740 
         1741 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Thu Jan 28 23:40:37 UTC 2021
         1742 
         1743 NetBSD/evbmips <span class="o">(</span>octeon<span class="o">)</span> <span class="o">(</span>constty<span class="o">)</span>
         1744 
         1745 login:
         1746 </code></pre></div></div>
         1747 
         1748 <p>Here is the output of running <em>file</em> on executables:</p>
         1749 
         1750 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ELF 32-bit MSB pie executable, MIPS, N32 MIPS-III version 1 <span class="o">(</span>SYSV<span class="o">)</span>, dynamically
         1751 linked, interpreter /libexec/ld.elf_so, <span class="k">for </span>NetBSD 9.99.79, not stripped
         1752 </code></pre></div></div>
         1753 
         1754 <p>For the record, OpenSSL speed benchmark results are available
         1755 <a href="/files/netbsd/openssl-speed-edgerouter-lite.txt">here</a>.</p>
         1756 
         1757 <p>System message buffer (dmesg output):</p>
         1758 
         1759 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>     1.000000] Copyright <span class="o">(</span>c<span class="o">)</span> 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
         1760 <span class="o">[</span>     1.000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
         1761 <span class="o">[</span>     1.000000]     2018, 2019, 2020, 2021 The NetBSD Foundation, Inc.  All rights reserved.
         1762 <span class="o">[</span>     1.000000] Copyright <span class="o">(</span>c<span class="o">)</span> 1982, 1986, 1989, 1991, 1993
         1763 <span class="o">[</span>     1.000000]     The Regents of the University of California.  All rights reserved.
         1764 
         1765 <span class="o">[</span>     1.000000] NetBSD 9.99.79 <span class="o">(</span>OCTEON<span class="o">)</span> <span class="c">#0: Thu Jan 28 18:52:43 UTC 2021</span>
         1766 <span class="o">[</span>     1.000000]         mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbmips/compile/OCTEON
         1767 <span class="o">[</span>     1.000000] Cavium Octeon CN5020-500
         1768 <span class="o">[</span>     1.000000] total memory <span class="o">=</span> 512 MB
         1769 <span class="o">[</span>     1.000000] avail memory <span class="o">=</span> 496 MB
         1770 <span class="o">[</span>     1.000000] timecounter: Timecounters tick every 10.000 msec
         1771 <span class="o">[</span>     1.000000] mainbus0 <span class="o">(</span>root<span class="o">)</span>
         1772 <span class="o">[</span>     1.000000] cpunode0 at mainbus0: 2 cores, crypto+kasumi, 64bit-mul, unaligned-access ok
         1773 <span class="o">[</span>     1.000000] cpu0 at cpunode0 core 0: 500.00MHz
         1774 <span class="o">[</span>     1.000000] cpu0: Cavium CN5020-500 <span class="o">(</span>0xd0601<span class="o">)</span> Rev. 1 with software emulated floating point
         1775 <span class="o">[</span>     1.000000] cpu0: 64 TLB entries, 512TB <span class="o">(</span>49-bit<span class="o">)</span> VAs, 512TB <span class="o">(</span>49-bit<span class="o">)</span> PAs, 256MB max page size
         1776 <span class="o">[</span>     1.000000] cpu0: 32KB/128B 4-way set-associative L1 instruction cache
         1777 <span class="o">[</span>     1.000000] cpu0: 16KB/128B 64-way set-associative write-through coherent L1 data cache
         1778 <span class="o">[</span>     1.000000] cpu0: 128KB/128B 8-way set-associative write-back L2 unified cache
         1779 <span class="o">[</span>     1.000000] cpu1 at cpunode0 core 1: disabled <span class="o">(</span>uniprocessor kernel<span class="o">)</span>
         1780 <span class="o">[</span>     1.000000] wdog0 at cpunode0: default period is 4 seconds
         1781 <span class="o">[</span>     1.000000] iobus0 at mainbus0
         1782 <span class="o">[</span>     1.000000] iobus0: initializing POW
         1783 <span class="o">[</span>     1.000000] iobus0: initializing FPA
         1784 <span class="o">[</span>     1.000000] com0 at iobus0 address 0x0001180000000800: ns16650, no ERS, 16-byte FIFO
         1785 <span class="o">[</span>     1.000000] com0: console
         1786 <span class="o">[</span>     1.000000] com at iobus0 address 0x0001180000000c00 not configured
         1787 <span class="o">[</span>     1.000000] octrnm0 at iobus0 address 0x0001180040000000
         1788 <span class="o">[</span>     1.000000] entropy: ready
         1789 <span class="o">[</span>     1.000000] octtwsi at iobus0 address 0x0001180000001000 not configured
         1790 <span class="o">[</span>     1.000000] octmpi at iobus0 address 0x0001070000001000 not configured
         1791 <span class="o">[</span>     1.000000] octsmi0 at iobus0 address 0x0001180000001800
         1792 <span class="o">[</span>     1.000000] octpip0 at iobus0 address 0x00011800a0000000
         1793 <span class="o">[</span>     1.000000] octgmx0 at octpip0
         1794 <span class="o">[</span>     1.000000] cnmac0 at octgmx0: <span class="nv">address</span><span class="o">=</span>0x1180008000000: RGMII
         1795 <span class="o">[</span>     1.000000] cnmac0: Ethernet address 44:d9:e7:9e:f5:9e
         1796 <span class="o">[</span>     1.000000] atphy0 at cnmac0 phy 7: Atheros AR8035 10/100/1000 PHY, rev. 2
         1797 <span class="o">[</span>     1.000000] atphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseSX-FDX, 1000baseT-FDX, auto
         1798 <span class="o">[</span>     1.000000] cnmac1 at octgmx0: <span class="nv">address</span><span class="o">=</span>0x1180008000000: RGMII
         1799 <span class="o">[</span>     1.000000] cnmac1: Ethernet address 44:d9:e7:9e:f5:9f
         1800 <span class="o">[</span>     1.000000] atphy1 at cnmac1 phy 6: Atheros AR8035 10/100/1000 PHY, rev. 2
         1801 <span class="o">[</span>     1.000000] atphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseSX-FDX, 1000baseT-FDX, auto
         1802 <span class="o">[</span>     1.000000] cnmac2 at octgmx0: <span class="nv">address</span><span class="o">=</span>0x1180008000000: RGMII
         1803 <span class="o">[</span>     1.000000] cnmac2: Ethernet address 44:d9:e7:9e:f5:a0
         1804 <span class="o">[</span>     1.000000] atphy2 at cnmac2 phy 5: Atheros AR8035 10/100/1000 PHY, rev. 2
         1805 <span class="o">[</span>     1.000000] atphy2: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseSX-FDX, 1000baseT-FDX, auto
         1806 <span class="o">[</span>     1.000000] dwctwo0 at iobus0 address 0x0001180068000000
         1807 <span class="o">[</span>     1.000000] dwctwo0: Core Release: 2.65a <span class="o">(</span><span class="nv">snpsid</span><span class="o">=</span>4f54265a<span class="o">)</span>
         1808 <span class="o">[</span>     1.000000] usb0 at dwctwo0: USB revision 2.0
         1809 <span class="o">[</span>     1.000000] bootbus0 at mainbus0
         1810 <span class="o">[</span>     1.000000] timecounter: Timecounter <span class="s2">"mips3_cp0_counter"</span> frequency 500000000 Hz quality 100
         1811 <span class="o">[</span>     1.000003] timecounter: Timecounter <span class="s2">"clockinterrupt"</span> frequency 100 Hz quality 0
         1812 <span class="o">[</span>     1.059978] uhub0 at usb0: NetBSD <span class="o">(</span>0x0000<span class="o">)</span> DWC2 root hub <span class="o">(</span>0x0000<span class="o">)</span>, class 9/0, rev 2.00/1.00, addr 1
         1813 <span class="o">[</span>     1.059978] uhub0: 1 port with 1 removable, self powered
         1814 <span class="o">[</span>     1.069975] aes: BearSSL aes_ct
         1815 <span class="o">[</span>     1.069975] aes_ccm: self-test passed
         1816 <span class="o">[</span>     1.069975] chacha: Portable C ChaCha
         1817 <span class="o">[</span>     1.079979] blake2s: self-test passed
         1818 <span class="o">[</span>     3.609971] umass0 at uhub0 port 1 configuration 1 interface 0
         1819 <span class="o">[</span>     3.620226] umass0: vendor 13fe <span class="o">(</span>0x13fe<span class="o">)</span> USB DISK 2.0 <span class="o">(</span>0x4200<span class="o">)</span>, rev 2.00/1.00, addr 2
         1820 <span class="o">[</span>     3.620226] umass0: using SCSI over Bulk-Only
         1821 <span class="o">[</span>     3.620226] scsibus0 at umass0: 2 targets, 1 lun per target
         1822 <span class="o">[</span>     3.632383] uhub0: autoconfiguration error: illegal <span class="nb">enable </span>change, port 1
         1823 <span class="o">[</span>     3.639974] sd0 at scsibus0 target 0 lun 0: &lt;, USB DISK 2.0, PMAP&gt; disk removable
         1824 <span class="o">[</span>     3.639974] sd0: 3824 MB, 959 cyl, 255 <span class="nb">head</span>, 32 sec, 512 bytes/sect x 7831552 sectors
         1825 <span class="o">[</span>     3.659974] sd0: GPT GUID: 6e7b1b6a-2e9f-4915-946a-567dad0caaa4
         1826 <span class="o">[</span>     3.669969] dk0 at sd0: <span class="s2">"octeon-boot"</span>, 163840 blocks at 32768, <span class="nb">type</span>: ntfs
         1827 <span class="o">[</span>     3.669969] dk1 at sd0: <span class="s2">"octeon-root"</span>, 7626752 blocks at 196608, <span class="nb">type</span>: ffs
         1828 <span class="o">[</span>     3.683879] WARNING: 1 error <span class="k">while </span>detecting hardware<span class="p">;</span> check system log.
         1829 <span class="o">[</span>     3.691430] boot device: sd0
         1830 <span class="o">[</span>     3.691430] root on dk1
         1831 <span class="o">[</span>     3.709975] root file system <span class="nb">type</span>: ffs
         1832 <span class="o">[</span>     3.719976] kern.module.path<span class="o">=</span>/stand/evbmips/9.99.79/modules
         1833 <span class="o">[</span>     3.719976] WARNING: no TOD clock present
         1834 <span class="o">[</span>     3.729990] WARNING: using filesystem <span class="nb">time</span>
         1835 <span class="o">[</span>     3.734057] WARNING: CHECK AND RESET THE DATE!
         1836 </code></pre></div></div>
         1837 
         1838 ]]></content>
         1839                 <summary type="html">
         1840                         <![CDATA[Running the NetBSD/evbmips port on Ubiquiti EdgeRouter Lite]]>
         1841                 </summary>
         1842 
         1843                 <category term="NetBSD" scheme="https://www.cambus.net/categories/netbsd"/>
         1844                 <category term="MIPS64" scheme="https://www.cambus.net/categories/mips64"/>
         1845         </entry>
         1846         <entry>
         1847         <title><![CDATA[Playing with Kore JSON API]]></title>
         1848                 <link href="https://www.cambus.net/playing-with-kore-json-api/"/>
         1849                 <id>https://www.cambus.net/playing-with-kore-json-api/</id>
         1850                 <published>2020-09-07T15:15:00Z</published>
         1851                 <updated>2020-09-07T15:15:00Z</updated>
         1852                 <content type="html"><![CDATA[<p>Kore <a href="https://kore.io/releases/4.0.0">4.0.0</a> has been released a few days ago, and features a brand
         1853 new <a href="https://docs.kore.io/4.0.0/api/json.html">JSON API</a> allowing to easily parse and serialize JSON objects.</p>
         1854 
         1855 <p>During the last couple of years, I have been using Kore for various projects,
         1856 including exposing hardware sensor values over the network via very simple
         1857 APIs. In this article, I would like to present a generalization of this
         1858 concept and show how easy it is to expose system information with Kore.</p>
         1859 
         1860 <p>This small API example allows identifying hosts over the network and has
         1861 been tested on Linux, OpenBSD, NetBSD, and macOS (thanks Joris!).</p>
         1862 
         1863 <p>After creating a new project:</p>
         1864 
         1865 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kodev create identify
         1866 </code></pre></div></div>
         1867 
         1868 <p>Populate <code>src/identify.c</code> with the following code snippet:</p>
         1869 
         1870 <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#include &lt;sys/utsname.h&gt;
         1871 </span>
         1872 <span class="cp">#include &lt;kore/kore.h&gt;
         1873 #include &lt;kore/http.h&gt;
         1874 </span>
         1875 <span class="cp">#if defined(__linux__)
         1876 #include &lt;kore/seccomp.h&gt;
         1877 </span>
         1878 <span class="n">KORE_SECCOMP_FILTER</span><span class="p">(</span><span class="s">"json"</span><span class="p">,</span>
         1879         <span class="n">KORE_SYSCALL_ALLOW</span><span class="p">(</span><span class="n">uname</span><span class="p">)</span>
         1880 <span class="p">);</span>
         1881 <span class="cp">#endif
         1882 </span>
         1883 <span class="kt">int</span>                <span class="nf">page</span><span class="p">(</span><span class="k">struct</span> <span class="n">http_request</span> <span class="o">*</span><span class="p">);</span>
         1884 
         1885 <span class="kt">int</span>
         1886 <span class="nf">page</span><span class="p">(</span><span class="k">struct</span> <span class="n">http_request</span> <span class="o">*</span><span class="n">req</span><span class="p">)</span>
         1887 <span class="p">{</span>
         1888         <span class="kt">char</span> <span class="o">*</span><span class="n">answer</span><span class="p">;</span>
         1889 
         1890         <span class="k">struct</span> <span class="n">utsname</span> <span class="n">u</span><span class="p">;</span>
         1891 
         1892         <span class="k">struct</span> <span class="n">kore_buf</span> <span class="n">buf</span><span class="p">;</span>
         1893         <span class="k">struct</span> <span class="n">kore_json_item</span> <span class="o">*</span><span class="n">json</span><span class="p">;</span>
         1894 
         1895         <span class="k">if</span> <span class="p">(</span><span class="n">uname</span><span class="p">(</span><span class="o">&amp;</span><span class="n">u</span><span class="p">)</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
         1896                 <span class="n">http_response</span><span class="p">(</span><span class="n">req</span><span class="p">,</span> <span class="n">HTTP_STATUS_INTERNAL_ERROR</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
         1897                 <span class="k">return</span> <span class="p">(</span><span class="n">KORE_RESULT_OK</span><span class="p">);</span>
         1898         <span class="p">}</span>
         1899 
         1900         <span class="n">kore_buf_init</span><span class="p">(</span><span class="o">&amp;</span><span class="n">buf</span><span class="p">,</span> <span class="mi">1024</span><span class="p">);</span>
         1901         <span class="n">json</span> <span class="o">=</span> <span class="n">kore_json_create_object</span><span class="p">(</span><span class="nb">NULL</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>
         1902 
         1903         <span class="n">kore_json_create_string</span><span class="p">(</span><span class="n">json</span><span class="p">,</span> <span class="s">"system"</span><span class="p">,</span> <span class="n">u</span><span class="p">.</span><span class="n">sysname</span><span class="p">);</span>
         1904         <span class="n">kore_json_create_string</span><span class="p">(</span><span class="n">json</span><span class="p">,</span> <span class="s">"hostname"</span><span class="p">,</span> <span class="n">u</span><span class="p">.</span><span class="n">nodename</span><span class="p">);</span>
         1905         <span class="n">kore_json_create_string</span><span class="p">(</span><span class="n">json</span><span class="p">,</span> <span class="s">"release"</span><span class="p">,</span> <span class="n">u</span><span class="p">.</span><span class="n">release</span><span class="p">);</span>
         1906         <span class="n">kore_json_create_string</span><span class="p">(</span><span class="n">json</span><span class="p">,</span> <span class="s">"version"</span><span class="p">,</span> <span class="n">u</span><span class="p">.</span><span class="n">version</span><span class="p">);</span>
         1907         <span class="n">kore_json_create_string</span><span class="p">(</span><span class="n">json</span><span class="p">,</span> <span class="s">"machine"</span><span class="p">,</span> <span class="n">u</span><span class="p">.</span><span class="n">machine</span><span class="p">);</span>
         1908 
         1909         <span class="n">kore_json_item_tobuf</span><span class="p">(</span><span class="n">json</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">buf</span><span class="p">);</span>
         1910 
         1911         <span class="n">answer</span> <span class="o">=</span> <span class="n">kore_buf_stringify</span><span class="p">(</span><span class="o">&amp;</span><span class="n">buf</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>
         1912         <span class="n">http_response</span><span class="p">(</span><span class="n">req</span><span class="p">,</span> <span class="mi">200</span><span class="p">,</span> <span class="n">answer</span><span class="p">,</span> <span class="n">strlen</span><span class="p">(</span><span class="n">answer</span><span class="p">));</span>
         1913 
         1914         <span class="n">kore_buf_cleanup</span><span class="p">(</span><span class="o">&amp;</span><span class="n">buf</span><span class="p">);</span>
         1915         <span class="n">kore_json_item_free</span><span class="p">(</span><span class="n">json</span><span class="p">);</span>
         1916 
         1917         <span class="k">return</span> <span class="p">(</span><span class="n">KORE_RESULT_OK</span><span class="p">);</span>
         1918 <span class="p">}</span>
         1919 </code></pre></div></div>
         1920 
         1921 <p>And finally launch the project:</p>
         1922 
         1923 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>kodev run
         1924 </code></pre></div></div>
         1925 
         1926 <p>The kodev tool will build and run the project, and we can now query the
         1927 API to identify hosts:</p>
         1928 
         1929 <div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span>
         1930   <span class="dl">"</span><span class="s2">system</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">OpenBSD</span><span class="dl">"</span><span class="p">,</span>
         1931   <span class="dl">"</span><span class="s2">hostname</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">foo.my.domain</span><span class="dl">"</span><span class="p">,</span>
         1932   <span class="dl">"</span><span class="s2">release</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">6.8</span><span class="dl">"</span><span class="p">,</span>
         1933   <span class="dl">"</span><span class="s2">version</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">GENERIC.MP#56</span><span class="dl">"</span><span class="p">,</span>
         1934   <span class="dl">"</span><span class="s2">machine</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">amd64</span><span class="dl">"</span>
         1935 <span class="p">}</span>
         1936 </code></pre></div></div>
         1937 
         1938 ]]></content>
         1939                 <summary type="html">
         1940                         <![CDATA[A small API example allowing to identify hosts over the network]]>
         1941                 </summary>
         1942 
         1943                 <category term="C" scheme="https://www.cambus.net/categories/c"/>
         1944         </entry>
         1945         <entry>
         1946         <title><![CDATA[Modernizing the OpenBSD console]]></title>
         1947                 <link href="https://www.cambus.net/modernizing-the-openbsd-console/"/>
         1948                 <id>https://www.cambus.net/modernizing-the-openbsd-console/</id>
         1949                 <published>2020-08-31T18:30:00Z</published>
         1950                 <updated>2020-08-31T18:30:00Z</updated>
         1951                 <content type="html"><![CDATA[<p>At the beginning were text mode consoles. Traditionally, *BSD and Linux
         1952 on i386 and amd64 used text mode consoles which by default provided
         1953 25 rows of 80 columns, the "80x25 mode". This mode uses an 8x16 font stored
         1954 in the VGA BIOS (which can be slightly different across vendors).</p>
         1955 
         1956 <p>OpenBSD uses the <a href="https://man.openbsd.org/wscons.4">wscons(4)</a> console framework, inherited from NetBSD.</p>
         1957 
         1958 <p>CRT monitors allowed you to set the resolution you wanted, so on bigger
         1959 monitors, the 80x25 console in textmode was fairly large but not blurry.</p>
         1960 
         1961 <p>Framebuffer consoles allowed taking advantage of larger monitor sizes,
         1962 to fit more columns and rows. With the switch to LCD monitors, also in
         1963 part driven by the decreasing costs of laptops, the fixed size panels
         1964 became a problem as the text mode resolution needed to be stretched,
         1965 leading to distortion and blurriness.</p>
         1966 
         1967 <p>One thing some people might not realize is the huge discrepancy between text
         1968 mode and framebuffer consoles regarding the amount of data you have to
         1969 write to cover the whole screen. In text mode, we only need to write 2 bytes
         1970 per character: 1 byte for the ASCII code, and 1 byte for attributes.
         1971 So in 80x25 text mode, we only need to write 80 * 25 * 2 bytes of data, which
         1972 is 4000 bytes, and the VGA card itself takes care of plotting characters to
         1973 the screen. In framebuffer, however, to fill a 4K UHD-1 (3840x2160) screen in
         1974 32bpp mode we need to send 3840 * 2160 * 4 bytes of data, which is 33177600
         1975 bytes (approximately 33 MB).</p>
         1976 
         1977 <p>On framebuffer consoles, OpenBSD uses the <a href="https://man.openbsd.org/rasops.9">rasops(9)</a> subsystem (raster
         1978 operations), imported from NetBSD in <a href="https://www.freshbsd.org/commit/openbsd/src/852174bf9aa5778a6d6090ce1d027ed0e60a2dbf7fc52c1c199edec5ba10c84e">2001</a>.</p>
         1979 
         1980 <p>While they had been used for a while on platforms without VGA cards,
         1981 framebuffer consoles were only enabled on i386 and amd64 in 2013 for
         1982 <a href="https://undeadly.org/cgi?action=article;sid=20130320095845">inteldrm(4)</a> and <a href="https://undeadly.org/cgi?action=article&amp;sid=20130812135734">radeondrm(4)</a>.</p>
         1983 
         1984 <p>In recent years, rasops(9) itself and framebuffer drivers have seen some
         1985 improvements:</p>
         1986 
         1987 <p>General improvements:</p>
         1988 
         1989 <ul>
         1990   <li>Add and enable efifb(4), EFI framebuffer driver (yasuoka@, <a href="https://www.freshbsd.org/commit/openbsd/src/8KYmU15QlyhusRif">August 2015</a>)</li>
         1991   <li>Implement counter-clockwise rotation (kettenis@, <a href="https://www.freshbsd.org/commit/openbsd/src/7lXpZyid0vR5Zwgg">August 2017</a>)</li>
         1992   <li>Implement scrollback in rasops(9) (jcs@, <a href="https://www.freshbsd.org/commit/openbsd/src/4k1QM7ucOEgRO0xS">April 2018</a>)</li>
         1993 </ul>
         1994 
         1995 <p>Performance related improvements:</p>
         1996 
         1997 <ul>
         1998   <li>Make it possible to use RI_WRONLY during early boot (kettenis@, <a href="https://www.freshbsd.org/commit/openbsd/src/nhg8EbZxMSdby1MI">September 2015</a>)</li>
         1999   <li>Introduce rasops_wronly_do_cursor() (kettenis@, <a href="https://www.freshbsd.org/commit/openbsd/src/ExenUcaOW8RQY3dr">August 2018</a>)</li>
         2000   <li>Remap EFI framebuffer early to use write combining (kettenis@, <a href="https://www.freshbsd.org/commit/openbsd/src/Ae4pR5YcC6xC3IAd">September 2018</a>)</li>
         2001   <li>Do PAT setup earlier, so mapping the framebuffer WC actually works (kettenis@, <a href="https://www.freshbsd.org/commit/openbsd/src/qzoeIV2QzazYULCu">December 2018</a>)</li>
         2002   <li>Fast conditional console scrolling (John Carmack, <a href="https://www.freshbsd.org/commit/openbsd/src/j2VU0SiC2NWlZh8H">June 2020</a>)</li>
         2003   <li>Optimize character rendering in 32bpp mode (John Carmack, <a href="https://www.freshbsd.org/commit/openbsd/src/uGCoC9GtqHLpxgqD">June 2020</a>)</li>
         2004 </ul>
         2005 
         2006 <p>Console fonts improvements:</p>
         2007 
         2008 <ul>
         2009   <li>Add Spleen 5x8, targeted at small OLED displays (<a href="https://www.freshbsd.org/commit/openbsd/src/5raMrDMpYlPYW01H">September 2018</a>)</li>
         2010   <li>Add Spleen 8x16, 12x24, 16x32 and 32x64 (<a href="https://www.freshbsd.org/commit/openbsd/src/Ltxorb7qChpBzpvJ">December 2018</a>)</li>
         2011   <li>Enable Spleen in wsfont by default (<a href="https://www.freshbsd.org/commit/openbsd/src/MoBCxKiAlFajRvSm">January 2019</a>)</li>
         2012   <li>Add Spleen 6x12, targeted at OLED displays (<a href="https://www.freshbsd.org/commit/openbsd/src/oYEZPggDT3gWguRz">July 2020</a>)</li>
         2013 </ul>
         2014 
         2015 <p>There is an <a href="https://undeadly.org/cgi?action=article;sid=20190110064857">article about Spleen</a> in the OpenBSD Journal with more
         2016 information, notably on the font selection mechanism relative to screen
         2017 resolution.</p>
         2018 
         2019 <p>And work slowly continues to make framebuffer consoles more usable.</p>
         2020 
         2021 <p>It is interesting to note that while NetBSD has been adding a lot of
         2022 features to rasops(9) over the years, OpenBSD has taken a more conservative
         2023 approach. There is however one major feature that NetBSD currently has which
         2024 would be beneficial: the capability for <a href="https://www.freshbsd.org/commit/netbsd/src/cWWZcRPLH1VI82Sz">loading fonts of different metrics
         2025 and subsequently resizing screens</a>.</p>
         2026 
         2027 <p>Looking forward, the performance of various operations could likely still be
         2028 improved, possibly by leveraging the new OpenBSD dynamic tracing mechanism
         2029 to analyze bottlenecks.</p>
         2030 
         2031 <p>Another open question is UTF-8 support, Miod Vallat started work in this
         2032 direction back in <a href="https://undeadly.org/cgi?action=article;sid=20131023125815">2013</a> but there are still a few things missing.
         2033 I have plans to implement sparse font files support in the future, at
         2034 least so one can take advantage of box drawing and possibly block elements
         2035 characters.</p>
         2036 
         2037 <p>Lastly, a major pain point has been the lack of larger fonts in RAMDISK
         2038 kernels, making installations and upgrades very difficult and error-prone
         2039 on large DPI monitors as the text is basically unreadable. There is no
         2040 technical blocker to make this happen, which ironically makes it the most
         2041 difficult kind of issue to tackle.</p>
         2042 
         2043 ]]></content>
         2044                 <summary type="html">
         2045                         <![CDATA[Facts, directions, and thoughts regarding the evolution of OpenBSD framebuffer consoles]]>
         2046                 </summary>
         2047 
         2048                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         2049         </entry>
         2050         <entry>
         2051         <title><![CDATA[NetBSD on the NanoPi NEO2]]></title>
         2052                 <link href="https://www.cambus.net/netbsd-on-the-nanopi-neo2/"/>
         2053                 <id>https://www.cambus.net/netbsd-on-the-nanopi-neo2/</id>
         2054                 <published>2020-08-06T20:41:00Z</published>
         2055                 <updated>2020-08-06T20:41:00Z</updated>
         2056                 <content type="html"><![CDATA[<p>The <a href="https://linux-sunxi.org/FriendlyARM_NanoPi_NEO2">NanoPi NEO2</a> from FriendlyARM has been serving me well since 2018,
         2057 being my test machine for OpenBSD/arm64 related things.</p>
         2058 
         2059 <p>As NetBSD/evbarm finally gained support for AArch64 in NetBSD 9.0, released
         2060 back in February, I decided to give it a try on this device. The board only
         2061 has 512MB of RAM, and this is where NetBSD really shines. Things have become
         2062 a lot easier since jmcneill@ now provides <a href="https://www.armbsd.org/arm/">bootable ARM images</a> for a
         2063 variety of devices, including the NanoPi NEO2.</p>
         2064 
         2065 <p><img src="/content/2021/02/nanopi-neo2.jpg" alt="NanoPi NEO2" title="NanoPi NEO2" /></p>
         2066 
         2067 <p>On first boot, the system will resize the filesystem to automatically expand
         2068 to the size of the SD card.</p>
         2069 
         2070 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Growing ld0 MBR partition <span class="c">#1 (1052MB -&gt; 60810MB)</span>
         2071 Growing ld0 disklabel <span class="o">(</span>1148MB -&gt; 60906MB<span class="o">)</span>
         2072 Resizing /
         2073 /dev/rld0a: grow cg |<span class="k">************************************</span>                 |  69%
         2074 </code></pre></div></div>
         2075 
         2076 <p>Once the system is up and running, we can add a regular user in the
         2077 <em>wheel</em> group:</p>
         2078 
         2079 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>useradd <span class="nt">-m</span> <span class="nt">-G</span> wheel username
         2080 </code></pre></div></div>
         2081 
         2082 <p>And add a password to the newly created user:</p>
         2083 
         2084 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>passwd username
         2085 </code></pre></div></div>
         2086 
         2087 <p>From there we do not need the serial console anymore and can connect to
         2088 the device using SSH.</p>
         2089 
         2090 <p>NetBSD has binary packages available for this architecture, and installing
         2091 and configuring pkgin can be done as follow:</p>
         2092 
         2093 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">PKG_PATH</span><span class="o">=</span>https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/aarch64/9.0/All/
         2094 pkg_add pkgin
         2095 <span class="nb">echo</span> <span class="nv">$PKG_PATH</span> <span class="o">&gt;</span> /usr/pkg/etc/pkgin/repositories.conf
         2096 pkgin update
         2097 </code></pre></div></div>
         2098 
         2099 <p>The base system can be kept up to date using <a href="https://pkgsrc.se/sysutils/sysupgrade">sysupgrade</a>, which can be
         2100 installed via <strong>pkgin</strong>:</p>
         2101 
         2102 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pkgin <span class="k">in </span>sysupgrade
         2103 </code></pre></div></div>
         2104 
         2105 <p>The following variable need to be set in <em>/usr/pkg/etc/sysupgrade.conf</em>:</p>
         2106 
         2107 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">RELEASEDIR</span><span class="o">=</span><span class="s2">"https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-aarch64"</span>
         2108 </code></pre></div></div>
         2109 
         2110 <p>Lastly, the device has two user controllable LEDs which can be toggled
         2111 on and off using <strong>sysctl</strong>.</p>
         2112 
         2113 <p>To switch both LEDs on:</p>
         2114 
         2115 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sysctl <span class="nt">-w</span> hw.led.nanopi_green_pwr<span class="o">=</span>1
         2116 sysctl <span class="nt">-w</span> hw.led.nanopi_blue_status<span class="o">=</span>1
         2117 </code></pre></div></div>
         2118 
         2119 <p>To switch off the power LED automatically at boot time:</p>
         2120 
         2121 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">echo</span> <span class="s2">"hw.led.nanopi_green_pwr=0"</span> <span class="o">&gt;&gt;</span> /etc/sysctl.conf
         2122 </code></pre></div></div>
         2123 
         2124 <p>Here is a dmesg for reference purposes:</p>
         2125 
         2126 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>     1.000000] Copyright <span class="o">(</span>c<span class="o">)</span> 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
         2127 <span class="o">[</span>     1.000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
         2128 <span class="o">[</span>     1.000000]     2018, 2019, 2020 The NetBSD Foundation, Inc.  All rights reserved.
         2129 <span class="o">[</span>     1.000000] Copyright <span class="o">(</span>c<span class="o">)</span> 1982, 1986, 1989, 1991, 1993
         2130 <span class="o">[</span>     1.000000]     The Regents of the University of California.  All rights reserved.
         2131 
         2132 <span class="o">[</span>     1.000000] NetBSD 9.0_STABLE <span class="o">(</span>GENERIC64<span class="o">)</span> <span class="c">#0: Wed Aug  5 15:20:21 UTC 2020</span>
         2133 <span class="o">[</span>     1.000000]         mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbarm/compile/GENERIC64
         2134 <span class="o">[</span>     1.000000] total memory <span class="o">=</span> 497 MB
         2135 <span class="o">[</span>     1.000000] avail memory <span class="o">=</span> 479 MB
         2136 <span class="o">[</span>     1.000000] timecounter: Timecounters tick every 10.000 msec
         2137 <span class="o">[</span>     1.000000] armfdt0 <span class="o">(</span>root<span class="o">)</span>
         2138 <span class="o">[</span>     1.000000] simplebus0 at armfdt0: FriendlyARM NanoPi NEO 2
         2139 <span class="o">[</span>     1.000000] simplebus1 at simplebus0
         2140 <span class="o">[</span>     1.000000] simplebus2 at simplebus0
         2141 <span class="o">[</span>     1.000000] cpus0 at simplebus0
         2142 <span class="o">[</span>     1.000000] simplebus3 at simplebus0
         2143 <span class="o">[</span>     1.000000] psci0 at simplebus0: PSCI 1.1
         2144 <span class="o">[</span>     1.000000] cpu0 at cpus0: Cortex-A53 r0p4 <span class="o">(</span>Cortex V8-A core<span class="o">)</span>
         2145 <span class="o">[</span>     1.000000] cpu0: package 0, core 0, smt 0
         2146 <span class="o">[</span>     1.000000] cpu0: IC enabled, DC enabled, EL0/EL1 stack Alignment check enabled
         2147 <span class="o">[</span>     1.000000] cpu0: Cache Writeback Granule 16B, Exclusives Reservation Granule 16B
         2148 <span class="o">[</span>     1.000000] cpu0: Dcache line 64, Icache line 64
         2149 <span class="o">[</span>     1.000000] cpu0: L1 32KB/64B 2-way read-allocate VIPT Instruction cache
         2150 <span class="o">[</span>     1.000000] cpu0: L1 32KB/64B 4-way write-back read-allocate write-allocate PIPT Data cache
         2151 <span class="o">[</span>     1.000000] cpu0: L2 512KB/64B 16-way write-back read-allocate write-allocate PIPT Unified cache
         2152 <span class="o">[</span>     1.000000] cpu0: <span class="nv">revID</span><span class="o">=</span>0x180, PMCv3, 4k table, 64k table, 16bit ASID
         2153 <span class="o">[</span>     1.000000] cpu0: <span class="nv">auxID</span><span class="o">=</span>0x11120, FP, CRC32, SHA1, SHA256, AES+PMULL, NEON, rounding, NaN propagation, denormals, 32x64bitRegs, Fused Multiply-Add
         2154 <span class="o">[</span>     1.000000] cpu1 at cpus0: Cortex-A53 r0p4 <span class="o">(</span>Cortex V8-A core<span class="o">)</span>
         2155 <span class="o">[</span>     1.000000] cpu1: package 0, core 1, smt 0
         2156 <span class="o">[</span>     1.000000] cpu2 at cpus0: Cortex-A53 r0p4 <span class="o">(</span>Cortex V8-A core<span class="o">)</span>
         2157 <span class="o">[</span>     1.000000] cpu2: package 0, core 2, smt 0
         2158 <span class="o">[</span>     1.000000] cpu3 at cpus0: Cortex-A53 r0p4 <span class="o">(</span>Cortex V8-A core<span class="o">)</span>
         2159 <span class="o">[</span>     1.000000] cpu3: package 0, core 3, smt 0
         2160 <span class="o">[</span>     1.000000] gic0 at simplebus1: GIC
         2161 <span class="o">[</span>     1.000000] armgic0 at gic0: Generic Interrupt Controller, 224 sources <span class="o">(</span>215 valid<span class="o">)</span>
         2162 <span class="o">[</span>     1.000000] armgic0: 16 Priorities, 192 SPIs, 7 PPIs, 16 SGIs
         2163 <span class="o">[</span>     1.000000] fclock0 at simplebus2: 24000000 Hz fixed clock <span class="o">(</span>osc24M<span class="o">)</span>
         2164 <span class="o">[</span>     1.000000] sunxisramc0 at simplebus1: SRAM Controller
         2165 <span class="o">[</span>     1.000000] fclock1 at simplebus2: 32768 Hz fixed clock <span class="o">(</span>ext_osc32k<span class="o">)</span>
         2166 <span class="o">[</span>     1.000000] gtmr0 at simplebus0: Generic Timer
         2167 <span class="o">[</span>     1.000000] gtmr0: interrupting on GIC irq 27
         2168 <span class="o">[</span>     1.000000] armgtmr0 at gtmr0: Generic Timer <span class="o">(</span>24000 kHz, virtual<span class="o">)</span>
         2169 <span class="o">[</span>     1.000000] timecounter: Timecounter <span class="s2">"armgtmr0"</span> frequency 24000000 Hz quality 500
         2170 <span class="o">[</span>     1.000010] sun8ih3ccu0 at simplebus1: H3 CCU
         2171 <span class="o">[</span>     1.000010] sun8ih3rccu0 at simplebus1: H3 PRCM CCU
         2172 <span class="o">[</span>     1.000010] sunxide2ccu0 at simplebus1: DE2 CCU
         2173 <span class="o">[</span>     1.000010] sunxigpio0 at simplebus1: PIO
         2174 <span class="o">[</span>     1.000010] gpio0 at sunxigpio0: 94 pins
         2175 <span class="o">[</span>     1.000010] sunxigpio0: interrupting on GIC irq 43
         2176 <span class="o">[</span>     1.000010] sunxigpio1 at simplebus1: PIO
         2177 <span class="o">[</span>     1.000010] gpio1 at sunxigpio1: 12 pins
         2178 <span class="o">[</span>     1.000010] sunxigpio1: interrupting on GIC irq 77
         2179 <span class="o">[</span>     1.000010] fregulator0 at simplebus0: vcc3v3
         2180 <span class="o">[</span>     1.000010] fregulator1 at simplebus0: usb0-vbus
         2181 <span class="o">[</span>     1.000010] fregulator2 at simplebus0: gmac-3v3
         2182 <span class="o">[</span>     1.000010] sun6idma0 at simplebus1: DMA controller <span class="o">(</span>12 channels<span class="o">)</span>
         2183 <span class="o">[</span>     1.000010] sun6idma0: interrupting on GIC irq 82
         2184 <span class="o">[</span>     1.000010] com0 at simplebus1: ns16550a, working fifo
         2185 <span class="o">[</span>     1.000010] com0: console
         2186 <span class="o">[</span>     1.000010] com0: interrupting on GIC irq 32
         2187 <span class="o">[</span>     1.000010] sunxiusbphy0 at simplebus1: USB PHY
         2188 <span class="o">[</span>     1.000010] sunxihdmiphy0 at simplebus1: HDMI PHY
         2189 <span class="o">[</span>     1.000010] sunximixer0 at simplebus1: Display Engine Mixer
         2190 <span class="o">[</span>     1.000010] sunxilcdc0 at simplebus1: TCON1
         2191 <span class="o">[</span>     1.000010] sunxilcdc0: interrupting on GIC irq 118
         2192 <span class="o">[</span>     1.000010] sunxirtc0 at simplebus1: RTC
         2193 <span class="o">[</span>     1.000010] emac0 at simplebus1: EMAC
         2194 <span class="o">[</span>     1.000010] emac0: Ethernet address 02:01:f7:f9:2f:67
         2195 <span class="o">[</span>     1.000010] emac0: interrupting on GIC irq 114
         2196 <span class="o">[</span>     1.000010] rgephy0 at emac0 phy 7: RTL8211E 1000BASE-T media interface
         2197 <span class="o">[</span>     1.000010] rgephy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
         2198 <span class="o">[</span>     1.000010] h3codec0 at simplebus1: H3 Audio Codec <span class="o">(</span>analog part<span class="o">)</span>
         2199 <span class="o">[</span>     1.000010] sunximmc0 at simplebus1: SD/MMC controller
         2200 <span class="o">[</span>     1.000010] sunximmc0: interrupting on GIC irq 92
         2201 <span class="o">[</span>     1.000010] motg0 at simplebus1: <span class="s1">'otg'</span> mode not supported
         2202 <span class="o">[</span>     1.000010] ehci0 at simplebus1: EHCI
         2203 <span class="o">[</span>     1.000010] ehci0: interrupting on GIC irq 104
         2204 <span class="o">[</span>     1.000010] ehci0: EHCI version 1.0
         2205 <span class="o">[</span>     1.000010] ehci0: 1 companion controller, 1 port
         2206 <span class="o">[</span>     1.000010] usb0 at ehci0: USB revision 2.0
         2207 <span class="o">[</span>     1.000010] ohci0 at simplebus1: OHCI
         2208 <span class="o">[</span>     1.000010] ohci0: interrupting on GIC irq 105
         2209 <span class="o">[</span>     1.000010] ohci0: OHCI version 1.0
         2210 <span class="o">[</span>     1.000010] usb1 at ohci0: USB revision 1.0
         2211 <span class="o">[</span>     1.000010] ehci1 at simplebus1: EHCI
         2212 <span class="o">[</span>     1.000010] ehci1: interrupting on GIC irq 110
         2213 <span class="o">[</span>     1.000010] ehci1: EHCI version 1.0
         2214 <span class="o">[</span>     1.000010] ehci1: 1 companion controller, 1 port
         2215 <span class="o">[</span>     1.000010] usb2 at ehci1: USB revision 2.0
         2216 <span class="o">[</span>     1.000010] ohci1 at simplebus1: OHCI
         2217 <span class="o">[</span>     1.000010] ohci1: interrupting on GIC irq 111
         2218 <span class="o">[</span>     1.000010] ohci1: OHCI version 1.0
         2219 <span class="o">[</span>     1.000010] usb3 at ohci1: USB revision 1.0
         2220 <span class="o">[</span>     1.000010] sunxiwdt0 at simplebus1: Watchdog
         2221 <span class="o">[</span>     1.000010] sunxiwdt0: default watchdog period is 16 seconds
         2222 <span class="o">[</span>     1.000010] /soc/gpu@1e80000 at simplebus1 not configured
         2223 <span class="o">[</span>     1.000010] gpioleds0 at simplebus0: nanopi:green:pwr nanopi:blue:status
         2224 <span class="o">[</span>     1.000010] /soc/timer@1c20c00 at simplebus1 not configured
         2225 <span class="o">[</span>     1.000010] /soc/video-codec@1c0e000 at simplebus1 not configured
         2226 <span class="o">[</span>     1.000010] timecounter: Timecounter <span class="s2">"clockinterrupt"</span> frequency 100 Hz quality 0
         2227 <span class="o">[</span>     1.000010] cpu2: IC enabled, DC enabled, EL0/EL1 stack Alignment check enabled
         2228 <span class="o">[</span>     1.000010] cpu2: Cache Writeback Granule 16B, Exclusives Reservation Granule 16B
         2229 <span class="o">[</span>     1.040229] cpu2: Dcache line 64, Icache line 64
         2230 <span class="o">[</span>     1.040229] cpu2: L1 32KB/64B 2-way read-allocate VIPT Instruction cache
         2231 <span class="o">[</span>     1.050220] cpu2: L1 32KB/64B 4-way write-back read-allocate write-allocate PIPT Data cache
         2232 <span class="o">[</span>     1.060220] cpu2: L2 512KB/64B 16-way write-back read-allocate write-allocate PIPT Unified cache
         2233 <span class="o">[</span>     1.070220] cpu2: <span class="nv">revID</span><span class="o">=</span>0x180, PMCv3, 4k table, 64k table, 16bit ASID
         2234 <span class="o">[</span>     1.070220] cpu2: <span class="nv">auxID</span><span class="o">=</span>0x11120, FP, CRC32, SHA1, SHA256, AES+PMULL, NEON, rounding, NaN propagation, denormals, 32x64bitRegs, Fused Multiply-Add
         2235 <span class="o">[</span>     1.090221] cpu1: IC enabled, DC enabled, EL0/EL1 stack Alignment check enabled
         2236 <span class="o">[</span>     1.090221] cpu1: Cache Writeback Granule 16B, Exclusives Reservation Granule 16B
         2237 <span class="o">[</span>     1.100222] cpu1: Dcache line 64, Icache line 64
         2238 <span class="o">[</span>     1.110221] cpu1: L1 32KB/64B 2-way read-allocate VIPT Instruction cache
         2239 <span class="o">[</span>     1.110221] cpu1: L1 32KB/64B 4-way write-back read-allocate write-allocate PIPT Data cache
         2240 <span class="o">[</span>     1.120222] cpu1: L2 512KB/64B 16-way write-back read-allocate write-allocate PIPT Unified cache
         2241 <span class="o">[</span>     1.130222] cpu1: <span class="nv">revID</span><span class="o">=</span>0x180, PMCv3, 4k table, 64k table, 16bit ASID
         2242 <span class="o">[</span>     1.140223] cpu1: <span class="nv">auxID</span><span class="o">=</span>0x11120, FP, CRC32, SHA1, SHA256, AES+PMULL, NEON, rounding, NaN propagation, denormals, 32x64bitRegs, Fused Multiply-Add
         2243 <span class="o">[</span>     1.150222] cpu3: IC enabled, DC enabled, EL0/EL1 stack Alignment check enabled
         2244 <span class="o">[</span>     1.160223] cpu3: Cache Writeback Granule 16B, Exclusives Reservation Granule 16B
         2245 <span class="o">[</span>     1.160223] cpu3: Dcache line 64, Icache line 64
         2246 <span class="o">[</span>     1.170223] cpu3: L1 32KB/64B 2-way read-allocate VIPT Instruction cache
         2247 <span class="o">[</span>     1.180223] cpu3: L1 32KB/64B 4-way write-back read-allocate write-allocate PIPT Data cache
         2248 <span class="o">[</span>     1.180223] cpu3: L2 512KB/64B 16-way write-back read-allocate write-allocate PIPT Unified cache
         2249 <span class="o">[</span>     1.190223] cpu3: <span class="nv">revID</span><span class="o">=</span>0x180, PMCv3, 4k table, 64k table, 16bit ASID
         2250 <span class="o">[</span>     1.200224] cpu3: <span class="nv">auxID</span><span class="o">=</span>0x11120, FP, CRC32, SHA1, SHA256, AES+PMULL, NEON, rounding, NaN propagation, denormals, 32x64bitRegs, Fused Multiply-Add
         2251 <span class="o">[</span>     1.210224] sdmmc0 at sunximmc0
         2252 <span class="o">[</span>     1.240225] uhub0 at usb0: NetBSD <span class="o">(</span>0000<span class="o">)</span> EHCI root hub <span class="o">(</span>0000<span class="o">)</span>, class 9/0, rev 2.00/1.00, addr 1
         2253 <span class="o">[</span>     1.240225] uhub0: 1 port with 1 removable, self powered
         2254 <span class="o">[</span>     1.240225] uhub1 at usb2: NetBSD <span class="o">(</span>0000<span class="o">)</span> EHCI root hub <span class="o">(</span>0000<span class="o">)</span>, class 9/0, rev 2.00/1.00, addr 1
         2255 <span class="o">[</span>     1.250226] uhub1: 1 port with 1 removable, self powered
         2256 <span class="o">[</span>     1.250226] uhub2 at usb1: NetBSD <span class="o">(</span>0000<span class="o">)</span> OHCI root hub <span class="o">(</span>0000<span class="o">)</span>, class 9/0, rev 1.00/1.00, addr 1
         2257 <span class="o">[</span>     1.260226] uhub2: 1 port with 1 removable, self powered
         2258 <span class="o">[</span>     1.260226] uhub3 at usb3: NetBSD <span class="o">(</span>0000<span class="o">)</span> OHCI root hub <span class="o">(</span>0000<span class="o">)</span>, class 9/0, rev 1.00/1.00, addr 1
         2259 <span class="o">[</span>     1.275641] uhub3: 1 port with 1 removable, self powered
         2260 <span class="o">[</span>     1.275641] IPsec: Initialized Security Association Processing.
         2261 <span class="o">[</span>     1.350228] sdmmc0: SD card status: 4-bit, C10, U1, A1
         2262 <span class="o">[</span>     1.350228] ld0 at sdmmc0: &lt;0x03:0x5344:SC64G:0x80:0x0cd9141d:0x122&gt;
         2263 <span class="o">[</span>     1.360690] ld0: 60906 MB, 7764 cyl, 255 <span class="nb">head</span>, 63 sec, 512 bytes/sect x 124735488 sectors
         2264 <span class="o">[</span>     1.370228] ld0: 4-bit width, High-Speed/SDR25, 50.000 MHz
         2265 <span class="o">[</span>     1.990242] boot device: ld0
         2266 <span class="o">[</span>     1.990242] root on ld0a dumps on ld0b
         2267 <span class="o">[</span>     2.000243] root file system <span class="nb">type</span>: ffs
         2268 <span class="o">[</span>     2.010242] kern.module.path<span class="o">=</span>/stand/evbarm/9.0/modules
         2269 </code></pre></div></div>
         2270 
         2271 ]]></content>
         2272                 <summary type="html">
         2273                         <![CDATA[Some notes on installing and running NetBSD on the NanoPi NEO2, with detailed steps on how to create user accounts and install pkgin]]>
         2274                 </summary>
         2275 
         2276                 <category term="NetBSD" scheme="https://www.cambus.net/categories/netbsd"/>
         2277                 <category term="ARM" scheme="https://www.cambus.net/categories/arm"/>
         2278         </entry>
         2279         <entry>
         2280         <title><![CDATA[Viewing ANSI art in MS-DOS virtual machines]]></title>
         2281                 <link href="https://www.cambus.net/viewing-ansi-art-in-ms-dos-virtual-machines/"/>
         2282                 <id>https://www.cambus.net/viewing-ansi-art-in-ms-dos-virtual-machines/</id>
         2283                 <published>2020-06-19T16:28:00Z</published>
         2284                 <updated>2020-06-19T16:28:00Z</updated>
         2285                 <content type="html"><![CDATA[<p>I sometimes get reports about <a href="https://www.ansilove.org">Ansilove</a> rendering some artworks
         2286 differently than other ANSI art editors and viewers for modern platforms.</p>
         2287 
         2288 <p>Ansilove tries to be faithful to <a href="https://en.wikipedia.org/wiki/ANSI.SYS">ANSI.SYS</a> and MS-DOS based editors
         2289 and viewers rendering, as the vast majority of artworks were created
         2290 during the DOS era. Most of the time, using <strong>ACiDDraw</strong> and <strong>ACiD View</strong>
         2291 in <strong>DOSBox</strong> is enough, but when in doubt, it can be useful to verify how
         2292 ANSI.SYS rendered a particular piece.</p>
         2293 
         2294 <p>Once we have MS-DOS installed and working in a virtual machine, the
         2295 next step is accessing files within the VM. The easiest way to do so
         2296 is to create and use virtual floppy images to transfer files.</p>
         2297 
         2298 <p>On a Linux machine, one can use <strong>mkfs.msdos</strong> to create an empty floppy
         2299 image:</p>
         2300 
         2301 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mkfs.msdos <span class="nt">-C</span> floppy.img 1440
         2302 </code></pre></div></div>
         2303 
         2304 <p>The image can then be mounted on the host to copy the desired content,
         2305 then attached to the virtual machine.</p>
         2306 
         2307 <p>In the MS-DOS guest, we need to enable <strong>ANSI.SYS</strong> in CONFIG.SYS:</p>
         2308 
         2309 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">DEVICE</span><span class="o">=</span>C:<span class="se">\D</span>OS<span class="se">\A</span>NSI.SYS
         2310 </code></pre></div></div>
         2311 
         2312 <p>We can then render the files we want to verify:</p>
         2313 
         2314 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>A:
         2315 TYPE ANSI.ANS
         2316 </code></pre></div></div>
         2317 
         2318 <p>80x50 mode can be enabled this way:</p>
         2319 
         2320 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>MODE CON <span class="nv">COLS</span><span class="o">=</span>80 <span class="nv">LINES</span><span class="o">=</span>50
         2321 </code></pre></div></div>
         2322 
         2323 ]]></content>
         2324                 <summary type="html">
         2325                         <![CDATA[Some notes on creating virtual floppies and enabling ANSI.SYS in MS-DOS virtual machines]]>
         2326                 </summary>
         2327 
         2328                 <category term="Ansi Art" scheme="https://www.cambus.net/categories/ansi-art"/>
         2329                 <category term="DOS" scheme="https://www.cambus.net/categories/dos"/>
         2330         </entry>
         2331         <entry>
         2332         <title><![CDATA[OpenBSD framebuffer console and custom color palettes]]></title>
         2333                 <link href="https://www.cambus.net/openbsd-framebuffer-console-and-custom-color-palettes/"/>
         2334                 <id>https://www.cambus.net/openbsd-framebuffer-console-and-custom-color-palettes/</id>
         2335                 <published>2020-06-06T16:33:00Z</published>
         2336                 <updated>2020-06-06T16:33:00Z</updated>
         2337                 <content type="html"><![CDATA[<p>On framebuffer consoles, OpenBSD uses the <a href="https://man.openbsd.org/rasops.9">rasops(9)</a> subsystem, which was
         2338 imported from NetBSD in March 2001.</p>
         2339 
         2340 <p>The RGB values for the ANSI color palette in rasops have been chosen to
         2341 match the ones in Open Firmware, and are different from those in the VGA
         2342 text mode color palette.</p>
         2343 
         2344 <p>Rasops palette:</p>
         2345 
         2346 <p><img src="/content/2020/06/rasops-palette.png" alt="Rasops palette" /></p>
         2347 
         2348 <p>VGA text mode palette:</p>
         2349 
         2350 <p><img src="/content/2020/06/vga-palette.png" alt="VGA text mode palette" /></p>
         2351 
         2352 <p>As one can see, the difference is quite significant, and decades of exposure
         2353 to MS-DOS and Linux consoles makes it quite difficult to adapt to a different
         2354 palette.</p>
         2355 
         2356 <p>RGB values for the ANSI color palette are defined in <strong>sys/dev/rasops/rasops.c</strong>,
         2357 and here are the proper ones to use to match the VGA text mode palette:</p>
         2358 
         2359 <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#define        NORMAL_BLACK        0x000000
         2360 #define        NORMAL_RED        0xaa0000
         2361 #define        NORMAL_GREEN        0x00aa00
         2362 #define        NORMAL_BROWN        0xaa5500
         2363 #define        NORMAL_BLUE        0x0000aa
         2364 #define        NORMAL_MAGENTA        0xaa00aa
         2365 #define        NORMAL_CYAN        0x00aaaa
         2366 #define        NORMAL_WHITE        0xaaaaaa
         2367 </span>
         2368 <span class="cp">#define        HILITE_BLACK        0x555555
         2369 #define        HILITE_RED        0xff5555
         2370 #define        HILITE_GREEN        0x55ff55
         2371 #define        HILITE_BROWN        0xffff55
         2372 #define        HILITE_BLUE        0x5555ff
         2373 #define        HILITE_MAGENTA        0xff55ff
         2374 #define        HILITE_CYAN        0x55ffff
         2375 #define        HILITE_WHITE        0xffffff
         2376 </span></code></pre></div></div>
         2377 
         2378 <p>And here is a <a href="/files/openbsd/rasops-palette.diff">diff</a> doing just that, which I sent to tech@ back in
         2379 <a href="https://marc.info/?l=openbsd-tech&amp;m=148374502927423&amp;w=2">January 2017</a>.</p>
         2380 
         2381 <p><strong>EDIT:</strong> The enthusiasm around this article led me to make another <a href="https://marc.info/?l=openbsd-tech&amp;m=159412787807528&amp;w=2">try</a>,
         2382 which didn't fare any better.</p>
         2383 
         2384 ]]></content>
         2385                 <summary type="html">
         2386                         <![CDATA[Some notes on how Use proper RGB values for the ANSI color palette on OpenBSD framebuffer consoles]]>
         2387                 </summary>
         2388 
         2389                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         2390         </entry>
         2391         <entry>
         2392         <title><![CDATA[OpenBSD/armv7 on the CubieBoard2]]></title>
         2393                 <link href="https://www.cambus.net/openbsd-armv7-on-the-cubieboard2/"/>
         2394                 <id>https://www.cambus.net/openbsd-armv7-on-the-cubieboard2/</id>
         2395                 <published>2020-05-27T22:39:00Z</published>
         2396                 <updated>2020-05-27T22:39:00Z</updated>
         2397                 <content type="html"><![CDATA[<p>I bought the <a href="https://linux-sunxi.org/Cubietech_Cubieboard2">CubieBoard2</a> back in 2016 with the idea to run OpenBSD
         2398 on it, but because of various reliability issues with the onboard NIC,
         2399 it ended up <a href="/netbsd-on-the-cubieboard2/">running NetBSD</a> for a few weeks before ending up in a
         2400 drawer.</p>
         2401 
         2402 <p>Back in October, Mark Kettenis committed code to allow switching to the
         2403 framebuffer "glass" console in the bootloader on OpenBSD/armv7, making
         2404 it possible to install the system without using a serial cable.</p>
         2405 
         2406 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;&gt;</span> OpenBSD/armv7 BOOTARM 1.14
         2407 boot&gt; <span class="nb">set tty </span>fb0
         2408 switching console to fb0
         2409 </code></pre></div></div>
         2410 
         2411 <p>This prompted me to plug the board again, and having support for the
         2412 framebuffer console is a game changer. It also allows running Xenocara,
         2413 if that's your thing.</p>
         2414 
         2415 <p><img src="/content/2021/03/cubieboard2.jpg" alt="Cubieboard2" title="Cubieboard2" /></p>
         2416 
         2417 <p>Here is the output of running <em>file</em> on executables:</p>
         2418 
         2419 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ELF 32-bit LSB shared object, ARM, version 1
         2420 </code></pre></div></div>
         2421 
         2422 <p>And this is the result of the <strong>md5 -t</strong> benchmark:</p>
         2423 
         2424 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>MD5 <span class="nb">time </span>trial.  Processing 10000 10000-byte blocks...
         2425 Digest <span class="o">=</span> 52e5f9c9e6f656f3e1800dfa5579d089
         2426 Time   <span class="o">=</span> 1.340000 seconds
         2427 Speed  <span class="o">=</span> 74626865.671642 bytes/second
         2428 </code></pre></div></div>
         2429 
         2430 <p>For the record, LibreSSL speed benchmark results are available
         2431 <a href="/files/openbsd/openssl-speed-cubieboard2.txt">here</a>.</p>
         2432 
         2433 <p>System message buffer (dmesg output):</p>
         2434 
         2435 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>OpenBSD 6.7-current <span class="o">(</span>GENERIC<span class="o">)</span> <span class="c">#299: Sun May 24 18:25:45 MDT 2020</span>
         2436     deraadt@armv7.openbsd.org:/usr/src/sys/arch/armv7/compile/GENERIC
         2437 real mem  <span class="o">=</span> 964190208 <span class="o">(</span>919MB<span class="o">)</span>
         2438 avail mem <span class="o">=</span> 935088128 <span class="o">(</span>891MB<span class="o">)</span>
         2439 random: good seed from bootblocks
         2440 mainbus0 at root: Cubietech Cubieboard2
         2441 cpu0 at mainbus0 mpidr 0: ARM Cortex-A7 r0p4
         2442 cpu0: 32KB 32b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
         2443 cpu0: 256KB 64b/line 8-way L2 cache
         2444 cortex0 at mainbus0
         2445 psci0 at mainbus0: PSCI 0.0
         2446 sxiccmu0 at mainbus0
         2447 agtimer0 at mainbus0: tick rate 24000 KHz
         2448 simplebus0 at mainbus0: <span class="s2">"soc"</span>
         2449 sxiccmu1 at simplebus0
         2450 sxipio0 at simplebus0: 175 pins
         2451 sxirtc0 at simplebus0
         2452 sxisid0 at simplebus0
         2453 ampintc0 at simplebus0 nirq 160, ncpu 2: <span class="s2">"interrupt-controller"</span>
         2454 <span class="s2">"system-control"</span> at simplebus0 not configured
         2455 <span class="s2">"interrupt-controller"</span> at simplebus0 not configured
         2456 <span class="s2">"dma-controller"</span> at simplebus0 not configured
         2457 <span class="s2">"lcd-controller"</span> at simplebus0 not configured
         2458 <span class="s2">"lcd-controller"</span> at simplebus0 not configured
         2459 <span class="s2">"video-codec"</span> at simplebus0 not configured
         2460 sximmc0 at simplebus0
         2461 sdmmc0 at sximmc0: 4-bit, sd high-speed, mmc high-speed, dma
         2462 <span class="s2">"usb"</span> at simplebus0 not configured
         2463 <span class="s2">"phy"</span> at simplebus0 not configured
         2464 ehci0 at simplebus0
         2465 usb0 at ehci0: USB revision 2.0
         2466 uhub0 at usb0 configuration 1 interface 0 <span class="s2">"Generic EHCI root hub"</span> rev 2.00/1.00 addr 1
         2467 ohci0 at simplebus0: version 1.0
         2468 <span class="s2">"crypto-engine"</span> at simplebus0 not configured
         2469 <span class="s2">"hdmi"</span> at simplebus0 not configured
         2470 sxiahci0 at simplebus0: AHCI 1.1
         2471 scsibus0 at sxiahci0: 32 targets
         2472 ehci1 at simplebus0
         2473 usb1 at ehci1: USB revision 2.0
         2474 uhub1 at usb1 configuration 1 interface 0 <span class="s2">"Generic EHCI root hub"</span> rev 2.00/1.00 addr 1
         2475 ohci1 at simplebus0: version 1.0
         2476 <span class="s2">"timer"</span> at simplebus0 not configured
         2477 sxidog0 at simplebus0
         2478 <span class="s2">"ir"</span> at simplebus0 not configured
         2479 <span class="s2">"codec"</span> at simplebus0 not configured
         2480 sxits0 at simplebus0
         2481 com0 at simplebus0: ns16550, no working fifo
         2482 sxitwi0 at simplebus0
         2483 iic0 at sxitwi0
         2484 axppmic0 at iic0 addr 0x34: AXP209
         2485 sxitwi1 at simplebus0
         2486 iic1 at sxitwi1
         2487 <span class="s2">"gpu"</span> at simplebus0 not configured
         2488 dwge0 at simplebus0: address 02:0a:09:03:27:08
         2489 rlphy0 at dwge0 phy 1: RTL8201L 10/100 PHY, rev. 1
         2490 <span class="s2">"hstimer"</span> at simplebus0 not configured
         2491 <span class="s2">"display-frontend"</span> at simplebus0 not configured
         2492 <span class="s2">"display-frontend"</span> at simplebus0 not configured
         2493 <span class="s2">"display-backend"</span> at simplebus0 not configured
         2494 <span class="s2">"display-backend"</span> at simplebus0 not configured
         2495 gpio0 at sxipio0: 32 pins
         2496 gpio1 at sxipio0: 32 pins
         2497 gpio2 at sxipio0: 32 pins
         2498 gpio3 at sxipio0: 32 pins
         2499 gpio4 at sxipio0: 32 pins
         2500 gpio5 at sxipio0: 32 pins
         2501 gpio6 at sxipio0: 32 pins
         2502 gpio7 at sxipio0: 32 pins
         2503 gpio8 at sxipio0: 32 pins
         2504 usb2 at ohci0: USB revision 1.0
         2505 uhub2 at usb2 configuration 1 interface 0 <span class="s2">"Generic OHCI root hub"</span> rev 1.00/1.00 addr 1
         2506 usb3 at ohci1: USB revision 1.0
         2507 uhub3 at usb3 configuration 1 interface 0 <span class="s2">"Generic OHCI root hub"</span> rev 1.00/1.00 addr 1
         2508 simplefb0 at mainbus0: 1920x1080, 32bpp
         2509 wsdisplay0 at simplefb0 mux 1: console <span class="o">(</span>std, vt100 emulation<span class="o">)</span>
         2510 scsibus1 at sdmmc0: 2 targets, initiator 0
         2511 sd0 at scsibus1 targ 1 lun 0: &lt;SD/MMC, SC64G, 0080&gt; removable
         2512 sd0: 60906MB, 512 bytes/sector, 124735488 sectors
         2513 uhidev0 at uhub2 port 1 configuration 1 interface 0 <span class="s2">"Lenovo ThinkPad Compact USB Keyboard with TrackPoint"</span> rev 2.00/3.30 addr 2
         2514 uhidev0: iclass 3/1
         2515 ukbd0 at uhidev0: 8 variable keys, 6 key codes
         2516 wskbd0 at ukbd0: console keyboard, using wsdisplay0
         2517 uhidev1 at uhub2 port 1 configuration 1 interface 1 <span class="s2">"Lenovo ThinkPad Compact USB Keyboard with TrackPoint"</span> rev 2.00/3.30 addr 2
         2518 uhidev1: iclass 3/1, 22 report ids
         2519 ums0 at uhidev1 reportid 1: 5 buttons, Z and W <span class="nb">dir
         2520 </span>wsmouse0 at ums0 mux 0
         2521 uhid0 at uhidev1 reportid 16: <span class="nv">input</span><span class="o">=</span>2, <span class="nv">output</span><span class="o">=</span>0, <span class="nv">feature</span><span class="o">=</span>0
         2522 uhid1 at uhidev1 reportid 17: <span class="nv">input</span><span class="o">=</span>2, <span class="nv">output</span><span class="o">=</span>0, <span class="nv">feature</span><span class="o">=</span>0
         2523 uhid2 at uhidev1 reportid 19: <span class="nv">input</span><span class="o">=</span>8, <span class="nv">output</span><span class="o">=</span>8, <span class="nv">feature</span><span class="o">=</span>8
         2524 uhid3 at uhidev1 reportid 21: <span class="nv">input</span><span class="o">=</span>2, <span class="nv">output</span><span class="o">=</span>0, <span class="nv">feature</span><span class="o">=</span>0
         2525 uhid4 at uhidev1 reportid 22: <span class="nv">input</span><span class="o">=</span>2, <span class="nv">output</span><span class="o">=</span>0, <span class="nv">feature</span><span class="o">=</span>0
         2526 vscsi0 at root
         2527 scsibus2 at vscsi0: 256 targets
         2528 softraid0 at root
         2529 scsibus3 at softraid0: 256 targets
         2530 bootfile: sd0a:/bsd
         2531 boot device: sd0
         2532 root on sd0a <span class="o">(</span>f7b555b0fa0e8c49.a<span class="o">)</span> swap on sd0b dump on sd0b
         2533 </code></pre></div></div>
         2534 
         2535 <p>Sensors output:</p>
         2536 
         2537 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>sysctl hw.sensors
         2538 hw.sensors.sxits0.temp0<span class="o">=</span>39.50 degC
         2539 hw.sensors.axppmic0.temp0<span class="o">=</span>30.00 degC
         2540 hw.sensors.axppmic0.volt0<span class="o">=</span>4.95 VDC <span class="o">(</span>ACIN<span class="o">)</span>
         2541 hw.sensors.axppmic0.volt1<span class="o">=</span>0.03 VDC <span class="o">(</span>VBUS<span class="o">)</span>
         2542 hw.sensors.axppmic0.volt2<span class="o">=</span>4.85 VDC <span class="o">(</span>APS<span class="o">)</span>
         2543 hw.sensors.axppmic0.current0<span class="o">=</span>0.11 A <span class="o">(</span>ACIN<span class="o">)</span>
         2544 hw.sensors.axppmic0.current1<span class="o">=</span>0.00 A <span class="o">(</span>VBUS<span class="o">)</span>
         2545 hw.sensors.axppmic0.indicator0<span class="o">=</span>On <span class="o">(</span>ACIN<span class="o">)</span>, OK
         2546 hw.sensors.axppmic0.indicator1<span class="o">=</span>Off <span class="o">(</span>VBUS<span class="o">)</span>
         2547 </code></pre></div></div>
         2548 
         2549 ]]></content>
         2550                 <summary type="html">
         2551                         <![CDATA[Some notes on installing and running OpenBSD/armv7 on the CubieBoard2]]>
         2552                 </summary>
         2553 
         2554                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         2555                 <category term="ARM" scheme="https://www.cambus.net/categories/arm"/>
         2556         </entry>
         2557         <entry>
         2558         <title><![CDATA[Chinese BBSes and Unicode ANSi Art]]></title>
         2559                 <link href="https://www.cambus.net/chinese-bbses-and-unicode-ansi-art/"/>
         2560                 <id>https://www.cambus.net/chinese-bbses-and-unicode-ansi-art/</id>
         2561                 <published>2020-04-14T20:50:00Z</published>
         2562                 <updated>2020-04-14T20:50:00Z</updated>
         2563                 <content type="html"><![CDATA[<p>After doing my series on Taiwanese BBSes (<a href="/taiwanese-bbses-and-unicode-ansi-art/">first part</a>,
         2564 <a href="/taiwanese-bbses-and-unicode-ansi-art-part-ii/">second part</a>), I also took some
         2565 screenshots from two Chinese BBS systems, but only found those files
         2566 again recently.</p>
         2567 
         2568 <p>Those screens were captured in March 2013 and cover <strong>Lilac</strong> and <strong>NewSMTH</strong>
         2569 systems. While I could not find much English information about Lilac, which
         2570 seems to be located in Hong Kong, there is a Wikipedia page about
         2571 <a href="https://en.wikipedia.org/wiki/SMTH_BBS">SMTH</a> which appears to have had
         2572 a complicated history.</p>
         2573 
         2574 <p>Lilac Login Screen:</p>
         2575 
         2576 <p><img src="/content/2020/04/lilac-login.png" alt="Lilac" /></p>
         2577 
         2578 <p>Lilac Main Menu Screens:</p>
         2579 
         2580 <p><img src="/content/2020/04/lilac-mainmenu01.png" alt="Lilac" /></p>
         2581 
         2582 <p><img src="/content/2020/04/lilac-mainmenu02.png" alt="Lilac" /></p>
         2583 
         2584 <p>Lilac Goodbye Screens:</p>
         2585 
         2586 <p><img src="/content/2020/04/lilac-goodbye01.png" alt="Lilac" /></p>
         2587 
         2588 <p><img src="/content/2020/04/lilac-goodbye02.png" alt="Lilac" /></p>
         2589 
         2590 <p><img src="/content/2020/04/lilac-goodbye03.png" alt="Lilac" /></p>
         2591 
         2592 <p>NewSMTH Welcome Screens:</p>
         2593 
         2594 <p><img src="/content/2020/04/newsmth-welcome01.png" alt="NewSMTH" /></p>
         2595 
         2596 <p><img src="/content/2020/04/newsmth-welcome02.png" alt="NewSMTH" /></p>
         2597 
         2598 <p>NewSMTH Login Screen:</p>
         2599 
         2600 <p><img src="/content/2020/04/newsmth-login.png" alt="NewSMTH" /></p>
         2601 
         2602 <p>NewSMTH Main Menu Screens:</p>
         2603 
         2604 <p><img src="/content/2020/04/newsmth-mainmenu01.png" alt="NewSMTH" /></p>
         2605 
         2606 <p><img src="/content/2020/04/newsmth-mainmenu02.png" alt="NewSMTH" /></p>
         2607 
         2608 <p><img src="/content/2020/04/newsmth-mainmenu03.png" alt="NewSMTH" /></p>
         2609 
         2610 <p><img src="/content/2020/04/newsmth-mainmenu04.png" alt="NewSMTH" /></p>
         2611 
         2612 <p><img src="/content/2020/04/newsmth-mainmenu05.png" alt="NewSMTH" /></p>
         2613 
         2614 <p><img src="/content/2020/04/newsmth-mainmenu06.png" alt="NewSMTH" /></p>
         2615 
         2616 <p>NewSMTH Goodbye Screens:</p>
         2617 
         2618 <p><img src="/content/2020/04/newsmth-goodbye.png" alt="NewSMTH" /></p>
         2619 ]]></content>
         2620                 <summary type="html">
         2621                         <![CDATA[ANSI screens from Chinese BBSes]]>
         2622                 </summary>
         2623 
         2624                 <category term="Ansi Art" scheme="https://www.cambus.net/categories/ansi-art"/>
         2625         </entry>
         2626         <entry>
         2627         <title><![CDATA[My OpenBSD commits]]></title>
         2628                 <link href="https://www.cambus.net/my-openbsd-commits/"/>
         2629                 <id>https://www.cambus.net/my-openbsd-commits/</id>
         2630                 <published>2019-08-31T17:45:00Z</published>
         2631                 <updated>2019-08-31T17:45:00Z</updated>
         2632                 <content type="html"><![CDATA[<p>Today marks my three year anniversary as an OpenBSD developer. I got my
         2633 commit bit on August 31th 2016 during the g2k16 hackathon in Cambridge, UK.</p>
         2634 
         2635 <p>A few months ago, I came across a Perl <a href="https://gist.github.com/bessarabov/674ea13c77fc8128f24b5e3f53b7f094">one-liner script</a> to produce
         2636 commit time distribution ASCII graphs from a Git repository, and I finally
         2637 have a good pretext to run it :-)</p>
         2638 
         2639 <p>As of this day, I have done 749 commits to OpenBSD, in the following
         2640 repositories: src (<a href="https://www.freshbsd.org/search?project=openbsd&amp;committer=fcambus&amp;repository=src">127</a>), ports(<a href="https://www.freshbsd.org/search?project=openbsd&amp;committer=fcambus&amp;repository=ports">596</a>), www (24), and xenocara (<a href="https://www.freshbsd.org/search?project=openbsd&amp;committer=fcambus&amp;repository=xenocara">2</a>).</p>
         2641 
         2642 <p>Commits in the src repository:</p>
         2643 
         2644 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>00 -    0
         2645 01 -    0
         2646 02 -    0
         2647 03 -    0
         2648 04 -    0
         2649 05 -    0
         2650 06 -    1 <span class="k">***</span>
         2651 07 -    4 <span class="k">**************</span>
         2652 08 -    8 <span class="k">****************************</span>
         2653 09 -    9 <span class="k">********************************</span>
         2654 10 -   13 <span class="k">**********************************************</span>
         2655 11 -    9 <span class="k">********************************</span>
         2656 12 -   10 <span class="k">***********************************</span>
         2657 13 -   11 <span class="k">***************************************</span>
         2658 14 -   13 <span class="k">**********************************************</span>
         2659 15 -    4 <span class="k">**************</span>
         2660 16 -    5 <span class="k">*****************</span>
         2661 17 -    6 <span class="k">*********************</span>
         2662 18 -    4 <span class="k">**************</span>
         2663 19 -    9 <span class="k">********************************</span>
         2664 20 -   14 <span class="k">**************************************************</span>
         2665 21 -    4 <span class="k">**************</span>
         2666 22 -    3 <span class="k">**********</span>
         2667 23 -    0
         2668 </code></pre></div></div>
         2669 
         2670 <p>Commits in the ports repository:</p>
         2671 
         2672 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>00 -    1
         2673 01 -    0
         2674 02 -    0
         2675 03 -    0
         2676 04 -    0
         2677 05 -    2 <span class="k">*</span>
         2678 06 -   14 <span class="k">**********</span>
         2679 07 -   32 <span class="k">***********************</span>
         2680 08 -   34 <span class="k">*************************</span>
         2681 09 -   67 <span class="k">**************************************************</span>
         2682 10 -   46 <span class="k">**********************************</span>
         2683 11 -   53 <span class="k">***************************************</span>
         2684 12 -   40 <span class="k">*****************************</span>
         2685 13 -   38 <span class="k">****************************</span>
         2686 14 -   34 <span class="k">*************************</span>
         2687 15 -   34 <span class="k">*************************</span>
         2688 16 -   35 <span class="k">**************************</span>
         2689 17 -   20 <span class="k">**************</span>
         2690 18 -   15 <span class="k">***********</span>
         2691 19 -   24 <span class="k">*****************</span>
         2692 20 -   34 <span class="k">*************************</span>
         2693 21 -   43 <span class="k">********************************</span>
         2694 22 -   19 <span class="k">**************</span>
         2695 23 -   11 <span class="k">********</span>
         2696 </code></pre></div></div>
         2697 
         2698 <p>Commits in the www repository:</p>
         2699 
         2700 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>00 -    0
         2701 01 -    0
         2702 02 -    0
         2703 03 -    0
         2704 04 -    0
         2705 05 -    0
         2706 06 -    0
         2707 07 -    1 <span class="k">************</span>
         2708 08 -    0
         2709 09 -    3 <span class="k">*************************************</span>
         2710 10 -    2 <span class="k">*************************</span>
         2711 11 -    4 <span class="k">**************************************************</span>
         2712 12 -    0
         2713 13 -    2 <span class="k">*************************</span>
         2714 14 -    1 <span class="k">************</span>
         2715 15 -    1 <span class="k">************</span>
         2716 16 -    1 <span class="k">************</span>
         2717 17 -    1 <span class="k">************</span>
         2718 18 -    1 <span class="k">************</span>
         2719 19 -    3 <span class="k">*************************************</span>
         2720 20 -    3 <span class="k">*************************************</span>
         2721 21 -    1 <span class="k">************</span>
         2722 22 -    0
         2723 23 -    0
         2724 </code></pre></div></div>
         2725 
         2726 <p>Commits in the xenocara repository:</p>
         2727 
         2728 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>00 -    0
         2729 01 -    0
         2730 02 -    0
         2731 03 -    0
         2732 04 -    0
         2733 05 -    0
         2734 06 -    0
         2735 07 -    0
         2736 08 -    0
         2737 09 -    0
         2738 10 -    0
         2739 11 -    0
         2740 12 -    0
         2741 13 -    0
         2742 14 -    1 <span class="k">**************************************************</span>
         2743 15 -    0
         2744 16 -    0
         2745 17 -    0
         2746 18 -    0
         2747 19 -    0
         2748 20 -    0
         2749 21 -    1 <span class="k">**************************************************</span>
         2750 22 -    0
         2751 23 -    0
         2752 </code></pre></div></div>
         2753 
         2754 ]]></content>
         2755                 <summary type="html">
         2756                         <![CDATA[My OpenBSD commits time distribution ASCII graphs]]>
         2757                 </summary>
         2758 
         2759                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         2760         </entry>
         2761         <entry>
         2762         <title><![CDATA[Fuzzing DNS zone parsers]]></title>
         2763                 <link href="https://www.cambus.net/fuzzing-dns-zone-parsers/"/>
         2764                 <id>https://www.cambus.net/fuzzing-dns-zone-parsers/</id>
         2765                 <published>2019-07-11T13:00:00Z</published>
         2766                 <updated>2019-07-11T13:00:00Z</updated>
         2767                 <content type="html"><![CDATA[<p>In my never-ending quest to improve the quality of my C codebases, I've been
         2768 using AFL to fuzz <a href="https://github.com/fcambus/statzone">statzone</a>, the zone parser I use to generate monthly
         2769 statistics on <a href="https://www.statdns.com">StatDNS</a>. It helped me to find and fix a NULL pointer
         2770 dereference.</p>
         2771 
         2772 <p>I initially used the <strong>.arpa</strong> zone file as input, but then remembered that
         2773 OpenDNSSEC bundles a <a href="https://raw.githubusercontent.com/opendnssec/testing/master/zonedatatest/all.rr.org">special zone</a> for testing purposes, containing a
         2774 lot of seldom used resource records types, and decided to use this one too.</p>
         2775 
         2776 <p>Out of curiosity, I decided to try fuzzing other DNS zone parsers. I started
         2777 with validns 0.8, and within seconds the fuzzer found <a href="https://github.com/tobez/validns/issues/73">multiple NULL pointer
         2778 dereferences</a>.</p>
         2779 
         2780 <p><img src="/content/2019/07/validns.png" alt="validns" /></p>
         2781 
         2782 <p>The first occurrence happens in the name2findable_name() function, and can be
         2783 triggered with the following input:</p>
         2784 
         2785 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>arpa                    86400   IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2019021500 1800 900 604800 86400
         2786 arpa.                   86400   IN      RRSIG   SOA 8 1 86400 20190228000000 20190214230000 49906 arpa. Qot7qHAA2QhNmAz3oJUIGmxGJrKnWsIzEvZ92R+LV03K7YTFozio2U7Z534RZBhc0UJvlF1YenrbM6ugmF0z55CJD9JY7cFicalFPOkIuWslSl62vuIWHLwN5sA7VZ0ooVN2ptQpPHDa3W/9OPJRF0YqjBBBwD7IiL7V560rbXM<span class="o">=</span>
         2787 </code></pre></div></div>
         2788 
         2789 <p>With the above input, the following call to strlen(3) in rr.c results in a
         2790 NULL pointer dereference because 's' ends up being NULL:</p>
         2791 
         2792 <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">static</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="nf">name2findable_name</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span><span class="n">s</span><span class="p">)</span>
         2793 <span class="p">{</span>
         2794     <span class="kt">int</span> <span class="n">l</span> <span class="o">=</span> <span class="n">strlen</span><span class="p">(</span><span class="n">s</span><span class="p">);</span>
         2795 </code></pre></div></div>
         2796 
         2797 <p>The second occurrence happens in the nsec_validate_pass2() function, and can
         2798 be triggered with the following input:</p>
         2799 
         2800 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>arpa.                   86400   IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2019021500 1800 900 604800 86400
         2801 arpa.                   86400   IN      NSEC    a
         2802 </code></pre></div></div>
         2803 
         2804 <p>With the above input, the following call to strcasecmp(3) in rr.c results
         2805 in a NULL pointer dereference because 'rr-&gt;next_domain' ends up being NULL:</p>
         2806 
         2807 <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="p">(</span><span class="n">strcasecmp</span><span class="p">(</span><span class="n">rr</span><span class="o">-&gt;</span><span class="n">next_domain</span><span class="p">,</span> <span class="n">zone_apex</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
         2808 </code></pre></div></div>
         2809 
         2810 <p>Given those encouraging results, I went on to fuzz BIND, NSD and Knot
         2811 zone parsers, using their zone validation tools <strong>named-checkzone</strong>,
         2812 <strong>nsd-checkzone</strong>, and <strong>kzonecheck</strong> respectively.</p>
         2813 
         2814 <p>While the fuzzers didn't produce any crash for BIND and Knot after running
         2815 for 3 days and 11 hours, they did produce some valid ones for NSD, and I
         2816 decided to continue on <strong>nsd-checkzone</strong> and stop the other fuzzers.</p>
         2817 
         2818 <p><img src="/content/2019/07/nsd-checkzone01.png" alt="nsd-checkzone" /></p>
         2819 
         2820 <p>I let AFL complete one cycle, and as I didn't need the box for anything else
         2821 at this time, I decided to let it run for a few more days. I ended the process
         2822 after 16 days and 19 hours, completing 2 cycles with 167 unique crashes.</p>
         2823 
         2824 <p><img src="/content/2019/07/nsd-checkzone02.png" alt="nsd-checkzone" /></p>
         2825 
         2826 <p>After sorting and analyzing the crashes, I had two valid issues to report.</p>
         2827 
         2828 <p>The first one is an <a href="https://github.com/NLnetLabs/nsd/issues/19">out-of-bounds read</a> caused by improper validation
         2829 of array index, in the rdata_maximum_wireformat_size() function, in rdata.c.</p>
         2830 
         2831 <p>The second one is a <a href="https://github.com/NLnetLabs/nsd/issues/20">stack-based buffer overflow</a> in the dname_concatenate()
         2832 function in dname.c, which got assigned <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-13207">CVE-2019-13207</a>.</p>
         2833 
         2834 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">=================================================================</span>
         2835 <span class="o">==</span><span class="nv">7395</span><span class="o">==</span>ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffcd6a9763f at pc 0x0000004dadbc bp 0x7ffcd6a97510 sp 0x7ffcd6a96cc0
         2836 WRITE of size 8 at 0x7ffcd6a9763f thread T0
         2837     <span class="c">#0 0x4dadbb in __asan_memcpy (/home/fcambus/nsd/nsd-checkzone+0x4dadbb)</span>
         2838     <span class="c">#1 0x534251 in dname_concatenate /home/fcambus/nsd/dname.c:464:2</span>
         2839     <span class="c">#2 0x69e61f in yyparse /home/fcambus/nsd/./zparser.y:1024:12</span>
         2840     <span class="c">#3 0x689fd1 in zonec_read /home/fcambus/nsd/zonec.c:1623:2</span>
         2841     <span class="c">#4 0x6aedd1 in check_zone /home/fcambus/nsd/nsd-checkzone.c:61:11</span>
         2842     <span class="c">#5 0x6aea07 in main /home/fcambus/nsd/nsd-checkzone.c:127:2</span>
         2843     <span class="c">#6 0x7fa60ece6b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310</span>
         2844     <span class="c">#7 0x41c1d9 in _start (/home/fcambus/nsd/nsd-checkzone+0x41c1d9)</span>
         2845 
         2846 Address 0x7ffcd6a9763f is located <span class="k">in </span>stack of thread T0 at offset 287 <span class="k">in </span>frame
         2847     <span class="c">#0 0x533f8f in dname_concatenate /home/fcambus/nsd/dname.c:458</span>
         2848 
         2849   This frame has 1 object<span class="o">(</span>s<span class="o">)</span>:
         2850     <span class="o">[</span>32, 287<span class="o">)</span> <span class="s1">'temp'</span> <span class="o">(</span>line 459<span class="o">)</span> &lt;<span class="o">==</span> Memory access at offset 287 overflows this variable
         2851 HINT: this may be a <span class="nb">false </span>positive <span class="k">if </span>your program uses some custom stack unwind mechanism or swapcontext
         2852       <span class="o">(</span>longjmp and C++ exceptions <span class="k">*</span>are<span class="k">*</span> supported<span class="o">)</span>
         2853 SUMMARY: AddressSanitizer: stack-buffer-overflow <span class="o">(</span>/home/fcambus/nsd/nsd-checkzone+0x4dadbb<span class="o">)</span> <span class="k">in </span>__asan_memcpy
         2854 Shadow bytes around the buggy address:
         2855   0x10001ad4ae70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2856   0x10001ad4ae80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2857   0x10001ad4ae90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2858   0x10001ad4aea0: 00 00 00 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00
         2859   0x10001ad4aeb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2860 <span class="o">=&gt;</span>0x10001ad4aec0: 00 00 00 00 00 00 00[07]f3 f3 f3 f3 f3 f3 f3 f3
         2861   0x10001ad4aed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2862   0x10001ad4aee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2863   0x10001ad4aef0: 00 00 00 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00
         2864   0x10001ad4af00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2865   0x10001ad4af10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         2866 Shadow byte legend <span class="o">(</span>one shadow byte represents 8 application bytes<span class="o">)</span>:
         2867   Addressable:           00
         2868   Partially addressable: 01 02 03 04 05 06 07 
         2869   Heap left redzone:       fa
         2870   Freed heap region:       fd
         2871   Stack left redzone:      f1
         2872   Stack mid redzone:       f2
         2873   Stack right redzone:     f3
         2874   Stack after <span class="k">return</span>:      f5
         2875   Stack use after scope:   f8
         2876   Global redzone:          f9
         2877   Global init order:       f6
         2878   Poisoned by user:        f7
         2879   Container overflow:      <span class="nb">fc
         2880   </span>Array cookie:            ac
         2881   Intra object redzone:    bb
         2882   ASan internal:           fe
         2883   Left alloca redzone:     ca
         2884   Right alloca redzone:    cb
         2885 <span class="o">==</span><span class="nv">7395</span><span class="o">==</span>ABORTING
         2886 </code></pre></div></div>
         2887 
         2888 <p>Both issues have been fixed and will be part of the <a href="https://www.nlnetlabs.nl/news/2019/Aug/19/nsd-4.2.2-released/">NSD 4.2.2</a> release.</p>
         2889 
         2890 <p>I also fuzzed ldns using <strong>ldns-read-zone</strong> for 12 days and 7 hours but
         2891 the only crashes it produced were in fact only triggering assertions.</p>
         2892 
         2893 <p>It's been an interesting journey so far, and while finding issues is still
         2894 relatively easy, time required to sort crashes and distinguish between valid,
         2895 duplicates, and false positives takes a lot of time. Nonetheless, reading 3rd
         2896 party source code and analyzing what is going on and why the program crashes
         2897 is both very instructing and rewarding.</p>
         2898 
         2899 <p>For the time being, I plan to continue fuzzing stuff and will write more
         2900 about my findings.</p>
         2901 
         2902 ]]></content>
         2903                 <summary type="html">
         2904                         <![CDATA[Reflections on fuzzing several DNS zone parsers with American Fuzzy Lop]]>
         2905                 </summary>
         2906 
         2907                 <category term="DNS" scheme="https://www.cambus.net/categories/dns"/>
         2908                 <category term="Security" scheme="https://www.cambus.net/categories/security"/>
         2909         </entry>
         2910         <entry>
         2911         <title><![CDATA[Running a free public API, a post-mortem]]></title>
         2912                 <link href="https://www.cambus.net/running-a-free-public-api-a-post-mortem/"/>
         2913                 <id>https://www.cambus.net/running-a-free-public-api-a-post-mortem/</id>
         2914                 <published>2018-11-30T22:29:00Z</published>
         2915                 <updated>2018-11-30T22:29:00Z</updated>
         2916                 <content type="html"><![CDATA[<p>It's been a little bit more than three years since Telize public API was
         2917 permanently shut down on November 15th, 2015. I have previously written
         2918 about the <a href="https://www.cambus.net/adventures-in-running-a-free-public-api/">adventure</a> itself, and about the <a href="https://www.cambus.net/decommissioning-a-free-public-api/">decommissioning</a> of
         2919 the API.</p>
         2920 
         2921 <p>Before shutting down the public API of <a href="https://www.telize.com/">Telize</a>, a paid version was
         2922 launched on Mashape to ease the transition for those who couldn't host their
         2923 own instances. The Mashape API Marketplace became a part of RapidAPI last
         2924 year, the service is still running and will keep doing so for the foreseeable
         2925 future. You can support my work on Telize by <a href="https://rapidapi.com/fcambus/api/telize">subscribing</a> to the service.</p>
         2926 
         2927 <p>While a small fraction of the userbase switched to the paid API, the vast
         2928 majority didn't, and the number of requests exploded due to retries, as
         2929 detailed in the article about the API decommission. One thing I wondered
         2930 at the time was how long it would take for the traffic to become negligible.
         2931 The Internet is a very strange place and things can go unnoticed for a very
         2932 long time, years sometimes. Of course, Telize case is no exception.</p>
         2933 
         2934 <p>Every year since the public API was closed down, I've been logging requests
         2935 for a few days in a row to get a glimpse of how many of them were still being
         2936 made. While the number of unique IP addresses querying the API kept decreasing,
         2937 the amount of requests themselves went up again compared to last year.</p>
         2938 
         2939 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>2016-11-06 - Requests: 51,896,923 - Unique IPs: 2,543,814
         2940 2016-11-07 - Requests: 56,427,258 - Unique IPs: 2,756,065
         2941 2016-11-08 - Requests: 53,641,121 - Unique IPs: 2,746,005
         2942 2016-11-09 - Requests: 53,704,140 - Unique IPs: 2,536,632
         2943 2016-11-10 - Requests: 53,194,946 - Unique IPs: 2,525,167
         2944 2016-11-11 - Requests: 50,444,003 - Unique IPs: 2,652,730
         2945 2016-11-12 - Requests: 49,224,863 - Unique IPs: 2,670,926
         2946 2016-11-13 - Requests: 48,526,303 - Unique IPs: 2,492,765
         2947 2017-11-10 - Requests: 35,325,037 - Unique IPs: 1,736,815
         2948 2017-11-11 - Requests: 33,582,167 - Unique IPs: 1,613,161
         2949 2017-11-12 - Requests: 33,334,836 - Unique IPs: 1,587,549
         2950 2017-11-13 - Requests: 36,131,909 - Unique IPs: 1,593,255
         2951 2017-11-14 - Requests: 34,457,433 - Unique IPs: 1,571,144
         2952 2017-11-15 - Requests: 33,225,149 - Unique IPs: 1,563,845
         2953 2018-11-12 - Requests: 50,612,559 - Unique IPs:   611,302
         2954 2018-11-13 - Requests: 50,858,236 - Unique IPs:   640,836
         2955 2018-11-14 - Requests: 51,991,454 - Unique IPs:   661,410
         2956 2018-11-15 - Requests: 53,008,712 - Unique IPs:   689,646
         2957 2018-11-16 - Requests: 51,651,814 - Unique IPs:   686,646
         2958 2018-11-17 - Requests: 49,236,779 - Unique IPs:   662,717
         2959 2018-11-18 - Requests: 47,237,596 - Unique IPs:   692,718
         2960 2018-11-19 - Requests: 51,679,888 - Unique IPs:   735,396
         2961 2018-11-20 - Requests: 50,245,134 - Unique IPs:   755,177
         2962 2018-11-21 - Requests: 50,745,725 - Unique IPs:   773,949
         2963 2018-11-22 - Requests: 50,609,750 - Unique IPs:   786,963
         2964 2018-11-23 - Requests: 49,991,775 - Unique IPs:   687,652
         2965 2018-11-24 - Requests: 47,479,703 - Unique IPs:   584,058
         2966 2018-11-25 - Requests: 47,346,829 - Unique IPs:   597,153
         2967 </code></pre></div></div>
         2968 
         2969 <p>Bandwidth usage, measured with nload:</p>
         2970 
         2971 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Incoming:
         2972 
         2973 
         2974 
         2975 
         2976 
         2977 
         2978                                                                     Curr: 2.44 MBit/s
         2979                                                                     Avg: 2.08 MBit/s
         2980   <span class="nb">.</span>  ....        ...  <span class="nb">.</span>     ...   ......  ...     ..           ...  Min: 1.76 MBit/s
         2981 <span class="c">#########################|######################|#################  Max: 2.70 MBit/s</span>
         2982 <span class="c">##################################################################  Ttl: 2217.35 GByte</span>
         2983 Outgoing:
         2984 
         2985 
         2986 
         2987 
         2988 
         2989 
         2990                                                                     Curr: 1.22 MBit/s
         2991                                                                     Avg: 1.07 MBit/s
         2992                                                                     Min: 904.10 kBit/s
         2993      ....                   ..                                   <span class="nb">.</span>  Max: 1.45 MBit/s
         2994 <span class="c">################################################|#################  Ttl: 1111.68 GByte</span>
         2995 </code></pre></div></div>
         2996 
         2997 <p>So more than 3 years after the decommission, I'm still getting around 50
         2998 millions daily requests. I'm honestly quite astonished to notice that the
         2999 numbers went up again significantly this year.</p>
         3000 
         3001 <p>Below is a report of user agents which performed more than 1M daily requests
         3002 on November 12th 2018, top offenders being Android applications and Wordpress
         3003 sites… How surprising.</p>
         3004 
         3005 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Apache-HttpClient/UNAVAILABLE                  24,729,923
         3006 Dalvik/2.1.0                                    1,113,530
         3007 WordPress/4.2.21                                3,200,750
         3008 WordPress/4.1.24                                2,223,350
         3009 WordPress/4.3.17                                1,212,849
         3010 </code></pre></div></div>
         3011 
         3012 <p>On a more positive note, those are recent Wordpress releases, which means
         3013 it might be possible to identify the plugins performing those requests
         3014 and contact their authors.</p>
         3015 
         3016 <p>Regarding the open source project itself, I released <a href="https://github.com/fcambus/telize/releases/tag/2.0.0">2.0.0</a> back in March,
         3017 which is now using GeoIP2/GeoLite2 databases, as GeoIP/GeoLite databases have
         3018 been <a href="https://support.maxmind.com/geolite-legacy-discontinuation-notice/">deprecated</a> since April. I'm currently working on a rewrite in C
         3019 using <a href="https://kore.io">Kore</a>, which will bring in a couple of improvements compared to
         3020 the current version. I will write about the new iteration in a following post.</p>
         3021 
         3022 ]]></content>
         3023                 <summary type="html">
         3024                         <![CDATA[Deprecating Telize free public API, an update after three years]]>
         3025                 </summary>
         3026 
         3027                 <category term="Miscellaneous" scheme="https://www.cambus.net/categories/miscellaneous"/>
         3028         </entry>
         3029         <entry>
         3030         <title><![CDATA[OpenBSD/arm64 on the NanoPi NEO2]]></title>
         3031                 <link href="https://www.cambus.net/openbsd-arm64-on-the-nanopi-neo2/"/>
         3032                 <id>https://www.cambus.net/openbsd-arm64-on-the-nanopi-neo2/</id>
         3033                 <published>2018-11-13T11:20:00Z</published>
         3034                 <updated>2018-11-13T11:20:00Z</updated>
         3035                 <content type="html"><![CDATA[<p>I bought the <a href="http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO2">NanoPi NEO2</a> solely for it's form-factor, and I haven't
         3036 been disappointed. It's a cute little board (40*40mm), which is to the best
         3037 of my knowledge the smallest possible device one can run OpenBSD on.</p>
         3038 
         3039 <p><img src="/content/2021/02/nanopi-neo2.jpg" alt="NanoPi NEO2" title="NanoPi NEO2" /></p>
         3040 
         3041 <p>The CPU is a quad-core <strong>ARM Cortex-A53</strong> which is quite capable, a
         3042 GENERIC.MP kernel build taking 15 minutes. On the downside, the board only
         3043 has 512MB of RAM.</p>
         3044 
         3045 <p>An USB to TTL serial cable is required to <a href="http://wiki.friendlyarm.com/wiki/index.php/File:NEO2_DBG_UART.jpg">connect</a> to the board and
         3046 perform installation. The system doesn't have a supported miniroot so
         3047 the preparation steps detailed in the <strong>INSTALL.arm64</strong> file have to be
         3048 performed to get a working installation image.</p>
         3049 
         3050 <p>The following packages need to be installed:</p>
         3051 
         3052 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pkg_add dtb u-boot-aarch64
         3053 </code></pre></div></div>
         3054 
         3055 <p>After writing the miniroot image to an SD card, the correct <strong>DTB</strong>
         3056 should be copied:</p>
         3057 
         3058 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mount /dev/sdXi /mnt
         3059 <span class="nb">mkdir</span> /mnt/allwinner
         3060 <span class="nb">cp</span> /usr/local/share/dtb/arm64/allwinner/sun50i-h5-nanopi-neo2.dtb /mnt/allwinner
         3061 umount /mnt
         3062 </code></pre></div></div>
         3063 
         3064 <p>Lastly, the correct <strong>U-Boot image</strong> should be written:</p>
         3065 
         3066 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">dd </span><span class="k">if</span><span class="o">=</span>/usr/local/share/u-boot/nanopi_neo2/u-boot-sunxi-with-spl.bin <span class="nv">of</span><span class="o">=</span>/dev/sdXc <span class="nv">bs</span><span class="o">=</span>1024 <span class="nv">seek</span><span class="o">=</span>8
         3067 </code></pre></div></div>
         3068 
         3069 <p>After performing the installation process, the DTB should be copied again
         3070 to the SD card before attempting to boot the system.</p>
         3071 
         3072 <p>Here is the output of running <em>file</em> on executables:</p>
         3073 
         3074 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ELF 64-bit LSB shared object, AArch64, version 1
         3075 </code></pre></div></div>
         3076 
         3077 <p>And this is the result of the <strong>md5 -t</strong> benchmark:</p>
         3078 
         3079 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>MD5 <span class="nb">time </span>trial.  Processing 10000 10000-byte blocks...
         3080 Digest <span class="o">=</span> 52e5f9c9e6f656f3e1800dfa5579d089
         3081 Time   <span class="o">=</span> 1.070000 seconds
         3082 Speed  <span class="o">=</span> 93457943.925234 bytes/second
         3083 </code></pre></div></div>
         3084 
         3085 <p>For the record, LibreSSL speed benchmark results are available
         3086 <a href="/files/openbsd/openssl-speed-nanopi-neo2.txt">here</a>.</p>
         3087 
         3088 <p>System message buffer (dmesg output):</p>
         3089 
         3090 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>OpenBSD 6.4-current <span class="o">(</span>GENERIC.MP<span class="o">)</span> <span class="c">#262: Mon Nov 12 01:54:10 MST 2018</span>
         3091     deraadt@arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/GENERIC.MP
         3092 real mem  <span class="o">=</span> 407707648 <span class="o">(</span>388MB<span class="o">)</span>
         3093 avail mem <span class="o">=</span> 367030272 <span class="o">(</span>350MB<span class="o">)</span>
         3094 mainbus0 at root: FriendlyARM NanoPi NEO 2
         3095 cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
         3096 cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
         3097 cpu0: 512KB 64b/line 16-way L2 cache
         3098 efi0 at mainbus0: UEFI 2.7
         3099 efi0: Das U-Boot rev 0x0
         3100 sxiccmu0 at mainbus0
         3101 psci0 at mainbus0: PSCI 0.2
         3102 simplebus0 at mainbus0: <span class="s2">"soc"</span>
         3103 syscon0 at simplebus0: <span class="s2">"syscon"</span>
         3104 sxiccmu1 at simplebus0
         3105 sxipio0 at simplebus0: 94 pins
         3106 ampintc0 at simplebus0 nirq 224, ncpu 4 ipi: 0, 1: <span class="s2">"interrupt-controller"</span>
         3107 sxiccmu2 at simplebus0
         3108 sxipio1 at simplebus0: 12 pins
         3109 sximmc0 at simplebus0
         3110 sdmmc0 at sximmc0: 4-bit, sd high-speed, mmc high-speed, dma
         3111 ehci0 at simplebus0
         3112 usb0 at ehci0: USB revision 2.0
         3113 uhub0 at usb0 configuration 1 interface 0 <span class="s2">"Generic EHCI root hub"</span> rev 2.00/1.00 addr 1
         3114 ehci1 at simplebus0
         3115 usb1 at ehci1: USB revision 2.0
         3116 uhub1 at usb1 configuration 1 interface 0 <span class="s2">"Generic EHCI root hub"</span> rev 2.00/1.00 addr 1
         3117 dwxe0 at simplebus0: address 02:01:f7:f9:2f:67
         3118 rgephy0 at dwxe0 phy 7: RTL8169S/8110S/8211 PHY, rev. 5
         3119 com0 at simplebus0: ns16550, no working fifo
         3120 com0: console
         3121 sxirtc0 at simplebus0
         3122 gpio0 at sxipio0: 32 pins
         3123 gpio1 at sxipio0: 32 pins
         3124 gpio2 at sxipio0: 32 pins
         3125 gpio3 at sxipio0: 32 pins
         3126 gpio4 at sxipio0: 32 pins
         3127 gpio5 at sxipio0: 32 pins
         3128 gpio6 at sxipio0: 32 pins
         3129 gpio7 at sxipio1: 32 pins
         3130 agtimer0 at mainbus0: tick rate 24000 KHz
         3131 cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
         3132 cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
         3133 cpu1: 512KB 64b/line 16-way L2 cache
         3134 cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
         3135 cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
         3136 cpu2: 512KB 64b/line 16-way L2 cache
         3137 cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
         3138 cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
         3139 cpu3: 512KB 64b/line 16-way L2 cache
         3140 scsibus0 at sdmmc0: 2 targets, initiator 0
         3141 sd0 at scsibus0 targ 1 lun 0: &lt;SD/MMC, SC64G, 0080&gt; SCSI2 0/direct removable
         3142 sd0: 60906MB, 512 bytes/sector, 124735488 sectors
         3143 vscsi0 at root
         3144 scsibus1 at vscsi0: 256 targets
         3145 softraid0 at root
         3146 scsibus2 at softraid0: 256 targets
         3147 bootfile: sd0a:/bsd
         3148 boot device: sd0
         3149 root on sd0a <span class="o">(</span>1fbfe51d132e41c0.a<span class="o">)</span> swap on sd0b dump on sd0b
         3150 </code></pre></div></div>
         3151 
         3152 ]]></content>
         3153                 <summary type="html">
         3154                         <![CDATA[Running the OpenBSD/arm64 port on the NanoPi NEO2]]>
         3155                 </summary>
         3156 
         3157                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         3158                 <category term="ARM" scheme="https://www.cambus.net/categories/arm"/>
         3159         </entry>
         3160         <entry>
         3161         <title><![CDATA[Spleen - Monospaced bitmap fonts]]></title>
         3162                 <link href="https://www.cambus.net/spleen-monospaced-bitmap-fonts/"/>
         3163                 <id>https://www.cambus.net/spleen-monospaced-bitmap-fonts/</id>
         3164                 <published>2018-09-19T15:45:00Z</published>
         3165                 <updated>2018-09-19T15:45:00Z</updated>
         3166                 <content type="html"><![CDATA[<p>Spleen started as a personal challenge. Patrick Wildt (patrick@) recently
         3167 imported <strong>ssdfb(4)</strong>, a driver for small <strong>OLED displays</strong> in OpenBSD and
         3168 needed a 5x8 font to be able to squeeze more columns and rows on those
         3169 devices.</p>
         3170 
         3171 <p>As someone spending most of his time in a terminal, I have been thinking about
         3172 drawing my own font for a while, and this was the perfect opportunity.</p>
         3173 
         3174 <p>To be able to test character spacing and alignment, I started to use the font
         3175 in <strong>xterm</strong>, then a zoomed version, and one thing leading to another, I
         3176 started creating a 8x16 version, and then bigger versions based on it. Spleen
         3177 is now available in 5 sizes: 5x8, 8x16, 12x24, 16x32, and 32x64.</p>
         3178 
         3179 <p>Fonts are provided in the Glyph Bitmap Distribution Format (<strong>BDF</strong>), and in
         3180 the <strong>.dfont</strong> format for Macintosh users. All sizes contain all ISO/IEC 8859-1
         3181 characters, except for the 5x8 version which only contains printable ASCII
         3182 characters.</p>
         3183 
         3184 <p>The fonts are available on <a href="https://github.com/fcambus/spleen">GitHub</a>, along with some instructions on how
         3185 to install and use them.</p>
         3186 
         3187 <p>Here is a screenshot showing the 16x32 version displaying code:</p>
         3188 
         3189 <p><img src="https://www.cambus.net/content/2018/09/spleen-hello.png" alt="Spleen - Hello" /></p>
         3190 
         3191 <p>And again the 16x32 version showing prose:</p>
         3192 
         3193 <p><img src="https://www.cambus.net/content/2018/09/spleen-etranger.png" alt="Spleen - L'etranger" /></p>
         3194 
         3195 <p>Looking ahead, my immediate plans are to continue improving glyphs themselves
         3196 as well as characters spacing and alignment. This comes through extensive
         3197 everyday use of the various font sizes. Another short term goal is to add
         3198 support for Central European languages, with Polish being the immediate
         3199 priority.</p>
         3200 
         3201 <p>Meanwhile, I'm working on getting packages created for operating systems, and
         3202 I just imported the OpenBSD port for Spleen this morning.</p>
         3203 
         3204 ]]></content>
         3205                 <summary type="html">
         3206                         <![CDATA[Introducing Spleen, a monospaced bitmap font for consoles and terminals]]>
         3207                 </summary>
         3208 
         3209                 <category term="Type Design" scheme="https://www.cambus.net/categories/type-design"/>
         3210         </entry>
         3211         <entry>
         3212         <title><![CDATA[The future of VIA x86 processors]]></title>
         3213                 <link href="https://www.cambus.net/the-future-of-via-x86-processors/"/>
         3214                 <id>https://www.cambus.net/the-future-of-via-x86-processors/</id>
         3215                 <published>2018-07-30T18:08:00Z</published>
         3216                 <updated>2018-07-30T18:08:00Z</updated>
         3217                 <content type="html"><![CDATA[<p>I've been interested in <strong>VIA</strong> motherboards and CPUs ever since they came
         3218 up with the <strong>Mini-ITX</strong> standard in the very early 2000s. Their approach
         3219 of bringing fanless and power-efficient designs to the x86 market was
         3220 groundbreaking at the time.</p>
         3221 
         3222 <p>VIA processors are designed by <strong>Centaur Technology</strong>, and there is an
         3223 excellent documentary entitled "<a href="https://vimeo.com/ondemand/riseofthecentaur">Rise of the Centaur</a>" retracing their
         3224 history, which I really enjoyed watching.</p>
         3225 
         3226 <p>It's unfortunately very difficult to find information about recent VIA x86
         3227 CPUs. The VIA QuadCore, their latest one, was <a href="https://www.viatech.com/en/2011/05/via-announces-new-via-quadcore-processor/">announced</a> in May 2011,
         3228 and it remains an open question whether there will be newer ones or not,
         3229 as the company seems to be focusing on the ARM architecture.</p>
         3230 
         3231 <p>In fact, the status of VIA's x86 licensing agreement is quite unclear. There
         3232 was an <a href="https://www.ftc.gov/news-events/press-releases/2010/08/ftc-settles-charges-anticompetitive-conduct-against-intel">FTC ruling against Intel</a> in 2010 specifying that a five years
         3233 extension should be offered to VIA once the ongoing agreement would expire
         3234 in 2013, and that the agreement should be modified to allow VIA (among other
         3235 companies) to consider mergers or joint ventures. The latter being the way
         3236 VIA apparently took, which gave birth to <a href="http://www.zhaoxin.com/">Zhaoxin</a>.</p>
         3237 
         3238 <p>Some information in English about <strong>Zhaoxin x86 CPUs</strong> is available on
         3239 <a href="https://en.wikichip.org/wiki/zhaoxin">WikiChip</a>. However, those CPUs seem to only be available within China.
         3240 For now?</p>
         3241 
         3242 <p>Given the current state of affairs on the x86 market (Intel ME, AMD Secure
         3243 Technology, Meltdown, Spectre) and upcoming vulnerabilities announcements
         3244 lurking on the horizon, there is definitely a spot for alternative x86
         3245 processors.</p>
         3246 
         3247 ]]></content>
         3248                 <summary type="html">
         3249                         <![CDATA[Past, present, and future of VIA x86 processors]]>
         3250                 </summary>
         3251 
         3252                 <category term="Hardware" scheme="https://www.cambus.net/categories/hardware"/>
         3253         </entry>
         3254         <entry>
         3255         <title><![CDATA[Oldest domains in the .com, .net, and .org TLDs]]></title>
         3256                 <link href="https://www.cambus.net/oldest-domains-in-the-com-net-and-org-tlds/"/>
         3257                 <id>https://www.cambus.net/oldest-domains-in-the-com-net-and-org-tlds/</id>
         3258                 <published>2018-06-26T15:57:00Z</published>
         3259                 <updated>2018-06-26T15:57:00Z</updated>
         3260                 <content type="html"><![CDATA[<p>As someone interested in <strong>DNS</strong> and <strong>Internet history</strong>, I've always been
         3261 enjoying facts and articles about early registered domain names. Wikipedia
         3262 has a <a href="https://en.wikipedia.org/wiki/List_of_the_oldest_currently_registered_Internet_domain_names">page</a> on the subject, but the list is extremely short for .net
         3263 and .org domains.</p>
         3264 
         3265 <p>Using the <strong>DDN NIC domain summaries</strong>, it shouldn't be too difficult to
         3266 extract a list of domains, <strong>perform whois queries</strong> to get registration
         3267 dates, and sort the results. Let's find out.</p>
         3268 
         3269 <p>For the record, the oldest issue I could find, dating from December 1987,
         3270 doesn't list nordu.net, the first .net domain ever registered. So I opted
         3271 for the <a href="https://www.statdns.com/files/domain-info-19950813.txt">August 1995 edition</a> to be on the safe side. While I could also
         3272 find an issue from 1996, there are a lot more domains listed so the whois
         3273 lookups would take a lot more time, for no evident benefit.</p>
         3274 
         3275 <h3 id="preparing-the-domain-lists">Preparing the domain lists</h3>
         3276 
         3277 <p>After manually splitting the file to get rid of the TLDs we are not interested
         3278 in, we save them in a distinct file for each TLD.</p>
         3279 
         3280 <p>Then, we need to process the lists so that each domain is on its own line, and
         3281 we strip the eventual subdomains with rev using a neat trick:</p>
         3282 
         3283 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">tr</span> <span class="nt">-s</span> <span class="s2">"[[:blank:]]"</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> &lt; com | <span class="se">\</span>
         3284     rev | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s1">'.'</span> <span class="nt">-f</span> 1 <span class="nt">-f</span> 2 | rev | <span class="nb">sort</span> | <span class="nb">uniq</span> <span class="o">&gt;</span> com.txt
         3285 
         3286 <span class="nb">tr</span> <span class="nt">-s</span> <span class="s2">"[[:blank:]]"</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> &lt; net | <span class="se">\</span>
         3287     rev | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s1">'.'</span> <span class="nt">-f</span> 1 <span class="nt">-f</span> 2 | rev | <span class="nb">sort</span> | <span class="nb">uniq</span> <span class="o">&gt;</span> net.txt
         3288 
         3289 <span class="nb">tr</span> <span class="nt">-s</span> <span class="s2">"[[:blank:]]"</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> &lt; org | <span class="se">\</span>
         3290     rev | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s1">'.'</span> <span class="nt">-f</span> 1 <span class="nt">-f</span> 2 | rev | <span class="nb">sort</span> | <span class="nb">uniq</span> <span class="o">&gt;</span> org.txt
         3291 </code></pre></div></div>
         3292 
         3293 <h3 id="performing-whois-requests">Performing whois requests</h3>
         3294 
         3295 <p>Internic whois server allows to query domains in the .com and .net TLDs without
         3296 imposing any drastic rate limit, albeit slowly. As our corpus is rather short,
         3297 this isn't an issue.</p>
         3298 
         3299 <p>Whois script for .com and .net domains:</p>
         3300 
         3301 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/sh</span>
         3302 <span class="k">while </span><span class="nb">read </span>domain
         3303 <span class="k">do
         3304         </span><span class="nv">creation_date</span><span class="o">=</span><span class="si">$(</span>whois <span class="nt">-h</span> whois.internic.net <span class="nv">$domain</span> <span class="o">=</span><span class="nv">$domain</span> |
         3305             <span class="nb">grep</span> <span class="s2">"   Creation Date:"</span> | <span class="nb">uniq</span> | <span class="nb">sed</span> <span class="nt">-e</span> <span class="s1">'s/Creation Date://'</span><span class="si">)</span>
         3306 
         3307         <span class="k">if</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-z</span> <span class="s2">"</span><span class="nv">$creation_date</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then
         3308                 </span><span class="nb">date</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="nv">$creation_date</span> | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s1">'T'</span> <span class="nt">-f</span> 1 -<span class="si">)</span>
         3309                 <span class="nb">echo</span> <span class="nv">$date</span> <span class="nv">$domain</span>
         3310         <span class="k">fi</span>
         3311 
         3312         <span class="c"># Wait one second to avoid triggering rate-limiting mechanisms</span>
         3313         <span class="nb">sleep </span>1
         3314 <span class="k">done</span> &lt; <span class="nv">$1</span>
         3315 </code></pre></div></div>
         3316 
         3317 <p>On the other hand, the Public Interest Registry whois server only allows 4
         3318 queries per minute, so we have to sleep for a little while between each
         3319 request.</p>
         3320 
         3321 <p>Whois script for .org domains:</p>
         3322 
         3323 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/sh</span>
         3324 <span class="k">while </span><span class="nb">read </span>domain
         3325 <span class="k">do
         3326         </span><span class="nv">creation_date</span><span class="o">=</span><span class="si">$(</span>whois <span class="nv">$domain</span> <span class="o">=</span><span class="nv">$domain</span> | <span class="nb">grep</span> <span class="s2">"Creation Date:"</span> |
         3327             <span class="nb">uniq</span> | <span class="nb">sed</span> <span class="nt">-e</span> <span class="s1">'s/Creation Date://'</span><span class="si">)</span>
         3328 
         3329         <span class="k">if</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-z</span> <span class="s2">"</span><span class="nv">$creation_date</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then
         3330                 </span><span class="nb">date</span><span class="o">=</span><span class="si">$(</span><span class="nb">echo</span> <span class="nv">$creation_date</span> | <span class="nb">cut</span> <span class="nt">-d</span> <span class="s1">'T'</span> <span class="nt">-f</span> 1 -<span class="si">)</span>
         3331                 <span class="nb">echo</span> <span class="nv">$date</span> <span class="nv">$domain</span>
         3332         <span class="k">fi</span>
         3333 
         3334         <span class="c"># Wait thirty seconds to avoid triggering rate-limiting mechanisms</span>
         3335         <span class="nb">sleep </span>30
         3336 <span class="k">done</span> &lt; <span class="nv">$1</span>
         3337 </code></pre></div></div>
         3338 
         3339 <p>We can now launch the scripts to perform whois requests:</p>
         3340 
         3341 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sh internic.sh com.txt <span class="o">&gt;</span> com.dates.txt
         3342 sh internic.sh net.txt <span class="o">&gt;</span> net.dates.txt
         3343 sh pir.sh org.txt <span class="o">&gt;</span> org.dates.txt
         3344 </code></pre></div></div>
         3345 
         3346 <p>And finally sort results and keep the 100 oldest domains for each TLD:</p>
         3347 
         3348 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sort </span>com.dates.txt | <span class="nb">head</span> <span class="nt">-n100</span>
         3349 <span class="nb">sort </span>net.dates.txt | <span class="nb">head</span> <span class="nt">-n100</span>
         3350 <span class="nb">sort </span>org.dates.txt | <span class="nb">head</span> <span class="nt">-n100</span>
         3351 </code></pre></div></div>
         3352 
         3353 <h3 id="results">Results</h3>
         3354 
         3355 <p>Oldest registered <strong>.com</strong> domains:</p>
         3356 
         3357 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1985-03-15 symbolics.com
         3358 1985-04-24 bbn.com
         3359 1985-05-24 think.com
         3360 1985-07-11 mcc.com
         3361 1985-09-30 dec.com
         3362 1985-11-07 northrop.com
         3363 1986-01-09 xerox.com
         3364 1986-01-17 sri.com
         3365 1986-03-03 hp.com
         3366 1986-03-05 bellcore.com
         3367 1986-03-19 ibm.com
         3368 1986-03-19 sun.com
         3369 1986-03-25 intel.com
         3370 1986-03-25 ti.com
         3371 1986-04-25 att.com
         3372 1986-05-08 gmr.com
         3373 1986-05-08 tek.com
         3374 1986-07-10 fmc.com
         3375 1986-07-10 ub.com
         3376 1986-08-05 bell-atl.com
         3377 1986-08-05 ge.com
         3378 1986-08-05 grebyn.com
         3379 1986-08-05 isc.com
         3380 1986-08-05 nsc.com
         3381 1986-08-05 stargate.com
         3382 1986-09-02 boeing.com
         3383 1986-09-18 itcorp.com
         3384 1986-09-29 siemens.com
         3385 1986-10-18 pyramid.com
         3386 1986-10-27 alphacdc.com
         3387 1986-10-27 bdm.com
         3388 1986-10-27 fluke.com
         3389 1986-10-27 inmet.com
         3390 1986-10-27 kesmai.com
         3391 1986-10-27 mentor.com
         3392 1986-10-27 nec.com
         3393 1986-10-27 ray.com
         3394 1986-10-27 rosemount.com
         3395 1986-10-27 vortex.com
         3396 1986-11-05 alcoa.com
         3397 1986-11-05 gte.com
         3398 1986-11-17 adobe.com
         3399 1986-11-17 amd.com
         3400 1986-11-17 das.com
         3401 1986-11-17 data-io.com
         3402 1986-11-17 octopus.com
         3403 1986-11-17 portal.com
         3404 1986-11-17 teltone.com
         3405 1986-12-11 3com.com
         3406 1986-12-11 amdahl.com
         3407 1986-12-11 ccur.com
         3408 1986-12-11 ci.com
         3409 1986-12-11 convergent.com
         3410 1986-12-11 dg.com
         3411 1986-12-11 peregrine.com
         3412 1986-12-11 quad.com
         3413 1986-12-11 sq.com
         3414 1986-12-11 tandy.com
         3415 1986-12-11 tti.com
         3416 1986-12-11 unisys.com
         3417 1987-01-19 cgi.com
         3418 1987-01-19 cts.com
         3419 1987-01-19 spdcc.com
         3420 1987-02-19 apple.com
         3421 1987-03-04 nma.com
         3422 1987-03-04 prime.com
         3423 1987-04-04 philips.com
         3424 1987-04-23 datacube.com
         3425 1987-04-23 kai.com
         3426 1987-04-23 tic.com
         3427 1987-04-23 vine.com
         3428 1987-04-30 ncr.com
         3429 1987-05-14 cisco.com
         3430 1987-05-14 rdl.com
         3431 1987-05-20 slb.com
         3432 1987-05-27 parcplace.com
         3433 1987-05-27 utc.com
         3434 1987-06-26 ide.com
         3435 1987-07-09 trw.com
         3436 1987-07-13 unipress.com
         3437 1987-07-27 dupont.com
         3438 1987-07-27 lockheed.com
         3439 1987-07-28 rosetta.com
         3440 1987-08-18 toad.com
         3441 1987-08-31 quick.com
         3442 1987-09-03 allied.com
         3443 1987-09-03 dsc.com
         3444 1987-09-03 sco.com
         3445 1987-09-22 gene.com
         3446 1987-09-22 kccs.com
         3447 1987-09-22 spectra.com
         3448 1987-09-22 wlk.com
         3449 1987-09-30 mentat.com
         3450 1987-10-14 wyse.com
         3451 1987-11-02 cfg.com
         3452 1987-11-09 marble.com
         3453 1987-11-16 cayman.com
         3454 1987-11-16 entity.com
         3455 1987-11-24 ksr.com
         3456 1987-11-30 nynexst.com
         3457 </code></pre></div></div>
         3458 
         3459 <p>Oldest registered <strong>.net</strong> domains:</p>
         3460 
         3461 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1985-01-01 nordu.net
         3462 1986-04-01 broken.net
         3463 1986-11-05 nsf.net
         3464 1987-01-27 nyser.net
         3465 1987-05-20 uu.net
         3466 1987-07-21 sesqui.net
         3467 1988-05-25 mr.net
         3468 1988-06-09 oar.net
         3469 1988-07-08 sura.net
         3470 1988-09-07 the.net
         3471 1988-09-16 nwnet.net
         3472 1988-10-21 es.net
         3473 1988-10-25 mid.net
         3474 1989-01-04 barrnet.net
         3475 1989-01-05 cic.net
         3476 1989-01-27 hawaii.net
         3477 1989-03-07 psi.net
         3478 1989-03-27 near.net
         3479 1989-04-11 eu.net
         3480 1989-06-29 ln.net
         3481 1989-09-12 sub.net
         3482 1989-09-14 westnet.net
         3483 1989-11-06 cypress.net
         3484 1989-11-15 cerf.net
         3485 1989-11-17 risq.net
         3486 1990-02-09 ca.net
         3487 1990-05-21 wiscnet.net
         3488 1990-07-25 cent.net
         3489 1990-07-26 alter.net
         3490 1990-09-27 ans.net
         3491 1990-11-07 mich.net
         3492 1991-02-26 hk.net
         3493 1991-04-10 cix.net
         3494 1991-04-11 team.net
         3495 1991-05-07 five-colleges.net
         3496 1991-05-17 ja.net
         3497 1991-06-03 illinois.net
         3498 1991-06-20 more.net
         3499 1991-06-24 ohio-dmz.net
         3500 1991-07-08 icp.net
         3501 1991-08-07 swip.net
         3502 1991-08-15 michnet.net
         3503 1991-11-29 notes.net
         3504 1991-12-10 merit.net
         3505 1991-12-31 mu.net
         3506 1992-01-17 first.net
         3507 1992-02-17 ebone.net
         3508 1992-02-19 holonet.net
         3509 1992-02-25 ripe.net
         3510 1992-03-24 csn.net
         3511 1992-04-06 mcast.net
         3512 1992-04-08 life.net
         3513 1992-04-20 rahul.net
         3514 1992-04-21 cyber.net
         3515 1992-05-11 sprintlink.net
         3516 1992-05-18 ids.net
         3517 1992-05-21 q.net
         3518 1992-06-01 netconnect.net
         3519 1992-07-07 use.net
         3520 1992-07-16 tip.net
         3521 1992-07-27 capcon.net
         3522 1992-07-27 nexsys.net
         3523 1992-07-29 umass.net
         3524 1992-07-31 solinet.net
         3525 1992-08-06 fish.net
         3526 1992-08-18 ps.net
         3527 1992-09-10 eds.net
         3528 1992-09-18 lig.net
         3529 1992-10-01 ix.net
         3530 1992-10-19 aol.net
         3531 1992-10-30 win.net
         3532 1992-11-02 cren.net
         3533 1992-11-03 path.net
         3534 1992-11-04 quake.net
         3535 1992-11-20 access.net
         3536 1992-11-20 tsoft.net
         3537 1992-11-23 inter.net
         3538 1992-11-30 individual.net
         3539 1992-12-04 raider.net
         3540 1992-12-09 europa.net
         3541 1992-12-21 demon.net
         3542 1992-12-22 press.net
         3543 1992-12-23 bc.net
         3544 1993-01-01 internic.net
         3545 1993-01-04 cls.net
         3546 1993-01-20 sam.net
         3547 1993-02-09 kanren.net
         3548 1993-02-11 ubs.net
         3549 1993-02-15 digex.net
         3550 1993-02-15 mobilecomm.net
         3551 1993-02-17 xlink.net
         3552 1993-02-18 fr.net
         3553 1993-03-03 onenet.net
         3554 1993-03-08 aco.net
         3555 1993-03-24 clark.net
         3556 1993-03-24 olympus.net
         3557 1993-03-24 satlink.net
         3558 1993-04-02 netcom.net
         3559 1993-04-07 nl.net
         3560 1993-04-13 ins.net
         3561 </code></pre></div></div>
         3562 
         3563 <p>Oldest registered <strong>.org</strong> domains:</p>
         3564 
         3565 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1985-07-10 mitre.org
         3566 1986-03-25 src.org
         3567 1986-07-10 super.org
         3568 1987-01-07 aero.org
         3569 1987-01-15 mcnc.org
         3570 1987-04-02 rand.org
         3571 1987-04-04 mn.org
         3572 1987-05-01 rti.org
         3573 1987-07-14 usenix.org
         3574 1987-09-03 software.org
         3575 1988-02-25 fidonet.org
         3576 1988-04-27 ampr.org
         3577 1988-08-04 osf.org
         3578 1988-08-11 ida.org
         3579 1988-09-09 cactus.org
         3580 1988-09-09 nm.org
         3581 1988-09-22 ccf.org
         3582 1988-10-21 erim.org
         3583 1988-11-11 ski.org
         3584 1988-11-30 iti.org
         3585 1989-01-11 jax.org
         3586 1989-01-13 ncsc.org
         3587 1989-02-09 aaai.org
         3588 1989-02-24 ie.org
         3589 1989-03-29 stjude.org
         3590 1989-04-11 mbari.org
         3591 1989-05-24 castle.org
         3592 1989-06-07 carl.org
         3593 1989-06-27 msri.org
         3594 1989-07-15 agi.org
         3595 1989-07-17 sf-bay.org
         3596 1989-07-31 mef.org
         3597 1989-08-11 oclc.org
         3598 1989-08-23 ei.org
         3599 1989-09-05 cas.org
         3600 1989-09-11 battelle.org
         3601 1989-09-12 sub.org
         3602 1989-09-21 aip.org
         3603 1989-09-28 sdpa.org
         3604 1989-11-08 lonestar.org
         3605 1989-12-01 ieee.org
         3606 1990-01-10 cit.org
         3607 1990-01-22 sematech.org
         3608 1990-02-07 omg.org
         3609 1990-02-12 decus.org
         3610 1990-03-13 sublink.org
         3611 1990-03-16 cam.org
         3612 1990-03-20 cpl.org
         3613 1990-04-10 ori.org
         3614 1990-04-13 fhcrc.org
         3615 1990-05-16 nwf.org
         3616 1990-05-18 mskcc.org
         3617 1990-05-23 boystown.org
         3618 1990-05-24 bwc.org
         3619 1990-05-31 topsail.org
         3620 1990-06-28 ciit.org
         3621 1990-07-17 central.org
         3622 1990-07-27 mind.org
         3623 1990-08-03 stonemarche.org
         3624 1990-08-28 cshl.org
         3625 1990-08-30 fstrf.org
         3626 1990-09-12 dorsai.org
         3627 1990-09-14 elf.org
         3628 1990-09-18 siggraph.org
         3629 1990-09-21 sjh.org
         3630 1990-09-27 igc.org
         3631 1990-10-10 cotdazr.org
         3632 1990-10-10 eff.org
         3633 1990-10-10 sfn.org
         3634 1990-10-31 csn.org
         3635 1990-11-01 sfbr.org
         3636 1990-11-07 ais.org
         3637 1990-11-07 hjf.org
         3638 1991-01-04 uniforum.org
         3639 1991-01-04 wgbh.org
         3640 1991-02-01 fsf.org
         3641 1991-02-06 eso.org
         3642 1991-02-06 tiaa.org
         3643 1991-02-13 nysernet.org
         3644 1991-02-20 acr.org
         3645 1991-02-26 nybc.org
         3646 1991-02-26 nypl.org
         3647 1991-04-10 cnytdo.org
         3648 1991-04-10 htr.org
         3649 1991-04-10 hvtdc.org
         3650 1991-04-10 nycp.org
         3651 1991-04-11 bpl.org
         3652 1991-04-11 scra.org
         3653 1991-04-12 amnh.org
         3654 1991-04-15 hellnet.org
         3655 1991-04-15 sil.org
         3656 1991-04-18 apc.org
         3657 1991-04-22 mobot.org
         3658 1991-04-25 cni.org
         3659 1991-05-01 gumption.org
         3660 1991-05-02 hslc.org
         3661 1991-05-13 guild.org
         3662 1991-05-22 acs.org
         3663 1991-05-22 lpl.org
         3664 1991-05-22 rsage.org
         3665 </code></pre></div></div>
         3666 
         3667 ]]></content>
         3668                 <summary type="html">
         3669                         <![CDATA[Oldest registered domain names in the .com, .net, and .org top-level domains]]>
         3670                 </summary>
         3671 
         3672                 <category term="DNS" scheme="https://www.cambus.net/categories/dns"/>
         3673         </entry>
         3674         <entry>
         3675         <title><![CDATA[Booting OpenBSD kernels in EFI mode with QEMU]]></title>
         3676                 <link href="https://www.cambus.net/booting-openbsd-kernels-in-efi-mode-with-qemu/"/>
         3677                 <id>https://www.cambus.net/booting-openbsd-kernels-in-efi-mode-with-qemu/</id>
         3678                 <published>2018-06-24T11:50:00Z</published>
         3679                 <updated>2018-06-24T11:50:00Z</updated>
         3680                 <content type="html"><![CDATA[<p>I've been working on stuff involving the EFI framebuffer lately, and needed a
         3681 way to quickly test kernels without having to reboot my development machine
         3682 each and every time.</p>
         3683 
         3684 <p>As it turns out, it's possible to achieve using <strong>OVMF</strong> (Open Virtual Machine
         3685 Firmware), a BSD licensed <strong>UEFI firmware implementation</strong> targeted at virtual
         3686 machines. A prebuilt image can be downloaded <a href="https://sourceforge.net/projects/edk2/files/OVMF/OVMF-X64-r15214.zip/download">here</a>.</p>
         3687 
         3688 <p>We will need to create two drives:</p>
         3689 
         3690 <ul>
         3691   <li>One drive using a FAT filesystem to store the EFI payload (the OpenBSD
         3692 bootloader)</li>
         3693   <li>Another drive using a FFS filesystem containing the OpenBSD kernel</li>
         3694 </ul>
         3695 
         3696 <p>Thankfully, QEMU allows to create virtual drives with FAT filesystems from
         3697 local directories, and we can easily create an FFS filesystem image using
         3698 <strong>makefs(8)</strong>.</p>
         3699 
         3700 <p>We will start by creating a directory structure:</p>
         3701 
         3702 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> bootloader/efi/boot
         3703 <span class="nb">mkdir</span> <span class="nt">-p</span> kernel/etc
         3704 </code></pre></div></div>
         3705 
         3706 <p>We then copy the OpenBSD <strong>EFI bootloader</strong>:</p>
         3707 
         3708 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cp</span> /usr/mdec/BOOTX64.EFI bootloader/efi/boot
         3709 </code></pre></div></div>
         3710 
         3711 <p>Alternatively, an OpenBSD EFI bootloader can be downloaded <a href="https://fastly.cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/BOOTX64.EFI">here</a>.</p>
         3712 
         3713 <p>Then, we need to place the EFI firmware image at the root of our directory, and
         3714 the OpenBSD kernel we want to boot in the kernel directory.</p>
         3715 
         3716 <p>The directory structure should look as follow:</p>
         3717 
         3718 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>OVMF.fd
         3719 bootloader
         3720 bootloader/efi
         3721 bootloader/efi/boot
         3722 bootloader/efi/boot/BOOTX64.EFI
         3723 kernel
         3724 kernel/etc
         3725 kernel/bsd
         3726 </code></pre></div></div>
         3727 
         3728 <p>We can now create the <strong>random.seed</strong> file and build the FFS filesystem image:</p>
         3729 
         3730 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">dd </span><span class="k">if</span><span class="o">=</span>/dev/random <span class="nv">of</span><span class="o">=</span>kernel/etc/random.seed <span class="nv">bs</span><span class="o">=</span>512 <span class="nv">count</span><span class="o">=</span>1
         3731 makefs <span class="nt">-t</span> ffs kernel.img kernel
         3732 </code></pre></div></div>
         3733 
         3734 <p>Finally, let's start QEMU:</p>
         3735 
         3736 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>qemu-system-x86_64 <span class="nt">-s</span> <span class="nt">--bios</span> OVMF.fd <span class="se">\</span>
         3737         <span class="nt">-drive</span> <span class="nv">format</span><span class="o">=</span>raw,file<span class="o">=</span>fat:rw:bootloader,media<span class="o">=</span>disk <span class="se">\</span>
         3738         <span class="nt">-drive</span> <span class="nv">format</span><span class="o">=</span>raw,file<span class="o">=</span>kernel.img,media<span class="o">=</span>disk
         3739 </code></pre></div></div>
         3740 
         3741 <p>And boot our kernel:</p>
         3742 
         3743 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>boot&gt; boot hd1a:/bsd
         3744 </code></pre></div></div>
         3745 ]]></content>
         3746                 <summary type="html">
         3747                         <![CDATA[Some notes on booting an OpenBSD kernel in EFI mode with QEMU using OVMF]]>
         3748                 </summary>
         3749 
         3750                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         3751         </entry>
         3752         <entry>
         3753         <title><![CDATA[The journey back to C]]></title>
         3754                 <link href="https://www.cambus.net/the-journey-back-to-c/"/>
         3755                 <id>https://www.cambus.net/the-journey-back-to-c/</id>
         3756                 <published>2018-02-21T13:10:00Z</published>
         3757                 <updated>2018-02-21T13:10:00Z</updated>
         3758                 <content type="html"><![CDATA[<p>A few months ago, I realized that I would be celebrating 20 years of C
         3759 programming this February. Although I had several few years of hiatuses back
         3760 and then, that's still a very long period for a single language.</p>
         3761 
         3762 <p>My journey back to C started in the spring of 2015, out of envy to scratch
         3763 a long time itch and write a Web log analyzer. I found <a href="http://cslibrary.stanford.edu/101/">Essential C</a> to
         3764 be a great refresher, which got me motivated and <a href="https://www.logswan.org">Logswan</a> happened.</p>
         3765 
         3766 <p>Fast forward to the fall of 2017, when I decided to finally tackle the
         3767 pile of material I collected and printed over the year. This started with
         3768 <a href="http://www.literateprogramming.com/ctraps.pdf">C Traps and Pitfalls</a>, then the free <a href="https://trailofbits.github.io/ctf/vulnerabilities/references/Dowd_ch06.pdf">C Language Issues</a> chapter
         3769 from TAOSSA, and I'm currently reading and enjoying <a href="https://gforge.inria.fr/frs/download.php/latestfile/5298/ModernC.pdf">Modern C</a>.</p>
         3770 
         3771 <p>Meanwhile, I've been reading <a href="https://greenteapress.com/thinkos/">Think OS</a> and I will continue the journey
         3772 with <a href="http://www.apuebook.com/">Advanced Programming in the Unix Environment</a> before devoting myself
         3773 to more material about operating systems.</p>
         3774 
         3775 <p>Languages come and go, but C is forever.</p>
         3776 
         3777 ]]></content>
         3778                 <summary type="html">
         3779                         <![CDATA[My journey back to C, through reading and practice]]>
         3780                 </summary>
         3781 
         3782                 <category term="C" scheme="https://www.cambus.net/categories/c"/>
         3783         </entry>
         3784         <entry>
         3785         <title><![CDATA[OpenBSD/octeon on the EdgeRouter Lite]]></title>
         3786                 <link href="https://www.cambus.net/openbsd-octeon-on-the-edgerouter-lite/"/>
         3787                 <id>https://www.cambus.net/openbsd-octeon-on-the-edgerouter-lite/</id>
         3788                 <published>2017-08-24T22:45:00Z</published>
         3789                 <updated>2017-08-24T22:45:00Z</updated>
         3790                 <content type="html"><![CDATA[<p>I've had the EdgeRouter Lite from Ubiquiti since a little more than a
         3791 year now, and it's a nice and affordable little fanless device to run
         3792 <a href="https://www.openbsd.org/octeon.html">OpenBSD/octeon</a> on.</p>
         3793 
         3794 <p>The CPU on this machine is a dual-core Cavium Octeon CN50xx (MIPS64 ISA)
         3795 which can run in both BE and LE modes. OpenBSD runs in big-endian mode on
         3796 this architecture.</p>
         3797 
         3798 <p>On the minus side, there is no internal clock and no FPU.</p>
         3799 
         3800 <p><img src="/content/2017/08/edgerouter-lite.jpg" alt="OpenBSD on the EdgeRouter Lite" /></p>
         3801 
         3802 <p>Here is the output of running <em>file</em> on executables:</p>
         3803 
         3804 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ELF 64-bit MSB shared object, MIPS, MIPS-III version 1
         3805 </code></pre></div></div>
         3806 
         3807 <p>And this is the result of the <strong>md5 -t</strong> benchmark:</p>
         3808 
         3809 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>MD5 <span class="nb">time </span>trial.  Processing 10000 10000-byte blocks...
         3810 Digest <span class="o">=</span> 52e5f9c9e6f656f3e1800dfa5579d089
         3811 Time   <span class="o">=</span> 2.183314 seconds
         3812 Speed  <span class="o">=</span> 45801932.291920 bytes/second
         3813 </code></pre></div></div>
         3814 
         3815 <p>For the record, LibreSSL speed benchmark results are available
         3816 <a href="/files/openbsd/openssl-speed-edgerouter-lite.txt">here</a>.</p>
         3817 
         3818 <p>System message buffer (dmesg output):</p>
         3819 
         3820 <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Copyright <span class="o">(</span>c<span class="o">)</span> 1982, 1986, 1989, 1991, 1993
         3821         The Regents of the University of California.  All rights reserved.
         3822 Copyright <span class="o">(</span>c<span class="o">)</span> 1995-2017 OpenBSD. All rights reserved.  https://www.OpenBSD.org
         3823 
         3824 OpenBSD 6.2-beta <span class="o">(</span>GENERIC.MP<span class="o">)</span> <span class="c">#0: Wed Aug 23 05:12:05 UTC 2017</span>
         3825     visa@octeon:/usr/src/sys/arch/octeon/compile/GENERIC.MP
         3826 real mem <span class="o">=</span> 536870912 <span class="o">(</span>512MB<span class="o">)</span>
         3827 avail mem <span class="o">=</span> 523943936 <span class="o">(</span>499MB<span class="o">)</span>
         3828 mainbus0 at root
         3829 cpu0 at mainbus0: CN50xx CPU rev 0.1 500 MHz, Software FP emulation
         3830 cpu0: cache L1-I 32KB 4 way D 8KB 64 way, L2 128KB 8 way
         3831 cpu1 at mainbus0: CN50xx CPU rev 0.1 500 MHz, Software FP emulation
         3832 cpu1: cache L1-I 32KB 4 way D 8KB 64 way, L2 128KB 8 way
         3833 clock0 at mainbus0: int 5
         3834 iobus0 at mainbus0
         3835 simplebus0 at iobus0: <span class="s2">"soc"</span>
         3836 octciu0 at simplebus0
         3837 cn30xxsmi0 at simplebus0
         3838 com0 at simplebus0: ns16550a, 64 byte fifo
         3839 com0: console
         3840 dwctwo0 at iobus0 base 0x1180068000000 irq 56
         3841 usb0 at dwctwo0: USB revision 2.0
         3842 uhub0 at usb0 configuration 1 interface 0 <span class="s2">"Octeon DWC2 root hub"</span> rev 2.00/1.00 addr 1
         3843 octrng0 at iobus0 base 0x1400000000000 irq 0
         3844 cn30xxgmx0 at iobus0 base 0x1180008000000
         3845 cnmac0 at cn30xxgmx0: RGMII, address 44:d9:e7:9e:f5:9e
         3846 atphy0 at cnmac0 phy 7: AR8035 10/100/1000 PHY, rev. 2
         3847 cnmac1 at cn30xxgmx0: RGMII, address 44:d9:e7:9e:f5:9f
         3848 atphy1 at cnmac1 phy 6: AR8035 10/100/1000 PHY, rev. 2
         3849 cnmac2 at cn30xxgmx0: RGMII, address 44:d9:e7:9e:f5:a0
         3850 atphy2 at cnmac2 phy 5: AR8035 10/100/1000 PHY, rev. 2
         3851 /dev/ksyms: Symbol table not valid.
         3852 umass0 at uhub0 port 1 configuration 1 interface 0 <span class="s2">"vendor 0x13fe USB DISK 2.0"</span> rev 2.00/1.00 addr 2
         3853 umass0: using SCSI over Bulk-Only
         3854 scsibus0 at umass0: 2 targets, initiator 0
         3855 sd0 at scsibus0 targ 1 lun 0: &lt;, USB DISK 2.0, PMAP&gt; SCSI4 0/direct removable serial.13fe42005BB4EF1C4C68
         3856 sd0: 3824MB, 512 bytes/sector, 7831552 sectors
         3857 vscsi0 at root
         3858 scsibus1 at vscsi0: 256 targets
         3859 softraid0 at root
         3860 scsibus2 at softraid0: 256 targets
         3861 boot device: sd0
         3862 root on sd0a <span class="o">(</span>cf2da3d2e43090ca.a<span class="o">)</span> swap on sd0b dump on sd0b
         3863 cpu1 launched
         3864 </code></pre></div></div>
         3865 ]]></content>
         3866                 <summary type="html">
         3867                         <![CDATA[Running the OpenBSD/octeon port on Ubiquiti EdgeRouter Lite]]>
         3868                 </summary>
         3869 
         3870                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         3871                 <category term="MIPS64" scheme="https://www.cambus.net/categories/mips64"/>
         3872         </entry>
         3873         <entry>
         3874         <title><![CDATA[OpenBSD g2k16 hackathon]]></title>
         3875                 <link href="https://www.cambus.net/openbsd-g2k16-hackathon/"/>
         3876                 <id>https://www.cambus.net/openbsd-g2k16-hackathon/</id>
         3877                 <published>2016-12-24T19:39:00Z</published>
         3878                 <updated>2016-12-24T19:39:00Z</updated>
         3879                 <content type="html"><![CDATA[<p>First hackathon. Things started in Rzeszow in a quite surrealistic atmosphere, as I was driving
         3880 to the airport under heavy rain while a thunderstorm was ongoing. The rest of the trip went smoothly
         3881 though, allowing me to reach Cambridge without issues.</p>
         3882 
         3883 <p>I came to the hackathon with plans to work on audio, emulators, and graphics related ports, and had a relatively large list of potential stuff to port.
         3884 Porting is a strange addiction. Trying to make sense of custom build systems, patching hardcoded compiler and linker flags, fixed paths, Linuxisms, bashisms, and so far and so on. Oh, and let's not forget programs requiring data files relative to the executable path. It's a time-consuming process, and a few hours can slip by until it's time to admit defeat. For the most part, each port brings a new and unique case of problems to solve. Some of the
         3885 ports I imported were previous failed attempts, but knowledge gained porting other programs allowed
         3886 me to overcome blocking issues. It's a never-ending challenge, but a rewarding one as each patch brings the
         3887 opportunity to attempt upstreaming changes and get in touch with developers which in the vast majority
         3888 are helpful and happy to see their program being packaged.</p>
         3889 
         3890 <p>On the second day, I got my commit bit and managed to import a few things, update some others, and commit daily until the end of the hackathon.
         3891 I found out that CVS, which is a frequent source of complaints and questions from people external to the project, enforces discipline, a clean workflow, and is actually rather pleasant to work with.</p>
         3892 
         3893 <p>Overall, the most important part of the hackathon was the human aspect: meeting people in person, some of them I knew from IRC, some I only knew by name from the mailing
         3894 lists, and finding out that the crowd is both cheerful and welcoming. Having fun, hearing a lot of technical discussions, seeing how the project is evolving and moving forward is super motivating.
         3895 I left Cambridge very inspired and determined to start a foray into src, one step at a time.</p>
         3896 
         3897 <p>Thanks to Anil, Gemma, and the OpenBSD foundation for organizing such a nice event. I know it has been a few months since g2k16 already, but I had this draft laying on my disk so I figured it was still time
         3898 to publish it.</p>
         3899 
         3900 ]]></content>
         3901                 <summary type="html">
         3902                         <![CDATA[My OpenBSD g2k16 hackathon report]]>
         3903                 </summary>
         3904 
         3905                 <category term="OpenBSD" scheme="https://www.cambus.net/categories/openbsd"/>
         3906         </entry>
         3907 </feed>