F28HS FAQ
This page discusses frequently asked questions in the context of the course on Hardware-Software Interface.
First things to do after installation
First time you boot the RPi from the SD card, it will ask you to install the OS: just pick 'Raspbian' from the available options, and use the default settings for any questions asked.
Once the installation is complete, start the configuration tool from the command line like this:
sudo raspbi-configand use the options:
- 1. Expand Filesystem
- 3. Boot Options
- 9. Advanced Options
If you want to change the resolution of your display, you can use the top left menus on your desktop, or directly edit the relevant file using
sudo nano /boot/config.txtand uncommenting the following 2 lines in this file
framebuffer_width=1280 framebuffer_height=720
How do I download files onto the Raspberry Pi 2?
The RPi2 we are using doesn't have a WiFi chip, and it can't be easily connected to the deptal network. So, the best way to bring a file onto the RPi2 is to download it onto the lab machine that you are using, copy it to a USB stick and then plug the USB stick into the RPi2. See the next question for mounting the USB stick.
How do I mount a USB stick on the Raspberry Pi 2?
When you plug in a USB stick on the RPi2, it won't automatically show up in a filebrowser. Do the following steps to mount the USB stick and make it visible as dir /mnt/tmp on the Rpi2:
sudo mkdir /mnt/tmp sudo mount /dev/sda1 /mnt/tmp ls /mnt/tmp
Now you can copy files from /mnt/tmp to your directory etc. When you are finished, to safely remove the USB stick do:
sudo umount /dev/sda1
If you get an error like /dev/sda1 not found us the command lsblk to see which device corresponds to the USB stick.
How do I use gdb to debug C or Assembler programs?
These slides from Greg's part of the course discuss gdb usage in detail. A gdb quick reference sheet is available here..
How do I compile C programs for debugging?
Add the compile-time flag -g, which adds symbol-table information to the generated binary, so that you can see proper variable names when single-stepping through the program:
gcc -g -o hello hello.c
You can also find basic information on the edit-compile-run cycle, in partiuclar for C programs, in this section of the Linux Introduction.
How do I test whether my wiring is correct?
The Lab-sheet on LED and Button control has a section on this. Here is a summary.
To test that the wiring is correct you can use several tools.
Python libraries: The ``Adventures in Raspberry Pi'' book, chapter 8 discusses how to do this with Python scripts. See the early course handouts of this book chapter for details. You can use these, if you want, for testing, but in the course we are using C and Assembler for controlling devices more directly.
C libraries (wiringPi): Therefore, it's recommended that you install the wiringPi library by Gordon Henderson. Follow these installation instuctions. This is also a very useful source of example code, so you may want to look-up the directory \ttt{wiringPi/examples}, with several example programs, and wiringPi/wiringPi with the core implementation in C.
Using wiringPi you can test your LED, connected through pin 12, like this:
> gpio -g mode 12 out > gpio -g write 12 1
and your LED should blink. But remember this is just for testing.
To close the session do
> gpio -g write 12 0 > gpio -g unexport 12
Using wiringPi you can test your Button, connected through pin 26, like this:
> gpio -g mode 26 in > while [ 1 -eq 1 ] ; do gpio -g read 26 ; done
You should see a sequence of 0's, one per line, initially. When you press the button, that needs to be wired to pin 26, the 0's should change 1's, validating that the wiring is correct.
You can get an overview pin layout map, with modes and current values, by typing:
> gpio readall
Linux SysFS: You can also control the LED directly from the command-line like this (see these Tutorial slides on SysFS usage, note that you need to do this as root!):
> echo 12 > /sys/class/gpio/export > echo out > /sys/class/gpio/gpio12/direction > echo 1 > /sys/class/gpio/gpio12/value
and your LED should blink. Once finished, close your session like this
echo 0 > /sys/class/gpio/gpio12/value echo 12 > /sys/class/gpio/unexport
How do I view the Fritzing diagram project file?
The diagram showing the wiring for lab-sheets and course-work has been generated using the free Fritzing application: download it here and follow the installation instructions. Here are the steps in detail:
# install fritzing diagram software and display the F28HS CW3 spec wiring if [ ! -d ~/ftp/ ] ; then mkdir ~/ftp/ ; fi cd ~/ftp/ # get specific version of prg (64-bit Linux); check the website for other versions wget http://fritzing.org/download/0.9.2b/linux-64bit/fritzing-0.9.2b.linux.AMD64.tar.bz2 # unpack tar xfj fritzing-0.9.2b.linux.AMD64.tar.bz2 # get the Fritizing diagram project files wget http://www.macs.hw.ac.uk/~hwloidl/Courses/F28HS/fritz_CW3.fzz # start the program; use it to zoom and get pin number info sh ~/ftp/fritzing-0.9.2b.linux.AMD64/Fritzing fritz_CW3.fzz
I'm getting a message about `GLIBC_2.14' not found . What's wrong?
Your system libraries are to run with the downloaded binary. You could upgrade your distribution to the latest version, which is likely to fix the issue. Alternatively, download the sources of the application and build it from the sources.
How ...