I’m trying to create my own USB device compile option, such as USB_SERIAL_HID, with VScode platformio, but it didn’t work. For instance, I can copy paste the USB_SERIAL_HID block and define the copy as USB_SERIAL_HID2, everything being the same as USB_SERIAL_HID. Then if I add this to my platformio.ini
build_flags = -D USB_SERIAL_HID2
It just won’t compile the option. Compilation proceeds without taking any #defines under this option. I inserted a #warning in the option to make sure I see the option compiles. Only the originally defined option names shown in the following work with the build_flags. Any deviation from it say by renaming it with a 1 or 2 will not trigger the option’s compilation:
Thanks. I took a different approach. I installed VScode and platformio on another computer, so no core modification whatsoever.
Then I edited usb_desc.h to add this line to USB_SERIAL_HID option:
#elif defined(USB_SERIAL_HID)
#warning "Compiling a new option"
This causes the compiler to emit this warning during build so I know this option is being compiled.
In platformio.ini, I have:
build_flags = -D USB_SERIAL_HID
I then renamed this option in usb_desc.h to USB_SERIAL_HID2:
#elif defined(USB_SERIAL_HID2)
#warning "Compiling a new option"
No copy pasting, just renamed it. I also renamed the option in platformio.ini:
build_flags = -D USB_SERIAL_HID2
First thing I noticed is content under this option is no longer highlighted, but greyed out as if USB_SERIAL_HID2 was not defined. Next thing is building this project no longer emits the warning that is still there.
So this confirms that this option is NOT defined and build_flags somehow isn’t working.
This simple test can be replicated on someone else’s computer I believe.