Tuesday, February 17, 2015

Getting started with Nuttx


NuttX is a real-time operating system developed by Gregory Ellis Nutt, I came across few weeks ago, unfortunately as the Nuttx Getting Started wiki says "There is no "Getting Started" Guide for NuttX yet.", in this post I would like to scratch a possible getting started guide.

So as my favourite O.S. is Linux let's start with NuttX on Linux Xbuntu

1. Install the Xubuntu 14.04

Xbuntu is available for download at http://xubuntu.org/getxubuntu/, I choose the 32-bit, and I installed it in Oracle Virtual Box 4.3.20

2. Install some stuff that will help in building the Buildroot toolchain:

$sudo apt-get install libgmp-dev libgmp3-dev libmpfr-dev libmpc-dev texinfo

3. Let's clone the Nuttx git repository:

$git clone http://git.code.sf.net/p/nuttx/git nuttx-code

As I write the latest commit, the one I use, is 9e161f81bbddf6998549c98ad36a48794faaa007 

4. A new directory named nuttx-code is created, inside you can find:

├── apps
├── misc
├── nuttx
└── NxWidgets

5. First of all let's configure Nuttx for target we want:

$cd  nuttx/tools
$./configure.sh lm3s6965-ek/nx

6. Now, let's move in the buildroot dir and let's build the building tools:

    $cd ../../misc/buildroot/
    $cp configs/cortexm3-eabi-defconfig-4.6.3 .config
    $make oldconfig (press enter to accept default settings)

7. Modify the GCC  and “NuttX Binary Support” sections in the .config as it follows:

# GCC Options
#
BR2_PACKAGE_GCC=y
# BR2_GCC_VERSION_3_3_6 is not set
# BR2_GCC_VERSION_3_4_6 is not set
# BR2_GCC_VERSION_4_2_4 is not set
# BR2_GCC_VERSION_4_3_3 is not set
# BR2_GCC_VERSION_4_5_2 is not set
# BR2_GCC_VERSION_4_6_3 is not set
# BR2_GCC_VERSION_4_7_3 is not set
BR2_GCC_VERSION_4_8_2=y
BR2_GCC_SUPPORTS_SYSROOT=y
BR2_GCC_VERSION="4.8.2"
# BR2_GCC_USE_SJLJ_EXCEPTIONS is not set
BR2_EXTRA_GCC_CONFIG_OPTIONS=""
BR2_INSTALL_LIBSTDCPP=y
# BR2_INSTALL_LIBGCJ is not set
# BR2_INSTALL_OBJC is not set
# BR2_INSTALL_FORTRAN is not set

#
# NuttX Binary Support
#
#BR2_PACKAGE_NXFLAT is not set
BR2_PACKAGE_GENROMFS=y
BR2_PACKAGE_KCONFIG_FRONTENDS=y
# BR2_NCONF_FRONTEND is not set
# BR2_GCONF_FRONTEND is not set
# BR2_QCONF_FRONTEND is not set
BR2_KCONFIG_FRONTENDS_VERSION="3.12.0.0"
and start the build:
$make

8. Buildroot will download all the stuff needed and will build the toolchain.

More information about Buildroot can be found here:http://buildroot.uclibc.org/
The version of Buildroot inside the cloned git repository has been hacked to build the NuttX-compatible toolchains and some other useful tools like kconfig.

9. At this point we should have our toolchain and tools ready to be used.

10. Let's move in the nuttx directory, let's modify a couple of env vars and let's build our image.

$cd ../../nuttx/
$export PATH=`pwd`/../misc/buildroot/build_arm_nofpu/staging_dir/bin:$PATH
$export CROSSDEV=arm-elf-
$make
pay attention that ` is the character above the tab in the English US Keyboard.

11. At the end of the process we will obtain the nuttx images ready to be downloaded on the target.

As unfortunately I don't have a Stellaris Board I will use a simulator, qemu:

     $sudo apt-get install qemu-system-arm

and now let's rock:

    $qemu-system-arm -M lm3s6965evb -kernel nuttx
and our Nuttx will run inside Qemu:






Links:
http://paregov.net/projects/17-manuals/nuttx/18-install-and-configure-nuttx-arm-build-environment-in-linux
https://cristovaorufino.wordpress.com/2014/01/14/compiling-nuttx-for-stm32f4discovery/
http://www.nuttx.org/
http://www.zilogic.com/blog/building-nuttx.html

No comments :

Post a Comment