43 views
in System Integration by

I am running into something very strange during a simple trial run of writing my own function to check if "make" works.

In the "DeviceDriver.c" I made a function named  "XInt32 DeviceDriver_GetADC( void)" . In this function I am calling  two simple functions that just return an integer value for sanity sake.

1. ADC = EwBspadc_ar_GetFakeAdc1()

2. ADC = EwBspadc_ar_GetFakeAdc2();   

 I created new header and C files "ew_bsp_adc_ar.h" and " ew_bsp_adc_ar.c"  The function  " int EwBspadc_ar_GetFakeAdc1( void)"  is  prototyped and defined in "ew_bsp_adc_ar.h/c" . The second function " int EwBspadc_ar_GetFakeAdc2( void)" is prototyped and defined  in pre-existing header and c files named "ew_bsp_inout.h/c".

If I invoke "make" and compile  using the function call in the "DeviceDriver.c" That call the "int EwBspadc_ar_GetFakeAdc2( void)" which is prototyped and defined in "ew_bsp_inout.h/c", the "make" compiles and links OK..

If I make and compile using the function call  in the DeviceDriver.c  "int EwBspadc_ar_GetFakeAdc1( void)"  prototyped and defined in header and c files named  "ew_bsp_adc_ar.h/c", the "make" gives an error of "undefined reference on the EwBspadc_ar_GetFakeAdc1" function call. See the Error log below:

Does the make file not like the newly created "ew_bsp_adc_ar.h" and "ew_bsp_adc_ar.c" files where I prototyped the new function "int EwBspadc_ar_GetFakeAdc2( void)"?

Here are snippets of the pertinent files for reference: 

Here is a snippet of the  DeviceDriver.c that shows the #include ew_bsp_adc_ar.h and the function call defined in the "ew_bsp_adc_ar.c" file that does not compile.

#include "ewrte.h"

#include "ew_bsp_adc_ar.h"

#include "ew_bsp_inout.h"

#include "ew_bsp_clock.h"

:
:
:


XInt32 DeviceDriver_GetADC1( void )
{
  ADC = EwBspadc_ar_GetFakeAdc1();  // Does Not Compile
//ADC = EwBspadc_ar_GetFakeAdc2();  // Compiles OK!
}

Here is snippet of the function definition in Ew_bsp_adc_ar.c

//ew_bsp_adc_ar.c

#include "ewconfig.h"
#include "stm32f7xx_hal.h"
#include "stm32746g_discovery.h"

#include "ew_bsp_adc_ar.h"


int  EwBspadc_ar_GetFakeAdc1(void)
{
    
    return 100;
}


/* msy */

 

.This DeviceDeriver.C using the function call defined in ew_bsp_inout.c Compiles OK.


#include "ewrte.h"

#include "ew_bsp_adc_ar.h"

#include "ew_bsp_inout.h"

#include "ew_bsp_clock.h"

:
:
:


XInt32 DeviceDriver_GetADC1( void )
{
// ADC = EwBspadc_ar_GetFakeAdc1();  // Does Not Compile
ADC = EwBspadc_ar_GetFakeAdc2();  // Compiles OK!
}
 

 

Snippet of ew_bsp_inout.c 


int  EwBspadc_ar_GetFakeAdc2(void)
{
    
    return 100;
}

 

Good compile:

 

1 Answer

0 votes
by
 
Best answer

Hi me,

I figured out the problem. I needed to modify the "Make" file in  /Application/Project/GCC/

I had to add the newly created "ew_bsp_adc_ar.c" definition file in the "Make".

Here is the Make File modified in its entirity:

###############################################################################
# PROJECT     : Embedded Wizard Application Demo
###############################################################################
export MAKEFLAGS += --silent

###############################################################################
# GENERAL PROJECT CONFIGURATION
###############################################################################
APP_FILE                      = EmbeddedWizard-STM32F746-Discovery

FREE_RTOS                     ?= 1
# REMARK: Set the macro FREE_RTOS to 1 to build an Embedded Wizard project
# based on FreeRTOS.

EXTERNAL_FLASH                ?= 1
# REMARK: Set the macro EXTERNAL_FLASH to 1 to locate Embedded Wizard resources
# to the external FLASH device.

###############################################################################
# GENERAL SETTINGS & PATHS
###############################################################################
EMWI_APP_PATH     = ../../GeneratedCode

SRC_PATH          = ../../Source
EMWI_BSP_PATH     = ../../../TargetSpecific

OBJ_PATH          = ./Obj
BIN_PATH          = ./Bin

SDK_PATH          = ../../../ThirdParty/STM32Cube_FW_F7
DRIVERS_PATH      = $(SDK_PATH)/Drivers
FREE_RTOS_PATH    = $(SDK_PATH)/Middlewares/Third_Party/FreeRTOS
STARTUP           = ./startup_stm32f746xx.s
LINK_SCRIPT       = ./stm32f7_flash.ld

ifeq ($(FREE_RTOS),1)
FREE_RTOS_SOURCE_PATH =                                                        \
         $(FREE_RTOS_PATH)/Source                                              \
         $(FREE_RTOS_PATH)/Source/CMSIS_RTOS                                   \
         $(FREE_RTOS_PATH)/Source/portable/MemMang                             \
         $(FREE_RTOS_PATH)/Source/portable/GCC/ARM_CM7/r0p1
endif

###############################################################################
# Include standard rules and utilities
# Include Embedded Wizard configuration and list of generated source code
###############################################################################
include ./utilities.mk
include ./rules.mk

ifeq (,$(wildcard $(EMWI_APP_PATH)/ewfiles.inc))
  $(error ERROR: $n$nThe file '(EMWI_APP_PATH)/ewfiles.inc' is missing!\
    $nPlease open Embedded Wizard project and generate code before calling make!)
endif

include $(EMWI_APP_PATH)/ewfiles.inc

EMWI_RTE_PATH     = ../../../PlatformPackage/RTE
EMWI_GFX_PATH     = ../../../PlatformPackage/$(EMWI_COLOR_FORMAT)

include $(EMWI_GFX_PATH)/ewgfx.inc
include $(EMWI_RTE_PATH)/ewrte.inc

###############################################################################
# Standard directories for C files
###############################################################################
vpath %.c           $(SRC_PATH)                                                \
                    $(EMWI_APP_PATH)                                           \
                    $(EMWI_RTE_PATH)                                           \
                    $(EMWI_GFX_PATH)                                           \
                    $(EMWI_BSP_PATH)                                           \
                    $(EMWI_BSP_PATH)/Drivers                                   \
                    $(DRIVERS_PATH)/STM32F7xx_HAL_Driver/Src                   \
                    $(DRIVERS_PATH)/BSP/STM32746G-Discovery                    \
                    $(FREE_RTOS_SOURCE_PATH)

##############################################################################
# EMBEDDED WIZARD - APPLICATION DEMO
###############################################################################
APP_C =                                                                        \
                    main.c                                                     \
                    ewmain.c                                                   \
                    DeviceDriver.c                                             \

# automatically compile all files generated by Embedded Wizard
APP_EMWI_C =        $(EMWIFILES)

# compile all files for the Embedded Wizard Runtime Environment (RTE)
RTE_EMWI_C =        $(EMWI_RTE_FILES)

# compile all files for the Embedded Wizard Graphics Engine (GFX)
GFX_EMWI_C =        $(EMWI_GFX_FILES)

BOARD_CONFIG_C =                                                               \
                    ew_bsp_system.c                                            \
                    ew_bsp_clock.c                                             \
                    ew_bsp_event.c                                             \
                    ew_bsp_display.c                                           \
                    ew_bsp_touch.c                                             \
                    ew_bsp_console.c                                           \
                    ew_bsp_inout.c                                             \
                    ew_bsp_graphics.c                                          \
                    stm32f7xx_it.c                                             \
                    system_stm32f7xx.c                                         \
                    ft5336.c                                                   \
                    ew_bsp_adc_ar.c                                            \

BSP_C =                                                                        \
                    stm32f7xx_hal.c                                            \
                    stm32f7xx_hal_rcc.c                                        \
                    stm32f7xx_hal_rcc_ex.c                                     \
                    stm32f7xx_hal_cortex.c                                     \
                    stm32f7xx_hal_gpio.c                                       \
                    stm32f7xx_hal_sdram.c                                      \
                    stm32f7xx_hal_dma.c                                        \
                    stm32f7xx_hal_ltdc.c                                       \
                    stm32f7xx_hal_dma2d.c                                      \
                    stm32f7xx_hal_i2c.c                                        \
                    stm32f7xx_hal_spi.c                                        \
                    stm32f7xx_ll_fmc.c                                         \
                    stm32f7xx_hal_uart.c                                       \
                    stm32f7xx_hal_pwr_ex.c                                     \
                    stm32f7xx_hal_tim.c                                        \
                    stm32f7xx_hal_tim_ex.c                                     \
                    stm32f7xx_hal_rtc.c                                        \
                    stm32f7xx_hal_rtc_ex.c                                     \
                    stm32746g_discovery.c                                      \
                    stm32746g_discovery_sdram.c                                \

ifeq ($(EXTERNAL_FLASH),1)
BSP_C +=            stm32f7xx_hal_qspi.c                                       \
                    stm32746g_discovery_qspi.c
endif

FREE_RTOS_C =                                                                  \
                    list.c                                                     \
                    queue.c                                                    \
                    tasks.c                                                    \
                    timers.c                                                   \
                    cmsis_os.c                                                 \
                    heap_4.c                                                   \
                    port.c                                                     \

###############################################################################
# LIBRARIES
###############################################################################
LIBS := c                                                                      \
        nosys                                                                  \
        m                                                                      \
        $(EMWI_RTE_LIB)                                                        \
        $(EMWI_GFX_LIB)                                                        \

###############################################################################
# INCLUDES
###############################################################################
INCLUDES =                                                                     \
            -I$(SRC_PATH)                                                      \
            -I$(EMWI_BSP_PATH)                                                 \
            -I$(EMWI_BSP_PATH)/Drivers                                         \
            -I$(EMWI_APP_PATH)                                                 \
            -I$(EMWI_RTE_PATH)                                                 \
            -I$(EMWI_GFX_PATH)                                                 \
            -I$(DRIVERS_PATH)/CMSIS/Device/ST/STM32F7xx/Include                \
            -I$(DRIVERS_PATH)/CMSIS/Include                                    \
            -I$(DRIVERS_PATH)/STM32F7xx_HAL_Driver/Inc                         \
            -I$(DRIVERS_PATH)/BSP/STM32746G-Discovery                          \
            -I$(DRIVERS_PATH)/BSP/Components/Common                            \

ifeq ($(FREE_RTOS),1)
INCLUDES +=                                                                    \
            -I$(FREE_RTOS_PATH)/Source/portable/GCC/ARM_CM7/r0p1               \
            -I$(FREE_RTOS_PATH)/Source/CMSIS_RTOS                              \
            -I$(FREE_RTOS_PATH)/Source/include
endif

###############################################################################
# DEFINES
###############################################################################
CFLAGS  = -O2 -Wall -mcpu=cortex-m7 -mlittle-endian -mthumb                    \
          -mthumb-interwork -mfpu=fpv5-sp-d16 -mfloat-abi=hard                 \
          -ffunction-sections -fdata-sections                                  \
          -DUSE_HAL_DRIVER -DSTM32F746xx -DUSE_STM32746G_DISCO                 \
          -DEW_FRAME_BUFFER_COLOR_FORMAT=EW_FRAME_BUFFER_COLOR_FORMAT_$(EMWI_COLOR_FORMAT) \
          -DEW_SURFACE_ROTATION=$(EMWI_SURFACE_ROTATION)                       \
          -DEW_USE_FREE_RTOS=$(FREE_RTOS)                                      \
          -DEW_USE_EXTERNAL_FLASH=$(EXTERNAL_FLASH)                            \


ifeq ($(EXTERNAL_FLASH),1)
CFLAGS += -DEW_BITMAP_PIXEL_SECTION_NAME=.SectionEwResource
CFLAGS += -DEW_FONT_PIXEL_SECTION_NAME=.SectionEwResource
endif

###############################################################################
# OBJECTS
###############################################################################
APP_OBJ           := $(foreach file,$(APP_C),             $(OBJ_PATH)/$(strip $(basename $(file))).o)
APP_EMWI_OBJ      := $(foreach file,$(APP_EMWI_C),        $(OBJ_PATH)/$(strip $(basename $(file))).o)
RTE_EMWI_OBJ      := $(foreach file,$(RTE_EMWI_C),        $(OBJ_PATH)/$(strip $(basename $(file))).o)
GFX_EMWI_OBJ      := $(foreach file,$(GFX_EMWI_C),        $(OBJ_PATH)/$(strip $(basename $(file))).o)
BOARD_CONFIG_OBJ  := $(foreach file,$(BOARD_CONFIG_C),    $(OBJ_PATH)/$(strip $(basename $(file))).o)
BSP_OBJ           := $(foreach file,$(BSP_C),             $(OBJ_PATH)/$(strip $(basename $(file))).o)

ifeq ($(FREE_RTOS),1)
FREE_RTOS_OBJ     := $(foreach file,$(FREE_RTOS_C),       $(OBJ_PATH)/$(strip $(basename $(file))).os)
endif

OBJS := $(APP_OBJ) $(APP_EMWI_OBJ) $(RTE_EMWI_OBJ) $(GFX_EMWI_OBJ) $(BOARD_CONFIG_OBJ) $(BSP_OBJ) $(FREE_RTOS_OBJ)

# Some flickering in display was noticed, if the FreeRTOS part is comiled with -O2 option
# Therefore the compiler optimization is reduced to -O1 in case of FreeRTOS code
CCRUN_NO_OPTIMIZATION = $(subst -O2, -O1, $(CCRUN_STD))

$(OBJ_PATH)/%.os: %.c $(DEPENDENCY_FILES)
	@echo Compiling $<
#	@echo $(CCRUN_NO_OPTIMIZATION)
	$(CCRUN_NO_OPTIMIZATION)


MAPFILE   = -Wl,-Map=$(BIN_PATH)/$(APP_FILE).map

LINKING   = $(LD) -mcpu=cortex-m7 -mlittle-endian -mthumb -mthumb-interwork    \
            -mfpu=fpv5-sp-d16 -mfloat-abi=hard -Wl,--gc-sections               \
            $(MAPFILE)                                                         \
            $(STARTUP)                                                         \
            $(OBJS)                                                            \
            $(addprefix -L,$(EMWI_RTE_PATH))                                   \
            $(addprefix -L,$(EMWI_GFX_PATH))                                   \
            $(addprefix -l,$(LIBS))                                            \
            -T $(LINK_SCRIPT)                                                  \
            -o $(BIN_PATH)/$(APP_FILE).elf


ifeq ($(EXTERNAL_FLASH),1)
EXTERNAL_FLASH_LOADER = -EL "$(STLINK_EXT_FLASH_LOADER)"
endif

TRANSLATE = $(OBJCOPY) -O ihex $(BIN_PATH)/$(APP_FILE).elf $(BIN_PATH)/$(APP_FILE).hex
FLASHING  = $(STLINK) -P $(BIN_PATH)/$(APP_FILE).hex $(EXTERNAL_FLASH_LOADER)

PRINT_SIZE  = $(SIZE) $(BIN_PATH)/$(APP_FILE).elf

RESET       = $(STLINK) -Rst
RUN         = $(STLINK) -run 0x8000000

###############################################################################
# RULES
###############################################################################
$(APP_FILE): precompile $(OBJS)
	@echo Linking $(APP_FILE)
	@echo $(LINKING)
	$(LINKING)
	@echo Memory Usage:
	$(PRINT_SIZE)
	$(TRANSLATE)
	@echo $(APP_FILE) successfully built !!

install: $(APP_FILE)
	@echo Flashing $(APP_FILE)
	@echo $(FLASHING)
	$(FLASHING)
	$(RESET)
	@echo $(APP_FILE) successfully flashed !!

projectecho:
	@echo -------------------------------------------------
	@echo Creating $(APP_FILE)
	@echo -------------------------------------------------
	@echo Compiler Options: $(CFLAGS)

createdirs:
	@echo -------------------------------------------------
	@echo Creating object and binary directories
	-$(MKDIR) $(OBJ_PATH)
	-$(MKDIR) $(BIN_PATH)
	@echo -------------------------------------------------

precompile: projectecho createdirs ;

clean:
	@echo Cleaning $(OBJ_PATH) and $(BIN_PATH)
	-$(RM) $(OBJ_PATH)
	-$(RM) $(BIN_PATH)

include $(wildcard $(patsubst %,%.d,$(basename $(OBJS))))

Here is the snippet section of the Make file modification:

BOARD_CONFIG_C =                                                               \
                    ew_bsp_system.c                                            \
                    ew_bsp_clock.c                                             \
                    ew_bsp_event.c                                             \
                    ew_bsp_display.c                                           \
                    ew_bsp_touch.c                                             \
                    ew_bsp_console.c                                           \
                    ew_bsp_inout.c                                             \
                    ew_bsp_graphics.c                                          \
                    stm32f7xx_it.c                                             \
                    system_stm32f7xx.c                                         \
                    ft5336.c                                                   \
   Add------------> ew_bsp_adc_ar.c                                            \

 

by
Hi,

correct - all files that you want to add to your project have to be added manually to the list of source files within your makefile or project file.

Only the generated source codes are added automatically, because of the generated file ewfiles.inc.

Best regards,

Manfred.

Embedded Wizard Website | Privacy Policy | Imprint

...