Skip to main content

FreeWili Finder

A cross-platform C/C++ library for discovering and interfacing with FreeWili devices connected to a host system.

Overview

The FreeWili Finder library provides both modern C++ and C APIs to:

  • Discover all connected FreeWili devices automatically
  • Enumerate USB devices associated with each FreeWili
  • Identify device types (Serial ports, Mass storage, FTDI/FPGA, etc.)
  • Access device information (VID/PID, serial numbers, port paths)

Supported Devices

Device DeviceType Detection
FREE-WILi (FW1) FreeWili Hub VID 0x0424 / PID 0x2513
FREE-WILi2 (FW2) FreeWili2 Hub VID 0x093C / PID 0x2059
DEFCON 2024 Badge DEFCON2024Badge Standalone
DEFCON 2025 Badge DEFCON2025FwBadge Standalone
Winky Winky Standalone
UF2 Bootloader UF2 Standalone

FREE-WILi2 components

Every FW2 presents an internal 7-port hub with its processors hanging off of it:

Component Hub port VID / PID USBDeviceType
Hub 0x093C / 0x2059 Hub
Main 1 0x093C / 0x205A SerialMain
Display (optional, usually not populated) 0x093C / 0x2060 SerialDisplay
FTDI / FPGA 3 0x0403 / 0x6014 FTDI
Debug Probe (CMSIS-DAP) 4 0x2E8A / 0x000C DebugProbe
ESP32 (JTAG/serial debug unit) 5 0x303A / 0x1001 ESP32
Mass Storage ("FW Ultra Fast Media") 6 0x093C / 0x205F MassStorage

An ESP32 is only reported as part of a FREE-WILi2 when it is a child of the FW2 hub. A bare ESP32 plugged in elsewhere on the bus is not a standalone FreeWili device and is ignored.

The FW2 serial number is taken from the hub descriptor and is shared by the Main and FTDI components. The Debug Probe and Mass Storage report their own serials.

Features

  • Dual API Support: Modern C++23 API with std::expected error handling, plus C API for maximum compatibility
  • Language Bindings: Python (pyfwfinder) and Zig bindings
  • Cross-Platform: Supports Windows, macOS, and Linux
  • Type Safety: Strongly-typed USB device classification system
  • Error Handling: Comprehensive error reporting and handling
  • Memory Safe: RAII in C++, explicit memory management in C API
  • Testing: Full test suite with GoogleTest integration

Quick Start

C++ API Example

#include <fwfinder.hpp>
#include <iostream>

int main() {
    if (auto devices = Fw::find_all(); devices.has_value()) {
        for (const auto& device : devices.value()) {
            std::cout << "Found: " << device.name
                     << " (Serial: " << device.serial << ")\n";

            // Get serial ports
            auto serials = device.getUSBDevices(Fw::USBDeviceType::Serial);
            for (const auto& serial : serials) {
                std::cout << "  Port: " << serial.port.value_or("Unknown") << "\n";
            }
        }
    } else {
        std::cerr << "Error: " << devices.error() << "\n";
    }
    return 0;
}

C API Example

#include <cfwfinder.h>
#include <stdio.h>

int main(void) {
    fw_freewili_device_t* devices[16];
    uint32_t device_count = 16;
    char error_msg[256];
    uint32_t error_size = sizeof(error_msg);

    if (fw_device_find_all(devices, &device_count, error_msg, &error_size) == fw_error_success) {
        printf("Found %u device(s)\n", device_count);

        for (uint32_t i = 0; i < device_count; ++i) {
            char name[64];
            fw_device_get_str(devices[i], fw_stringtype_name, name, sizeof(name));
            printf("Device: %s\n", name);
        }

        fw_device_free(devices, device_count);
    }
    return 0;
}

Building

Prerequisites

  • CMake 3.20 or later
  • C++23 compatible compiler (GCC 11+, Clang 14+, MSVC 2022+)
  • Platform dependencies:
    • Linux: libudev-dev
    • macOS: Xcode command line tools
    • Windows: Windows SDK (SetupAPI, Cfgmgr32)

Build Instructions

# Clone the repository
git clone https://github.com/your-org/freewili-finder.git
cd freewili-finder

# Create build directory
mkdir build && cd build

# Configure
cmake .. -DCMAKE_BUILD_TYPE=Release

# Build
cmake --build .

# Run tests
ctest --output-on-failure

CMake Options

  • FW_FINDER_BUILD_TESTS=ON/OFF - Build test suite (default: ON)
  • FW_BUILD_C_API=ON/OFF - Build C API library (default: ON)
  • FW_BUILD_STATIC=ON/OFF - Build static libraries (default: ON)
  • FW_BUILD_EXAMPLES=ON/OFF - Build example applications (default: ON)

Python Bindings (pyfwfinder)

Requires Python 3.11+ and uv (recommended) or pip.

# Install with uv (recommended)
uv sync

# Or install with pip
pip install .

Usage:

import pyfwfinder

devices = pyfwfinder.find_all()
for device in devices:
    print(f"{device.name} (Serial: {device.serial})")
    for usb in device.usb_devices:
        print(f"  {usb.kind}: {usb.name}")

API Reference

C++ API (fwfinder.hpp)

Core Functions

namespace Fw {
    // Find all connected FreeWili devices
    auto find_all() noexcept -> std::expected<FreeWiliDevices, std::string>;

    // USB device type detection
    auto getUSBDeviceTypeFrom(uint16_t vid, uint16_t pid) -> USBDeviceType;
    auto getUSBDeviceTypeName(USBDeviceType type) -> std::string;
}

Device Types

enum class DeviceType {
    Unknown,           // Unknown device
    FreeWili,          // FREE-WILi (FW1)
    DEFCON2024Badge,   // DEFCON 2024 Badge
    DEFCON2025FwBadge, // DEFCON 2025 Badge
    UF2,               // UF2 Bootloader mode
    Winky,             // Winky
    FreeWili2,         // FREE-WILi2 (FW2)
};

enum class USBDeviceType {
    Hub,              // USB Hub (parent device)
    Serial,           // Serial Port (general)
    SerialMain,       // MainCPU Serial Port
    SerialDisplay,    // DisplayCPU Serial Port
    MassStorage,      // Mass Storage Device
    ESP32,            // ESP32 USB (JTAG/RTT)
    FTDI,             // FTDI/FPGA Device
    Other,            // Other USB device
    DebugProbe        // CMSIS-DAP Debug Probe (FREE-WILi2)
};

C API (cfwfinder.h)

Core Functions

// Find all devices
fw_error_t fw_device_find_all(fw_freewili_device_t** devices, uint32_t* count,
                              char* error_msg, uint32_t* error_size);

// Device validation and info
bool fw_device_is_valid(fw_freewili_device_t* device);
fw_error_t fw_device_get_str(fw_freewili_device_t* device, fw_stringtype_t type,
                             char* buffer, uint32_t buffer_size);

// USB device enumeration
fw_error_t fw_usb_device_begin(fw_freewili_device_t* device);
fw_error_t fw_usb_device_count(fw_freewili_device_t* device, uint32_t* count);
fw_error_t fw_usb_device_next(fw_freewili_device_t* device);
fw_error_t fw_usb_device_get_str(fw_freewili_device_t* device, fw_stringtype_t type,
                                 char* buffer, uint32_t buffer_size);
fw_error_t fw_usb_device_get_int(fw_freewili_device_t* device, fw_inttype_t type,
                                 uint32_t* value);

// Memory management
fw_error_t fw_device_free(fw_freewili_device_t** devices, uint32_t count);

Examples

Complete example applications are provided in the examples/ directory:

  • basic_usage.cpp - Modern C++ API demonstration
  • c_api_basic_usage.cpp - C API demonstration (compiled as C++)
  • c_api_basic_usage_pure_c.c - Pure C implementation

Build and run examples:

cd build
make basic_usage_cpp basic_usage_c
./examples/basic_usage_cpp
./examples/basic_usage_c

Project Structure

freewili-finder/
├── include/
│   ├── fwfinder.hpp          # Main C++ API header
│   └── usbdef.hpp            # USB device definitions
├── src/
│   ├── fwfinder.cpp          # Core implementation
│   ├── fwfinder_linux.cpp    # Linux-specific code
│   ├── fwfinder_mac.cpp      # macOS-specific code
│   ├── fwfinder_windows.cpp  # Windows-specific code
│   └── usbdef.cpp            # USB device type mappings
├── c_api/
│   ├── include/cfwfinder.h   # C API header
│   ├── src/cfwfinder.cpp     # C API implementation
│   └── test/                 # C API tests
├── test/                     # C++ API tests
├── examples/                 # Example applications
├── bindings/
│   ├── python/               # Python bindings (pyfwfinder)
│   └── zig/                  # Zig bindings
└── pyproject.toml            # Python package configuration

Testing

The library includes comprehensive tests using GoogleTest:

cd build
ctest --output-on-failure

Tests cover:

  • Device discovery functionality
  • USB device type detection
  • C API functionality
  • Cross-platform compatibility
  • Error handling scenarios

Platform Support

Platform Status Requirements
Linux ✅ Supported libudev
macOS ✅ Supported IOKit framework
Windows ✅ Supported Windows SDK (SetupAPI, Cfgmgr32)

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure all tests pass and add tests for new functionality.

License

Copyright Free-Wili

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyfwfinder-0.6.0-cp312-abi3-win_amd64.whl (152.6 kB view details)

Uploaded CPython 3.12+Windows x86-64

pyfwfinder-0.6.0-cp312-abi3-manylinux_2_34_x86_64.whl (249.6 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.34+ x86-64

pyfwfinder-0.6.0-cp312-abi3-macosx_10_15_universal2.whl (187.8 kB view details)

Uploaded CPython 3.12+macOS 10.15+ universal2 (ARM64, x86-64)

pyfwfinder-0.6.0-cp311-cp311-win_amd64.whl (153.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pyfwfinder-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl (253.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pyfwfinder-0.6.0-cp311-cp311-macosx_10_15_universal2.whl (194.5 kB view details)

Uploaded CPython 3.11macOS 10.15+ universal2 (ARM64, x86-64)

File details

Details for the file pyfwfinder-0.6.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: pyfwfinder-0.6.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 152.6 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyfwfinder-0.6.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4bdcdab05ca3b9c377e62deb44d8b53cf096245266facddff4bf4e79aa0ea00f
MD5 383f0ee4947d56ecd67289e02ff6844a
BLAKE2b-256 cc4a198fedb7a5cf018d33b09f996131f1f304131210f5fa25562a553db49ab4

See more details on using hashes here.

File details

Details for the file pyfwfinder-0.6.0-cp312-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyfwfinder-0.6.0-cp312-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4aa0d515795c6c71ee6fee4a4f6749b030f948b1d2068cbf040acb7339c09d3e
MD5 bbd02ade10c680c589732fa9730a7ea0
BLAKE2b-256 8c234b340fd59389b07297f47b7065f531865dc740d80c7570f4a99893192152

See more details on using hashes here.

File details

Details for the file pyfwfinder-0.6.0-cp312-abi3-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for pyfwfinder-0.6.0-cp312-abi3-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 11a11c928c57d66f985c5a6d96c3a74c7637339cf4291aea2595fdcb19dea3fb
MD5 9462271f0bdd8a1767ca1e99d45f512e
BLAKE2b-256 ad9dbdc5926e9f7e7b3cfd2fb92e09ef566308f7648c7b512a8004257ee848d2

See more details on using hashes here.

File details

Details for the file pyfwfinder-0.6.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyfwfinder-0.6.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 153.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pyfwfinder-0.6.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a2a83550c8ab9bb87e351ded0c37c094822c8bc000efbc5c3d445fc60a20b689
MD5 cfb3f4495ed0340acfaefc8b9510f890
BLAKE2b-256 890b7cf1ccbb840d512a7f75954b58abf0fb4ef50f0bfdcea13e29c9ff7e3859

See more details on using hashes here.

File details

Details for the file pyfwfinder-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyfwfinder-0.6.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 15a2246e4255af9a8b2f6ec4e7bc18031948925cb76d2e23238df11c5b608e57
MD5 f9ae0b1e062934d3eb3b14f55fee95ad
BLAKE2b-256 f82003395a5fb25b6164419d3d39f4551767082a7eb914b01c8a6a9c9495a542

See more details on using hashes here.

File details

Details for the file pyfwfinder-0.6.0-cp311-cp311-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for pyfwfinder-0.6.0-cp311-cp311-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 baa8fd975500177871909cf7ff00cce38312178b4a7821983265a2d62e9f502f
MD5 402756ba7515c824891b60d7dd451a8a
BLAKE2b-256 692abcab87382c4667e4f6a56ba0cf343ff898613abcd0f174ce9d3fdf0469b2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.0 This release

6 files

0.5.0

15 files

0.4.2

15 files

0.4.1

15 files

0.4.0

15 files

0.3.0

15 files

0.2.0

15 files

0.0.3

15 files

0.0.2

15 files

0.0.1

19 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page