NuttX on a Netduino Plus 2; build/dev machine setup

as per usual for me these days, I create self-contained build/dev environments in VMWare images.  This is a habit I got into years ago from some OpenWRT work, and its wonderful to be able to archive, transport, and snapshot a purpose-specific computer in a hardware-independent way.  Anyway, for me the first step in a project is setting up that build machine.

Also, I typically use Ubuntu for my Linuxian things.  So I created a new machine, and installed Ubuntu 12.10 64-bit, thinking it is modern, and stable.  OK, I guess I’m not up with the times, but they have changed to a faux OSX window manager, called ‘Unity’ I think.  It’s obscenely slow for some reason, and anyway all my cheese has been moved.  So after wasting some time figuring that out:

sudo apt-get install gnome-session-fallback
sudo apt-get install synaptic

and the world is sane again.  I also need to have vmware tools and basic connectivity, so

sudo apt-get install build-essential linux-headers-$(uname -r)
(for building vmware tools)
sudo apt-get install aptitude
sudo apt-get install openssh-server

Now, chain chain chain.  Chain of tools.  I decided to use CodeSourcery since it is tested.  Upon looking back, I might have used something different, but this is what I did.  It’s free; you have to register your email with Mentor, though, to get the super secret link to the free download.

You need to fiddle with stuff to make it install, though:

sudo dpkg-reconfigure -plow dash
Install as /bin/sh? No
sudo apt-get install ia32-libs

then you can install:

/bin/sh ./arm-2013.05-23-arm-none-eabi.bin
(click through with the defaults)

Now your build environment should be setup, and you can get the source.  I usually shut my machine down and snapshot here as ‘clean machine’.  I usually try stuff out, adding missing components I discover along the way, revert, and update the ‘clean machine’ snapshot until it is complete.  But I’m pretty sure what I described above is complete for your build system.

I started using the current NuttX source, 6.27.  It took me a while (quite a while!) to figure out what I really needed to do, but here is a summary:

  • get stuff form sourceforge
  • get ‘nuttx’ the os, and ‘apps’ the auxilliary, but required, application source code
  • also get the kconfig-frontend, which is how you are going to setup your source.  This was somewhere else on sourceforge, the package I got at the time of this writing was named kconfig-frontends-3.3.0-0.tar.bz2, so you should be able to search and find.
  • create a directory structure in your home laid out this way:
  • untar all the stuff (the three files) where I showed them
  • rename the resulting ‘apps-6.27’ dir to ‘apps’ and the ‘nuttx-6.27’ dir to ‘nuttx’

First, build and install the kconfig-frontend, so you can do configuration of your source:

sudo apt-get install gperf libncurses5-dev
cd nuttx-dev/misc/kconfig-frontends-3.3.0-0
./configure –enable-mconf –disable-nconf –disable-gconf –disable-qconf –program-prefix=kconfig-
sudo install
sudo ldconfig
cd ../..

(that little sudo ldconfig step is vital.  took me a while to figure it out.)

OK, now your source tree is setup.  I like to do a trial build of something as a sanity check.  Never mind if its not for my board, but just to prove I’ve got all the stuff in the right places.  I chose to build the stm32f4discovery as my proving point since I planned on using that as the basis for my project.

cd nuttx-dev/nuttx/tools
./ stm32f4discovery/nsh
cd ..
. ./

OK, the next steps are to configure the source, and then do the build.  The source as-configured out-of-box will not work, you need to make some mods. First, we will just modify the toolchain.  Out-of-box it comes for Windows, and the Windows Code Sourcery.

so ‘make menuconfig’, and go to ‘build setup, build host platform’ and change to ‘Linux’.  Then go back up the tree to ‘system type’ and down to ‘toolchain selection’ and pick ‘CodeSourcery’.  Use Exit until you get out and save the change.

NOW you can do ‘make’.  It should all finish up eventually, with the last output being CP of the nuttx.hex and nuttx.bin.  These are your firmware.  In particular you will need the nuttx.hex so you can burn it onto your board.  The nuttx.bin is presumably elf, and I suspect it can be used with gdb for debugging, but I haven’t done that.

Anyway, regardless, this was just a trial build — you can’t actually put this on the Netduino Plus 2 board.  So clean it all up squeaky-clean this way:

make distclean

The regular ‘make clean’ will remove all the build artifacts, but leave the system configured for your board.  the ‘make distclean’ will blitz the board configuration also, and take you to as you were when you untarred your source.

Next, as my next sanity check, I want to try to build something I can deploy to a board without actually modifying any source.  I have a small ocean of dev boards (well a pond at least, perhaps), so maybe I can do that to one of them….


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s