Some quick notes and tests to start developing with NuttX on STM32F4 Discovery board using an open software stack with GNU/Linux.



Running NuttX on STM32F4 Discovery board

Install dependencies:

$ sudo apt-get install \
     gperf libncurses5-dev flex bison \
     curl automake autoconf libtool perl \
     pkg-config minicom build-essential \
     cmake libusb-1.0-0-dev libgtk-3-dev

Follow this documentation to install the toolchain.

Build and install kconfig-frontends package:

$ mkdir ~/sandbox && cd ~/sandbox
$ KF= && \
  wget ${KF}/kconfig-frontends-
$ tar xvf kconfig-frontends-
$ cd kconfig-frontends-
$ curl -O \
$ patch -p1 -i 20190715-kconfig-frontends.patch
$ autoreconf -fi
$ ./configure --prefix=/usr
$ make
$ sudo make install

Build NuttX and Apps with the build host platform to Linux:

$ cd ~/sandbox
$ mkdir nx
$ git clone nuttx
$ git clone apps
$ cd nuttx
$ tools/ stm32f4discovery/usbnsh
$ make menuconfig
#  Build Setup
#     `--> Build Host Platform (Linux)
$ make

Build ST-Link:

$ cd ~/sandbox
$ git clone
$ cd stlink
$ make release
$ find . -type f -name "st-*" | grep build
$ cd build/Release
$ sudo make install
$ sudo ldconfig

Plug the board and run st-info:

$ sudo st-info
st-info --version
st-info --flash
st-info --sram
st-info --descr
st-info --pagesize
st-info --chipid
st-info --serial
st-info --hla-serial
st-info --probe
$ sudo st-info --version
$ sudo st-info --flash
$ sudo st-info --sram
$ sudo st-info --descr
F4 device
$ sudo st-info --pagesize
$ sudo st-info --chipid
$ sudo st-info --serial
$ sudo st-info --hla-serial
$ sudo st-info --probe
Found 1 stlink programmers
 serial: 303030303030303030303031
openocd: "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x31"
  flash: 1048576 (pagesize: 16384)
   sram: 196608
 chipid: 0x0413
  descr: F4 device

Flash NuttX:

$ cd ~/sandbox/nx/nuttx
$ sudo st-flash write nuttx.bin 0x8000000

NSH test with Minicom (115200-8-N-1):

$ sudo minicom -s -c on -D /dev/ttyACMX

Welcome to minicom 2.7.1

Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyACMX, 00:01:02

Press CTRL-A Z for help on special keys

NuttShell (NSH)
nsh> help
help usage:  help [-v] []

  [         cp        exec      kill      mv        set       uname
  ?         cmp       exit      ls        mw        sh        umount
  basename  dirname   false     mb        ps        sleep     unset
  break     dd        free      mkdir     pwd       test      usleep
  cat       df        help      mh        rm        time      xd
  cd        echo      hexdump   mount     rmdir     true

Builtin Apps:

Debugging NuttX on STM32F4 Discovery board

Build with debug symbols (needed for use with a debugger):

$ cd ~/sandbox/nx/nuttx
$ make menuconfig
# Build Setup
#    `--> Debug Options
#            `--> Generate Debug Symbols
$ make
$ cat ~/.gdbinit
target extended-remote :4242
monitor halt
monitor reset
break __start

Run st-util:

$ sudo st-util -p 4242
st-util 1.5.1-30-g84f63d2
2019-07-15T00:01:02 INFO usb.c: -- exit_dfu_mode
2019-07-15T00:01:02 INFO common.c: Loading device parameters....
2019-07-15T00:01:02 INFO common.c: Device connected is: F4 device, id 0x10036413
2019-07-15T00:01:02 INFO common.c: SRAM size: 0x30000 bytes (192 KiB),
 Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes
2019-07-15T00:01:02 INFO gdb-server.c: Chip ID is 00000413, Core ID is  2ba01477.
2019-07-15T00:01:02 INFO gdb-server.c: Listening at *:4242...

Run the debugger:

$ arm-none-eabi-gdb nuttx
GNU gdb (GNU MCU Eclipse ARM Embedded GCC, 64-bit)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from nuttx...
__start () at chip/stm32_start.c:271
271     {
Loading section .text, size 0x11eb9 lma 0x8000000
Loading section .ARM.extab, size 0x240 lma 0x8011ebc
Loading section .ARM.exidx, size 0x12e0 lma 0x80120fc
Loading section .data, size 0x6c lma 0x80133dc
Start address 0x8000188, load size 78917
Transfer rate: 9 KB/sec, 7891 bytes/write.
Breakpoint 1 at 0x8000188: file chip/stm32_start.c, line 271.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, __start () at chip/stm32_start.c:271
271     {



comments powered by Disqus

Recent Entries