Giter VIP home page Giter VIP logo

spark-template's Introduction

Spark Project Template

Spark projects depend on the core-common, core-communication-lib and the core-firmware projects.

This project contains these projects as git submodules to allow one to setup a development environment a bit quicker.

Because this project is set-up using git submodules, the advantage of locking the active revision of each submodule is now yours.

We use this approach to ensure that every one of our developers' environments have the right dependencies and versions just to keep us all on the same page.

When we decide to use newer revisions of submodules, we can update these submodules and push these changes to allow our developers to get up to speed by simply updating their clone. The nice thing is that we will not run into merge conflicts since we do not (or hardly) touch the codebases written by the Spark team.

Setup

The assumption is made that your environment has been setup correctly. In case of doubt or problems consult the Spark README for the instructions on setting up the development environment.

After cloning, initialize the submodules using

git submodule init

And possibly update your submodules to reflect the changes required by the project by running

git submodule update

You could also combine both steps by just running git submodule update --init ๐Ÿ˜‰.

Once all Spark submodules are updated, an application will need to be added. For the sake of exploration you could

  • try our demo application, otherwise you
  • follow our instructions for creating a new application within the template repository or
  • add a new application as another git submodule.

Built-in Demo

For the sake of demonstration, a demo application named serial has been provided in the demo/multiple-apps branch.

By checking out the demo/multiple-apps branch an applications directory is created which contains the serial app.

git checkout demo/multiple-apps

Because your application is named serial the DEFAULT_APP variable set in settings.mk has to be set accordingly. Furthermore the application's name also needs to be added to the APPLICATIONS variable. After performing the checkout these changes will be checkout out as well.

New Application within Current Repository

If you want to set up a new application within the current repository you could simply create an applications directory in the project's root. Within the applications directory you add a app directory which contains an arbitrary name as long as it simply contains alphanumeric characters and underscores.

Creating a geiger_counter application would result to the following directory structure

spark-template
โ”œโ”€โ”€ core-common-lib
โ”œโ”€โ”€ core-communications-lib
โ”œโ”€โ”€ core-firmware/applications
โ””โ”€โ”€ applications
    โ””โ”€โ”€ geiger_counter
        โ””โ”€โ”€ application.cpp

You are at liberty to create as much application as you please within the applications directory. Just make sure that you set the DEFAULT_APP and the APPLICATIONS variables in settings.mk accordingly.

Usage

We have a simple makefile ready for you to get started ASAP, so I would recommend you take a peek. For those who don't want to read through the makefile there is no other alternatives other than reading the rest of of this document.

Compile

Build your application named tinker.

make compile APP=tinker

Build the DEFAULT_APP as specified in the settings.mk file

make compile

Please note that the compile task creates the symlinks, attempts the compilation and removes the symlinks prior to calling it quits.

Clean-up

Remove all project symlinks and clean up the build directories

make clean

Information

View which application is the to be compiled with the given CLI variables and settings

make which

View which applications are currently available for compilation, upload or something else given the current system variables and project settings

make apps

Upload the your application to a Spark core through USB

make upload

Compilation

Compile by running

make compile

or simply

make

which will take the liberty of cleaning your build directory as well.

Multiple applications may be contained within the applications directory. You may select the application to compile by appending APP=APPLICATION_NAME to the make command, replacing APPLICATION_NAME for the application you really want to compile.

Unless APP is specified, the makefiles will regard the DEFAULT_APP specified in the settings.mk file as the application to be built, effectively changing make to make APP=WHATEVER_THE_DEFAULT_APP_IS.

With the BUILD_PATH buildfiles are stored in a directory of your choosing. We would recommend you use the default directory which is simply the build directory inside this project's root.

Structure

In order to allow development without increased risk of merge conflicts as the Spark team keeps polishing the codebases, some effort has been invested in keeping all project-specific code out of the Spark repositories.

Instead of integrating all source code within the core-firmware project one may now use the core-firmware/applications directory to store user files. The chances of source files running into merge conflicts with new Spark updates are smaller when using the core-firmware/applications directory because the Spark team and you will no longer be touching the same files in the pursuit of building something that works ๐Ÿ”ง.

Instead of working inside core-firmware/applications we decided to take it one step further, by trying not to touch the core-firmware project at all in our development efforts.

Inside the root directory one may specify an APPLICATIONS_PATH. This is where your user applications, as Spark calls them, are stored.

Within the APPLICATIONS_PATH one may have several applications stored in appropriately named subdirectories. Spark has documented the use of User applications in their README on Building a User Application.

A simple example of the new project structure is presented below. This time you only ever touch the applications and build subdirectories. The rest is Spark's territory.

your_project
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ applications
โ”‚   โ”œโ”€โ”€ tinker
โ”‚   โ”‚   โ””โ”€โ”€ application.cpp
โ”‚   โ””โ”€โ”€ serial
โ”‚       โ”œโ”€โ”€ printsomething.cpp
โ”‚       โ”œโ”€โ”€ helpers.cpp
โ”‚       โ””โ”€โ”€ header.h
โ”œโ”€โ”€ build
โ”‚   โ”œโ”€โ”€ serial.bin
โ”‚   โ”œโ”€โ”€ serial.elf
โ”‚   โ”œโ”€โ”€ serial.hex
โ”‚   โ”œโ”€โ”€ serial.map
โ”‚   โ”œโ”€โ”€ tinker.bin
โ”‚   โ”œโ”€โ”€ tinker.elf
โ”‚   โ”œโ”€โ”€ tinker.hex
โ”‚   โ””โ”€โ”€ tinker.map
โ”œโ”€โ”€ core-common-lib
โ”œโ”€โ”€ core-communications-lib
โ”œโ”€โ”€ core-firmware/applications
โ””โ”€โ”€ settings.mk

spark-template's People

Contributors

vidbina avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.