These instructions will help you get started with C programming exercises and later the hardware device both in the workstation classroom and at home. Detailed information about the setup for programming the device will be shown during the mandatory lab exercise sessions.
We expect you have some basic computing skills e.g. using a text editor or utilizing your terminal. Please, have a look to the introductory lecture of Elementary Programming course for further details.
Software recommended for programming¶
For programming C Exercises you can choose among all these options:
- Code::Blocks IDE
- C compiler (gcc) + Preferred text editor. In Windows you can use mingw-w-64. It can be downloaded from here You can also build
Make
files or ask CMake to do create them for you. - Visual Studio Code IDE
- In addition you would need to install a C compiler and the C/C++ extension pack. The Code Runner extension is also recommended to run quickly the code. You can find further information on installing the compiler below.
- Very detailed information on how to setup environment in this tutorial. More information can be found in this tutorial or a more simpler one
- Online tools
- Onlinedgb
- Visual Studio Code online. Use same extensions ans Visual Studio Code IDE.
- Replit. Now requires registration and it is limited to 3 projects.
- Onecompiler Does not have a debugger.
For Programming the SensorTag:
- TI CCS IDE. Setup is a bit tricky. We recommend to use the Virtual Machine.
For Programming the Raspberry Pi Pico
- Visual Studio Code IDE+ extensions (provided later in the laboratory exercise)
Instructions to setup software¶
Following instructions show how to install the required software for the course(s) for either remote use at home or at the university classrooms.
All software required for this course is installed in a VirtualBox virtual machine. You can run this virtual machine either in the computer classroom or in your home computer when you install VirtualBox (see instructions below). With a virtualization environment A virtualization environment, like VirtualBox, allows you to run multiple operating systems simultaneously on a single physical machine by creating virtual machines (VMs). Each VM operates as if it were a separate computer, with its own resources, and software, completely isolated from the host system.
Important: Files saved on the virtual machines in the workstations will be deleted between uses, so remember to back up your code after the exercises.
NOTE FOR FITECH STUDENTS: It is not needed to setup the virtual machine. Any of the previous software would do it.
Virtual machine¶
Fall 2024 you can freely go to the computer classrooms (TS135 and TS137) to work on the course tasks. They have installed the virtual machines.
Course virtual machine¶
In the workstations at the classrooms you can download a virtual machine (VirtualBox) that contain all the required software:
- C compiler (gcc)
- Code::Blocks IDE
- Visual Studio Code + Development extensions for programming Raspberry Pi Pico
- Text editor
- TI CCS IDE for programming the SensorTag device
- y86 assembly compiler
- Git
The virtual machine is based on the "Linux Lite" lightweight distribution, so you will be using Linux in the course. Just so you realize, Linux isn’t that scary after all.
Setting up virtualBox¶
- Download the Virtual Machine. Link can be found from this Lovelace page
- Copy the file: TKJ_24.ova in your own account.
- Open VirtualBox and press import. Choose the
.ova
file. - Check that in Settings > USB you have activated the 3.0 option.
- Run the virtual machine.
Transfer files between systems¶
Files are removed from the virtual machines when you restart the machine. There are several ways you can transmit your code between your virtual machine and your host system or your home computer.
GIT¶
By far this is the most appropiate option.
- Create a Git project in Gitlab, Github or your preferred GIT cloud service. You can also use version.oulu.fi, university hosted gitlab service (only available within university network, ie if you are not physically at university you need to use a VPN).
Traditional¶
Use USB memory stick to copy and move files. You can also use GoogleDrive, OneDrive, Dropbox, or even email. But these methods are not very orthodox for this course.
Dragging Dropping / Copy Paste¶
- You can Drag&Drop files from the Host to the Guest and the Guest to the Host. You need to activate the option in
Devices > Drag and Drop > Bidirectional
. Sometimes this option is not working - You can Copy&Paste text from the Host to the Guest and the Guest to the Host. You need to activate the option in
Devices > Copy and Paste > Bidirectional
. Sometimes this option is not working
Moving from Host (University Workstation) to VM using SCP¶
scp
is a Unix command line interface used to transfer files from one machine to another. You have access to scp through the Git Bash
in your host machine. You would need the user password. Ask any of the course staff for it. - For moving files from Host computer (Windows workstation) to Virtual Machine open the
Git Bash
,cd
to the path of your file and type:
scp -P 2222linuxlite@localhost:/path/to/destination
- For moving files from Virtual Machine to Host computer (Windows workstation) to open the
Git Bash
,cd
to the path of your file and type:
scp -P 2222 linuxlite@localhost:/path/to/destination
You can save your files persistently in the
K:
drive of the University Workstation. This is the home directory of your university computer systems account Setting up envrionment at home and other computers¶
MAC IS NOT SUPPORTTED If you find the way of running the virtualbox image in modern MAC computers, please share the knowledge with rest of students.
Using the VirtualBox and the Provided Virtual Machine¶
Of course, you can always use VirtualBox image. But first you must install and configure virtualbox:
- Download and install VirtualBox. This manual offers good instructions of first steps.
- Download and install VirtualBox Extension pack, using the following instructions
- Import and execute the VM for the first time. You can go to Virtualbox > Tools * Before using the virtual machine with the SensorTag, connect the SensorTag to your computer and open Settings > USB and choose USB 3.0 (xHCI) Controller. You can add the USB device automatically by clicking Ennen virtuaalitietokoneen käynnistämistä yhdistä SensorTag tietokoneeseesi. VirtualBoxissa avaa Settings > USB ja valitse USB 3.0 (xHCI) Controller. You can add the computer’s USB devices to be automatically recognized by clicking the + icon on the right side of the window.
- Install the Linux Guest Additions in the VM (guest computer). This page contains nice instructions.
Installing C compiler¶
These instructions explain how to install a C compiler in your own computer at home.
Windows machines¶
The easiest option is to install a IDE which contains all necessary sofware including compiler. You have multiple options
- CodeBlocks Easy to install and use. This is the recommended option by the course staff. You can install it for free in your own computer
- Visual Studio Community: Perhaps too complex to setup for this course.
Setting up gcc Compiler in Windows¶
Alternatively, specially if you want to program from command line, or you want to use Visual Studio Code you would need to install a Windows gcc compiler. The best option is mingw-w-64
Installing mingw-w-64.
- Download from https://sourceforge.net/projects/mingw/
- During installation select architecture: x86_64. Select the i686 architecture only if you really know what you are doing.
- Otherwise just click Next.
- Section 4 in advanced of this tutorial provide some additional information
- After mingw has installed, navigate to the installation directory and run
mingw-w64.bat
. This will setup the needed environment variables - Finally check tne installation by opening command prompt and typing
gcc --version
. Now you should see gcc version information.
As mingw-w64 contains just the compiler, you may also want to install a development environment for C programming.
The list of options include:
- Visual Studio Code
- Dev-C++
- CodeLite
- Eclipse CDT
Command line compiler¶
Obviously, when you installed minGW shell, you can use gcc directly from there.
Linux machines¶
Install gcc through your Linux distribution.
- Debian / Ubuntu:
sudo apt-get install gcc
- RHEL: Fedora, CentOS, etc. use
yum
command - Gentoo: use command
emerge
(probably?) - Arch linux: use command
pacman
(probably?)
- Open a terminal program (such as konsole, gnome-terminal, urvxt, xterm, ...)
- write
gcc --version
to check that gcc is installed.
You can also use any othe alternative IDES such us Code::Blocks IDE
MacOS¶
Option 1. Using any of the multiplatform IDEs such us Code::Blocks IDE
Option 2.
- Install XCode. You may need an Apple user account.
Option 3.
- Install Homebrew by following the site intructions
- Open a terminal window
- Type command
brew install gcc
. - Type command
gcc --version
to check that installation is ok.
Online C Compilers¶
Try google search with keywords c online compiler.
- Online gdb
- replit
- Onecompiler Does not have a debugger.
- Visual Studio Code online
Programming the embedded device¶
Don't worry about this setup yet, you will learn how to program the device during the mandatory laboratory exercise!
At home or with your laptop, you use the Code Composer Studio-development environment. This program requires license, which is provided through the course device SensorTag.
If you are programming the Raspberry Pico, you would need to install Visual Studio Code with following extensions: