USB Port Switching for Batch In-Circuit Programming and Testing

2024 October 23

Enhancing Production Efficiency with Batch ICP

In device manufacturing, firmware is flashed onto devices using in-circuit programmers (ICPs).  automated batch programming can help remove the ICP bottleneck.  In this application note, we'll look at how to use USB port switching with Acroname's Industrial USB hubs to boost throughput for batch in-circuit programming and testing.

Typical In-Circuit Programming Setup

In a typical in-circuit programming setup, a host PC is connected to the ICP via USB, and the ICP connects to the Device Under Test (DUT) in a fixture through a header or programming pads. The ICP then flashes the DUT with the necessary firmware. Functional testing can be performed at this stage as well.

Figure 1: Single ICP setup

Improving ICP throughput

Gang Programming

Gang programming allows multiple DUTs to be programmed at once by connecting them in parallel. While this method reduces programming time by flashing several devices simultaneously, some ICP tools require connection of one programmer at a time. 

This is where batch ICP sequencing can offer a good alternative.

Batch ICP with Acroname USB hubs

Acroname's industrial USB hubs, like the USBHub3+, offer a simple solution for batch ICP. By enabling and disabling ports using the Brainstem API, you can control which ICP connects to the host PC, enabling sequential programming. 

Each USBHUb3+ can support up 8 ICPs, and can be daisy chained to support up 32 ICPs, making it a scalable solution for production environments.. 

Figure 2: 8-up batch ICP configuration, ICP 3 active, all others disabled

While batch ICP takes longer than gang programming, the total programming time can still be relatively short.  Operator time is significantly reduced because the system can handle multiple devices in sequence without manual intervention.

Here's how a typical batch ICP process might work in a production environment:

  1. Load DUTs into fixtures: Multiple devices are set up in fixtures that connect to the ICPs via headers or pads.
  2. Trigger the batch ICP script: The host PC initiates the batch programming script, which controls the USB ports via the Brainstem API.
  3. Sequentially program each device:
    • Enable the USB port: The script enables the USB port connected to the ICP, allowing communication between the host PC and the ICP.
    • Flash the DUT and run tests: The ICP uploads firmware to the DUT and optionally performs functional tests.
    • Disable the USB port: Once programming and testing are complete, the port is disabled, freeing up the host for the next ICP and device in the sequence.
  4. Unload DUTs: Once all DUTs in the batch are programmed, they are unloaded and the fixtures are prepared for the next batch.

Transitioning from Single-ICP to Batch Operations

If you are currently using a single-ICP workflow, upgrading to batch ICP is straightforward. You can either modify your existing ICP script to include USB port switching via the BrainStem API or create a batch sequencing script. This sequencing script would control port switching and call your single-ICP flash script for each connected DUT.

Implementing USB Port Control in Python

You can manage USB port switching in your batch ICP script using Python and the subprocess module. This will allow you to execute shell commands, wait for them to complete, and process the exit status to see if the programming was successful.

Here's an example of how you could control USB ports using the BrainStem API in Python:

import brainstem
import subprocess

# Initialize the Acroname USB Hub
hub = brainstem.stem.USBHub3p()
result = hub.discoverAndConnect(brainstem.link.Spec.USB)

if result == Result.NO_ERROR:
    print("Connected\r\n");
else:
    print("Unable to discover device\r\n");
    sys.exit(1)

# Example batch ICP script
def flash_device(port_number, script_command):
    hub.port[port_number].setEnabled(True)  # Enable the port
    result = subprocess.run(script_command, shell=True)  # Run the ICP script
    hub.port[port_number].setEnabled(False)  # Disable the port after flashing
    return result.returncode

# List of ICP ports and their corresponding flash commands
devices = [(0, "flash_script_1.sh"), (1, "flash_script_2.sh")]

for port, command in devices:
    return_code = flash_device(port, command)
    if return_code == 0:
        print(f"Device on port {port} flashed successfully")
    else:
        print(f"Error flashing device on port {port}")

Useful BrainStem API Functions 

To control the USB ports, Acroname provides the following BrainStem API port control functions:

Enable/disable a port:

stem.hub.port[x].setEnabled(True) # Enable port 
stem.hub.port[x].setEnabled(False) # Disable port

Check if a port is enabled:

stem.hub.port[x].getEnabled()

For more details and examples on how to control USB ports with Acroname hubs, visit the official Acroname USBHub3+ documentation.


By building Acroname USB hubs into your batch ICP setup, you can improve throughput and reduce operator intervention.  With simple control via the BrainStem API, you can easily automate the process to maximize the efficiency of your in-circuit programming workflow.

 

 

Add New Comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
We are bots. Are you?