2016 June 24
Disabling USB Port for Acroname Hub
Many customers have found the Acroname USBHub2x4 useful in production environments, but in some cases, when the hub is powered up/booted it may be best if the downstream ports are NOT enabled. This is particularly useful for cases when there are networking address collisions between the downstream USB devices - or when you are testing USB devices, but only one of those devices can be attached to the host at any given time.
The default behavior of the USBHub2x4 when it boots up is to enable all four of it's downstream ports. Though this makes sense for normal off-the-shelf USB hub behavior, it may not be convenient for test or embedded environments. This is where the flexibility of Acroname's programmability features via BrainStem and Reflex functions becomes apparent and can be fully exploited. Since the USBHub2x4 has an on-board RTOS and supports several slots for Reflex programs, we can load and then enable a Reflex that will disable all of the downstream ports.
Below is an example Reflex for implementing the "all downstream ports disabled at boot" function
The Reflex will stay resident and persistent in the device and execute immediately after boot time/power on. Once loaded into the hub and enabled, this Reflex will change the effective default state of the downstream ports to disabled. The ports can then be enabled selectively via BrainStem API or the HubTool interface. In the future, if this function is no longer needed, the Reflex can be disabled or removed from the USBHub2x4.
To start, you will need a USBHub2x4, powered up of course, attached to your host computer. In this case, the USBHub2x4 is connected to a Mac and we will use the Python command line interface to compile the "USBHub_disable_on_boot.reflex" file, load the Reflex file into our hub and then enable it. Once we are done, the Reflex will execute each time the USBHub2x4 is powered on or reset - and we should see that all the downstream ports are disabled. Here is a copy of the USBHub_disable_on_boot.reflex code. You can save it directly to a .reflex file using a standard text editor:
#include <ausbhub2x4.reflex> // Create a reference to this module. aUSBHub2x4 hub; #define DELAY 1000000 // mapEnable executes when the reflex is enabled. // we set upd the counter, set the timer mode to // repeat, and set the timer to expire after delay. reflex mapEnable() { hub.usb.setPortDisable(0); hub.usb.setPortDisable(1); hub.usb.setPortDisable(2); hub.usb.setPortDisable(3); }
1. Download the Brainstem Development kit software package from our support download page, you need at least v2.2.6.
2. Extract the package, on windows this is a zip file, on linux its a tgz and on mac its a dmg.
3. Place the attached USBHub_disable_on_boot.reflex file into the bin directory from the download. (This is just a text document, check it out in our reference guide on Reflex functions)
3. Open your command line utility and navigate to the package bin directory. (Here, we show it with a mac command line, but the procedure is similar on all platforms.)
HeavyLightning:~> cd /path/to/kit/bin
4. Compile the reflex file
HeavyLightning:bin> ./arc USBHub_disable_on_boot.reflex
Acroname Reflex Compiler (arc)
version 1.0, build 33051391
Copyright 1994-2015, Acroname Inc.
compiled to 41 bytes in USBHub_disable_on_boot.map
5. Load the resulting map file with the ReflexLoader utility (-h will show you usage info). the -d option argument should be the serial number of your device.
HeavyLightning:bin> ./ReflexLoader -d 0x5BFE8F91 -L -i USBHub_disable_on_boot.map INTERNAL 0
ReflexLoader [Version: 1.0 Jun 9 2016 14:56:44]
[BrainStem Release: 2.2.7]
[Copyright (C) 2016, Acroname Inc.]
ReflexLoader: connected to device: 5BFE8F91
PROCESSING DOWNLOAD
Bytes loaded: 41
The slot was loaded successfully
ReflexLoader [Version: 1.0 Jun 9 2016 14:56:44]
[BrainStem Release: 2.2.7]
[Copyright (C) 2016, Acroname Inc.]
5a. If you need to find your Hub’s serial number you can use Updater to list it.
HeavyLightning:bin> ./Updater -D -t USB
Updater [Version: 1.1 Jun 9 2016 14:56:39] [BrainStem Release:2.2.7] [Copyright (C) 1994-2016, Acroname Inc.]
Discovering Devices [USB]:
Device Module Router Model Firmware Version
5BFE8F91 06 06 11 [USBHub2x4 ] 2.2.6 (0)
Completed processing: Updater [Version: 1.1 Jun 9 2016 14:56:39] [BrainStem Release:2.2.7] [Copyright (C) 1994-2016, Acroname Inc.]
6. Enable the reflex on boot.
HeavyLightning:bin> ./ReflexLoader -d 0x5BFE8F91 -B INTERNAL 0
ReflexLoader [Version: 1.0 Jun 9 2016 14:56:44]
[BrainStem Release: 2.2.7]
[Copyright (C) 2016, Acroname Inc.]
ReflexLoader: connected to device: 5BFE8F91
PROCESSING SET BOOT
The new boot slot has been set and saved; However, a system reset is still required
ReflexLoader [Version: 1.0 Jun 9 2016 14:56:44]
[BrainStem Release: 2.2.7]
[Copyright (C) 2016, Acroname Inc.]
7. Power cycle the Hub and using HubTool, the Reflex will execute and you should see that all of the devices stay disabled.
You can still enable and disable them via HubTool or the software API’s.
You can still enable and disable them via HubTool or the software API’s.