Packaging

| categories: usb, ups, linux | View Comments

A few posts ago I described the proof of concept for making my Tripplite UPS work despite the braindamage in the USB interface. Well, that UPS is even more expensive now, because to avoid having to redo all those hacks on a major OS update, you have to package the code. This means wrapping up all the little configs and scripts and other packages that also need to be installed, so that installing the package does all or almost all of the work for you.

I was also reminded of the importance of proper licensing. My original hack was based on hubpower, which has no license. This means I would have to contact the author and ask for written permission in order to distribute his code (or a compiled version). So for my package to be public, I had to adjust it to use hub-ctrl, which includes the written permission along with the code. This is a necessary feature of open source code if you expect anyone else to build on it. No one is going to take the time to contact you to get written permission.

So, after some more debugging with the new component, and some packaging, I have a mostly working version of trippfix. I still haven't figured out how to disable hald-addon-hid-ups in the package. I have to manually kill it when rebooting. I do have a hal policy file, but it doesn't work. Hal goes away in EL7 (having been assimilated into the borg...I mean systemd), so it is not worth spending too much time on it.

Read and Post Comments

Standards Schmandards

| categories: usb, ups, linux | View Comments

The Good News

As part of upgrading my home data center to better serve Spanish House Ministries, I bought a new UPS unit with longer runtime and AVR. The good news is that the new Tripp Lite has a 50 minute runtime at 18% load (versus 35 minutes with my old APC 1500). It also has robust AVR (Active Voltage Regulation) that is confirmed to compensate for switchover to generator power.

The Bad News

The bad news is that they totally screwed up the USB port needed for the server to monitor the UPS. It locks up every few days, and even resetting the hub controller does not reset it - it ignores the reset and address assignment requests from the hub, i.e. it does not implement the mandatory reset feature of the USB 2.0 standard. Reviews indicate that even their proprietary Windows software is stymied by this defect, but Windows users accept it as par for the course, naturally. (Windows users have trouble distinguishing between hardware and software problems.)

Industry Standards to the Rescue

It can be reset by removing and reinserting the USB cable, however. So, since the USB 2.0 standard mandates that all hubs implement port power control (either individually, or at a minimum, turning off all ports on the hub), I can just power cycle the port. In the worst case, with a cheap hub, I might have to dedicate a hub to the UPS if nothing else could be turned off. Here are the relevant paragraphs from the USB 2.0 specification:

Optional Per Port Power Switching (PPPS)

Self-powered hubs may have power switches that control delivery of power downstream facing ports but it is not required. Bus-powered hubs are required to have power switches. A hub with power switches can switch power to all ports as a group/gang, to each port individually, or have an arbitrary number of gangs of one or more ports. A hub indicates whether or not it supports power switching by the setting of the Logical Power Switching Mode field in wHubCharacteristics. If a hub supports per-port power switching, then the power to a port is turned on when a SetPortFeature(PORT_POWER) request is received for the port. Port power is turned off when the port is in the Powered-off or Not Configured states. If a hub supports ganged power switching, then the power to all ports in a gang is turned on when any port in a gang receives a SetPortFeature(PORT_POWER) request. The power to a gang is not turned off unless all ports in a gang are in the Powered-off or Not Configured states.

Mandatory All Ports Off State

Although a self-powered hub is not required to implement power switching, the hub must support the Powered-off state for all ports. Additionally, the hub must implement the PortPwrCtrlMask (all bits set to 1B) even though the hub has no power switches that can be controlled by the USB System Software.

The Sad Reality

While most USB microcontrollers used in hubs properly implement one or both of these options (controlled by configuration pins), unfortunately, it seems that nearly all actual USB hubs in a box on the market ignore this mandatory feature, and just hardwire Vcc on all ports to 5V.

The Workaround

A few enterprising hardware hackers have fixed this with a soldering iron, but that was beyond the level of "enjoyable challenge" in getting this already ridiculously expensive (given my time spent) UPS to work. So I found a list of working hubs, and bought a Linksys USB2HUB4. I hooked it up just now and tested it. Woo Hoo! I can turn the LED lamp plugged into a port off and on! Now to wait for the USB port on the UPS to fail again and verify that a power cycle resets it. Assuming that works, I just need to add a hook to the NUT software on the server to power cycle the port whenever the UPS drops off the USB bus.

Read and Post Comments

Fedora CJDNS package accepted

| categories: mesh, linux | View Comments

One of my spare time projects for the last few months has been getting my Fedora package for CJDNS accepted. Today, it was approved.

CJDNS history

CJDNS was originally a project to address the increasing government censorship through DNS. The goal was to create a decentralized DNS replacement. DNS is a hard problem, because the government authorities also address legitimate issues like squatters on trademarked domains1.

As part of the infrastructure for CJDNS, CJD created an end-to-end IP6 vpn with cryptographic address allocation. This protects against spoofing of IPs, and Man-in-the-middle attacks. CJDs DNS solution was problematic, but the IP6 VPN was simple and elegant, and has taken off. All that is to explain why an IP6 VPN is named CJDNS when it has nothing to do with DNS. There have, of course, been efforts to rename the project, but none have gained much traction.

CJDNS addresses

A CJDNS node creates an elliptic curve public/private key pair. The truncated SHA-512 hash of the public key forms the IP6 address. To allow interoperation with the IANA internet, only IPs in the FC00::/8 net are used. FC00::/7 is reserved by IANA for private address spaces.

Source routing

The CJDNS protocol is source routed. This makes experimenting with new routing algorithms much easier, as other nodes don't need to know about your new algorithm. They just follow the route instructions provided by the source node, and send back an error packet if there is a problem (a peer no longer exists, for instance). I've been working on electric routing.


  1. In my opinion, the DNS censorship problem has been adequately addressed with namecoin. Namecoin domains typically point to traditional DNS servers. I've proposed an extension to namecoin that attempts to provide a decentralized replacement for traditional DNS servers. 

Read and Post Comments