GangFlasher-ST DLL custom USB configuration

The GangFlasher-ST software provides various functions for handling multiple targets using automatically assigned or fixed USB ports.

  1. This function executes an automatic scan of all USB ports for detection on a first-detected assignation of all MPU USB-DFU devices found. As the devices are detected, they are assigned to targets 1 through 8. The function will detect all available devices (up to 8) but the mapping of a specific MPU found to device index might not be the same if running the function multiple times:

    F_USBAutoScanAndAssign(); //Detect all connected devices .. F_SaveUSBConfig("my_automatic_usb.cfg"); //Save current mapping to file for reuse.
  2. This function provides a more deterministic way to map the MPU devices to target indices and their corresponding USB cables. Each call of this function will add one MPU’s USB port/hub address to the next available target index. Therefore, by connecting one new MPU to the computer at a time, then calling this function in a loop with a prompt, each cable can be labelled 1 through 8 with the corresponding added target (code example below). After the mapping process, the result USB addressing file can be saved using the

F_USBAutoScanAssignSingle(); //Detect devices one at a time. (call multiple times with prompt) ... F_SaveUSBConfig("my_defined_usb.cfg"); //Save current mapping to file for reuse.

 

In the context of the above functions, any existing mapping is reset when the target configuration is loaded using the F_LoadTargetConfig() function. Therefore F_USBAutoScanAndAssign() must be called before F_USBAutoScanAssign() or F_USBAutoScanAssignSingle().

Example below “simple_debug.cpp“ that can be ran from the demo/bin directory. It requires the GangFlasher.lib to be included:

#include <stdio.h> #include <string> #include <iostream> #include "../include/GangFlasher-Dll.h" using namespace std; int main(int argc, char* argv[]) { int st; if (argc < 2) { cout << "Usage: <config>" << endl; return 1; } cout << "F_Init : " << dec << F_Init() << endl; cout << "F_LoadTargetConfig : " << dec << F_LoadTargetConfig(argv[1]) << endl; //Uncomment to assign all units at once //cout << "F_USBAutoScanAndAssign : " << dec << F_USBAutoScanAndAssign() << endl; //This sequence will assign units one at a time for (int i = 0; i < 8; i++) { cout << "F_USBAutoScanAssignSingle : " << dec << F_USBAutoScanAssignSingle() << endl; //Add enter prompt or other wait state to have time to connect one device at a time } F_SaveUSBConfig("C:\\Users\\Public\\lastused_gfst_USB_setup.cfg"); cout << "F_LoadUSBConfig( \"C:\\Users\\Public\\lastused_gfst_USB_setup.cfg\" ) : " << dec << F_LoadUSBConfig("C:\\Public\\Downloads\\lastused_gfst_USB_setup.cfg") << endl; cout << "F_Connect : " << dec << F_Connect() << endl; cout << "F_Load_OS : " << dec << F_Load_OS() << endl; cout << F_Get_Target_Report(0) << endl; cout << F_Get_Target_Report(1) << endl; cout << "F_DeInit : " << dec << F_DeInit() << endl; return 0; }

Each call of F_USBAutoScanAssignSingle() adds a single device to GF_DLL configuration. Saving of USB configuration enables way for fixed USB ports usage for future GF_DLL programming.