I discovered NuttX RTOS few weeks ago (thanks Marcelo Barros) and I like it very much, then I decided to test it on Olimex LPC2378-STK.
NuttX is a very small foot-print RTOS (starting about 20KB) which follows the POSIX and ANSI API, this means you can port your Linux application to run on this RTOS easily. I know FreeRTOS is even smaller and have a bigger community, but NuttX has advantage for follow the *nix APIs and recreate the Linux devices structure.
The only concern about it is the license, it is BSD. I never contributed for a BSD project (For As Long As I Can Recall). Then I need to get used with this idea.
Let start downloading the NuttX source code:
The current stable version is 5.17, but I prefer always using the repository version, so lets download it:
$ svn co https://nuttx.svn.sourceforge.net/svnroot/nuttx nuttx
Now is time to download the cross-compiler (toolchain). I’m using the CodeSourcery toolchain:
Download and install it:
$ chmod a+x arm-2010.09-51-arm-none-eabi.bin $ ./arm-2010.09-51-arm-none-eabi.bin
I installed it on /opt/cs/sourcelite but feel free to install it any place, just remember to place the corresponding binary directory (i.e.: /opt/cs/sourcelite/bin) in our PATH.
I selected the Minimum installation since I don’t want to use its IDE.
Now we need to modify some files to get NuttX compiled with CS toolchain:
Edit file nuttx/configs/olimex-lpc2378/nsh/defconfig and change the toolchain to CodeSourcery on Linux (Note: currently it is already defined):
CONFIG_OLIMEX_LPC2378_CODESOURCERYW=n CONFIG_OLIMEX_LPC2378_CODESOURCERYL=y CONFIG_OLIMEX_LPC2378_DEVKITARM=n CONFIG_OLIMEX_LPC2378_BUILDROOT=n
Make sure to include the toolchain in the PATH:
$ export PATH=/opt/cs/sourcelite/bin:$PATH
Now configure NuttX to compile the NSH shell using LPC2378 configuration:
$ cd tools $ ./configure.sh olimex-lpc2378/nsh $ make
It will create two files: nuttx and nuttx.bin. The first is the ELF binary and the second is the firmware binary.
We can see more information about the ELF file using the size command:
$ size nuttx BFD: nuttx: warning: sh_link not set for section `.ARM.exidx' text data bss dec hex filename 78228 368 2332 80928 13c20 nuttx
Now we need to flash the firmware (nuttx.bin) inside Olimex-LPC2378-STK. We can use OpenOCD to flash the firmware. I used Amontec JTAGKey for flash programming.
Run OpenOCD, it will open a telnet daemon on port 4444.
Note: nuttx.bin needs to be in the same directory where you ran openocd.
# openocd -f jtagkey.cfg -f lpc2378.cfg
Connect to OpenOCD’s telnet:
$ telnet 127.0.0.1 4444
Execute these commands to erase the flash and write the firmware on it:
> reset run > reset halt > flash erase_sector 0 0 26 > flash write_bank 0 nuttx.bin 0
Connect a serial cable on LPC2378-STK port1 (RS232_0) to your computer and configure minicom to 9600 8n1. You should see the NuttShell (NSH) prompt “nsh>”.