Some time ago I needed to link with ARM DSP library on NuttX to use FFT feature and I decided to document who I did it and some tricks to reduce the final binary size.
In fact to include a library all you need to do is add it to your board Make.defs. See a simple patch file to stm32f4discovery:
index 59aa60bf6b..5e6845c81c 100644 --- a/boards/arm/stm32/stm32f4discovery/scripts/Make.defs +++ b/boards/arm/stm32/stm32f4discovery/scripts/Make.defs @@ -63,6 +63,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ +EXTRA_LIBS = "$(TOPDIR)/3rparty/libarmdsp.a" + NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048
It means you need to create a “3rdpary” directory at root of nuttx/ and put your library there.
But after the compilation you will notice that your nuttx.bin binary will become very big. It happens because the linker will include all the functions in the library.
You can instruct it to include only the needed functions using this parameter with LDFLAGS:
LDFLAGS += --gc-sections
Now your binary will become way smaller