1.1. Getting Started

1.1.1. Prerequisites

Need a running version of Ubuntu 16.04 LTS or above, or Mac OS X (OS X Yosemite and above), or Windows 10 with WSL installed.

You must also have the following pre-installed:

  • Python 2.7+
    • Default installed on WSL, Ubuntu 16.04 and Mac OS X
  • Git
    • Default installed on Mac OS X
    • To install on WSL & Ubuntu 16.04 run sudo apt install git-all
  • make
    • Default installed on WSL, Ubuntu 16.04
    • On Mac OSX this is installed after you run xcode-select --install

If you are running Mac OS X you will need to install the xcode command line tools prior to running the setup. xcode-select --install. After the xcode tools are finished installing, follow the instructions below.

1.1.2. Prerequisites For Windows

Note: this is for Windows build 16215 or later

  1. Open PowerShell as Administrator and run

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

  2. Restart computer when prompted.

  3. Open Windows Store and choose Ubuntu as Linux distro

  4. Select “Get”

  5. After download completes select “Launch”

    1. Create UNIX user account
    2. If you get any errors go here: https://docs.microsoft.com/en-us/windows/wsl/install-win10

After this point, you should be able to run bash from the start menu.

1.1.3. Installation

Step 0

Clone the repository

git clone https://github.com/kammce/SJSU-Dev.git
Step 1

Change directory into SJSU-Dev

cd SJSU-Dev
Step 2

Run setup script.

./setup

Note

This will download and install the gcc-arm binaries, hyperload, telemetry locally to the repo. It will also generate the environment variables file and link the makefile and environment file to all of the default folders.

Step 3

Edit the env.sh script. Change the line SJDEV=/dev/ttyUSB0 to equal what you have on your system.

How to find your serial device on Ubuntu

You probably do not have to change anything.

If no other devices are connected to your machine, then it will be /dev/ttyUSB0. It is recommended to keep it at this value, because when you add more devices, it will increment to /dev/ttyUSB1. Once you remove your devices and replace them, the value will reset.

How to find your serial device on Mac OS X

  1. Remove the SJ-One from your computer if it is connected.
  2. List the files in the /dev folder by running the following ls /dev/.
  3. Plug it into your computer and run ls /dev/.
  4. Observe the new file that was created.
  5. On mac, the path should look something like the following /dev/tty.cumodemfd1337.
  6. If so, change the line in env.sh to that file path from SJDEV=/dev/ttyUSB0 -> SJDEV=/dev/tty.

How to find your serial device on Windows Linux Subsystem

On Windows it should be /dev/ttyS3. Check your device manager to see what number COM device your device. The number after COM is the number after the S in the /dev/ttyS string. That is your device. Replace the line SJDEV=/dev/ttyUSB0 -> SJDEV=/dev/ttyS

1.1.4. Building and Loading Hello World Application

Step 0

From the root of the repository

cd firmware/Starter
Step 1

Source the env.sh. You only need to do this once for each terminal session. After sourcing, the necessary environment variables will be added to your shell.

source env.sh
Step 2

Run make build within the Starter folder to compile it into a HEX file located in the bin folder.

make build

Note

use the --help argument to get additional information on how to use the build script.

Step 3

To load the hex file into your SJ-One, run the following make command:

make flash

Note

If you run this command without first building, this command will build your project and then flash it. So you can skip the step above if you like.

Note

If the device port of your SJOne did not appear as the device set in your env.sh file, then run make flash SJDEV=<PATH-TO-YOUR-PORT> and that will change your port path for that instant.

Step 4

To view serial output, and interact with the board, run the following make command:

make telemetry

Note

The interface will pop up in your default browser on launch. If this does not occur you will need to enter the http://localhost:5001 web address into your browser’s address bar and load it.

Step 5
Done!!

1.1.5. Building and Loading FreeRTOS Project

Instructions are the same as Starter, but you need to enter the firmware/FreeRTOS folder and run make from there.

1.1.6. Creating your own Project

Copy and rename the FreeRTOS, Starter or any of the other template folders to any place in your computer to make a new project.