stm32duino / Arduino_Core_STM32

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

STM32WL platformio options for cortex-m4 turn on fpu, but STM32WL55 CMSIS driver defines __FPU_PRESENT=0 #1473

Closed dolfandringa closed 3 years ago

dolfandringa commented 3 years ago

Describe the bug See also https://www.stm32duino.com/viewtopic.php?p=8039#p8039

When compiling code for the Nucleo STM32WL55JC1 with the Arduino Core STM32 v2.0.0, platformio automatically adds the -mfpu=fpv4-sp-d16", "-mfloat-abi=hard options because the mcu is defined as cortex-m4. This results in an error because the CMSIS driver defines __FPU_PRESENT=0.

To Reproduce

  1. Use this branch (WIP) for platformio which adds support for the STM32WL55 board using the arduino framework: https://github.com/dolfandringa/platform-ststm32/tree/feature/stm32duino_stm32wl55_support
  2. Make a new project using the platformio.ini below. No need for any code, just use an empty main.cpp like below.
  3. run pio run to compile the code.

platformio.ini

[env:stm32wl55]
platform = ststm32
board = nucleo_wl55jc
framework = arduino

src/main.cpp

#include <Arduino.h>

void setup() {
}

void loop() {
}

this results in the following error:

In file included from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32WLxx/Include/stm32wl55xx.h:210,
                 from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/system/Drivers/CMSIS/Device/ST/STM32WLxx/Include/stm32wlxx.h:99,
                 from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/stm32_def.h:56,
                 from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/cores/arduino/stm32/clock.h:19,
                 from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring_time.h:23,
                 from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/cores/arduino/wiring.h:38,
                 from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/cores/arduino/Arduino.h:36,
                 from /home/dolfandringa/.platformio/packages/framework-arduinoststm32/variants/STM32WLxx/WL54JCI_WL55JCI_WLE4J(8-B-C)I_WLE5J(8-B-C)I/PeripheralPins.c:21:
/home/dolfandringa/.platformio/packages/framework-cmsis/CMSIS/Core/Include/core_cm4.h:105:8: error: #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
  105 |       #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"

Expected behavior The code should compile correctly.

Desktop (please complete the following information):

Board (please complete the following information):

dolfandringa commented 3 years ago

I am working on a resolution for this issue, and any other platformio related fixes in https://github.com/dolfandringa/Arduino_Core_STM32/tree/feature/support_stm32wl55jc1_on_platformio

fpistm commented 3 years ago

Hi @dolfandringa We do not support PIO here. Moreover there is no FPU for the STM32WL. For coretx M4, Floating-Point Unit (FPU) is optional, see: https://www.st.com/content/st_com/en/arm-32-bit-microcontrollers/arm-cortex-m4.html

CMSIS define is correct.

dolfandringa commented 3 years ago

There is a bug in your repository in https://github.com/stm32duino/Arduino_Core_STM32/blob/master/tools/platformio/platformio-build.py. That is a file you are clearlyt maintaining, since it is in this repository, and I am very happy to help with a fix.

fpistm commented 3 years ago

There is a bug in your repository in https://github.com/stm32duino/Arduino_Core_STM32/blob/master/tools/platformio/platformio-build.py. That is a file you are clearlyt maintaining, since it is in this repository, and I am very happy to help with a fix.

In fact no, it was provided by @valeros from pio to allow CI build that's all. 😉

dolfandringa commented 3 years ago

yes, but it is in your repository, so can only be fixed there, right? Who maintains that file? it is 1-1 in the pio framework-arduinoststm32, which includes your full repository.

fpistm commented 3 years ago

Honestly, I thought it was only used for the CI PIO build not by the framework itself. Hi @valeros please could you comment on this? Thanks in advance.

ghost commented 2 years ago

Hi @dolfandringa We do not support PIO here. Moreover there is no FPU for the STM32WL. For coretx M4, Floating-Point Unit (FPU) is optional, see: https://www.st.com/content/st_com/en/arm-32-bit-microcontrollers/arm-cortex-m4.html

CMSIS define is correct.

Thanks for clarifying that there is NO FPU in STM32WL core here. I misconceived that FPU is implemented in every STM32 CM4 microcontroller. For in PM0214 STM32 Cortex®-M4 MCUs and MPUs programming manual, section 1.3.3, it's written: "IEEE754-compliant single-precision FPU implemented in all STM32 Cortex-M4 microcontrollers". That made me conceive that every ST's CM4 core has FPU implemented.