Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 6 Uli Raich UCC semester 2017/2018

Similar presentations


Presentation on theme: "Lecture 6 Uli Raich UCC semester 2017/2018"— Presentation transcript:

1 Lecture 6 Uli Raich UCC semester 2017/2018
The Raspberry Pi Lecture 6 Uli Raich UCC semester 2017/2018

2 A first glimpse There are several versions of Raspberry Pis available on the market: Raspberry Pi 1 Model B released in 2012 There is also a simpler and cheaper model A Raspberry 2 with more memory Raspberry Pi zero a stripped down version for 5 US$ Raspberry Pi zero W same as zero but with WiFi and Bluetooth for 10 US$ Raspberry Pi 3 fully equipped model that we will be using For more information look up the Wikipedia page

3 Photo of Raspberry Pi 3

4 Raspberry Pi specs Again, more information can be found here

5 Official source of information
The Raspberry Pi has been sold at more than 8 million pieces! The user community is huge and is now increased by another 30 users! An enormous wealth of information on all sorts of subjects using the Raspberry Pi can be found on the WEB The official site is

6 Operating systems on the Pi
From the specs we can see that the Raspberry Pi 3 is a full blown computer. With its 64 bit quad core processor, 1 Gbyte of RAM, 32 Gbyte of SD card it by far outperforms the 80 kUS$ mini computer I had used to control a full particle accelerator and it is also much more powerful than the computer system that allowed the moon landing! This allows a great deal of flexibility when it comes to operating systems to be installed on the machine

7 Currently available OS
Raspbian, a Debian variant of Linux tailored to the Raspberry Pi. It contains most of the software packages you also find on Ubuntu The Desktop is however stripped down to make it more responsive on a processor that cannot cope with the speed of a PC This is what we are using! Ubuntu Mate is a Ubuntu variant for the Pi Windows 10 IOT core, a windows variant. I have never tried this but Windows gurus may give it a try if they cannot live without Windows on the Pi Android: There are several Android versions for the Pi floating around on the WEB. Your success on these may vary Kodi is a multimedia server that will allow you to listen to music, look at photos or watch films. Connect your Pi to a TV set (through the HDMI connector) and a stereo and off you go!4 If this is not enough for your then search the WEB for more

8 BCM2835 CPU The CPU has got an ARM processor core with 4 64 bit CPUs
The operating system and the Linux kernel are still 32 bit versions (After the course you may try to compile and install a 64 bit kernel yourself. This is a very good exercise to understand how the OS is built!) Around the CPU there are plenty of interfaces To know the details (the interfaces only!) have a look at the data sheet explaining them (205 pages!)

9 BCM2835 peripherals Here are some of the Raspberry Pi peripherals:
UART SPI BSC (serial controller) DMA controller External mass media controller PCM/ I2S Audio Pulse Width Modulation Timer USB I2C GPIO

10 Raspberry Pi and the real world
You can easily connect General Purpose Input Output signals These are 3.3 V single pin signals used e.g. to drive a LED, a relay or any other device needing a digital signal level You can program it input or output With pull-ups or pull-downs To read switch state To drive a 3.3V output level (and light a LED)

11 Connection to bread board The cobbler

12 Other RPI connections I2C is a serial bus often used in computer systems of for short distance interfacing. Many devices having a I2C port are available and we will program a few: ADC DAC Real time clock EEPROM We also have a 2-line LCD display needing some 8 signals (+ power and gnd). A serial to parallel interface (shift register) with I2C interface eases the connection to the Raspberry Pi as only 4 serial signal lines are needed: SDA, SCL,Vcc, gnd

13 More interfaces There are more interfaces which we will not necessarily use during the course. Students who think that they do not learn enough during this course are invited to come forward. We can easily give you more exercises, e.g to make The camera The touch screen interface The audio system Or the video system work

14 What you need to bring a RPI to life
This is what you will need to bring a Raspberry Pi to life: The Raspberry Pi board A case (this increases the chances the Pi will survive for more than a week) A 5V, 2.5A power supply with micro USB connector A USB keyboard and USB mouse A screen with HDMI connection of HDMI to VGA adapter Once the Raspberry Pi is up and running you can replace the screen, keyboard and mouse with your laptop or other computer and access the Pi through a remote desktop.

15 The software Go to the Raspberry Pi download page and download the Raspbian image. It comes in 2 versions NOOBS which contains the system itself + an installer Raspbian proper. This version may be slightly more difficult to install because it does not have the installer, which you would keep on your SD card even though after its first use you don’t need it any more This will get you a zip file, normally downloaded to your $HOME/Downloads directory. Since at Internet speeds that we experience at UCC this takes more than 1 hour to download we will distribute the zip file to all the PCs.

16 How to extract the file system on Ubuntu?
Once downloaded we must first unzip the file: Create a folder: /opt/ucc/micros/raspberry and copy the zip file into it cd /opt/ucc/micros/raspberry cp ~/Downloads/ raspbian-stretch.zip . unzip raspbian-stretch.zip which will give you raspbian-stretch.img This is the file system image which will be copied to the SD card bit by bit using the dd command

17 Structure of the image file
Can we know what is inside this image? We see that there are 2 disk partitions: FAT32 (Windows type) partition. This is the boot partition a Linux (ext4) partition which is the root file system

18 Looking inside the partitions
This is something only root (the superuser) can do We loop mount the file system: Now we can copy the contents to whatever directory we want This is the boot partition Then we can do the same thing for the root partition

19 The root partition Once we mount the second partition the same way we see that it contains: Have you seen this before? The boot partition we have seen before is mounted on /boot in this partition

20 How to get the OS onto the Raspberry Pi?
Now we have the OS on the PC where it does not help us much! We must put it onto a media that can be read by the Rpi. Traditionally this was the micro SD card but you can also use certain types of USB memory sticks (Be careful, not all sticks will work! I use a SanDisk cruzer)

21 Copying the OS to the SD card
If your PC has an SD card reader then you put the micro SD card into a normal SD card holder. Otherwise there are microSD to USB converters First check which disks you have on you system: Then you plug in your microSD adapter or your USB adapter and do the same thing again You should see 2 additional partitions, in my case probably /dev/sdc /dev/sdc1 /dev/sdc2

22 Copy the OS Now we are ready to copy the operating system to the SD card (or USB stick) Where X is the disk letter (in our case “c”) This may well take several minutes (the image is some 1.6 Gbytes!) To see the progress:

23 The moment of truth Safely remove the SD card from your system.
Put it into the SD card slot of the Pi Power on th machine With a little bit of luck, it should boot For more details of installing Raspbian on the SD card using a Linux system see /installing-images/linux.md

24 First login Raspbian has a default user named pi
with password raspberry (which must be changed immediately for security reasons) Create your own user and add him to the sudo group: adduser uli and follow the instructions on the screen usermod -a -G sudo uli Then login with this new user name and upgrade the system to the latest revision of all programs: apt update apt upgrade or apt dist-upgrade

25 Adding software packages
Once you have come this far you may want to add additional software packages, emacs being one of them You will continue adding packages as you use the system and you will see what is missing.

26 Configuring the system
We have seen that the system image takes 1.6 Gbytes our SD card however provides 32 Gbytes. How to use it to its full capacity? Start raspi-config Go through all the options of the program and see if they make sense to you.

27 Accessing the RPI remotely
Of course we can use the interfaces on the Raspberry Pi to connect a screen, keyboard and mouse and use it in stand-alone mode but we can also make use of the PC resources and access it remotely There are several ways to access the RPI remotely: Using the VNC server on the Pi you can access it with a remote desktop from the PC The secure shell (ssh) allows you to get a remote terminal in the Pi With scp you can copy files back and forth between the Pi and the PC With nfs you can mount part of the Pi file system into the PC file system tree and access the PI SD card as if it was a local PC disk.

28 The remote Desktop

29 ssh In the case of ssh you have a single terminal window that is connected to a shell on the Pi. The command is: ssh Where piIPaddress can be the Pi’s IP address of hostname. If you specify the -X option you can run X-11 based programs where the X protocol is run over the ssh connection.

30 ssh (2) Here you see a screen dump from the PC with a remote terminal that started an emacs session on the Pi

31 scp To copy a file from the PC to the Pi this would be the command:
scp myfile.c This will copy the file “myfile.c” into the sub-directory exercises/solutions/exercise_2 on my home directory on the Pi. Of course user uli must exist on raspberry10. Instead of specifying the machine name: rpi-10 you can also give its IP address.

32 Compiling C programs for the Raspberry Pi
Just like Linux on the PC, Linux on the Raspberry Pi uses the GNU C compiler gcc. The front end: Lexical Analyzer and the parser for the grammar are the same. However, the code generator is different since now we compile for the ARM processor and not the Intel processor used on the PC

33 Cross-Compilation for the Pi
As explained in a previous lecture we can also compile C programs for the Raspberry Pi on the PC Linux system using a cross-compiler. The cross compiler we will use is named arm-linux-gnueabihf-gcc and it is part of the tools package for the Pi It exists also as an Ubuntu package to be installed with apt.


Download ppt "Lecture 6 Uli Raich UCC semester 2017/2018"

Similar presentations


Ads by Google