back

@Levi--G's USBLibrarySTM32

Emulates AVR Arduino USB API, effectively replaces STM32duino core USBDevice library
reportedly works with Arduino sketches in platformio,
emulates PluggableUSB, but has issues in Arduino 2.
- wanted to pretend that it is ARDUINO_ARCH_AVR;
  instead, hacked MIDIUSB.h:
	- #if defined(ARDUINO_ARCH_AVR)
	+ #if defined(ARDUINO_ARCH_AVR) || defined(HAL_PCD_MODULE_ENABLED)

- requires USBCON and HAL_PCD_MODULE_ENABLED build flags
  probably set in menu based on usb_flags and platform.txt
- Arduino 2 does not see files in USBLibrarySTM32/include/;
  moving files to USBLibrarySTM32/src/ fixes that.
- reported my experience
- coordination with STM32duino core USB is discussed here;
  likely integration would be as a menu option

This compiles with hacked MIDIUSB Library for Arduino example sketch,
but then fails to link because it duplicates STM32duino USB library definitions.

STM32duino USB multiple definition possible workaround
install and use a custom core version
more detailsPlatform specification
- hopefully applies to Arduino 2...?
- is STM32duino "core" literally https://github.com/stm32duino/Arduino_Core_STM32?
  that seemingly matches (658MB) content at
AppData/Local/Arduino15/packages/STMicroelectronics/hardware/stm32/2.11.0/

results from grep -R USBD_Init

potential hack, based on feedback from @Levi--G
add platform.local.txt file in packages/STMicroelectronics/hardware/stm32/2.11.0/:
USBDevice_include_dir=/libraries/USBLibrarySTM32
With only this change, builds fail:
C:\Users\bleke\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.11.0\cores\arduino/WSerial.h:7:12:
	 fatal error: USBSerial.h: No such file or directory
    7 |   #include "USBSerial.h"
      |            ^~~~~~~~~~~~~
compilation terminated.
Success requires setting USB support (if available): "None", then:
$ cat MIDIUSB_loop/build_opt.h
-DUSBCON -DHAL_PCD_MODULE_ENABLED
Attempts to build a USBSerial library in user space failed
Compiling STM32 core seemingly uses incompatible rules...

USB enumeration, endpoints and descriptors
maintained by blekenbleu