Skip to content

stm32duino (official) USB CDC won't build with Sloeber #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cdrose opened this issue Mar 31, 2019 · 5 comments
Closed

stm32duino (official) USB CDC won't build with Sloeber #1083

cdrose opened this issue Mar 31, 2019 · 5 comments
Labels
domain: build The build does not work as the Arduino IDE. importance: board specific status: fixed in 4.3.3 status: workaround documented A workaround has been confirmed to solve this issue.

Comments

@cdrose
Copy link

cdrose commented Mar 31, 2019

Sorry I didn't think to search closed issues before raising this. It looks like this has been discussed before:
#1047

Eclipse with Sloeber plugin
STM32F103C8T6 BluePill
Arduino Core STM32 1.5.0 latest
Windows 10

When USB CDC components are selected for stm32duino, Sloeber fails to build the project. Sketches without the USB CDC components build fine, and the Arduino IDE builds USB CDC sketches fine. While I am unable to test this personally, it sounds like the issue may only exist on Windows and Sloeber on Linux works as expected.

I initially raised this on the STM32duino page but it looks like the issue lies with Sloeber, possibly something to do with how platforms.txt is parsed. The compiler flags for the USB configuration are missing the escape character for the quotation marks:

(edit: I have manually escaped the backslashes so they display correctly)

Arduino IDE 1.8.9:

-DSTM32F103x6 -DUSBCON -DUSBD_VID=0x0483 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"BLUEPILL_F103C6\"" -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC

Eclipse 2018-12 + Sloeber plugin V4:

-DSTM32F103xB -DUSBCON -DUSBD_VID=0x0483 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT="BLUEPILL_F103C8"" -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC

platforms.txt:

build.usb_flags=-DUSBCON` {build.usb_speed} -DUSBD_VID={build.vid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT="{build.board}"' -DHAL_PCD_MODULE_ENABLED

boards.txt:

GenF1.menu.pnum.BLUEPILL_F103C8.build.board=BLUEPILL_F103C8

It looks like the intention is to use the build.board parameter which has no quotation marks around it and then add some quotation marks so it works correctly in the string expansion macros in the core. The Arduino IDE correctly handles this and escapes the extra quotation marks while the Sloeber plugin does not.

See: stm32duino/Arduino_Core_STM32#486 (comment)

@mrv96
Copy link

mrv96 commented Apr 27, 2019

Hi, i have the same problem, have you found a temporary solution?

@cdrose
Copy link
Author

cdrose commented Apr 28, 2019

Sloeber seems to pull the info from platforms.txt and place it into the build environment variables. I had no luck editing platforms.txt so I changed the build variables instead. Simply add the escape characters for the quotation marks on the USB_PRODUCT variable.

image

@mrv96
Copy link

mrv96 commented Apr 29, 2019

Thank you very much. Now it works. Previously I tried to modify platform.txt without success. I hope that someone will be able to fix this issue also on windows.

@jantje jantje added importance: board specific status: workaround documented A workaround has been confirmed to solve this issue. domain: build The build does not work as the Arduino IDE. labels Oct 7, 2019
@dferbas
Copy link

dferbas commented Jan 20, 2020

@cdrose: This workaround is ok only for a certain board.

I succeeded in editing platform.txt. Purpose is to pass board name as a quoted string to allow its concatenation in utils.h. Just modify following line (only 2 defines are listed, all others are left untouched).

# USB Flags
# ---------
#build.usb_flags=... '-DUSB_MANUFACTURER={build.usb_manufacturer}'  '-DUSB_PRODUCT="{build.board}"' ...
build.usb_flags=... -DUSB_MANUFACTURER={build.usb_manufacturer}  -DUSB_PRODUCT=\"{build.board}\" ...

@jantje
Copy link
Member

jantje commented Mar 10, 2020

This should work now with the nightly out of the box.

@jantje jantje added the Status: waiting for confirmation fix works The nightly contains a fix but the fix has not yet been confirmed to work. label Mar 10, 2020
@jantje jantje added status: fixed in 4.3.3 and removed Status: waiting for confirmation fix works The nightly contains a fix but the fix has not yet been confirmed to work. labels Apr 21, 2020
@jantje jantje closed this as completed Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: build The build does not work as the Arduino IDE. importance: board specific status: fixed in 4.3.3 status: workaround documented A workaround has been confirmed to solve this issue.
Projects
None yet
Development

No branches or pull requests

4 participants