Getting Started with NuttX -- STM32F4 Discovery (Unix)

This how to assumes an installed arm-none-eabi toolchain and GIT. You can refer to e.g. the PX4 wiki for a generic tutorial how to install an arm-none-eabi toolchain (this website uses the same wiki system, so porting back the instructions to this wiki would be welcome).

mkdir nuttx-git
cd nuttx-git
git clone nuttx
git clone apps

Enter the nuttx-git/nuttx directory:

cd nuttx

# this step will not provide any output, but copy the configuration to
# nuttx-git/nuttx/.config

tools/ stm32f4discovery/usbnsh # nsh console/usb - need microUSB to USB cable
# or
tools/ stm32f4discovery/nsh # nsh console/UART2 - need UART-TTL to USB cable eg FTDI

Now configure with kconfig-frontends:

make menuconfig

This will bring up the top-level config screen. The most important setting is the toolchain.


  • Build Setup:
    • Build host platform: Linux (even on Mac OS that's perfectly fine)

Then exit and save. Now compile:


This will have generated a file called nuttx, which is an ELF file and can be flashed via SWD / JTAG. The stm32f4discovery has two usb connectors. The miniUSB connects to the onboard st-link SWD/JTAG. The stm32f4discovery can be flashed from any host that supports the USB st-link. The microUSB connects to the STM32F407 OTG-FS port. The NSH console “usbnsh” is only supported on a linux host and doesn't work on Windows as of ver17.13.

Black Magic Probe Flash Instructions
arm-none-eabi-gdb nuttx
target extended-remote </dev/ttyACM0 on Linux, /dev/tty.usbmodemXXXXXX on Mac OS X, or \\.\COMn on Windows>
mon swdp_scan
attach 1
texane/st-flash Flash Instructions

texane st-flash build-tutorial The stm32f4discovery has an onboard st-link(SWD/JTAG) that is accessed by the miniUSB and can be flashed with:

st-flash write nuttx.bin 0x8000000

Alternatively the Windows STM32 ST-Link Utility will also flash it.

If specified “stm32f4discovery/usbnsh” the device is directly available via USB (for linux only systems, doesn't work with Windows USB). To find it on the bus, run either of these commands:


# or
# then 
ls /dev/ttyACM*

Mac OS:

system_profiler SPUSBDataType

If the device listed correctly, you can connect via screen:

screen /dev/tty.usbmodem1 # Mac OS
# or
screen /dev/ttyACM0 # Linux

Default baud rate is 115200 8N1, no HW flow control.

Upon connection, the NSH prompt should be displayed (when not, try hitting Enter three times):


If specified “stm32f4discovery/nsh” then NSH prompt shows immediately on serial console.