Reading: ...
In this lab, you will set up a Contiki development environment. You will also build and run a sample program. This lab has no submission. It is only an opportunity to see something new.
You will not need your BeaglePlay for this lab.
In this part, you will install Docker Desktop which allows you to get and manipulate Docker images.
Proceed as follows.
If you are using Windows, you will first need to install and activate Windows Subsystem for Linux, version 2 (WSL2). Open a command prompt as the administrative user (right-click on the console icon and select "Run as Administrator"). Execute the following commands.
> wsl --install > wsl --set-default-version 2 > wsl --install -d Ubuntu
The last command installs the default Ubuntu system on top of WSL2. This includes a Ubuntu kernel and related files and utilities. If you want to use a specific Linux distribution, you can get a list of all Linux distributions available with the wsl --list --online command.
If you are using macOS, you do not need to do anything special here. You can proceed directly to installing docker.
Go to the Docker Desktop page and download the installer for your platform. You don't need to create an account on the Docker site, but you can create a (free) account if you want.
You can configure Docker Desktop to start whenever you start your computer, but you might not want that. If you click on the settings (gear icon at the top of the window) and look on the 'General' tab, you will find a checkbox that controls that behavior.
Open a command prompt and run the command docker pull contiker/contiki-ng to get the Contiki development image. The decompressed image is about 4 GB in size, so ensure you have sufficient disk space. Once the pull is completed, the image should appear in the "Images" tab of Docker Desktop.
Proceed as follows.
Start by installing GitHub Desktop. It may ask you to log in with your GitHub account, but since Contiki is a public repository, it should be possible to get a copy without creating an account on GitHub. However, creating a GitHub account isn't a bad idea; you will eventually want one.
Use GitHub Desktop to clone the Contiki-NG repository to your system. Use the clone URL of https://github.com/contiki-ng/contiki-ng.git. The precise location where you put the repository isn't critical, but take note of the location for later. I recommend avoiding paths that contain spaces. The repository and all of its submodules will use another gigabyte of disk space.
Detailed instructions for Windows are on this page, but instructions for other platforms are on the same site. The Windows instructions talk about installing an X server for Windows. That would allow you to use the graphical tools in the Contiki image, but it is not strictly necessary.
Proceed as follows.
Create a batch file named contiker.bat containing the following command. Replace the source path with the location of the Contiki GitHub clone on your system. Do not edit the destination path.
@echo off docker run --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 ^ --mount type=bind,source=/c/Projects/GitHub/contiki-ng,destination=/home/user/contiki-ng ^ -e DISPLAY="host.docker.internal:0.0" ^ -e LOCAL_UID=1000 ^ -e LOCAL_GID=1000 ^ -ti contiker/contiki-ng
Start a fresh container based on the Contiki image by running the batch file.
Go into the examples/hello-world folder and run the make command to build the sample program. Note that this entails building the parts of Contiki the application requires. Although simple, this application does compile the networking components.
Run the application to observe its effects. Since it is an infinite loop, you must use ^C to terminate the application.
Use exit to log out of the container.
Whenever you use the contiker batch file, you will create a new container based off the Contiki image. The containers are independent, although they will share the Contiki source code tree that you cloned from GitHub. The containers are lightweight. They consume minimal amounts of disk space (only the differences between the original image and whatever changes you made in the container).
If you want to reuse one of your existing containers, you must attach to it instead of creating an entirely new container.
docker start container-name docker attach container-name
Replace container-name with the name of the container as shown in Docker Desktop. You can also use the command docker ps -a to list all of your containers (and not just the running ones as docker ps would do). The listing shows the container name.
There is nothing to submit for this lab. Enjoy your summer!
Last Revised: 2024-04-22
© Copyright 2025 by Peter Chapin <peter.chapin@vermontstate.edu>