How to install NuttX on Teensy 4.0/4.1 board

./teensy_loader_cli -w -v --mcu=TEENSY40 ~/nuttx/incubator-nuttx/nuttx.hex 
Teensy Loader, Command Line, Version 2.2
Read "/home/bashton/nuttx/incubator-nuttx/nuttx.hex": 73803 bytes, 3.6% usage
Found HalfKay Bootloader
Programming...................................................................
Booting

A chave para o sucesso

Mais uma frase para a categoria “Quem Disse”


“Determinação, coragem e auto-confiança são fatores decisivos parao sucesso. Se estamos possuídos por uma inabalável determinação,conseguiremos superá-los. Independentemente das circunstâncias,devemos ser sempre humildes, recatados e despidos de orgulho.” — Dalai Lama

NuttX apps compilation issue

If you decide you create your own NuttX application based on apps/examples/hello you could eventually face this issue:

CC: my_app_main.c
:0:6: error: expected identifier or '(' before numeric constant
:0:6: error: expected identifier or '(' before numeric constant
my_app_main.c:51:5: note: in expansion of macro 'main'
int main(int argc, FAR char *argv[])
^
make[3]: *** [/home/alan/apps/Application.mk:189: my_app_main.home.alan.apps.examples.my_app.o] Error 1

This error happens because your PROGNAME defined inside the Kconfig differs from your application name:

config EXAMPLES_MYAPPNAME_PROGNAME
string "Program name"
default "myapp"

If your PROGNAME is myapp then you need to have apps/examples/myapp/myapp_main.c otherwise it will not work. So don’t my_app for your app directory neither my_app_main.c for your main file, it needs to be myapp_main.c

Linking external libraries on NuttX

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