Overview

But a genius doesn’t work on an assembly line basis. Did Einstein, Kazanga, or…​ or Sitar of Vulcan produce new and revolutionary theories on a regular schedule? You can’t simply say, "Today I will be brilliant".

— Captain James T. Kirk
Star Trek 2:24 - The Ultimate Computer
The tutorials are Work In Progress…​

Bootstrapping a Core distribution

Overview

In this tutorial we will learn how to bootstrap a Core distribution.

Step I: Install Core

Example 1. Install Core
$ mkdir ~/core-sdk (1)
$ cd ~/core-sdk
$ wget -qO- http://get-core.novalabs.io/ | sh (2)
1 ~/core-sdk will be the Core distribution installation folder
2 here the magic happens
The installation script will ask you to give him either the root or sudo password. Do not worry: it is just to install the prerequisites (here there are the details).

Step II: setup the Core environment

To setup the Core environment some environment variables needs to be configured in order to let the build system find tools and sources.

Example 2. Setup the core Environment
$ cd ~/core-sdk
$ source core/setup.sh (1)
1 sets the needed environmental variables
Environmental variables must be set in each terminal, to avoid sourcing setup.sh in every new terminal you can add a line to your ~/.bashrc file: echo source ~/core-sdk/core/setup.sh >> ~/.bashrc

Working with the workspace

Overview

In this tutorial we will learn how to use the CLI tools to manage a workspace.

Step I: initialization

A workspace is nothing but a structured directory with a JSON file inside (here there are the details).

To create the structure and the JSON file the CoreWorkspace.py initialize command is provided.

Example 3. Creating an empty workspace
$ mkdir my_workspace
$ cd my_workspace
$ CoreWorkspace.py initialize

The expected output is:

Workspace initialized.
You can now do a 'source setup.sh'

SUCCESS

The workspace now contains the following folders:

.
├── build
│   ├── debug
│   ├── params
│   └── release
├── generated
│   ├── modules
│   ├── packages
│   └── params
├── setup.sh
├── src
│   ├── modules
│   ├── packages
│   ├── params
│   └── targets
└── WORKSPACE.json

A setup.sh file is also generated. This files sets the environments variable needed by the workspace. It includes the Core setup.sh file, so you just need to source it.

use the --force option to re-create the JSON and setup.sh files, without touching the contents of the workspace. It is useful, for example, if you move either the Core distribution or the workspace.

Step II: add a target

An empty workspace is pretty useless, so the first thing to do is to add a target to it (here there are the details).

To add a target to the workspace the CoreWorkspace.py target add command is provided. The first parameter specifies the target type (i.e., the Core module to which the code will be deployed), while the second parameter specifies the name of the target instance in your workspace (i.e., motor_test)

Example 4. Adding a target
$ source setup.sh
$ CoreWorkspace.py target add udc motor_test

The expected output is:

Using Core module 'udc'

SUCCESS

The workspace content now is:

.
├── build
│   ├── debug
│   ├── params
│   └── release
├── generated
│   ├── modules
│   ├── packages
│   └── params
├── setup.sh
├── src
│   ├── modules
│   ├── packages
│   ├── params
│   │   └── motor_test
│   │       └── default.json
│   └── targets
│       └── motor_test
│           ├── main.cpp
│           ├── MODULE_TARGET.json
│           ├── PARAMETERS.default.json
│           └── PARAMETERS.json
└── WORKSPACE.json

Step III: inspecting the workspace

Now we have something in the workspace. But what do we have exactly?

To inspect the content of a workspace the CoreWorkspace.py ls command is provided. It lists the content of the workspace, and all the dependencies needed to build it.

Example 5. Inspecting the workspace
$ CoreWorkspace.py ls

The expected output is:

= WORKSPACE

== PARAMETERS

Type: motor_test
Name: uDC module template configuration
Description: src/targets/motor_test

== PACKAGE DEPENDENCIES

Package: MC33926_driver
Source: Core
Notes:

Package: QEI_driver
Source: Core
Notes:

...

== MODULE DEPENDENCIES

Module: udc
Source: Core
Notes:

== MODULE TARGETS

Type: application
Name: motor_test
Description: motor_test
Module: udc
OS Version: CHIBIOS_16
Root: src/targets/motor_test
Status: OK

== PARAMETER TARGETS

Name: default
Description: Default configuration
Parameters: motor_test
Root: src/params
Status: OK

SUCCESS

Step IV: generate

Now that we have a workspace and a target, it is time to generate the corresponding files: the code, CMake files, Documentation, Eclipse project.

To generate the code CoreWorkspace.py generate command is provided. All the generated files will be inside the generated directory.

Example 6. Generate
$ CoreWorkspace.py generate

The command output shows details about allgenerated code.

Step V: build

Now that we have the generated source code, we can build the targets.

To build a target, you must call make from its build directory.

Example 7. Building a target
$ cd build/debug/motor_test
$ make

The output will show the compile process, and a successfull build will finish with:

[100%] Linking CXX executable firmware
[100%] Built target firmware

Setting up the Eclipse IDE

Overview

In this tutorial we will learn how to install and configure Eclipse to program and debug Core targets.

Step I: installation

Download the latest "Eclipse IDE for C/C++ Developers" release from the Eclipse website.

Layout

Extract the archive content in a folder of your choice, for example ~/core-sdk/eclipse.