The newt
tool is the build software used to build Mynewt OS images or executables for any embedded hardware device/board, including the one for the current tutorial (STM32-E407 development board from Olimex). You can run the newt
tool natively on a computer running any of the three Operating System machines - OSX, Linux, or Windows.
However, Mynewt OS images for a simulated target are built on the Windows machine by using Linux versions of the build software (newt)in a virtual machine on your Windows box. The Linux VM is set up by installing the Docker Toolbox. Your Windows machine will communicate with the Linux VM via transient ssh connections. You will then download a Docker image (newtvm.exe
)that allows you to run the newt commands in the Linux Docker instance. The Docker image contains:
The sequence of events when using the Docker image is as follows:
newtvm newt
command) is sent to the docker environment via ssh.Download the Docker Toolbox for Windows (version 1.9.0c or later) from https://www.docker.com/docker-toolbox. The Docker toolbox creates a consistently reproducible and self-contained environment in Linux.
Run the Docker Toolbox installer. All the default settings are OK.
You may need to add “C:\Program Files\Git\usr\bin” to your PATH environment variable. To add to the PATH environment variable, right-click on the Start button in the bottom left corner. Choose System -> Advanced system settings -> Environment Variables. Click on the PATH variable under “System variables” and click Edit to check and add it if it is not already there.
newt
directory. It includes the executable newtvm.exe
for the newtvm tool in the newtvm
directory.C:\Users\admin> git clone https://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt newt
The newtvm tool is what allows you to run programs in the Linux docker instance.
## . ## ## ## == ## ## ## ## ## === /"""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\_______/ docker is configured to use the default machine with IP 192.168.99.100 For help getting started, check out the docs at https://docs.docker.com admin@dev1 MINGW64 ~ (master) $
The first time you run this, it may take several minutes to complete. You will need to run the Docker Quickstart Terminal once each time you restart your computer.
C:\Users\admin\newt\newtvm> newtvm newt help
The newtvm tool will take a long time to run the first time you execute it. The delay is due to the fact that the tool must download the mynewt docker instance.
When you want to produce images for actual hardware board on your Windows machine, go through the following setup procedure and then proceed to the blinky project on the Olimex board with this method.
You have to install the following if you do not have them already. The steps below indicate specific folders where each of these programs should be installed. You can choose different locations, but the remainder of this tutorial for a Windows machine assumes the specified folders.
win-builds-i686
win-builds-x86_64
MSYS
gcc for ARM
openocd
zadig
git
go
Download from http://win-builds.org/doku.php/download_and_installation_from_windows. Install at: “C:\win-builds-i686”.
Be sure to click the i686 option (not x86_64). The defaults for all other options are OK. The installer will want to download a bunch of additional packages. They are not all necessary, but it is simplest to just accept the defaults.
Download from http://win-builds.org/doku.php/download_and_installation_from_windows. Install at “C:\win-builds-x86_64”
Run the installer a second time, but this time click the x86_64 option, NOT i686. The defaults for all other options are OK.
Start your download from http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/MSYS-20111123.zip
Unzip to “C:\msys”
Download the Windows installer from https://launchpad.net/gcc-arm-embedded/+download and install at “C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3”.
Download OpenOCD 0.8.0 from http://www.freddiechopin.info/en/download/category/4-openocd. Unzip to “C:\openocd”.
Download it from http://zadig.akeo.ie and install it at “C:\zadig”.
Click on https://git-scm.com/download/win to start the download. Install at “C:\Program Files (x86)\Git”. Specify the “Use Git from the Windows Command Prompt” option. The defaults for all other options are OK.
Download the release for Microsoft Windows from https://golang.org/dl/ and install it “C:\Go”.
The directory structure must be first readied for using Go. Go code must be kept inside a workspace. A workspace is a directory hierarchy with three directories at its root:
src contains Go source files organized into packages (one package per directory),
pkg contains package objects, and
bin contains executable commands.
The GOPATH environment variable specifies the location of your workspace. First create a ‘dev’ directory and then a ‘go’ directory under it. Set the GOPATH environment variable to this directory and then proceed to create the directory for cloning the newt tool repository.
$ cd c:\ $ mkdir dev\go $ cd dev\go
* GOPATH: C:\dev\go * PATH: C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3\bin;%GOPATH%\bin;C:\win-builds-x86_64\bin;C:\win-builds-i686\bin;C:\msys\bin
Steps:
$ go get github.com/tools/godep
$ go get git-wip-us.apache.org/repos/asf/incubator-mynewt-newt.git/newt $ dir bin pkg src $ dir src git-wip-us.apache.org github.com gopkg.in $ dir newt $ cd newt $ dir Godeps README.md coding_style.txt newt.go LICENSE cli design.txt
$ dir $GOPATH\src\git-wip-us.apache.org\repos\asf\incubator-mynewt-newt.git\newt Godeps README.md coding_style.txt newt.go LICENSE cli design.txt
go install
which compiles and writes the resulting executable to an output file named newt
. It installs the results along with its dependencies in $GOPATH/bin.$ go install $ ls "$GOPATH"/bin/ godep incubator-mynewt-newt.git newt
Try running newt using the compiled binary. For example, check for the version number by typing ‘newt version’. See all the possible commands available to a user of newt by typing ‘newt -h’.
Note: If you are going to be be modifying the newt tool itself often and wish to compile the program every time you call it, you may want to define the newt environment variable that allows you to execute the command via %newt%
. Use set newt=go run %GOPATH%\src\github.com\mynewt\newt\newt.go
or set it from the GUI. Here, you use go run
which runs the compiled binary directly without producing an executable.
$ newt version Newt version: 1.0 $ newt -h Newt allows you to create your own embedded project based on the Mynewt operating system. Newt provides both build and package management in a single tool, which allows you to compose an embedded workspace, and set of projects, and then build the necessary artifacts from those projects. For more information on the Mynewt operating system, please visit https://www.github.com/mynewt/documentation. Please use the newt help command, and specify the name of the command you want help for, for help on how to use a specific command Usage: newt [flags] newt [command] Examples: newt newt help [<command-name>] For help on <command-name>. If not specified, print this message. Available Commands: version Display the Newt version number. target Set and view target information egg Commands to list and inspect eggs on a nest nest Commands to manage nests & clutches (remote egg repositories) help Help about any command Flags: -h, --help=false: help for newt -l, --loglevel="WARN": Log level, defaults to WARN. -q, --quiet=false: Be quiet; only display error output. -s, --silent=false: Be silent; don't output anything. -v, --verbose=false: Enable verbose output when executing commands. Use "newt help [command]" for more information about a command.