End Presentation


TWiki Slide Show
Next
Accessing the Real World

Lecture 7


Uli Raich


UCC semester 2017/2018

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 1 of 21





















TWiki Slide Show
Next
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.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 2 of 21





















TWiki Slide Show
Next
The remote Desktop
piRemoteDesktop.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 3 of 21





















TWiki Slide Show
Next
Remote Desktop (2)
When running the remote desktop you are working on the Raspberry Pi

with the screen, keyboard and mouse replaced by the devices on the PC.

You have the same functionality as if the screen was connected

to the Pi’s HDMI port and keyboard and mouse were connected

to the USB ports on the Pi.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 4 of 21





















TWiki Slide Show
Next
nfs the network file system
With nfs you can mount part of the Pi’s file system tree

onto your PC file system.

This allows you access to the Pi’s files as if you were

using a local disk. You cannot run any Rasberry Pi

programs this way however.

It is interesting if you cross-compile Pi programs on your PC,

which will be immediately visible on the Pi.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 5 of 21





















TWiki Slide Show
Next
ssh the secure shell
In the case of ssh you have a single terminal window

that is connected to a shell on the Pi.

The command is:

ssh userOnPi@piIPaddress

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.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 6 of 21





















TWiki Slide Show
Next
ssh session example
Here you see a screen dump from the PC with a remote terminal

that started an emacs session on the Pi.

ssh-X.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 7 of 21





















TWiki Slide Show
Next
scp
To copy a file from the PC to the Pi this would be the command:

scp myfile.c uli@raspberry10:exercises/solutions/exercise_2


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:

raspberry10 you can also give its IP address.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 8 of 21





















TWiki Slide Show
Next
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

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 9 of 21





















TWiki Slide Show
Next
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.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 10 of 21





















TWiki Slide Show
Next
Access libraries
As we have already seen, the Raspberry Pi flat cable connector

and the cobbler + bread board, give access to external hardware though

  • gpio
  • I2C bus
  • SPI
  • serial port interface
Dedicated interfaces to camera and display

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 11 of 21





















TWiki Slide Show
Next
Software access
Of course you can access the external hardware through

the BCM-2837 interfaces and their registers directly, however,

this is not for the faint-hearted (read the 200 page manual first!)

The easier way to access these devices are ready made

libraries giving you a simpler API for access

To my knowledge there are 2 such libraries around

(at least these are the most popular ones):

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 12 of 21





















TWiki Slide Show
Next
How to download and install
Both libraries can be downloaded as git source archives,

which allows you to have the very latest version and

to keep your version up to date.

git is a revision control system allowing many developers

to work on the same project. You check out the current version,

work on it and you can upload to the git server

the modifications you made.

You can also create a new code branch where you implement

new functionality which may be specific to what you want

to use the code for, or it may be a try to implement new options

which may later be discarded or, in case everybody is interested

in this new functionality it may be merged back into the main branch.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 13 of 21





















TWiki Slide Show
Next
Getting the LED blink program to work
The wiringPi library has included a few example programs to show its use.

The most simple one is a program making a LED blink.

WiringPi has its own numbering system for the GPIO pins:

gpioNumbering.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 14 of 21





















TWiki Slide Show
Next
Creating blink.c
As you would expect, wiringPi has its own include file

which you must use in order to access the library:

#include <wiringPi.h>

On our systems we have installed this include file is in /usr/include

on the Pi file system while the library itself is in /usr/lib

As these are the standard positions for include files and libraries on a

Linux system all we have to do in the Makefile is to add

-lwiringPi to the LDLIBS macro.

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 15 of 21





















TWiki Slide Show
Next
The C code of blink.c
blink.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 16 of 21





















TWiki Slide Show
Next
The Makefile to build blink
blinkMakefile.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 17 of 21





















TWiki Slide Show
Next
Ohm's law
If you consider that the LED has no resistance and the Raspberry Pi

drives the GPIO pins with 3.3V and you connect as shown in the circuit diagram,

then what is the current flowing through the LED?

ledschematics.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 18 of 21





















TWiki Slide Show
Next
!WiringPi functions
The library has functions to

  • Setup and initialize the library
    This will open the needed device drivers and give access to them
  • Core functions: Functions to
    • set gpio pins to input or output and
    • to read and write from /to them
    • define pull-ups/pull-downs
  • Some Pi specific functions liking getting the version no
  • Timing functions (e.g. delays)

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 19 of 21





















TWiki Slide Show
Next
!WiringPi functions (2)
  • Priority, interrupts, threads
  • I2C bus functions
  • Serial line functions
  • SPI functions
  • Miscellaneous function

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 20 of 21





















TWiki Slide Show
Next
The gpio command
In addition to the library functions a new command:
gpio
is provided. This can be used to set gpio pins from bash
It has however many more options. Look them up in its man page.


First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 21 of 21





















First slide Previous End Presentation






























-- Uli Raich - 2017-09-27

Comments

I Attachment History Action Size Date Who Comment
PNGpng blink.png r1 manage 48.9 K 2017-09-27 - 14:26 UnknownUser  
PNGpng blinkMakefile.png r1 manage 6.6 K 2017-09-27 - 16:36 UnknownUser  
PNGpng gpioNumbering.png r1 manage 157.9 K 2017-09-27 - 14:26 UnknownUser  
PNGpng ledschematics.png r1 manage 7.2 K 2017-09-27 - 16:48 UnknownUser  
PNGpng piRemoteDesktop.png r1 manage 378.8 K 2017-09-27 - 14:53 UnknownUser  
PNGpng reminna.png r1 manage 3.9 K 2017-09-27 - 14:53 UnknownUser  
PNGpng ssh-X.png r1 manage 293.5 K 2017-09-27 - 15:07 UnknownUser  

This topic: Embedded_Systems > WebHome > LectureSlides > Lecture7:AccessingTheRealWorld
Topic revision: r3 - 2017-09-27 - uli
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback