OpenBSD on a Gigabyte S10m

We now return you to our (ir)regularly scheduled programming (sic). In this week's breaking news, there have been further reports of attempts to put OpenBSD into even more ridiculous computing environments. Several independent accounts that even tablet computers are not safe from the security-focused Unix-like computer operating system are circulating, and anonymous sources claim that bystanders were found holding several half-finished pint glasses of beer thought to belong to the primary suspect in the incident. The suspect was, however, not intoxicated at the time and is known for producing low-quality "hold my beer" jokes.


The Gigabyte S10m Slate is essentially the guts of a reasonably specified (x86!) laptop inside the skin of a tablet computer. It also has an RJ45 ethernet socket and VGA and HDMI video out, which is kind of cute. Someone on the Freenode IRC OpenBSD channel got their hands on one, and reported that it ran OpenBSD remarkably well -- WiFi, camera and touch screen all working right out of the box, with no extra configuration required.

At that point, I was in need of a tablet computer, and there was one going cheap on eBay. Given the opportunities for hilarity that an x86 tablet with functional driver support could provide, I bought it, if only because saying "I have a BSD-powered x86 tablet" is likely to generate the same sort of amusing reactions as linking people who know how DNS works to websites with punny domain names (cough).


The tablet, as originally released, comes with Windows 7 (plus some vendor value-add to make using the touch screen possible); the model is a few years old now, so the one I got came with Windows 8.1. The BIOS is accessible via some magic combination of the hardware buttons, but plugging in a USB keyboard and mashing F12 at boot time works too, though a "hold shift while clicking shutdown" Vulcan nerve pinch is required to prevent Windows from simply hibernating. An external keyboard certainly makes the BIOS menus easier to navigate, though it's possible to do it with just the on-screen pointer and the hardware mouse buttons. There's a reasonable number of knobs which can be frobbed within the BIOS; disabling secure boot is naturally one of the more useful ones for my purposes.

I took a recovery image of the Windows installation (not planning on going back, but nevertheless good practice and a good way to use up all of my decent USB sticks), and flashed the OpenBSD 6.3 install image (the one with all the install sets, so a network connection isn't required) onto a separate USB flash drive. Attempting to boot from the install USB results in a scary red error box warning me that the boot image does not have a valid secure boot signature (yes, in spite of putting what looks like the secure boot switch into the "off" position). Enabling the CSM and turning on various options regarding legacy BIOS booting did not help. The only other option in the security menu is to blow away all of the enrolled secure boot keys and databases, which sounds really awfully scary to someone who doesn't understand how even half of UEFI works (i.e. me). After about half a day of indecision, I got sufficiently impatient to select that option and erase the information. Result: the tablet now boots from my USB stick.

The OpenBSD installation runs as normal, though an external keyboard is a hard requirement. The WiFi chipset (iwn(4)) needs firmware, so an ethernet cable in the side is actually necessary post-install to download the firmware. The inbuilt WiFi adaptor also performs very poorly (though I suspect my device may simply have a bad antenna or a loose connection), but I have a handful of urtwn(4)-compatible adaptors which work acceptably well. I'm comfortable leaving one more or less permanently in one of the USB ports next to the fan exhaust (yes, this tablet has a CPU fan!), as that edge of the device will generally be pointing away from me.

Various miscellaneous tweaks that I make to all my OpenBSD installations follow, in this case installing syspatches, rcctl disable smtpd pflogd slaacd (I know in advance that the networks I'm going to be around will sadly be native-IPv6-free zones), pkg_add nano htop colorls and various customisations to user and system ksh(1) startup files. "Add a pinch of salt, and season to taste."


WM and interface

A little custom configuration is required to make this machine usable as a tablet. To begin with, I experimented with a few floating window managers and initially settled on Flwm, as it gives you a menu for opening new xterm(1)s when you left-click on the root window (which can thus be triggered by tapping in the root window). I then installed "Xvkbd" from packages, put this line into /etc/X11/xenodm/Xsetup_0:

/usr/local/bin/xvkbd -no-keypad -minimizable -secure -xdm -nonexitable -geometry 990x286+174+470

and enabled xenodm(1). This gives me a virtual on-screen keyboard when the login manager loads which persists into my login session and which, critically, I cannot close (as it runs as root and I don't).

Screen rotation

The screen does not automatically rotate -- this must be scripted. The tablet has a hardware push-switch next to the power button, which Windows interprets as "toggle autorotation on and off". xev(1) shows that pushing this switch delivers "Super_L + o" to the X server; this can be wired up to xbindkeys(1).

xrandr(1) can be used to change the screen orientation, but this does not rotate the touch screen inputs. Some quick googling yielded this GitHub gist, which combines xrandr(1) with xinput(1) to rotate both the display and touch screen inputs at the the same time -- set $TOUCHSCREEN to "/dev/wsmouse2", leave $TOUCHPAD empty and that script works as expected on my device. I adapted this script to toggle between the "normal" and "right" orientations, configured xbindkeys(1) to launch this script upon "Mod4 + o" and then added a line to my ~/.xsession to run xbindkeys(1) on session startup.

Unfortunately, I discovered at this point that Flwm doesn't handle screen rotation all that well. It will not compensate for windows moving out of the visible screen area upon the display rotating -- other window managers will move windows so that their edges are at least within the visible screen area. This can be a bit of a showstopper when xvkbd(1) is rotated out of the accessible screen region. I worked around this by switching to Openbox and then configuring it to launch the root window menu upon left click instead of right (grep for <context name="Root"> in rc.xml). I also increased the window border width to make it easier to grab the window borders to resize them -- mkdir ~/.themes and copy one of the themes from /usr/local/share/themes to ~/.themes (I just grabbed the default Clearlooks theme) and in the themerc file at the bottom of the theme's directory hierarchy, increase the border.width value (I used five pixels). openbox --reconfigure will load the changes in-place.


I installed Xournal from packages for taking handwritten notes; I haven't played with this extensively yet, but it seems to work pretty well so far.

For testing purposes, I installed Firefox and played a YouTube video or two, which Just Works (though a touch-screen interface to Firefox is a smidge cumbersome). The hardware volume control buttons also work out of the box, by the way, which is pretty refreshing.


Flames to 'SiFuh' on IRC for giving me the idea to do this in the first place. Kudos to 'SiFuh' on IRC for figuring out and sharing a whole load of details on configuring the tablet for use as a tablet, especially for mentioning that xvkbd(1) was a thing and providing the necessary incantation to start it appriopriately, and for coming up with the idea for hardware switch controlled screen rotation.


OpenBSD 6.3 (GENERIC.MP) #3: Fri May 18 00:06:26 CEST 2018
real mem = 4152766464 (3960MB)
avail mem = 4019843072 (3833MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xb8ad2018 (50 entries)
bios0: vendor American Megatrends Inc. version "S10M.F308" date 03/10/2014
bios0: GIGABYTE S10M
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: wakeup devices XHC1(S0) PXSX(S4) PXSX(S4) PXSX(S4) PXSX(S4) PWRB(S0) BRCM(S0)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Celeron(R) CPU N2805 @ 1.46GHz, 1466.94 MHz
cpu0: 1MB 64b/line 16-way L2 cache
acpitimer0: recalibrated TSC frequency 1466670625 Hz
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 133MHz
cpu0: mwait min=64, max=64, C-substates=, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Celeron(R) CPU N2805 @ 1.46GHz, 1466.67 MHz
cpu1: 1MB 64b/line 16-way L2 cache
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 87 pins
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-255
acpihpet0 at acpi0: 14318179 Hz
acpihpet0: recalibrated TSC frequency 1466669013 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (RP01)
acpiprt2 at acpi0: bus 2 (RP02)
acpiprt3 at acpi0: bus 3 (RP03)
acpiprt4 at acpi0: bus 4 (RP04)
acpiec0 at acpi0: not present
acpiec1 at acpi0
acpicpu0 at acpi0: C3(10@1500 mwait.1@0x52), C2(10@500 mwait.1@0x58), C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: C3(10@1500 mwait.1@0x52), C2(10@500 mwait.1@0x58), C1(1000@1 mwait.1), PSS
acpipwrres0 at acpi0: PLPE
acpipwrres1 at acpi0: PLPE
acpipwrres2 at acpi0: USBC, resource for EHC1, OTG1
acpipwrres3 at acpi0: CLK0, resource for CAM1
acpipwrres4 at acpi0: CLK1, resource for CAM0, CAM2
acpipwrres5 at acpi0: FN00, resource for FAN0
acpitz0 at acpi0: critical temperature is 90 degC
"INT3396" at acpi0 not configured
acpibat0 at acpi0: BAT1 model "S10M" serial   type LI-ION oem "GIGABYTE"
acpibat1 at acpi0: BAT2 not present
acpials0 at acpi0: ALS_
acpiac0 at acpi0: AC unit offline
"MSFT0001" at acpi0 not configured
"PNP0C14" at acpi0 not configured
acpibtn0 at acpi0: LID0
"DMA0F28" at acpi0 not configured
acpibtn1 at acpi0: PWRB
acpibtn2 at acpi0: SLPB
"BCM2E1A" at acpi0 not configured
"BCM4752" at acpi0 not configured
"INTCF0B" at acpi0 not configured
"INTCF1A" at acpi0 not configured
"INTCF1C" at acpi0 not configured
"SMO91D0" at acpi0 not configured
"ATML2000" at acpi0 not configured
"MSFT0002" at acpi0 not configured
"INT33BD" at acpi0 not configured
"PNP0C0B" at acpi0 not configured
acpivideo0 at acpi0: GFX0
acpivout0 at acpivideo0: DD1F
cpu0: Enhanced SpeedStep 1466 MHz: speeds: 1463, 1330, 1197, 1064, 931, 798, 665, 532 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel Bay Trail Host" rev 0x0a
inteldrm0 at pci0 dev 2 function 0 "Intel Bay Trail Video" rev 0x0a
drm0 at inteldrm0
inteldrm0: msi
inteldrm0: 1366x768, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
ahci0 at pci0 dev 19 function 0 "Intel Bay Trail AHCI" rev 0x0a: msi, AHCI 1.3
ahci0: port 0: 3.0Gb/s
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 0 lun 0: <ATA, LITEON IT LMT-64, HM63> SCSI3 0/direct fixed naa.5002303100216c73
sd0: 61057MB, 512 bytes/sector, 125045424 sectors, thin
xhci0 at pci0 dev 20 function 0 "Intel Bay Trail xHCI" rev 0x0a: msi
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 addr 1
"Intel Bay Trail TXE" rev 0x0a at pci0 dev 26 function 0 not configured
azalia0 at pci0 dev 27 function 0 "Intel Bay Trail HD Audio" rev 0x0a: msi
azalia0: codecs: Realtek ALC269, Intel/0x2882, using Realtek ALC269
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel Bay Trail PCIE" rev 0x0a: msi
pci1 at ppb0 bus 1
iwm0 at pci1 dev 0 function 0 "Intel Dual Band Wireless AC 7260" rev 0x73, msi
ppb1 at pci0 dev 28 function 1 "Intel Bay Trail PCIE" rev 0x0a: msi
pci2 at ppb1 bus 2
ppb2 at pci0 dev 28 function 2 "Intel Bay Trail PCIE" rev 0x0a: msi
pci3 at ppb2 bus 3
re0 at pci3 dev 0 function 0 "Realtek 8168" rev 0x06: RTL8168E/8111E-VL (0x2c80), msi, address 74:d4:35:eb:0d:9b
rgephy0 at re0 phy 7: RTL8169S/8110S/8211 PHY, rev. 5
ppb3 at pci0 dev 28 function 3 "Intel Bay Trail PCIE" rev 0x0a: msi
pci4 at ppb3 bus 4
pcib0 at pci0 dev 31 function 0 "Intel Bay Trail LPC" rev 0x0a
ichiic0 at pci0 dev 31 function 3 "Intel Bay Trail SMBus" rev 0x0a: apic 1 int 18
iic0 at ichiic0
spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM PC3-12800 SO-DIMM
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
vmm0 at mainbus0: VMX/EPT
efifb at mainbus0 not configured
urtwn0 at uhub0 port 1 configuration 1 interface 0 "Realtek 802.11n WLAN Adapter" rev 2.00/2.00 addr 2
urtwn0: MAC/BB RTL8188CUS, RF 6052 1T1R, address 00:0f:12:17:11:90
uhub1 at uhub0 port 3 configuration 1 interface 0 "Genesys Logic USB2.0 Hub" rev 2.00/32.98 addr 3
uhidev0 at uhub1 port 1 configuration 1 interface 0 "Full-Speed Mouse Full-Speed Mouse" rev 1.10/0.08 addr 4
uhidev0: iclass 3/1, 2 report ids
ums0 at uhidev0 reportid 1: 5 buttons, Z dir
wsmouse0 at ums0 mux 0
uhid0 at uhidev0 reportid 2: input=2, output=2, feature=0
uhidev1 at uhub1 port 1 configuration 1 interface 1 "Full-Speed Mouse Full-Speed Mouse" rev 1.10/0.08 addr 4
uhidev1: iclass 3/1
ukbd0 at uhidev1: 8 variable keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
ugen0 at uhub1 port 2 "Intel product 0x07dc" rev 2.00/0.01 addr 5
uhidev2 at uhub1 port 4 configuration 1 interface 0 "eGalax Inc. eGalaxTouch EXC7903-48v00_Test9" rev 2.00/48.00 addr 6
uhidev2: iclass 3/1, 7 report ids
ums1 at uhidev2 reportid 1: 2 buttons
wsmouse1 at ums1 mux 0
uhid1 at uhidev2 reportid 3: input=63, output=63, feature=0
uhid2 at uhidev2 reportid 5: input=0, output=0, feature=2
ums2 at uhidev2 reportid 6: 1 button, tip
wsmouse2 at ums2 mux 0
ums3 at uhidev2 reportid 7
ums3: mouse has no X report
uhub2 at uhub0 port 4 configuration 1 interface 0 "Genesys Logic USB2.0 Hub" rev 2.00/32.98 addr 7
uvideo0 at uhub2 port 1 configuration 1 interface 0 "27C40-06N20-L01S44I3YX HD WebCam" rev 2.00/0.03 addr 8
video0 at uvideo0
uhidev3 at uhub2 port 3 configuration 1 interface 0 "STMicroelectronics ST_SENSOR_HUB" rev 2.00/0.26 addr 9
uhidev3: iclass 3/0, 14 report ids
uhid3 at uhidev3 reportid 1: input=50, output=0, feature=55
uhid4 at uhidev3 reportid 2: input=50, output=0, feature=55
uhid5 at uhidev3 reportid 3: input=50, output=0, feature=55
uhid6 at uhidev3 reportid 4: input=50, output=0, feature=55
uhid7 at uhidev3 reportid 5: input=50, output=0, feature=55
uhid8 at uhidev3 reportid 6: input=50, output=0, feature=55
uhid9 at uhidev3 reportid 14: input=16, output=16, feature=0
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (b4251e7cdb54e046.a) swap on sd0b dump on sd0b
iwm0: hw rev 0x140, fw ver 16.242414.0, address a0:a8:cd:07:bd:6d