raspberry pi
raspberry pi
By 436_gauri salunke
WHAT IS CROSS COMPILER AND WHY IT IS
NEEDED IN RASPBERRY PI
• Embedded computers often lack the necessary resources for developing and
compiling software.
• But while the code can be developed and built on the Raspberry Pi, it may
not always be the most suitable place for software development. One
reason is the lower performance of the SD card
• . To compile native code for the Raspberry Pi, you need a compiler and
linker that knows how to generate ARM binary executables. Yet it must run
on a host with a different architecture (for example, Mac OS X).
• Hence the reason it is called a cross-compiler. The cross-compiler will take
your source code on t.he local (build) platform and generate ARM binary
executables, to be installed on your target Pi.
BENEFITS OF CROSS COMPILATION IN
RASPBERRY PI AND SOME IMPORTANT TERMS
• Cross-compilation of the Raspberry Pi kernel is useful for two reasons:
1)It allows a 64-bit kernel to be built using a 32-bit OS, and vice versa, and
2) Even a modest laptop can cross-compile a Pi kernel significantly faster than
the Pi itself.
Some important terms
build: Also called the local platform, this is the platform that you perform the
compiling on
(for example, Mac OS X).
target: The destination platform, which is the Raspberry Pi
STEPS TO PERFORM CROSS COMPILATION IN
RASPBERRY PI
1) INSTALLING CROSSTOOL-NG ON CENTOS
http://crosstool-ng.org/ cd/usr/src. Or
http://crosstool-ng.org/ download/ crosstool-ng/crosstool-ng x.y.z.tar..bz2
2) Build the tool
• mkdir -p /opt/crosstool-ng
• chown-r nobody:nobody /opt/crosstool-ng
• chmod g+w,g+s /opt/ crosstool-ng /
• configure -prefix=/opt/crosstool-ng
SETUP AUTOCOMPLETION
CP CT-NG.COMP /ETC/ BASH_COMPLETION.D/
ADD CROSSTOOL'S BIN DIRECTORY TO THE USER'S PATH
PATH-$PATH:/OPT/CROSSTOOL-NG-1.20.0/BIN
CONFIGURE THE TOOLCHAIN
RE-LOGIN AS REGULAR USER, OR SOURCE -/.BASH_PROFILE
SETUP THE CONFIG DIRECTORY
MKDIR -P /OPT/CROSSTOOL-NG/CONFIG
CD/OPT/CROSSTOOL-NG/CONFIG
RUN THE CONFIGURATION TOOL
./CT-NG MENUCONFIG
BUILD THE TOOL
CT-NG BUILD
APPEND THE PATH WITH THE NEW TOOLS
PATH=$PATH:/OPT/CROSSTOOL-NG/TOOLS/ARM-BASHLINUX-LINUX-GNUEABI
PULSE WITH MODULATION
• Pulse with modulation controls
power and so controls the amount
of power going to the motor and
spins motor fastly
• The pulse will be given by PWM
output after 1/500 of a second. The
length of pulse controls the amount
of energy that the motor gets.If
there is no pulse motor will not
turn on and if short pulse it will
turn slowly
• Duty cycle:- The proportion for which the LED is ON
over the total time .and can be calculated as follows
• Duty Cycle =Turn ON time/ (Turn ON time + Turn OFF
time)
• Duty Cycle = (0.5/ (0.5+0.5) 50%
• Components required
• Here wewill use Raspberry pi 2 model B with
Raspbian Jessie OS
• Connecting pins .
• 220Ώ or 1K Ώ resistor
• LED
• Bread Board
WORKING EXPLAINATION
• Once everything is connected, we can turn
ON the Raspberry Pi to write the program in
PYHTON and execute it.
• We will talk about few commands which
we are going to use in PYHTON program .
• We are going to import GPIO file from
library, these function enables us to
program GPIO pins of PI.
• We are also renaming ,GPIO to IO, so in the
program whenever we want to refer to
GPIO pins we will use IO.
CODE
THANK YOU