Problem:
The firmware image created when linking to the static library is different from the firmware image generated when linking to objects directly extracted from the static library.
Both firmware images are connected without errors and successfully downloaded to the microcontroller.
The last binary (associated with the objects) runs successfully and, as expected, while the first (linked to the static library) does not.
The only warnings during compilation are those unused-but-set-variablesupplied by the manufacturer of the HAL, which, due to various macro definitions, is not required for the compiled implementation; and unused-parameterin various weak functions, also supplied by the manufacturer HAL.
Description:
I am developing an embedded application for the STM32F407. So far, I have worked with one code base, including the HAL microprocessor and installation code, a driver for a specific peripheral device, and an application that uses the first two.
Since I want to develop several applications using the same driver and HAL (both are complete and tested, so they will not change often), I want to compile and distribute HAL and the driver as a static library, which can be associated with the application source.
, . , , .
:
, :
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(APPOBJECTS) Library/libtest.a
, , :
@cd Library && $(AR) x libtest.a && cd ..
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(APPOBJECTS) Library/*.o
:
CFLAGS = $(INCLUDES) $(DEFS) -ggdb3 -O0 -std=c99 -Wall -specs=nano.specs -nodefaultlibs
CFLAGS+= -fdata-sections -ffunction-sections -mcpu=cortex-m4 -march=armv7e-m -mthumb
CFLAGS+= -mfloat-abi=hard -mfpu=fpv4-sp-d16 -MD -MP -MF $@.d
LDFLAGS = -T$(LDSCRIPT) -Wl,-static -Wl,-Map=$(@:.elf=.map),--cref -Wl,--gc-sections
-Wl,--print-gc-sections, app.map, , . -Wl,--gc-sections, .
arm-none-eabi-size :
text data bss dec hex filename
43464 76 8568 52108 cb8c workingapp.elf
text data bss dec hex filename
17716 44 8568 26328 66d8 brokenapp.elf
-Wl,--gc-sections
arm-none-eabi-gdb , , WWDG. , , , Default_Handler ( ). .
WWDG ,
-