Skip to content
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

Linking fails with STM32Duino platform >2.7.1 when USB CDC is used #1692

Open
arthurfprecht opened this issue Nov 25, 2024 · 3 comments
Open
Labels
status: workaround documented A workaround has been confirmed to solve this issue.

Comments

@arthurfprecht
Copy link

Describe your environment
Sloeber roduct 4.4.3
OS: Linux Mint 22
Platform and Arduino configurations on section below

Describe the bug
Linking fails with STM32Duino platform >2.7.1, due to changes in the USB CDC code structure when STM32duino updated from 2.7.1 to 2.8.0

To Reproduce
Steps to reproduce the behavior:

  1. Download Sloeber Product 4.4.3
  2. Add Platform from STM32Duino version >2.7.1
  3. Try any code with USB Serial (USB support to CDC gerenic Serial Supersede USART)
  4. Add the srcWrapper library and try to compile (Errors during linking will occur)
    Snippets of the errors:
    Starting combiner
    blink_f401.ino:10:(.text.setup+0x24): undefined reference to SerialUSB'
    STMicroelectronics/hardware/stm32/2.8.0/libraries/SrcWrapper/src/stm32/hw_config.c:79:(.text.hw_config_init+0x20): undefined reference to USBD_CDC_init'
    STMicroelectronics/hardware/stm32/2.8.0/cores/arduino/WSerial.cpp:66:(.text._Z14serialEventRunv+0x18): undefined reference to USBSerial::available()'
  5. (workaround attempt) Add USBDevice library, compile and run (USB Serial will not work)

platform:
Arduino Core STM32

screenshot of project properties->arduino:
image

Expected behavior
The linking should work (i.e. the library should be added automatically) and no workaround (manually adding USBDevice.h) should be employed

Data to back up your claim
Even if the workaround of manually adding the USBDevice.h causes the code to compile, the Serial does not work, as explained in a similar issue that happened on Platformio

@jantje
Copy link
Member

jantje commented Nov 27, 2024

Thanks for the issue and the workaround.

I tried to reproduce this and I have very similar behavior in Sloeber V5 and stmDuino version 2.8.1
The only difference were: in step 4
1 )srcWrapper was automagically added after the first build.
2) I got a different error message during linking but also USB related.

Unfortunately the platformio issue does not contain any info on how they fixed it.

@jantje jantje added the status: workaround documented A workaround has been confirmed to solve this issue. label Nov 27, 2024
@arthurfprecht
Copy link
Author

arthurfprecht commented Nov 30, 2024

Hello jantje, first thank you very much for replicating and adding the issue as documented.

Today I tested a little more and I think I had another issue with the Serial happening alongside this one from USBDevice:

The serial monitor view unfortunately is not working on my setup (described in the original post).
If I use this very simple sketch and compile it with package version 2.7.1:

#include "Arduino.h"

uint32_t lastBlink = 0;
bool previousLED = 0;

void setup()
{
	pinMode(LED_BUILTIN, OUTPUT);
	lastBlink = millis();
	Serial.begin(115200);
	while (!Serial);
}

void loop()
{
	if (millis()-lastBlink > 1000)
	{
		lastBlink = millis();
		previousLED = !previousLED;
		digitalWrite(LED_BUILTIN, previousLED);
		Serial.println("Something to test the serial\n");
	}
}

Then I upload and open the Serial monitor view, I get nothing:
image
But using other COM port visualizer, like minicom or picocom, I get the output:
image

I went ahead and tested the newest versions (tested up to 2.9.0). Applying the workaround (Adding USBDevice.h manually) is confirmed to work! 😄

Though now I need to figure out why the Serial monitor view is not working 🥴

@jantje
Copy link
Member

jantje commented Nov 30, 2024

Strange that the serial is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: workaround documented A workaround has been confirmed to solve this issue.
Projects
None yet
Development

No branches or pull requests

2 participants