Tag Archives: usb

Pine64 + USB drive

It looks like a crazy ball of string and rubber bands now. I added an external SSD in an enclosure powered by the compatible JMS578 chipset. But the board itself cannot supply enough power through USB to external drivers, so there’s also a powered USB hub (thus the whole thing needs two power supplies).

It works is the best I can say about it at this point.

Important edit: I discovered that the powered USB hub is not necessary (presumably because this is an SSD, not a spinning disk). That eliminates the power supply problem.


March 25, 2017 · 5:52 pm

USB Per Port Power Switching

Increasing numbers of single board computers are powered by USB ports using a cable like this:


Wouldn’t it be cool if you could plug these into a USB hub and have the hub individually power up and down the computers? Like a cheap APC power management board.

It turns out you can — with difficulty. The USB standard defines Per-Port Power Switching (PPPS) but unfortunately almost no hub in existence actually supports it. To save a few cents on the BOM, the manufacturers generally leave out the extra power transistors needed to make it work. One guy has modified his USB hub to add the extra part and full marks to him but that’s a lot of effort.

There is one hub which actually supports this: The D-Link DUB-H7, but only the first version (the silver/grey case). In the second version (black case), D-Link too realized their “mistake” and saved on the extra bits.

Armed with this knowledge, I bought one of these from the US (shipping cost 3x the cost of the hub itself).

And it works! Well, for a while.


I used the C hub-ctrl program from this page, and the instructions from here.

# lsusb
Bus 003 Device 005: ID 2001:f103 D-Link Corp. DUB-H7 7-port USB 2.0 hub

Switch off port 7 (right-most port):

# ./hub-ctrl -b 3 -d 5 -P 4 -p 0

Switch on port 7:

# ./hub-ctrl -b 3 -d 5 -P 4 -p 1

The ports are not numbered in the same sequence as the ports on the hub itself. I found by experimentation that the ports correspond as follows. I don’t know if it’ll be the same on every model:

Port hub-ctrl option
1 (left) -P 5
2 -P 6
3 -P 1
4 -P 2
5 -P 7
6 -P 3
7 (right) -P 4

The bigger problem is the hub is fairly unreliable. Switching ports on or off too frequently seems to result in the hub crashing, which appears to only be recoverable by powering the hub off for several seconds.

So I’m not quite there.


Filed under Uncategorized

Making a serial cable for the ODROID XU


As I’ve said before, developer boards should come with all the bits, and a UART is essential for development on ARM.

I built my own using the jump leads from an unused CP2102, and this 1.8v FTDI serial to USB cable purchased previously.

The ODROID-XU board has a four pin Molex-type UART connector. The pin-out is: 1 = Power (do not connect), 2 = RX, 3 = TX, 4 = Ground. Pin 1 has the triangular notch on the outside of the connector. In the photo above, black is connected to pin 4 (ground), blue is connected to pin 3 (TX), and purple is connected to pin 2 (RX).

The FTDI cable has: Black = ground, Yellow = RX, Orange = TX.

Normally I would swap RX & TX in the cable, but that didn’t work here, so as you can see I’ve connected RX-RX, TX-TX straight through.

The photograph shows the connection before I wrapped the whole lot in many layers of black electrical tape.


Filed under Uncategorized

Tip: Convert a Windows DVD ISO to a bootable USB key using guestfish

Situation: You have a Windows DVD (or ISO), but like any sane person in 2013 you don’t have a DVD drive on the computer. You want to convert the Windows DVD into a bootable USB key. There are many recipes for this online, but they all require another Windows machine and of course cannot be automated.

However with guestfish (and the always brilliant SYSLINUX doing most of the heavy lifting), this script will unpack the ISO and turn it into a bootable USB key.


  1. I am not going to support this script. You will need to read the script, look up the commands in the guestfish man page, and understand what it does. Any requests for help will be deleted unread.
  2. You need to edit the USB key device before using the script.
  3. You need libguestfs ≥ 1.21 with SYSLINUX support compiled in.
#!/bin/bash -

guestfish <<'EOF'
trace on

add-ro en_microsoft_hyper-v_server_2012_x64_dvd_915600.iso

# NB: The next line MUST be changed to your USB drive.
add /dev/sdX


# Inside the appliance, /dev/sda = DVD, /dev/sdb = USB.

echo "Partitioning the USB disk ..."
part-init /dev/sdb mbr
part-add /dev/sdb p 63 -1
part-set-mbr-id /dev/sdb 1 0xb
part-set-bootable /dev/sdb 1 true
mkfs vfat /dev/sdb1

echo "Copying the contents of the DVD to the USB key ..."
mkmountpoint /cd
mkmountpoint /usb
mount /dev/sda /cd
mount /dev/sdb1 /usb
# XXX We should add cp-r command XXX
debug sh "cp -rP /sysroot/cd/* /sysroot/usb"
#glob cp-a /cd/* /usb
umount /cd
umount /usb
rmmountpoint /cd
rmmountpoint /usb

echo "Making the USB key bootable using SYSLINUX ..."
syslinux /dev/sdb1
mount /dev/sdb1 /
upload /usr/share/syslinux/chain.c32 /chain.c32
write /syslinux.cfg "DEFAULT windows\n\nLABEL windows\nCOM32 chain.c32\nAPPEND fs ntldr=/bootmgr\n"
umount /dev/sdb1
upload /usr/share/syslinux/mbr.bin /dev/sdb

echo "Finished."



Filed under Uncategorized

Real cheap Software Defined Radios?

It seems someone worked out that the Realtek RTL2832U found in various very cheap USB DVB-T decoders can be repurposed as a complete software-defined radio. The sidebar of this subreddit seems to be the best place to start.

Update: This is the Ezcap EZTV645 from Deal Extreme:

[175189.929963] usb 1-1.1: new high-speed USB device number 7 using ehci_hcd
[175190.028379] usb 1-1.1: New USB device found, idVendor=0bda, idProduct=2838
[175190.028385] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[175190.028389] usb 1-1.1: Product: RTL2838UHIDIR
[175190.028392] usb 1-1.1: Manufacturer: Realtek
Bus 001 Device 007: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T


Filed under Uncategorized

guestfish — not just for disk images

You know you can run libguestfs / guestfish on anything, right? This question came up at one of the Summit parties, so maybe some people don’t know. But it works on USB keys, CDs, hard disks, partitions, and files (and more).

There is a practical benefit to using libguestfs on USB keys, because it adds a layer of isolation between the unknown contents of the USB key and your host kernel. Mounting random disks on your host kernel is deeply insecure.

In the example below, I’ve stuck in a random USB key (empty and safe as it happens, but how was I to know?) and I ran guestfish on the first partition directly:

$ guestfish -a /dev/sdb1

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> run
 100% ⟦▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉⟧ 00:00
><fs> mount-options "" /dev/vda /
><fs> ll /
total 36
drwxr-xr-x  2 root root 32768 Jan  1  1970 .
drwxr-xr-x 24  500  500  4096 Jul  9 17:11 ..
><fs> df-h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda              3.7G   32K  3.7G   1% /sysroot

(I don’t need to be root, because I’ve added myself to the “disk” group, which means I can access any block device.)

Above, I ran guestfish on the USB key’s first partition (/dev/sdb1, so that inside libguestfs the partition appears as a whole device (/dev/vda). Equally I could have run guestfish on the whole USB key (/dev/sdb), in which case libguestfs would see and be able to manipulate the partition table too.


Filed under Uncategorized

Yubikey arrived

It arrived this morning, about 20 hours after I placed the order. I haven’t had a chance to do anything other than plugging it in yet.

usb 1-1.1: new low speed USB device using ehci_hcd and address 5
usb 1-1.1: New USB device found, idVendor=1050, idProduct=0010
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.1: Product: Yubico Yubikey II
usb 1-1.1: Manufacturer: Yubico
input: Yubico Yubico Yubikey II as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input9
generic-usb 0003:1050:0010.0001: input,hidraw0: USB HID v1.11 Keyboard [Yubico Yubico Yubikey II] on usb-0000:00:1a.0-1.1/input0

lsusb output:

Bus 001 Device 005: ID 1050:0010 Yubico.com Yubikey

Pressing the one button on the yubikey sends a string of random letters (as if typed on the keyboard or another USB input device). The string is different each time.

That’s all for now folks!

Leave a comment

Filed under Uncategorized