Everything was building fine, I changed a Serial.printf statement, went to build again but then started receiving the following errors. I reverted the change, but still got the errors. Tried doing full clean, etc, redownloading deps, but the same issue remains. The only thing that changed between the working build and the non-working build was a change to a string, so I am thinking it might have just been coincidence and unrelated and that something else is wrong, but I can’t figure out what. I had not changed anything in my platformio.conf or anything on my system that I can recall at that time. I tried to restart just in case, as nothing else worked, but the issue remains.
I have a few devices profile/env’s in my config (current device is MakerBase xDrive using genericSTM32F405RG board profile), and noticed that the other stm32 based board (b-g431b-esc1) seems to have the same build issue/errors as well, and I had not made any changes to that profile or the code associated with that board in over a week. My esp32 based profile makes use of SerialUSB, etc, and still builds just fine.
Indexing .pio/build/xdrive_foc_0/libFrameworkArduino.a
Linking .pio/build/xdrive_foc_0/firmware.elf
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: warning: .pio/build/xdrive_foc_0/firmware.elf has a LOAD segment with RWX permissions
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/SrcWrapper/src/stm32/hw_config.c.o: in function `hw_config_init':
/home/mosthated/.platformio/packages/framework-arduinoststm32/libraries/SrcWrapper/src/stm32/hw_config.c:79: undefined reference to `USBD_CDC_init'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/libbc3/SimpleCAN/BaseCAN.cpp.o: in function `BaseCAN::BaseCAN()':
/home/mosthated/_dev/languages/esp32/xdrive_mini/foc/.pio/libdeps/xdrive_foc_0/SimpleCAN/src/BaseCAN.cpp:7: undefined reference to `SerialUSB'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/src/_xdrive/main.cpp.o: in function `CANHandler::HandleCanMessage(CanMsg const&, unsigned char const*)':
/home/mosthated/_dev/languages/esp32/canbus_lib/CANProfile/V1/CANProfile_V1.h:669: undefined reference to `SerialUSB'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/src/_xdrive/main.cpp.o: in function `_GLOBAL__sub_I_message_':
/home/mosthated/_dev/languages/esp32/xdrive_mini/foc/src/_xdrive/main.cpp:71: undefined reference to `SerialUSB'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/src/_xdrive/main.cpp.o: in function `CANBusSetup()':
/home/mosthated/_dev/languages/esp32/xdrive_mini/foc/src/_xdrive/main.cpp:121: undefined reference to `SerialUSB'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/src/_xdrive/main.cpp.o: in function `setup':
/home/mosthated/_dev/languages/esp32/xdrive_mini/foc/src/_xdrive/main.cpp:130: undefined reference to `USBSerial::begin(unsigned long)'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /home/mosthated/_dev/languages/esp32/xdrive_mini/foc/src/_xdrive/main.cpp:133: undefined reference to `USBSerial::operator bool()'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /home/mosthated/_dev/languages/esp32/xdrive_mini/foc/src/_xdrive/main.cpp:170: undefined reference to `SerialUSB'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/src/_xdrive/main.cpp.o: in function `CANBusLoop()':
/home/mosthated/_dev/languages/esp32/xdrive_mini/foc/src/_xdrive/main.cpp:486: undefined reference to `SerialUSB'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/src/_xdrive/main.cpp.o: in function `loop':
/home/mosthated/_dev/languages/esp32/xdrive_mini/foc/src/_xdrive/main.cpp:614: undefined reference to `SerialUSB'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/xdrive_foc_0/libFrameworkArduino.a(WSerial.cpp.o): in function `serialEventRun()':
/home/mosthated/.platformio/packages/framework-arduinoststm32/cores/arduino/WSerial.cpp:66: undefined reference to `USBSerial::available()'
/home/mosthated/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: /home/mosthated/.platformio/packages/framework-arduinoststm32/cores/arduino/WSerial.cpp:75: undefined reference to `SerialUSB'
collect2: error: ld returned 1 exit status
*** [.pio/build/xdrive_foc_0/firmware.elf] Error 1
It seems like it’s not finding SerialUSB related things at all anymore, but I didn’t add/remove any dependencies or build flags between the build that worked and the next build that didn’t work.
It feels like something with platformio packages or my system. Does anyone happen to have any ideas of what I might be able to check or fix?
You’re using platformIO, so normally things don’t just change by themselves… in ArduinoIDE it is easy to change some menu options and cause these kind of errors, but in PlatformIO you have edit the platformio.ini to make changes.
The error is related to the USB support - if you enable USB serial in the build flags, this error should normally go away because then SerialUSB is defined.
Are you sure you didn’t change the platformio.ini? And are you sure its using the env you intend it to use? Is it the case that some of your envs have USB defined and some do not?
Did you maybe git-pull some new code?
Is the same library maybe present in different locations?
Which… I believe have been there for 2+ weeks, and had been working just fine. I know for sure the USBD_USE_CDC had been there as well as the ENABLE_CDC, as I pieced the config together originally from my b-g431b-esc1 config and parts of the config from:
For some reason, now I had to remove all 3 of them for it to build. While I am glad to see it build, I don’t understand why or what in the world changed to cause this behavior.
I was under the impression that those were needed for Serial access over USB, ex. when you use Serial.print (except for the on_boot, which makes it wait for a serial connection to be opened)? I am not sure why they would suddenly make it not build when I am still using Serial.print statements.
When you say “Serial.print” the “Serial” is a class instance, and the type can be either “HardwareSerial” or “USBSerial” depending on whether your default “Serial” object is configured as USB or as USART.
You had some of these options in there, so Serial was being defined as an object of type USBSerial, but not all of the required options to make it work, so the type USBSerial was not being built and the linker could therefore not find any of its methods…
Something along these lines.
The real mystery is what got changed/deleted to suddenly cause the problem, and why.
Something I do frequently is hit some keys while the wrong window has focus - then you overtype something unintentionally, for example.
Edit: Looks like this finally showed up in the package issues board. Just updating here in case anyone else runs into it.
phew
Ok, so I am not losing my mind. Setting the ststm32 platform option manually to the previous release fixed the issue fully back to how it was, with USB serial working again.