Month: July 2015

Cloning NuttX repositories

The NuttX RTOS is moving from SourceForge to BitBucket, during this move Greg Nutt created some separated repositories for NuttX kernel, applications and other submodules.

You can see the steps to clone NuttX repositories in the README page:

Basically all you need to do is this:

$ mkdir nuttx
$ cd nuttx
$ git clone nuttx
$ git clone apps
$ cd nuttx
$ git submodule init
$ git submodule update

Now you can compile your “board” and your “config”:

$ cd tools
$ ./ "<board/config>"

Replace "<board/config>", example:
  $ ./ stm32f4discovery/usbnsh

$ cd ..
$ make oldconfig
$ make menuconfig
$ make

To keep your local repository updated execute:

$ git submodule foreach git pull

That’s all!!!

NuttX board initialization: Where can I put my code to be executed?

Essentially there are 3 levels of board initialization:

1. stm32_board_initialize()
Called immediately on boot up to set what resources are needed to boot this system. This includes a little bit of low level driver initialization if needed by up_initialize().

The OS is not yet initialized the nothing in stm32_board_initialize() can use ANY OS service. Nothing.

2. board_initialize() – (optional)
Called just before the application is started.

Here the OS is fully initialized, but you have to be careful because it is still running on the IDLE thread. That means that there are many things that you cannot do: You cannot wait for anything. You can’t use semaphores for example.

(There is CONFIG_BOARD_INITTHREAD that can be used to run board_intialize() on a separate thread if necessary).

board_initialize() is really only needed by code built with CONFIG_BUILD_KERNEL or CONFIG_BUILD_PROTECTED.

3. board_apps_initialize() via boardctrl()
Called after the application has started. This runs on the thread of the applications so it is always the best when available.

Note: This explanation is from an email from Greg Nutt, I decided to post it here to help other people to decide where to put their code.

More info: