Deploying NuttX to the Raspberry Pi PicoW
Currently taking a few weeks break and after a few days away from the computer I decided to do a little bit of research into the PicoW and NuttX. So time for a quick attempt at getting the system up and running.
I have for the last few years been working on the Meadow F7 board for Wilderness Labs. This board aims to provide a full .NET development environment bringing embedded development to a wider audience. There are three main technologies underpinning this board:
I spend much of my time working with NuttX and FreeRTOS so as you can gather, I’m not worried about working with C or C++. This gives a few options for working with the board:
- Native development using the Pico SDK
- NuttX
- FreeRTOS
I decided to start with a look at NuttX as I am currently spending a lot of time working with this RTOS.
Let’s Follow the Guide
First thing to do is head over the the documentation for NuttX on the RP2040. The getting started guide is really good and I thought I would be able to use the copy of the Pico SDK I had already on my machine.
This is where I hit my first problem. NuttX requires a specific version of the Pico SDk and using this version would impact any other Pico development that I would undertake in the future. To overcome this I decided to take a second copy of the Pico SDK specifically for use when developing with NuttX.
Having said we would follow the guide, we are deviating already.
So first up we create a development environment for the PicoW (all instructions are for working on a Mac but should also work on Linux).
mkdir NuttX-PicoW cd NuttX-PicoW git clone -b 1.1.2 https://github.com/raspberrypi/pico-sdk.git export PICO_SDK_PATH=$PWD/pico-sdk
Now we need to clone the NuttX OS and applications repositories:
git clone https://github.com/apache/nuttx.git nuttx git clone https://github.com/apache/nuttx-apps.git apps cd nuttx
Now we have the NuttX components cloned we need to make sure we are on the current releases. This is done using git to checkout the correct branches. At the time of writing the current release is 12.1 so the following commands will checkout the correct branches:
cd apps git checkout releases/12.1 cd ../nuttx git checkout releases/12.1
Now we have the correct branches we need to configure the system to work with the PicoW. There are several different boards and configurations available using the RP2040, not just the pico. The following command will list all of the available board configurations available for the Pico series of boards (not just the PicoW but all of the Pico boards):
./tools/configure.sh -L | grep pico
For NuttX 12.1 this returns the following list:
raspberrypi-pico:lcd1602 raspberrypi-pico:waveshare-lcd-1.3 raspberrypi-pico:usbmsc raspberrypi-pico:nshsram raspberrypi-pico:nsh-flash raspberrypi-pico:nsh raspberrypi-pico:audiopack raspberrypi-pico:composite raspberrypi-pico:st7735 raspberrypi-pico:displaypack raspberrypi-pico:spisd raspberrypi-pico:smp raspberrypi-pico:enc28j60 raspberrypi-pico:ssd1306 raspberrypi-pico:usbnsh raspberrypi-pico:waveshare-lcd-1.14 raspberrypi-PicoW:lcd1602 raspberrypi-PicoW:waveshare-lcd-1.3 raspberrypi-PicoW:usbmsc raspberrypi-PicoW:nshsram raspberrypi-PicoW:nsh-flash raspberrypi-PicoW:nsh raspberrypi-PicoW:audiopack raspberrypi-PicoW:composite raspberrypi-PicoW:st7735 raspberrypi-PicoW:displaypack raspberrypi-PicoW:spisd raspberrypi-PicoW:smp raspberrypi-PicoW:enc28j60 raspberrypi-PicoW:ssd1306 raspberrypi-PicoW:usbnsh raspberrypi-PicoW:waveshare-lcd-1.14 raspberrypi-PicoW:telnet
The configuration that is interesting here (to get started) is the raspberrypi-PicoW:usbnsh configuration. This will redirect the console output from NuttX over USB to the host machine using serial communication. This will allow a simple terminal application to connect to the board without the need for any additional hardware. So let’s configure NuttX and build the system.
First up, clean the system and set the configuration:
make distclean ./tools/configure.sh -l raspberrypi-PicoW:usbnsh
This should clear any previous configurations (distclean) and then set the board type and specific configuration to be built.
Now we should be able to build the system.
make
You can also tell make to use as many cores on your system as possible with the command make -j. After a short time the system will compile the NuttX OS and applications and create a UF2 file that can be uploaded to the PicoW.
The board can be programmed by starting the board in bootloader mode (press and hold the BOOTSEL button while plugging in the USB cable). The Pico should now present itself as a USB drive on the host computer. Drag and drop the nuttx.uf2 file onto the Raspberry Pi Pico drive on the host computer. The file will be copied to the board and the board will restart.
Connecting to NuttX
Time to check that the board has been programmed correctly. Open your favourite terminal application and set your connection settings to 115200,n,8,1 and connect to the serial port presented by the PicoW. The default is something like usbmodem01. Connect to the PicoW and hit enter a couple of times. On doing this you should be presented with something like this:
NuttShell (NSH) NuttX-12.1.0
nsh>
nsh>
If you have got this far then you have successfully built NuttX and deployed the OS to the PicoW. Typying help in the serial console should reveal the list of deployed applications.
Conclusion
At this point we have NuttX running on the PicoW. This opens up some new channels for investigation:
- Using both cores on NuttX
- C++ application development
In the next post we will look at enabling C++ development in NuttX.
Tags: Electronics, Pico, Raspberry Pi
Sunday, June 4th, 2023 at 6:03 am • Electronics, NuttX, Pico, Raspberry Pi • RSS 2.0 feed Both comments and pings are currently closed.
[…] of the UART redirection. The configuration we want is raspberrypi-pico-w:nsh, so following the first post in this series and making the change to the configuration we need to execute the […]