Build_flags = -include file option does never find file to be included

Hello there,
I was searching for a possibility to include the configuration header file by using the -include file option in my platformio ini file.

https://docs.platformio.org/en/latest/projectconf/section_env_build.html

The file currently is in the /src folder where the rest of the project resides (tried include and library as well…)

No matter what i write in my .ini file, the file is never found when I compile my project.

build_flags =
‘-include $PROJECT_DIR\src\variables_${extra.unitid}.h’

build_flags =
‘-include variables_${extra.unitid}.h’

build_flags =
‘-include $PROJECT_DIR\src\variables_${extra.unitid}.h’

build_flags =
‘-include {WHATEVER…}variables_${extra.unitid}.h’

Is this option working for anybody? (I could not find any usage on the web so far to get a clue…)

Thanks
Chris

Are you saying that the config file is in your src folder? If so, all you need is:

#include "my_config_file.h"

PlatformIO searches for *.cpp and *.h files in src, include, lib/* by default, so it should find your file regardless. Do not have a folder name in the #include, just the header file name.

HTH

Cheers,
Norm.

I met the same problems.

And I sove it by moving the .h file to the include_dir where default is include directory in root path in your project.

But I’m confusing with that, why I’ve add the path to the build_flags in platformio.ini but it seems still cannot find the .h file.

here is my platform.ini

[platformio]
src_dir = Core/Src
lib_dir = Lib

[env:genericSTM32F103ZE]
platform = ststm32
board = genericSTM32F103ZE
; framework = stm32cube
upload_protocol = stlink
debug_tool = stlink
build_flags =               ; Build options
    -D STM32F103xx
    -I Core/Inc
    -I Drivers/STM32F1xx_HAL_Driver/Inc
    -I Drivers/CMSIS/Include
    -I Drivers/CMSIS/Device/ST/STM32F1xx/Include
    -I Drivers/STM32F1xx_HAL_Driver/Inc/Legacy

board_build.ldscript = ./STM32F103ZETx_FLASH.ld

And I here is the structure of my project
image

I got such errors when I not put the key.h file into the include dir.

Lib\Key\key.h:34:41: error: 'GPIO_PIN_4' undeclared (first use in this function); did you mean 'GPIO_BRR_BR4'?

but all the .h file needed are in my build_flags, and I could “solve it” by moving the key.h to the include dir.

I was so confusing why it happen, I will be very grateful to you for answering my questions. :sneezing_face: :sneezing_face:

Well, I’ll have a bash at a reply, but I might not be completely correct! (Given the layout of your project, I’m more of an Uno man myself!)

For the main project, header files can live in src or include. Both are searched automatically at compile time without any further action on your part, as are any directories added using build_flags -I ....

For a library named “XXX”, there will be a directory, lib/XXX and in there, all the headers and sources for that particular library. When building a library, as part of a project build, only the particular library will be searched for headers. The src and include directories are not scanned. Other directories added with build_flags will be scanned.

If you have header files that you want to have included in the project, or library compilations, which do not live in the project itself, then, add the directory/directories they live in to the build_flags in platformio.ini.

Lets say you have headers in SourceCode/headers then your build_flags will look like:

build_flags =
    -I SourceCode/headers

In your project, or libraries, to include SourceCode/headers/myHeader.h you simply #include "myHeader.h" and it will be found.

Example:

  • I have a header file, my_duino.h which lives in /home/norman/SourceCode/headers/. This header reads Arduino.h and defines a macro, TOGGLE_LED, which maps onto a function, in the asm library, named toggle().
  • I have a library, for want of a better word, named asm, which is located in lib/asm under my project. The library contains:
    • A header file, asm.h whgich defines the prototypes for two functions, setup() and toggle().
    • A source file, in assembly, named asm.S which has the source for the setup() and toggle() functions.

The files are:

platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino

build_flags = 
    -I /home/norman/SourceCode/headers

main.cpp

// This header is in SourceCode/headers/.
#include "my_duino.h"

// This header is in lib/asm
#include "asm.h"

// setup() is called from the assembly code.
// And is not shown here.

// Loop simply calls toggle(), via TOGGLE_LED(), to toggle 
// the LED.
void loop() {
    TOGGLE_LED();
    delay(1000);
}

lib/asm/asm.h

#ifndef ASM_H
#define ASM_H

extern "C" {
    void setup();
    void toggle();
}

#endif

lib/asm/asm.S

#define __SFR_OFFSET 0
#include <avr/io.h>

.section .text
.global setup
.global toggle


setup:
    ldi r16,(1 << DDB5)
    out DDRB,r16
    ret


toggle:
    ldi r16,(1 << DDB5)
    out PINB,r16
    ret

SourceCode/headers/my_duino.h

#ifndef MYDUINO_H
#define MYDUINO_H

// The main.cpp needs this header always. At least when
// using the arduino framework that is!
#include <Arduino.h>

// A silly example to get something usable from this header.
#define TOGGLE_LED() toggle()


#endif

I have #included the header file which is out of the project structure, SourceCode.headers/my_duino.h and the header file from the library, lib/asm/asm.h, simply by using their terminal names. The platformio.ini file tells the compiler where to find the additional header that is out of the project structure, and the compiler knows to search in the library’s directory when compiling the library.

If you run a verbose compilation, you get these options passed for headers etc.

Compiling main.cpp

avr-g++  ... -Iinclude -Isrc -Ilib/asm -I/home/norman/SourceCode/headers ... 

Here you can see that src and include in the project structure are scanned, and also the directory added using build_flags and the asm library source folder too.

Compiling lib/asm/asm.S

avr-gcc ... -Ilib/asm -I/home/norman/SourceCode/headers ...

Here you can see that src and include in the project structure are not scanned, only the directory added using build_flags and the asm library source folder too.

HTH

Cheers,
Norm.

So which HAL driver headers does this include? The general one and the one for gpio?

I just search the macro-instruction and find it in the file stm32f1xx_hal_gpio.h
here is path for the hal driver .h file
image

and I turely add the path by
-I Drivers/STM32F1xx_HAL_Driver/Inc
But it still give such undefined error :sob:

@maxgerhardt @NormanDunbar Thanks for your prompt response!! I’ve find the error is cause by my careless that not#include "stm32f1xx_hal_gpio.h" in my lib key.h.

But the fact I can unskillfully solve that by add the key.h to the include, and i use the debug skills(learned from your reply) by running platformio.exe run -v

PLATFORM: ST STM32 (15.4.1) > STM32F103ZE (64k RAM. 512k Flash)
HARDWARE: STM32F103ZET6 72MHz, 64KB RAM, 512KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES: 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 2 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Encoder (License: Unknown, Path: D:\file_sum\hardware\learn\stm32f103zet6\radar_model_test\Lib\Encoder)
Building in release mode
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\dma.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\dma.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\gpio.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\gpio.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\main.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\main.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\stm32f1xx_hal_msp.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude--ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\stm32f1xx_hal_msp.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\stm32f1xx_it.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\stm32f1xx_it.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\syscalls.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\syscalls.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\system_stm32f1xx.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\system_stm32f1xx.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\tim.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\tim.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\usart.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -Iinclude -ICore\Src -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\usart.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\libe5c\Encoder\encoder.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Lib\Encoder\encoder.c
arm-none-eabi-gcc-ar rc .pio\build\genericSTM32F103ZE\libe5c\libEncoder.a .pio\build\genericSTM32F103ZE\libe5c\Encoder\encoder.o
arm-none-eabi-gcc-ranlib .pio\build\genericSTM32F103ZE\libe5c\libEncoder.a
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\firmware.elf -T ./STM32F103ZETx_FLASH.ld -Os -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m3 .pio\build\genericSTM32F103ZE\src\dma.o .pio\build\genericSTM32F103ZE\src\gpio.o .pio\build\genericSTM32F103ZE\src\main.o .pio\build\genericSTM32F103ZE\src\stm32f1xx_hal_msp.o .pio\build\genericSTM32F103ZE\src\stm32f1xx_it.o .pio\build\genericSTM32F103ZE\src\syscalls.o .pio\build\genericSTM32F103ZE\src\system_stm32f1xx.o .pio\build\genericSTM32F103ZE\src\tim.o .pio\build\genericSTM32F103ZE\src\usart.o -LC:\Users\57626\.platformio\platforms\ststm32\ldscripts -L.pio\build\genericSTM32F103ZE -Wl,--start-group .pio\build\genericSTM32F103ZE\libe5c\libEncoder.a -lc -lgcc -lm -lstdc++ -Wl,--end-group
c:/users/57626/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol Reset_Handler; defaulting to 08000000
MethodWrapper(["checkprogsize"], [".pio\build\genericSTM32F103ZE\firmware.elf"])

I found that it doesn’t compile the key.c that maybe it solve the problem falsely?

Then I just add the correct stm32f1xx_hal_gpio.h file to the key.h and put it in the Lib dir. And the debug info as following

PLATFORM: ST STM32 (15.4.1) > STM32F103ZE (64k RAM. 512k Flash)
HARDWARE: STM32F103ZET6 72MHz, 64KB RAM, 512KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES: 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 2 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Encoder (License: Unknown, Path: D:\file_sum\hardware\learn\stm32f103zet6\radar_model_test\Lib\Encoder)
|-- Key (License: Unknown, Path: D:\file_sum\hardware\learn\stm32f103zet6\radar_model_test\Lib\Key)        
Building in release mode
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\dma.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\dma.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\gpio.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\gpio.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\main.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\main.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\stm32f1xx_hal_msp.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\stm32f1xx_hal_msp.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\stm32f1xx_it.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\stm32f1xx_it.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\syscalls.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\syscalls.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\system_stm32f1xx.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\system_stm32f1xx.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\tim.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\tim.c    
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\src\usart.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -Iinclude -ICore\Src -ILib\Key -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Core\Src\usart.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\libe5c\Encoder\encoder.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -ILib\Encoder -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Lib\Encoder\encoder.c
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\lib7c0\Key\key.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60105 -DSTM32F103xE -DSTM32F1 -DSTM32F103xx -ILib\Key -ICore\Inc -IDrivers\STM32F1xx_HAL_Driver\Inc -IDrivers\CMSIS\Include -IDrivers\CMSIS\Device\ST\STM32F1xx\Include -IDrivers\STM32F1xx_HAL_Driver\Inc\Legacy Lib\Key\key.c
arm-none-eabi-gcc-ar rc .pio\build\genericSTM32F103ZE\libe5c\libEncoder.a .pio\build\genericSTM32F103ZE\libe5c\Encoder\encoder.o
arm-none-eabi-gcc-ar rc .pio\build\genericSTM32F103ZE\lib7c0\libKey.a .pio\build\genericSTM32F103ZE\lib7c0\Key\key.o
arm-none-eabi-gcc-ranlib .pio\build\genericSTM32F103ZE\libe5c\libEncoder.a
arm-none-eabi-gcc-ranlib .pio\build\genericSTM32F103ZE\lib7c0\libKey.a
arm-none-eabi-gcc -o .pio\build\genericSTM32F103ZE\firmware.elf -T ./STM32F103ZETx_FLASH.ld -Os -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m3 .pio\build\genericSTM32F103ZE\src\dma.o .pio\build\genericSTM32F103ZE\src\gpio.o .pio\build\genericSTM32F103ZE\src\main.o .pio\build\genericSTM32F103ZE\src\stm32f1xx_hal_msp.o .pio\build\genericSTM32F103ZE\src\stm32f1xx_it.o .pio\build\genericSTM32F103ZE\src\syscalls.o .pio\build\genericSTM32F103ZE\src\system_stm32f1xx.o .pio\build\genericSTM32F103ZE\src\tim.o .pio\build\genericSTM32F103ZE\src\usart.o -LC:\Users\57626\.platformio\platforms\ststm32\ldscripts -L.pio\build\genericSTM32F103ZE -Wl,--start-group .pio\build\genericSTM32F103ZE\libe5c\libEncoder.a .pio\build\genericSTM32F103ZE\lib7c0\libKey.a -lc -lgcc -lm -lstdc++ -Wl,--end-group
c:/users/57626/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol Reset_Handler; defaulting to 08000000
MethodWrapper(["checkprogsize"], [".pio\build\genericSTM32F103ZE\firmware.elf"])

I can see it compile the key.c successfully!

thanks for your reply again! and maybe there still have problem when dowloading to the board, because the program seems not work :rofl:

mybe it’s the problem about warning said warning: cannot find entry symbol Reset_Handler; defaulting to 08000000 ?

I just want to build project from stm32cubemx and use the hal_library from it instead the lib that platformio support(I can successfully use my program by add framework = stm32cube to my platformio.ini but I know it’s use the lib that platformio support).

Following some solution I’ve add the board_build.ldscript = ./STM32F103ZETx_FLASH.ld to my platformio.ini. But it still doesn’t work.

but there seems another file startup_stm32f103xe.s in my root dir which seems importent and I doesn’t add it to my platformio.ini could you guys advice me on this?

I’m still looking Using STM32CubeMX and PlatformIO - #57 by rwx for solution but it so long and mess…

Good morning. I’m afraid I am of little help to you regarding STM32, I have a couple of boards, but still in the boxes they came in. I’m more of a plain old Arduino, atmega328, kind of guy!

Sorry. :cry:

Cheers,
Norm.

It’s ok bro, you’ve help me a lot, have a nice day! :smiling_face:

1 Like