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.
NOTE : When you compile your code for the C exercises you need to be sure that you compile for C99 standard (
-std=C99) flag in gccSoftware recommended for programming¶
For programming C Exercises you can choose among all these options:
- Code::Blocks IDE
- 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
- More information in Installing C Compiler section below
- More information to configure the Visual Studio Code for C in the VScode Cheat Sheet
- C compiler (gcc) + Preferred text editor. In Windows you can use mingw-w-64. It can be downloaded from here You can also build
Makefiles or ask CMake to do create them for you. - 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.
- Compiler explorer Great tool to see assembly code. Does not have a debugger
'
For Programming the Raspberry Pi Pico
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 (not for Fitech students)¶
Note for FITECH students: Virtual machine is not necessary.
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
- 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 last version of the
.ovafile in your own account. If you are in a university computer, you can do it from a copy in University network. - Open VirtualBox and press import. Choose the
.ovafile. - 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,cdto 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,cdto 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
- 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
- Install MSYS and MINGW-w-64 environment (see setting compiler below)
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 installing the MSYS (Posix environment for windows) and then the development tools. Installing only the MINGW64 shell is also an option
Installing the MSYS environment
- Download the latest installer from MSYS2 page
- Run the installer and follow steps of the installation wizard. You can store it in any folder in your computer.
- Open the MSYS terminal and update the packages:
pacman -Syu - Open the MSYS UCRT64 shell and run install the development tools:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain - Finally check the installation by opening the MSYS UCRT64 shell typing
gcc --version. Now you should see gcc version information. - If you want to add it in your windows path so it can be executed from any program:
- Open System Properties → Environment Variables.
- Edit PATH (user or system).
- Add <your path to MSYS2 installation>\ucrt64\bin.
- Open CMD or powershell and type
gcc --version
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 the 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
yumcommand - Gentoo: use command
emerge(probably?) - Arch linux: use command
pacman(probably?)
If you want to have all the complete toolchain then try
sudo apt-get install build-essential- Open a terminal program (such as konsole, gnome-terminal, urvxt, xterm, ...)
- write
gcc --versionto 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 --versionto 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
- Compiler explorer
Programming the embedded device (Not for Fitech students)¶
Don't worry about this setup yet, you will learn how to program the device during the mandatory laboratory exercise!
If you want to use your own machine, we provide instructions in the mandory lab exercises