Thursday, January 18, 2018

iohyve / bhyve USB controller passthrough goodness

I used to have a Windows machine that was dedicated to running software for our printer since the open-source software wouldn't scan and print correctly. Thanks to iohyve and a $20 PCI USB card, I was able to eliminate this machine and replace it with a slimmed down virtual machine.

Here are some tips and steps to get it working:
  • Only PCI devices that support MSI (message signaled interrupts) will work. You can figure all of this out with the command:

    pciconf -lvc


    In my case, I get:

    xhci1@pci0:3:0:0:        class=0x0c0330 card=0x12421b21 chip=0x12421b21 rev=0x00 hdr=0x00
        vendor     = 'ASMedia Technology Inc.'
        device     = 'ASM1142 USB 3.1 Host Controller'
        class      = serial bus
        subclass   = USB
        cap 05[50] = MSI supports 8 messages, 64 bit
        cap 11[68] = MSI-X supports 8 messages
                     Table in map 0x10[0x2000], PBA in map 0x10[0x2080]
        cap 01[78] = powerspec 3  supports D0 D3  current D0
        cap 10[80] = PCI-Express 2 endpoint max data 128(512) NS
                     link x2(x2) speed 5.0(5.0) ASPM disabled(L0s/L1)
        ecap 0002[100] = VC 1 max VC0
        ecap 0001[200] = AER 1 0 fatal 0 non-fatal 0 corrected
        ecap 0019[280] = PCIe Sec 1 lane errors 0
        ecap 0018[300] = LTR 1

  • bhyve expects that PCI devices that will be passed through must be associated with the ppt driver. Rebooting your machine is not required. In the above example, the device is associated with the xhci driver. To associate it with the ppt driver:

    devctl detach pci3:0:0
    devctl set driver pci3:0:0 ppt

    If you execute pciconf -lvc again, you'll now notice:

    ppt1@pci0:3:0:0:        class=0x0c0330 card=0x12421b21 chip=0x12421b21 rev=0x00 hdr=0x00
  • In modern bhyve, you must supply the -S argument to bhyve in order to get PCI passthrough working:

    iohyve set vm_name_here bargs = "-H -w -S"
  • Create the mapping for the PCI device in question:

    iohyve set vm_name_here pcidev:1=passthru,3/0/0
  • Limit or completely disable network access to your virtual server!

Sunday, January 14, 2018

Installing Windows 10 in TrueOS (FreeBSD) in a bhyve container using iohyve

Here's an abbreviated HOWTO install Windows 10 using iohyve on TrueOS.
iohyve is a handy script that helps manage virtual machines in bhyve. More information is available here.

  1. Download installation ISOs
    You can use the Windows Media Creation Tool to download .iso files for Windows 10.
    Download the Red Hat VirtualIO network adapter ISO.
  2. Install the prerequisite packages for iohyve and bhyve
    pkg install tigervnc bhyve-firmware uefi-edk2-bhyve iohyve
  3. Initialize iohyve if you have never used iohyve before
    iohyve setup pool=zfs_poolname_here net=network_nic_here kmod=1
  4. Initialize components
    iohyve cpfw /usr/local/share/uefi-firmware/BHYVE_UEFI.fd
    iohyve cpiso /path/to/Windows_10_installer.iso
    iohyve cpiso /path/to/virtio-win.iso
  5. Create and configure device (example uses 32 gigabytes for C:)
    iohyve create win10 32g
    iohyve set win10 loader=uefi ram=2G cpu=2 vnc=YES vnc_tablet=YES vnc_port=6901 vnc_wait=YES bargs="-H -w" fw=BHYVE_UEFI.fd
  6. Install Windows 10
    iohyve install win10 Windows_10_installer.iso
    vncviewer localhost:6901

    ... stuff happens.
  7. Once install is completed and the VM shuts down, install the virtio network driver
    iohyve install win10 virtio-win.iso

    Navigate the explorer to the "d:" drive, open the NetKVM directory for your architecture, find the .inf file and right-click it to "Install." Congratulations, your VM can now download teh viruz!
  8. Do cool things to your Windows using zfs commands.
Some caveats about bhyve:
  1. You can't run bhyve and VirtualBox at the same time.
  2. If you try to run bhyve, and then want to run VirtualBox, it seems that it is not possible to kldunload the byhve module vmm that occupies the hypervisor (it is possible to unload nmdm).

Friday, October 6, 2017

Experimental 2 meter / 70 cm dual-band high-gain flower pot antenna using RG6 coax


I decided to modify the original VK2ZOI Experimental
Dual Band Flower Pot Antenna to work with RG6 coaxial cable and utilize a ten-foot-long section of 1+1/4" PVC pipe that is found endemically here in the United States. This resulted in an antenna with SWR of about 1.0 on 146.52 MHz simplex, and 2.0 on 144 and 148 MHz.

Changes from Original Design

Compared with the original VK2ZOI Experimental Flower Pot:
  • Lengths of all segments were implemented as drawn in the VK2ZOI plan
  • "Double-shielded" RG6 that used both foil and light outer braid instead of RG58
  • Top coil: 4 tight turns of RG6. The total length of this cable segment was therefore changed to 630 mm.
  • Bottom coil: 4 loose turns of RG6.

The plans of mice and men...

My original plan involved using a bottom coil of 5 turns RG6. Using SELFRES3.EXE as the calculator, I back-calculated the self-resonant frequencies of the VK2ZOI coils: top coil from 125 through 150 MHz, and bottom coil of 135 MHz. I did not compensate for velocity factor differences and assumed solid-core RG6 has a similar velocity factor to that of solid-core RG58.

The parameters that I used for my RG6:
  • Coil width 5.6 mm
  • Conductor diameter 5 mm
  • Diameter of coil = 42 mm OD of PVC + 6 mm diameter of RG6 = 48 mm

# of Turns Solenoid length, mm Calculated resonant frequency, MHz
3 17 180
4 22 143
5 40 135
5 28 122

Play-by-play

With the five-turn bottom coil, the SWR measured 3 at 146 MHz and ~1.2 at 144 MHz. Trimming the top of the antenna resulted in a reduction of SWR at 144 MHz and 146 MHz to 2.5; further shortening then increased the SWR to about 3 at 146 MHz and was stopped.

Because of the seemingly sharp "knee"-like SWR increase at ~145 MHz, I hypothesized that my lower coil was imparting too much inductance with high Q as the bottom coil ended up being  a lot more tightly packed than I had expected. I therefore removed one turn from the bottom coil and my SWR dropped dramatically at 146 MHz to be nearly 1.0.

I used aluminum foil for coupling sleeve only on the bottom of the antenna at the time of testing.

Prelimiary result with only lower sleeve in place:
SWR 2 144 MHz, 1 @ 146 MHZ, 2 @ 148 MHz.
SWR ~ 1.5 throughout 70cm band.

Special thanks to Roger W7RC (espouses the benefits of RG6) and Bill KG7ULE for
practical advice via the 146.52 MHz Portland Graveyard Net.


Saturday, November 26, 2016

Wiskott-Aldrich Syndrome mnemonic

immunodeficiency, thrombocytopenia, eczema
 Wiskott is riding an ostrich.

The ostrich is sick because it has immunodeficiency; it has epistaxis due to thrombocytopenia and a lot of eczema eggs.

X-linked disorder that causes cytoskeleton rearrangement.

Wednesday, November 23, 2016

Cytochrome P450 Inducers & Inhibitors mnemonics

Moderately offensive mnemonics that induce CYP450:
Nevir drive your carb by Ma's pines,
through the barbwire fence, and
up the ramp
into St. John's woods.

De-phen-ding griseoly bear (on a cycle, "Phossy,") will mo'dafinetly attack your drunk ass.
  • Nevirapine
  • Carbamazepine
  • Barbiturates
  • Rifampin
  • St. John's wort
  • Phenytoin
  • Griseofulvin
  • Cyclophosphamide
  • Modafinil
  • Chronic alcoholism
Offensive mnemonic that off-puts, or inhibits, CYP450:
Ami and Quinn pro-teased Sonia'z azole with grapes and Clara's myce on the ciment floor.
  • Amiodarone
  • Fluoroquinolones
  • Protease inhibitors
  • Isoniazid
  • -azole antifungals
  • Grapefruit juice
  • Clarithromycin
  • Cimetidine

Tuesday, November 22, 2016

Neural crest cell / MEN2 mnemonic

Here's a word-picture to help remember the facts.
Two men "A" and "B" are wearing crowns (neural crests) and are both eating melon (melanocytes).

Man B is really tall and skinny (marfanoid) and has big orthodontics, and he chokes on the melon -- it's gone down his trachea! He freaks out! His lips and his eyelids are swollen!

Man "A," Larry, gives him a cricothyrotomy -- right in his larynx.

Now that it's 10AM, man B enters a muffin store in order to RETurn his melon. There are some seriously lumpy muffins inside...

Man "A" goes to the middle of the store. A swan in the middle of a simulated "sea" (C cells) wearing a royal crest is giving birth. The swan wields a para -- an M249 machine gun, and has HUGE thighs, 'cuz it has been using 'roids.

With the help of her dula, who is pounding on a tympani to help the swan count, she gives birth to a baby swan. Baby swan spirals around, covered in a membrane.

MEN2A/B is a gain of function mutation in the RET (tyrosine kinase) proto-oncogene found on chromosome 10. This affects cells derived from the neural crest. Both types are associated with pheochromocytoma and parathyroid hyperplasia (in type 2A) or Marfanoid habitus and mucosal neuromas (type 2B). These cells are derivatives of neural crest cells and are listed in order of appearance:
  • Melanocytes
  • Odontoblasts
  • Tracheal & laryngeal cartilage
  • Enterochromaffin cells
  • Parafollicular thyroid cells
  • Schwann cells
  • Adrenal medulla
  • Spiral membrane / tympanic surface


Monday, November 21, 2016

Benzodiazepine mnemonics

The Benzos have a contest crossing the Alps.

https://img0.etsystatic.com/053/0/8584318/il_340x270.718469136_liwi.jpg
TOM tries with an ox mid-day;
Team Lorax crosses the Alps in less than a day;
The heavy Latin girls, Flura and Chlora, take more than one dia.

Short-acting: triazolam, oxazepam, midazolam (t½ < 6 hrs.)
Intermediate: temazepam, lorazepam, alprazolam (t½ < 24 hrs.)
Long: flurazepam, chlordiazepoxide, diazepam. (t½ > 24 hrs.)