Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Build_opt.h only used when compiled with LTO #2698

Closed
bbc25185 opened this issue Mar 24, 2025 · 1 comment
Closed

Build_opt.h only used when compiled with LTO #2698

bbc25185 opened this issue Mar 24, 2025 · 1 comment

Comments

@bbc25185
Copy link

Describe the bug
After testing, I noticed that the Build_opt.h file is used only if, as a compilation optimization, one with LTO is chosen.

To Reproduce
The Build_opt.h file contains the following code:
-DSERIAL_RX_BUFFER_SIZE=512 -DSERIAL_TX_BUFFER_SIZE=512
-DMAVLINK_COMM_NUM_BUFFERS=4
-DPIN_SERIAL1_RX=PB7 -DPIN_SERIAL1_TX=PB6
-DENABLE_HWSERIAL1
-DPIN_SERIAL2_RX=PA3 -DPIN_SERIAL2_TX=PA2
-DENABLE_HWSERIAL2
-DPIN_SERIAL3_RX=PB9 -DPIN_SERIAL3_TX=PB8
-DENABLE_HWSERIAL3
-DPIN_SERIAL4_RX=PA1 -DPIN_SERIAL4_TX=PA0
-DENABLE_HWSERIAL4

Steps to reproduce the behavior:
Selected Board: STM32G0 Series
Board Part Number: Generic G070KBTx
Usart Support: Enabled (No generic Serial)
Compiled with Optimize - Smallest: No error and Ram usage dont change with Buffer size change
Compiled with Optimize - Smallest with LTO: Various error reporting "note: 'SerialX' was previously declared here" and Buffer Size changing with Buffer Size setting.

Expected behavior
The file Build_opt.h always working

Desktop (please complete the following information):

  • Windows11
  • Arduino IDE version: 2.3.4
  • STM32 core version: 2.10.1
  • Tools menu settings if not the default: Usart Support: Enabled (no generic Serial)
  • Upload method: SWD

Board (please complete the following information):

  • Name: STM32G0 Series
  • Hardware Revision: Generic G070KBTx

Additional context
To solve the problem, I normally compiled with LTO but due to errors that appeared when I started implementing FreeRtos.
Without LTO the options in the Build_opt.h file are not applied for my project.

@fpistm
Copy link
Member

fpistm commented Mar 25, 2025

Hi @bbc25185
Here my result:

Default config::

Sketch uses 19996 bytes (15%) of program storage space. Maximum is 131072 bytes.
Global variables use 1432 bytes (3%) of dynamic memory, leaving 35432 bytes for local variables. Maximum is 36864 bytes.

With your build_opt.h:

Sketch uses 20304 bytes (15%) of program storage space. Maximum is 131072 bytes.
Global variables use 6084 bytes (16%) of dynamic memory, leaving 30780 bytes for local variables. Maximum is 36864 bytes.

Warning message:

warning: "ENABLE_HWSERIAL4" redefined
   84 |       #define ENABLE_HWSERIAL4
      |               ^~~~~~~~~~~~~~~~

That is normal as the default Serial for the GenericG070KBTx is the Serial4. So as you define it again in the build_opt.h....
Maybe you got an Arduino cache issue but there is no issue with build_opt.h.

@stm32duino stm32duino locked and limited conversation to collaborators Mar 25, 2025
@fpistm fpistm converted this issue into discussion #2699 Mar 25, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants