Getting Started with NuttX -- LM3S6965-EK (Ubuntu Linux)

This guide is based on NuttX revision 5544 date 20130121, and using an Ubuntu 12.04 (64-bits) development machine. It is not an exhaustive guide, but should be useful for those starting with NuttX on the LM3S6965-EK.

Note that NuttX has a thorough documentation through this website, this wiki, and the README files in the source code. This Guide was strongly based on documentation available at:

Building NuttX

1. The first step is to obtain the code from the Downloads page. When this guide was written, the code was obtained as follows:

svn checkout svn://svn.code.sf.net/p/nuttx/code/trunk nuttx-code
cd nuttx-code/nuttx
TOPDIR=`pwd`

2. Configure NuttX for the LM3S6963-EK

We're going to configure NuttX to use the nsh shell.

cd $TOPDIR/tools
./configure.sh lm3s6965-ek/nsh

3. Install the kconfig-frontends package

# Install kconfig-frontends dependencies (the upcoming configure may catch more dependencies)
sudo apt-get install gperf libncurses5-dev
git clone https://patacongo@bitbucket.org/nuttx/tools.git tools
cd tools/kconfig-frontends/
./configure --enable-mconf --disable-gconf --disable-qconf
make
sudo make install

4. Install the buildroot toolchain

# Install buildroot dependencies (the upcoming configure may catch more dependencies)
sudo apt-get install libgmp-dev libgmp3-dev libmpfr-dev libmpc-dev

The GMP version from the previous packages might not be enough for gcc-4.6.3, it's better to obtain the latest from http://gmplib.org/. In my case, this was enough:

mkdir --parents $HOME/temp
cd $HOME/temp
wget ftp://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.gz
tar xzvf gmp-4.3.2.tar.gz 
cd gmp-4.3.2/
./configure
make
sudo make install
# optional cleanup: rm -rf $HOME/temp/gmp-4.3.2*

Then you're ready to install buildroot.

git clone https://patacongo@bitbucket.org/nuttx/buildroot.git buildroot
cd buildroot
cp configs/cortexm3-eabi-defconfig-4.6.3 .config
make menuconfig # and just exit
make

5. Configure NuttX to use buildroot

cd $TOPDIR

# Be sure you have: 
#   Build Setup
#     `--> Build Host Platform (Linux)
#   System Type
#     `--> Toolchain Selection (Buildroot (Cygwin or Linux))
#     `--> [ ] OABI (vs EABI)  # De-select
make menuconfig

# Set the environment
. ./setenv.sh

6. Build

make

After you build, you'll have generated a nuttx.bin file.

Installing NuttX

The installation is based on the openocd tool.

1. Connect your LM3S6965-EK to your development PC.

Connect your board to your computer, using both the USB cable and the Ethernet cable.

2. Start the openocd daemon

Install openocd.

sudo apt-get install openocd

There's a helper script and a configuration file available at nuttx/configs/lm3s6965-ek/tools. The configuration file ek-lm3s6965.cfg is based on the already existing files provided by openocd:

  • /usr/share/openocd/scripts/interface/luminary.cfg
  • /usr/share/openocd/scripts/board/ek-lm3s6965.cfg
  • /usr/share/openocd/scripts/target/stellaris.cfg

To start the openocd daemon:

cd $TOPDIR
configs/lm3s6965-ek/tools/oocd.sh $PWD

3. Connecting GDB

For this step you need GDB, it's no particularly important which one you use, whether arm-nuttx-elf-gdb or one provided by a CodeSourcery toolchain like arm-none-eabi-gdb.

cd $TOPDIR
arm-none-eabi-gdb
(gdb) target remote localhost:3333
(gdb) symbol-file nuttx
(gdb) monitor reset
(gdb) monitor halt
(gdb) load nuttx

4. Using nsh

Now you can connect to your board using a tool like termnet and termnetd. This is my configuration for the USB port in /etc/termnetd.conf

3001:on:/dev/ttyUSB0:B115200   CLOCAL IGNBRK CS8 CREAD;

When you're done configuring termnetd, you can restart the termnetd service to load the new configurations:

sudo service termnetd restart

Then:

termnetd localhost 3001

You can then reboot your board and watch it boot until you get your nsh line:

nsh> ls

See Also

References