Project Sim Slinky

This tutorial shows you how to create, build and run the Slinky application and communicate with newtmgr for a simulated device. This is supported on Mac OS and Linux platforms.


Meet the prerequisites listed in Project Slinky

Creating a new project

Instructions for creating a project are located in the Basic Setup section of the Mynewt Documentation

We will list only the steps here for brevity. We will name the project slinky.

$ newt new slinky
Downloading project skeleton from apache/mynewt-blinky...
Installing skeleton in slinky...
Project slinky successfully created.
$ cd slinky
$ newt upgrade
Downloading repository mynewt-core (commit: master) ...
apache-mynewt-core successfully upgraded to version 1.7.0
mcuboot successfully upgraded to version 1.3.1

Setting up your target build

Create a target for slinky using the native bsp. We will list only the steps and suppress the tool output here for brevity.

$ newt target create sim_slinky
$ newt target set sim_slinky bsp=@apache-mynewt-core/hw/bsp/native
$ newt target set sim_slinky build_profile=debug
$ newt target set sim_slinky app=@apache-mynewt-core/apps/slinky

Building Your target

To build your target, use newt build. When complete, an executable file is created.

$ newt build sim_slinky
Building target targets/sim_slinky
Compiling repos/mcuboot/boot/bootutil/src/caps.c
Compiling repos/mcuboot/boot/bootutil/src/encrypted.c
Compiling repos/mcuboot/boot/bootutil/src/bootutil_misc.c
Compiling repos/apache-mynewt-core/apps/slinky/src/main.c
Compiling repos/mcuboot/boot/bootutil/src/image_ec.c
Compiling repos/mcuboot/boot/bootutil/src/image_ec256.c
Compiling repos/mcuboot/boot/bootutil/src/image_ed25519.c
Compiling repos/mcuboot/boot/bootutil/src/image_rsa.c
Compiling repos/apache-mynewt-core/boot/split/src/split_config.c
Compiling repos/mcuboot/boot/bootutil/src/loader.c


Archiving @apache-mynewt-core_util_rwlock.a
Archiving @apache-mynewt-core_util_streamer.a
Linking ~/dev/slinky/bin/targets/sim_slinky/app/@apache-mynewt-core/apps/slinky/slinky.elf
Target successfully built: targets/sim_slinky

Run the target

Run the executable you have build for the simulated environment. The serial port name on which the simulated target is connected is shown in the output when mynewt slinky starts.

$ ~/dev/slinky/bin/targets/sim_slinky/app/apps/slinky/slinky.elf
uart0 at /dev/ttys005

In this example, the slinky app opened up a com port /dev/ttys005 for communications with newtmgr.

NOTE: This application will block. You will need to open a new console (or execute this in another console) to continue the tutorial.*

Setting up a connection profile

You will now set up a connection profile using newtmgr for the serial port connection and start communicating with the simulated remote device.

$ newtmgr conn add sim1 type=serial connstring=/dev/ttys005
Connection profile sim1 successfully added
$ newtmgr conn show
Connection profiles:
  sim1: type=serial, connstring='/dev/ttys005'

Executing newtmgr commands with the target

You can now use connection profile sim1 to talk to the running sim_slinky. As an example, we will query the running mynewt OS for the usage of its memory pools.

$ newtmgr -c sim1 mpstat
Return Code = 0
                        name blksz  cnt free  min
                      msys_1   292   12   10   10

As a test command, you can send an arbitrary string to the target and it will echo that string back in a response to newtmgr.

$ newtmgr -c sim1 echo "Hello Mynewt"
Hello Mynewt

In addition to these, you can also examine running tasks, statistics, logs, image status (not on sim), and configuration.