PlatformIO Community

Advice on Hardware\Software Stack for Composite USB HID Device


I am trying to complete a project and finding myself in what I feel are time consuming rabbit holes. I have been trying to use STM32F103 chips with LibopenCM3 to create a composite HID device with a DFU Mode. I have managed to make all of my HMI and DFU code work, but the composite HID has been challenging for a variety of reasons I have been working through. I want to use FreeRTOS because in theory it simplifies the sharing of resources between HMI interrupts and the USB HID stuff. I also was hoping to have USART debugging always on - but it seems you cannot use the libopenCM3 HID libraries along-side their USART libraries. Maybe it is interrupts? That is what led me to try and use FreeRTOS in the first place, was attempting to get USART output to work alongside USB HID.


This is roughly what I am trying to make.

I still want to use STM32, but at this point I am growing weary of libopencm3 because it does not seem to have a dedicated help forum! The freeRTOS forum has some copy-paste response they do to any question about using it with libopencm3, meanwhile the supported STM32 FreeRTOS ports are either commercial (IAR) or CubeMX, which does not support composite HID!

The link above is working HID code for openlibCM3. I have not yet started trying to convert it to composite USB because I cannot get a USART debug output going along side the libopencm3 USB HID. I tried all 3 of the STM32F103s USART hardware devices to see if they maybe used different interrupts or something, and all 3 caused the USB HID device to fail, as well as stopped the USART communication. It causes the program to crash without error.

I feel like this should be a common issue, but googling aggressively has not brought me to other people discussing it. Likewise, exploratory attempts to use FreeRTOS with a working ‘threaded’ USART output to try and alleviate interrupt priority issues just has the HID code also breaking FreeRTOS completely. I cannot get a freeRTOS task to run once the USB device is instantiated.

Anyway I am ready to try something else - either paying someone to help me with this early stage of the project, or possibly changing platform. I am thinking about going back to the arduino stm32, but the community is fragmented and I was enjoying learning more ‘bare metal’ programming approaches, but at this point it is becoming hard to continue when I am either not capable of it, or I need a different platform with just a little more hand holding!