Compile error using Arduino IDE 1.8.15 with build_opt.h

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
jasonhk
Posts: 3
Joined: Mon Aug 09, 2021 5:07 am

Compile error using Arduino IDE 1.8.15 with build_opt.h

Post by jasonhk »

I am going to use 2 serial ports in my STM32F103C8 project. My development environment is Windows 10, Arduino IDE 1.8.15, Arduino_Core_STM32 2.0.0

My testing code is:
void setup() {
Serial1.begin(115200);
Serial2.begin(115200);
}

void loop() {
}

build_opt.h
-DENABLE_HWSERIAL2

I got compilation error with Arduino IDE 1.8.15 as follows:
arm-none-eabi-g++: error: #line: No such file or directory
arm-none-eabi-g++: error: 1: No such file or directory
exit status 1
Error compiling for board Generic STM32F1 series.

However when I use Arduino IDE 1.8.5 (older version) to compile the same code, the result is successful.

When I check the compilation process of Arduino IDE 1.8.15, I found the build_opt.h in build folder have a additional line at the beginning like this.

#line 1 "C:\\Users\\xxxxx\\Documents\\Arduino\\stm32-sample-codes\\hwserial-test\\build_opt.h"
-DENABLE_HWSERIAL2

Even though I manually modify the build_opt.h in build folder. I still can't build the sketch as the compiler cannot find SrcWrapper.h.

C:\\Temp\\arduino_build_300941\\sketch\\SrcWrapper.cpp:1:10: fatal error: SrcWrapper.h: No such file or directory
1 | #include <SrcWrapper.h>
| ^~~~~~~~~~~~~~
compilation terminated.

Does anybody have the same problem and is there any way to resolve it?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Compile error using Arduino IDE 1.8.15 with build_opt.h

Post by fpiSTM »

Hi @jasonhk

This is a know issue linked to Arduino cli which now preprocess ".h" file.
I've made a fix to bypass this issue:
https://github.com/stm32duino/Arduino_C ... /pull/1442

Arduino cli issue discussed here:
https://github.com/arduino/arduino-cli/issues/1338
jasonhk
Posts: 3
Joined: Mon Aug 09, 2021 5:07 am

Re: Compile error using Arduino IDE 1.8.15 with build_opt.h

Post by jasonhk »

Thanks, I try this later
madhavan
Posts: 29
Joined: Fri May 21, 2021 1:22 am

Re: Compile error using Arduino IDE 1.8.15 with build_opt.h

Post by madhavan »

i am uploading the sketch via FTDI - Serial ( UART1 ) it's working attached sketch
then i try to connect Serial 1 (UART2) ""NO"" output . - but no compile error
then i try to connect Serial 2 ( UART3) but following compiling error.

Arduino: 1.8.15 (Linux), Board: "Generic STM32F1 series, BluePill F103CB (or C8 with 128k), STM32CubeProgrammer (Serial), Enabled (generic 'Serial'), None, Low/Full Speed, Smallest (-Os default), Newlib Nano (default)"
/home/madhavan/.arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/9.3.1-1.3/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: sketch/rs232_two_arduino.ino.cpp.o: in function `setup':
rs232_two_arduino.ino.cpp:(.text.setup+0xc): undefined reference to `Serial2'
/home/madhavan/.arduino15/packages/STMicroelectronics/tools/xpack-arm-none-eabi-gcc/9.3.1-1.3/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: sketch/rs232_two_arduino.ino.cpp.o: in function `loop':
rs232_two_arduino.ino.cpp:(.text.loop+0x1c): undefined reference to `Serial2'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Generic STM32F1 series.


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Code: Select all

void setup() {


Serial2.begin(9600);
 
}

void loop() {

Serial2.println("ok");
delay(1000);
   

}
.



i have followed steps from https://github.com/arduino/arduino-cli/issues/1338

Add a build_opt.h file containing the line -DHAL_CRC_MODULE_ENABLED to an example folder next to the blink ino.Image




Arduino: 1.8.15 (Linux), Board: "Generic STM32F1 series, BluePill F103CB (or C8 with 128k), STM32CubeProgrammer (Serial), Enabled (generic 'Serial'), None, Low/Full Speed, Smallest (-Os default), Newlib Nano (default)"

arm-none-eabi-g++: error: #line: No such file or directory
arm-none-eabi-g++: error: 1: No such file or directory
exit status 1
Error compiling for board Generic STM32F1 series.


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Compile error using Arduino IDE 1.8.15 with build_opt.h

Post by fpiSTM »

You have to instantiate Serial2. See the wiki
madhavan
Posts: 29
Joined: Fri May 21, 2021 1:22 am

Re: Compile error using Arduino IDE 1.8.15 with build_opt.h

Post by madhavan »

thank so much for information.... now it's working ..after many research :D
Post Reply

Return to “IDE's”