bmd-studio / stm32-for-vscode

STM32 extension for working with STM32 and CubeMX in VSCode
MIT License
207 stars 27 forks source link

Missing sourceFiles entries in config.yaml #139

Closed Flo2410 closed 1 year ago

Flo2410 commented 1 year ago

I had issues building when using the ADC. After a bit of searching I found the files Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c and Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c to be missing in the sourceFiles list in the STM32-for-VSCode.config.yaml file.

jortbmd commented 1 year ago

Hi! Thank you for creating an issue for this. Could you perhaps provide me with the Makefile, the STM32Make.make file and your STM32-for-VSCode.config.yaml? This way I can check if this is an error in the extension or an error in the generated makefile from CubeMX.

Flo2410 commented 1 year ago

Sure. Here they are:

Makefile

##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.18.0-B7] date: [Mon Feb 13 15:27:24 CET 2023] 
##########################################################################################################################

# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
#   2017-02-10 - Several enhancements + project update mode
#   2015-07-22 - first version
# ------------------------------------------------

######################################
# target
######################################
TARGET = Test

######################################
# building variables
######################################
# debug build?
DEBUG = 1
# optimization
OPT = -Og

#######################################
# paths
#######################################
# Build path
BUILD_DIR = build

######################################
# source
######################################
# C sources
C_SOURCES =  \
Core/Src/main.c \
Core/Src/stm32l4xx_it.c \
Core/Src/stm32l4xx_hal_msp.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
Core/Src/system_stm32l4xx.c \
Core/Src/gpio.c \
Core/Src/i2c.c \
Core/Src/tim.c \
Core/Src/usart.c \
Core/Src/adc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c

# ASM sources
ASM_SOURCES =  \
startup_stm32l452xx.s

#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S

#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m4

# fpu
FPU = -mfpu=fpv4-sp-d16

# float-abi
FLOAT-ABI = -mfloat-abi=hard

# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# macros for gcc
# AS defines
AS_DEFS = 

# C defines
C_DEFS =  \
-DUSE_HAL_DRIVER \
-DSTM32L452xx

# AS includes
AS_INCLUDES = 

# C includes
C_INCLUDES =  \
-ICore/Inc \
-IDrivers/STM32L4xx_HAL_Driver/Inc \
-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
-IDrivers/CMSIS/Include

# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif

# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"

#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32L452RETxP_FLASH.ld

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = 
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin

#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
    $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
    $(AS) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
    $(CC) $(OBJECTS) $(LDFLAGS) -o $@
    $(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(HEX) $< $@

$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(BIN) $< $@    

$(BUILD_DIR):
    mkdir $@        

#######################################
# clean up
#######################################
clean:
    -rm -fR $(BUILD_DIR)

#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***

STM32Make.make

##########################################################################################################################
# File automatically-generated by STM32forVSCode
##########################################################################################################################

# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
#   2017-02-10 - Several enhancements + project update mode
#   2015-07-22 - first version
# ------------------------------------------------

######################################
# target
######################################
TARGET = Test

######################################
# building variables
######################################
# debug build?
DEBUG = 1
# optimization
OPT = -Og

#######################################
# paths
#######################################
# Build path
BUILD_DIR = build

######################################
# source
######################################
# C sources
C_SOURCES =  \
Core/Src/adc.c \
Core/Src/bno055.c \
Core/Src/capture_test.c \
Core/Src/gpio.c \
Core/Src/i2c.c \
Core/Src/main.c \
Core/Src/stm32l4xx_hal_msp.c \
Core/Src/stm32l4xx_it.c \
Core/Src/syscalls.c \
Core/Src/system_stm32l4xx.c \
Core/Src/tim.c \
Core/Src/usart.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c

CPP_SOURCES = \
Core/Src/Encoder.cpp \
Core/Src/bh1750.cpp \
Core/Src/cpp_main.cpp \
Core/Src/hcsr04.cpp \
Core/Src/interrupts.cpp

# ASM sources
ASM_SOURCES =  \
startup_stm32l452xx.s

#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
POSTFIX = "
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
GCC_PATH="/home/florian/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/12.2.1-1.2.1/.content/bin
ifdef GCC_PATH
CXX = $(GCC_PATH)/$(PREFIX)g++$(POSTFIX)
CC = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX)
AS = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX) -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy$(POSTFIX)
SZ = $(GCC_PATH)/$(PREFIX)size$(POSTFIX)
else
CXX = $(PREFIX)g++
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S

#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m4

# fpu
FPU = -mfpu=fpv4-sp-d16

# float-abi
FLOAT-ABI = -mfloat-abi=hard

# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# macros for gcc
# AS defines
AS_DEFS = 

# C defines
C_DEFS =  \
-DSTM32L452xx \
-DUSE_HAL_DRIVER

# CXX defines
CXX_DEFS =  \
-DSTM32L452xx \
-DUSE_HAL_DRIVER

# AS includes
AS_INCLUDES = \

# C includes
C_INCLUDES =  \
-I../libraries/etl/include \
-ICore/Inc \
-IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
-IDrivers/CMSIS/Include \
-IDrivers/STM32L4xx_HAL_Driver/Inc \
-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy

# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections

CXXFLAGS = $(MCU) $(CXX_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -feliminate-unused-debug-types

ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf -ggdb
CXXFLAGS += -g -gdwarf -ggdb
endif

# Add additional flags
CFLAGS += 
ASFLAGS += 
CXXFLAGS += 

# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
CXXFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"

#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32L452RETxP_FLASH.ld

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = \

# Additional LD Flags from config file
ADDITIONALLDFLAGS = -specs=nano.specs -u _printf_float 

LDFLAGS = $(MCU) $(ADDITIONALLDFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections

# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin

#######################################
# build the application
#######################################
# list of cpp program objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))

# list of C objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))

$(BUILD_DIR)/%.o: %.cpp STM32Make.make | $(BUILD_DIR) 
    $(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cpp=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.cxx STM32Make.make | $(BUILD_DIR) 
    $(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cxx=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.c STM32Make.make | $(BUILD_DIR) 
    $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s STM32Make.make | $(BUILD_DIR)
    $(AS) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) STM32Make.make
    $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
    $(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(HEX) $< $@

$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
    $(BIN) $< $@

$(BUILD_DIR):
    mkdir $@

#######################################
# flash
#######################################
flash: $(BUILD_DIR)/$(TARGET).elf
    "/home/florian/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/openocd/0.12.0-1.1/.content/bin/openocd" -f ./openocd.cfg -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit"

#######################################
# erase
#######################################
erase: $(BUILD_DIR)/$(TARGET).elf
    "/home/florian/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/openocd/0.12.0-1.1/.content/bin/openocd" -f ./openocd.cfg -c "init; reset halt; stm32l4x mass_erase 0; exit"

#######################################
# clean up
#######################################
clean:
    -rm -fR $(BUILD_DIR)

#######################################
# custom makefile rules
#######################################

#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***

STM32-for-VSCode.config.yaml

# Configuration file for the STM32 for VSCode extension
# Arrays can be inputted in two ways. One is: [entry_1, entry_2, ..., entry_final]
# or by adding an indented list below the variable name e.g.:
# VARIABLE:
# - entry_1
# - entry_2

# The project name
target: Test
# Can be C or C++
language: C++

optimization: Og

# MCU settings
targetMCU: stm32l4x
cpu: cortex-m4 # type of cpu e.g. cortex-m4
fpu: fpv4-sp-d16 # Defines how floating points are defined. Can be left empty.
floatAbi: -mfloat-abi=hard
ldscript: STM32L452RETxP_FLASH.ld # linker script

# Compiler definitions. The -D prefix for the compiler will be automatically added.
cDefinitions:
  - USE_HAL_DRIVER
  - STM32L452xx

cxxDefinitions:
  - USE_HAL_DRIVER
  - STM32L452xx

asDefinitions: []

# Compiler definition files. you can add a single files or an array of files for different definitions.
# The file is expected to have a definition each new line.
# This allows to include for example a .definition file which can be ignored in git and can contain
# This can be convenient for passing along secrets at compile time, or generating a file for per device setup.
cDefinitionsFile:
cxxDefinitionsFile:
asDefinitionsFile:

# Compiler flags
cFlags: []
cxxFlags: []
assemblyFlags: []
linkerFlags:
  - -specs=nano.specs
  - -u _printf_float # for printing floats

# libraries to be included. The -l prefix to the library will be automatically added.
libraries:
  - c
  - m
  - nosys

# Library directories. Folders can be added here that contain custom libraries.
libraryDirectories: []

# Files or folders that will be excluded from compilation.
# Glob patterns (https://www.wikiwand.com/en/Glob_(programming)) can be used.
# Do mind that double stars are reserved in yaml
# these should be escaped with a: \ or the name should be in double quotes e.g. "**.test.**"
excludes:
  - "**/Examples/**"
  - "**/examples/**"
  - "**/Example/**"
  - "**/example/**"
  - "**_template.*"

# Include directories (directories containing .h or .hpp files)
# If a CubeMX makefile is present it will automatically include the include directories from that makefile.
includeDirectories:
  - Core/Inc
  - Drivers/STM32L4xx_HAL_Driver/Inc
  - Drivers/STM32L4xx_HAL_Driver/Inc/Legacy
  - Drivers/CMSIS/Device/ST/STM32L4xx/Include
  - Drivers/CMSIS/Include
  - Inc/**
  - Core/Inc/**
  - Core/Lib/**
  - Src/**
  - Core/Src/**
  - Core/Lib/**
  - ../libraries/etl/include

# Files that should be included in the compilation.
# If a CubeMX makefile is present it will automatically include the  c and cpp/cxx files from that makefile.
# Glob patterns (https://www.wikiwand.com/en/Glob_(programming)) can be used.
# Do mind that double stars are reserved in yaml
# these should be escaped with a: \ or the name should be in double quotes e.g. "HARDWARE_DRIVER*.c"
sourceFiles:
  - startup_stm32l452xx.s
  - Core/Src/main.c
  - Core/Src/stm32l4xx_it.c
  - Core/Src/stm32l4xx_hal_msp.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c               # This line was missing
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c         # This line was missing
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c
  - Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c
  - Core/Src/system_stm32l4xx.c
  - Src/**
  - Core/Src/**
  - Core/Lib/**

# When no makefile is present it will show a warning pop-up.
# However when compilation without the CubeMX Makefile is desired, this can be turned of.
suppressMakefileWarning: false

# Custom makefile rules
# Here custom makefile rules can be added to the STM32Make.make file
# an example of how this can be used is commented out below.
customMakefileRules:
# - command: sayhello
#   rule: echo "hello"
#   dependsOn: $(BUILD_DIR)/$(TARGET).elf # can be left out

# Additional flags which will be used when invoking the make command
makeFlags:
# - -O  # use this option when the output of make is mixed up only works for make version 4.0 and upwards
# - --silent # use this option to silence the output of the build
jortbmd commented 1 year ago

Thanks for replying. Seems like everything should have build just fine. The required source files where in the original Makefile and the extension should process that fine. Could you tell me which version of VSCode you are using, which version of the STM32 for VSCode extension and which OS you use? Also if you would be able to share a project which reproduces this error that would be great and would help me track down the bug.

Flo2410 commented 1 year ago

Okay, here we go:

My system

OS: Kubuntu 22.10 x86_64 Kernel: 5.19.0-31-generic

VSCode about page:

Version: 1.75.1 Commit: 441438abd1ac652551dbe4d408dfcec8a499b8bf Date: 2023-02-08T21:35:30.018Z Electron: 19.1.9 Chromium: 102.0.5005.194 Node.js: 16.14.2 V8: 10.2.154.23-electron.0 OS: Linux x64 5.19.0-31-generic snap Sandboxed: No

STM32 for VSCode

Version: v3.2.3

Cube MX

Version: 6.7.0

Broken Project

Repo: https://github.com/Flo2410/STM-for-VSCode-ADC-Bug

What I did:

jortbmd commented 1 year ago

Thanks!

Had a quick look at it. For me it works perfectly fine and the adc files are included. Even when removed from the STM32-for_VSCode.config.yaml file it still builds (as it should). Regenerated the whole project from scratch and build it and it still worked. I will have a better look at it. Just to be absolutely sure that I will not chase a rabbit down a dead end, could delete everything in the project you have just send me except for the .ioc file. Regenerate the entire project from the .ioc file and check if the issue persists?

Flo2410 commented 1 year ago

Okay it's tricky to reproduce. I just tried a few things.

jortbmd commented 1 year ago

Followed the same procedure as you however for me it is still successful. Code you tell me what the error is your getting in the STM32 build task in the terminal?

Flo2410 commented 1 year ago

Okay... For me, sometime it works, sometimes not. It's really strange. I did switch between building normally and making a clean build.

Try adding a step:

With this order, it definitely just broke. But sometimes it will break with another order or not at all. Unfortunately, I have no idea how to reproduce the bug reliably, all I know is that it occurs from now and then. Maybe it's a problem on my side, but I wouldn't know where to look.

The Error

/home/florian/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/12.2.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld: build/adc.o: in function `MX_ADC1_Init':
/home/florian/syncthing/Dokumente/Schule/FHWN/6_Semester_S2023/BAC/code/Test_BUG/Core/Src/adc.c:61: undefined reference to `HAL_ADC_Init'
/home/florian/.config/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/12.2.1-1.2.1/.content/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld: /home/florian/syncthing/Dokumente/Schule/FHWN/6_Semester_S2023/BAC/code/Test_BUG/Core/Src/adc.c:74: undefined reference to `HAL_ADC_ConfigChannel'
Flo2410 commented 1 year ago

I just found out that this is happening not only with the ADC. I just added the CAN feature to my project, and it showed me a similar error as above, but only with the CAN methods. Removing all files related to the extension, reloading VS Code and building again solves this problem. But I have to add my custom settings to the STM32-for-VSCode.config.yaml all over again.

jortbmd commented 1 year ago

this would track with the behaviour you were already seeing with the ADC files. This at least means it is not specific for certain files. On top of this it should just get all the paths from the Makefile CubeMX generates. So it is weird that you need to add them manually. Could you perhaps remove those entries from the STM32-for-VSCode.config.yaml, check if the files for CAN you want are ik the CubeMX generated makefile and then regenerate? It almost seems like a caching issue so I am curious if it does not compile those files each time or only once.

Flo2410 commented 1 year ago

I don't need to add any files to the config.yaml. Adding the files did work for the ADC, though. Instead, I did the following for the CAN: I had a working project, then I added the CAN in CubeMX and generated the code. After that, building failed. What I did was, remove all files except the Core folder and the .ioc and regenerated the code in CubeMX. Now I did a reload of VS Code to reload the extension, after that building worked.

It seems like the extension fails to include paths added to the Makefile by CubeMX after the first build, where the STM32-for-VSCode.config.yaml is created. But maybe not always?! Although this is just I thought of mine and I have no idea if this is in any way correct.

jortbmd commented 1 year ago

I was able to reproduce the same issue on Windows. I have now created a fix for the next release. Could you check if this also resolves your issues? Release can be found here: https://github.com/bmd-studio/stm32-for-vscode/releases To install please download the VSIX file and use ctrl/cmd+shift+p to open up the command panel and type in: VSIX, then you should be able to select Extension: Install from VSIX. This way you can install the newest one. I will test the newest version for a short while and will probably release it in the marketplace next week.

Flo2410 commented 1 year ago

Okay. I tested a bit, and it seems to be fixed. Thank you.

jortbmd commented 1 year ago

Great to hear! Will test the extension a bit further and I will probably release the new version this week. I will let you know once that happens.

jortbmd commented 1 year ago

Release was a bit delayed, however 3.2.4 is out now with the fix and for this reason I will close this issue. Should you run into any issue feel free to re-open this issue or create a new one.