stm32duino / Arduino_Core_STM32

STM32 core support for Arduino
https://github.com/stm32duino/Arduino_Core_STM32/wiki
Other
2.76k stars 961 forks source link

Compilation error when using USB STM32L152CBT6 #1510

Closed ghost closed 2 years ago

ghost commented 2 years ago

Describe the bug Compilation error when making USB support. I tried to set different UART and USB settings, in all cases I get a compilation error. I need USB to exchange data via SERIAL.

To Reproduce Test sketch:

int sensorValue = 100;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(sensorValue);
  delay(10);
}

Steps to reproduce the behavior: The microcontroller is connected via STLink (SWD). Opening any sketch, trying to configure the UART over USB. The compilation runs without errors only if USB support is disabled. In all other cases, the compilation will cause errors. I've tried different UART and USB settings - compilation throws errors in all cases.

Expected behavior I need the UART to work via USB

Screenshots https://drive.google.com/file/d/18pP4FPUUW-Az42YfIWwL9xw_dm9VwKuM/view?usp=sharing https://drive.google.com/file/d/1mmg1MyJKM7QSyCB9ZK3yEKpF1NR0DZWn/view?usp=sharing

Desktop (please complete the following information):

Board (please complete the following information):

Additional context Error log:

In file included from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/stm32/PinNames.h:4,
                 from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/stm32/pinmap.h:22,
                 from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/stm32/PeripheralPins.h:34,
                 from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/stm32/analog.h:44,
                 from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/board.h:8,
                 from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/wiring.h:41,
                 from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/Arduino.h:36,
                 from C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\variants\STM32L1xx\L100C6Ux(A)_L151C(6-8-B)(T-U)x(A)_L152C(6-8-B)(T-U)x(A)\PeripheralPins.c:22:
C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\variants\STM32L1xx\L100C6Ux(A)_L151C(6-8-B)(T-U)x(A)_L152C(6-8-B)(T-U)x(A)\PeripheralPins.c:215:58: error: 'GPIO_AF10_USB' undeclared here (not in a function); did you mean 'GPIO_AF0_SWJ'?
  215 |   {PA_11, USB, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_USB)}, // USB_DM
      |                                                          ^~~~~~~~~~~~~
C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\cores\arduino/stm32/PinNamesTypes.h:83:29: note: in definition of macro 'STM_PIN_DEFINE'
   83 |                           ((AFNUM & STM_PIN_AFNUM_MASK) << STM_PIN_AFNUM_SHIFT))
      |                             ^~~~~
C:\Users\�����\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.0.0\variants\STM32L1xx\L100C6Ux(A)_L151C(6-8-B)(T-U)x(A)_L152C(6-8-B)(T-U)x(A)\PeripheralPins.c:215:16: note: in expansion of macro 'STM_PIN_DATA'
  215 |   {PA_11, USB, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_USB)}, // USB_DM
      |                ^~~~~~~~~~~~
exit status 1
Ошибка компиляции для платы Generic STM32L1 series.
fpistm commented 2 years ago

Hi, This is a known and fixed issue. See #1451 Will be part of the next release as a workaround simply fixed the PeripheralPins.c by replacing GPIO_AF10_USB by GPIO_AF_NONE