Completed: / exercises
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 gcc

Software recommended for programming

For programming C Exercises you can choose among all these options:
'
For Programming the Raspberry Pi Pico

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:
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

  1. Download the Virtual Machine. Link can be found from this Lovelace page
  2. Copy the last version of the .ova file in your own account. If you are in a university computer, you can do it from a copy in University network.
  3. Open VirtualBox and press import. Choose the .ova file.
  4. Check that in Settings > USB you have activated the 3.0 option.
  5. 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.

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

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.
scp -P 2222  linuxlite@localhost:/path/to/destination
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:

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

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
  1. Download the latest installer from MSYS2 page
  2. Run the installer and follow steps of the installation wizard. You can store it in any folder in your computer.
  3. Open the MSYS terminal and update the packages: pacman -Syu
  4. Open the MSYS UCRT64 shell and run install the development tools: pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
  5. Finally check the installation by opening the MSYS UCRT64 shell typing gcc --version. Now you should see gcc version information.
  6. 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.
  1. Download from https://sourceforge.net/projects/mingw/
  2. During installation select architecture: x86_64. Select the i686 architecture only if you really know what you are doing.
  3. Otherwise just click Next.
  4. Section 4 in advanced of this tutorial provide some additional information
  5. After mingw has installed, navigate to the installation directory and run mingw-w64.bat. This will setup the needed environment variables
  6. 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:

Command line compiler

Obviously, when you installed minGW shell, you can use gcc directly from there.

Linux machines

Install gcc through your Linux distribution.
If you want to have all the complete toolchain then try sudo apt-get install build-essential
  1. Open a terminal program (such as konsole, gnome-terminal, urvxt, xterm, ...)
  2. 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.
  1. Install XCode. You may need an Apple user account.
Option 3.
  1. Install Homebrew by following the site intructions
  2. Open a terminal window
  3. Type command brew install gcc.
  4. Type command gcc --version to check that installation is ok.

Online C Compilers

Try google search with keywords c online compiler.

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
?