Bringing MicroPython on NuttX
MicroPython is a lean and fast implementation of the Python3 programming language that is optimized to run on a microcontroller. In this article will show, the steps to compile MicroPython as a built-in app for NuttShell on NuttX over ZKit-ARM-1769.
The article Building NuttX for ZKit-ARM-1769 shows how to set up the environment for building NuttX. The same environment is required for bringing up MicroPython on NuttShell.
Download the following files from the NuttX SourceForge Download page and follow the steps from the above article.
nuttx-7.12.tar.gz- contains NuttX RTOS
apps-7.12.tar.gz- contains sample applications
The toolchain needs to be setup in the host system that builds the NuttX along with MicroPython. The toolchain used is available here.
The above toolchain requires the 32-bit libraries to be installed.
# dpkg --add-architecture i386
# apt-get update
# apt-get install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386
$ tar -xf arm-2014.05-28-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
The above command will create a directory
directory has to be added to the
$ export PATH=<path/to/>arm-2014.05/bin:$PATH
Configuring NuttShell on NuttX
configs/zkit-arm-1769 corresponds to our target
board. Pre-canned NuttX configurations to run applications are
available under the sub-folders here. The configuration for NuttShell
is available under
NuttX can be built for a specific test application by selecting one of
the above pre-canned configurations. A script called
available for this purpose, under
nuttx/tools. The script has to be
invoked with the board name and test application name as argument, as
# Make sure you are in nuttx-dev/nuttx
$ pushd tools
$ ./configure.sh zkit-arm-1769/nsh
MicroPython as Built-in application
MicroPython is available as an interpreter in NuttX. The location is
Before invoking make, we will have to configure MicroPython as
built-in application. The following configuration variables are to be
verified or added in the
The steps to build are the same. Invoke make and use CodeSourcery
toolchain, by setting
and disable the Buildroot toolchain, by setting
$ make CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL=y CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=n
Finally, we get nuttx.hex, that can be flashed on to the board. The
board prompts into
help on this prompt will show
python as built-in app as shown below.
NuttShell (NSH) NuttX-7.12
help usage: help [-v] [<cmd>]
[ echo ifdown mkrd pwd umount
? exec ifup mh rm unset
break exit kill mount rmdir usleep
cat false losetup mv set wget
cd free ls mw sh xd
cp get mb nslookup sleep
cmp help mkdir ping test
dd hexdump mkfatfs ps true
df ifconfig mkfifo put uname
Micro Python on 2015-12-25
Type "help()" for more information.