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).
| Code Block |
|---|
mkdir nuttx-git
cd nuttx-git
git clone https://bitbucket.org/nuttx/nuttx.git nuttx
git clone https://bitbucket.org/nuttx/apps.git apps
|
Enter the nuttx-git/nuttx directory:
| Code Block |
|---|
# this step will not provide any output, but copy the configuration to
# nuttx-git/nuttx/.config
|
| Code Block |
|---|
tools/configure.sh stm32f4discovery:usbnsh # nsh console/usb - need microUSB to USB cable
# or
tools/configure.sh stm32f4discovery:nsh # nsh console/UART2 - need UART-TTL to USB cable eg FTDI
|
Now configure with kconfig-frontends:
| Code Block |
|---|
|
make menuconfig
|
This will bring up the top-level config screen. The most important setting is the toolchain.
Select:
- 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
| Code Block |
|---|
|
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
load
kill
|
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:
| Code Block |
|---|
|
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:
Linux:
| Code Block |
|---|
|
lsusb
# or
dmesg
# then
ls /dev/ttyACM*
|
Mac OS:
| Code Block |
|---|
|
system_profiler SPUSBDataType
|
If the device listed correctly, you can connect via screen:
| Code Block |
|---|
|
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.