microembedded technologies, pune. a user manual for · pdf filemicroembedded technologies,...

12
MicroEmbedded Technologies: Using the BBB on Linux Platform MicroEmbedded Technologies, Pune. A user manual for Using the BeagleBone Black with Linux Host.

Upload: ledan

Post on 12-Mar-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

MicroEmbedded Technologies, Pune.

A user manual for

Using the BeagleBone Black

with Linux Host.

Page 2: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

Introduction to BeagleBone Black. ............................................................................................... 3

1.0. Connecting the BeagleBone Black (BBB) with the PC. ................................................. 5

1.1. Connecting the BBB to the Host PC using USB and Login using SSH. ............................... 5

1.2. BBB: Logout / Power OFF . ............................................................................................. 5

2.0. File Transfer operations. ...................................................................................................... 6

2.1. Copying the files from the Host PC to BBB. .................................................................... 6

2.2. Copying the files from the BBB to Host PC. .................................................................... 7

3.0. Compiling and Executing the Programs. .......................................................................... 8

3.1. Compiling and executing C / C++ programs. ................................................................... 8

3.2. Executing python programs. ......................................................................................... 8

3.3. Compiling and Executing PL-3 Assignments. ................................................................... 9

3.4. Compiling and Executing PL-IV Assignments. ............................................................... 11

3.4.1. Parallel interface DAC-DAC08 . ................................................................................. 11

3.4.2. I2C ADC/DAC : PCF8591. ........................................................................................... 12

Page 3: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

Introduction to BeagleBone Black.

The BeagleBone Black is the newest member of the BeagleBoard family. It is a lower-cost, high-expansion focused BeagleBoard using a low cost Sitara XAM3359AZCZ100 Cortex A8 ARM processor from Texas Instruments.

The BeagleBone is a compact, low cost, open source Linux computing platform that can be used to build complex applications that interface high level software and low level electronic circuits. It is an ideal platform for prototyping project and product designs that take advantage of the power and freedom of Linux, combined with direct access to input/output pins and buses, allowing you to interface with electronics components, modules, and USB devices. The characteristics of the BeagleBone platform are that it is powerful, as it contains a processor that can perform up to 2 billion instructions per second,

is low‐cost, available for as little as $45–$55,

supports many standard interfaces for electronics devices, uses little power, running at between 1 W (idle) and 2.3 W (peak), is expandable through the use of daughterboards and USB devices, is supported by a huge community of innovators and enthusiasts, and is open‐hardware and supports open‐software tools and applications.

The BeagleBone runs the Linux operating system, which means that you can use many open‐

source software libraries and applications directly with it. Open source software driver availability also enables you to interface devices such as USB cameras, keyboards and Wi‐Fi

adapters with your project, without having to source proprietary alternatives. Therefore, you have access to comprehensive libraries of code that have been built by a talented open‐source

community; however, it is important to remember that the code typically comes without any type of warranty or guarantee. If there are problems, then you have to rely on the good nature of the community to resolve them. Of course, you could also fi x the problems yourself and make the solutions publicly available. The BeagleBone platform is formed by the integration of a high performance microprocessor on a printed circuit board (PCB) and an extensive software ecosystem. The physical PCB is not a complete product; rather it is a prototype reference design that you can use to build a complete product. It is an open‐hardware platform, meaning that

you can download and use the BeagleBone hardware schematics and layout directly within your own product design. In fact, despite the impressive capability of the BeagleBone platform, it does not fully expose all of the features and interfaces of the Texas Instruments Sitara AM335x microprocessor.

BeagleBone Black is a low-cost, community-supported development platform for developers and hobbyists. Boot Linux in under 10 seconds and get started on development in less than 5 minutes with just a single USB cable.

Page 4: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

Processor: AM335x 1GHz ARM® Cortex-A8

512MB DDR3 RAM 4GB 8-bit eMMC on-board flash storage also additional storage via SD card. 3D graphics accelerator NEON floating-point accelerator 2x PRU 32-bit microcontrollers

Connectivity

USB client for power & communications USB host Ethernet HDMI 2x 46 pin headers (P8 and P9)

Page 5: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

1.0. Connecting the BeagleBone Black (BBB) with the PC.

There are 3 methods using which we can use the BeagleBone Black kit.

1. Standalone: you can connect the BBB using the HDMI cable and USB hub. The HDMI cable is connected to the HDMI monitor and USB hub is connected to a USB keyboard and USB mouse. This is like using the BBB as a CPU.

2. Connected to Host using VNC: using the BBB in a network and connecting to the Host using VNC.

3. Connected to Host using USB Device: this is the most preferred method for system developers. The BBB is connected to the Host using the USB device connection.

1.1. Connecting the BBB to the Host PC using USB and Login using SSH.

For development purposes the BBB is connected remotely to the PC via SSH (secured shell).

Connect the BBB to the PC using the USB cable: the Host end to the PC and the device end to the BBB (micro USB connector just below the LAN connector).

The BBB will be powered ON and the USER LED’s will blink randomly, the BBB will boot the debian Linux OS on the board. Once booted, the BBB will show itself as a mass storage device (boot or BEAGLEBONE drive).

Now open a Linux terminal on your Host PC. On the (# or $) prompt type the following command;

ssh [email protected] [press enter key]

192.168.7.2 is the default IP address of the BBB (Ethernet over USB interface- USB0).

The BBB will get remotely connected with the PC and the terminal will now show the BeagleBone prompt

root@beaglebone:#

You can now go to the /home directory and see the files in file system:

The /home should be the default location for all user data. As a good practice keep all user data in home directory. Do not use other location for storing data.

cd /home [press enter key]

1.2. BBB: Logout / Power OFF .

When the user wants to logout from the BBB the command is ;

exit [press enter key]

but this will just logout the user from the BBB shell. The BBB will still be available for connection. When the user wants to shutdown the BBB he can type the following command;

shutdown –h now &&exit [press enter key]

Or

poweroff [press enter key]

Page 6: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

2.0. File Transfer operations.

There are many scenarios where one may want to do file transfer operations between the BBB and Host PC. The user may develop the code in C, C++ or Python on the PC using his favorite editor (vi, nano, gedit, emacs etc), but this code needs to be transferred to the BBB for compilation and/or execution purpose. The user can compile the code on the PC using a cross compiler and transfer the executable to BBB for execution.

2.1. Copying the files from the Host PC to BBB.

When the user wants to transfer files from the Host PC to the BBB he can do the following; Open a terminal on Linux (shortcut : CTRL +ALT+ T) In the terminal go to the directory where your file is located on the PC.

To transfer the file we will use secure copy command;

scp source_filename [email protected]:/home [press enter key]

scp is the command for transferring the file from one terminal to remote terminal using Ethernet.

source_filename is the name of the source file to be transferred

[email protected]:/home is the remote address, where root is the login name and /home is the directory in which the file is to be transferred.

To transfer multiple file use the command;

scp file1,file2,...,fileN [email protected]:/home [press enter key]

Note1: user can execute the scp command only if user has logged into the BBB as shown in 1.1.

Note2: when you transfer a executable you need to change the file permissions

(using chmod +x filename) for the particular file in order to execute it.

Example:

The host PC has a login for students with the username being student. The task is to transfer a file helloworld.c located in the home folder on the PC to /home directory in BBB.

Solution:

Open a terminal on the PC (shortcut: CTRL +ALT+ T). In the terminal go to the home folder for the student;

cd /home/student [press enter key]

the home folder for the student login is located in /home/student.

Now execute the scp command to transfer the file from host to BBB.

scp /home/student/helloworld.c [email protected]:/home [press enter key]

This will now have copied the command from the PC to the BBB.

Page 7: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

2.2. Copying the files from the BBB to Host PC.

The user may need to copy some files from the BBB to the PC for viewing or some other purpose, for this we will follow the procedure as below;

Open a terminal on the Host PC (shortcut: CTRL +ALT+ T).

Execute the scp command on the host terminal;

scp [email protected]:/home/filename /home/login_name/ [press enter key]

scp is the command for transferring the file from one terminal to remote terminal using Ethernet.

[email protected]:/home/filename is the complete path of the file filename (source file) on the BBB to be transferred

/home/login_name/ is the location on the host pc where you want to store the transferred file.

Example:

The host PC has a login for students with the username being student. The task is to transfer a file mypic.jpg located in the home folder on the BBB to /home directory in PC.

Solution:

Open a terminal on the PC (shortcut: CTRL +ALT+ T). In the terminal go to the home folder for the student;

cd /home/student [press enter key]

the home folder for the student login is located in /home/student.

Now execute the scp command to transfer the file from host to BBB.

scp [email protected]:/home/mypic.jpg /home/student/ [press enter key]

This will now have copied the command from the BBB to the PC.

Note1: user can execute the scp command only if user has logged into the BBB as shown in 1.1.

Page 8: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

3.0. Compiling and Executing the Programs.

The source codes provided by us are arranged as below

BeagleBoneBlack_PL/Practicals/PL3 for PL3

BeagleBoneBlack_PL/Practicals/PL4 for PL4

In order to compile and execute the C/C++ or python programs;

Power the BBB with the 5V adapter. Connect the BBB to the PC using the USB cable. Login to the BBB using SSH. Transfer the code to BBB using SCP. Connect the relevant interface card and execute the code. Observe the output on the interface.

3.1. Compiling and executing C / C++ programs.

To compile the C/C++ programs on the BBB go to the folder where the source file is located;

For C:

gcc program.c – o outputname

Where program.c is the name of the C source file and output name is the name of the executable.

To execute the program:

./outputname

For C++:

g++ program.cpp – o outputname

Where program.cpp is the name of the C++ source file and output name is the name of the executable.

To execute the program:

./outputname

3.2. Executing python programs.

To execute python programs on the BBB go to the folder where the source file is located;

python program.py

Where program.py is the name of the python source file.

Page 9: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

3.3. Compiling and Executing PL-3 Assignments.

traffic.cpp (BeagleBoneBlack_PL/Practicals/PL3/A_02_traffic_cpp/traffic.cpp)

Transfer the program to BBB using scp. Program: traffic.cpp. Compilation:

g++ traffic.cpp – o traffic

Execute:

./traffic

traffic.py

Program: traffic.py (BeagleBoneBlack_PL/Practicals/PL3/A_02_traffic_python/traffic.py) Transfer the program to BBB using scp.

Execute:

python traffic.py

elevator.cpp (BeagleBoneBlack_PL/Practicals/PL3/A_01_elevator_cpp/elevator.cpp)

Program: elevator.cpp. Transfer the program to BBB using scp Compilation:

g++ elevator.cpp – o elevator

Execute:

./traffic

elevator.py

Program: elevator.py (BeagleBoneBlack_PL/Practicals/PL3/A_01_elevator_python/elevator.py) Transfer the program to BBB using scp.

Execute:

python traffic.py

cpu_freq_pwm.py

Program:cpu_freq_pwm.py.(BeagleBoneBlack_PL/Practicals/PL3/B_01_cpu_freq_python/cpu_freq_pwm.py)

Transfer the program to the BBB. Connect the CRO: Connect the signal wire of the probe to pin 14 on add-on cape and the

ground wire of the probe to pin 26 on the add-on cape. (Make sure that pin 25 and 26 do not touch)

Execute the following commands on the BBB terminal before executing the program;

echo am33xx_pwm > /sys/devices/bone_capemgr.9/slots

echo bone_pwm_P8_13 > /sys/devices/bone_capemgr.9/slots

Execute the program on BBB: python pwm.py press enterkey.

python cpu_freq_pwm.py

Observe the waveform on the CRO.

Page 10: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

SquareWave.py

Program: SquareWave.py.(BeagleBoneBlack_PL/Practicals/PL3/B_01_cpu_freq_python/ SquareWave.py)

Transfer the program to the BBB. Connect the CRO: Connect the signal wire of the probe to pin 13 on add-on cape and the

ground wire of the probe to pin 26 on the add-on cape. (Make sure that pin 25 and 26 do not touch)

Execute the program on BBB:

python SquareWave.py

Observe the waveform on the CRO.

oddeven.c (BeagleBoneBlack_PL/Practicals/PL3/ B_04_odd_even_sort_c/oddeven.c)

Program: oddeven.c. Transfer the program to BBB using scp Compilation:

gcc oddeven.c -fopenmp –o oddeven

Execute:

./oddeven

Executing the Set IP/Network application Program.

To execute the setIPnFTP.py network based application program, we will have to run file server like vsftpd on Linux platform (your network admin will assist you in running the file server).

Refer to the document FileTransfer_VSFTPD.pdf provided by us for this experiment.

setIPnFTP.py

Program: setIPnFTP.py (BeagleBoneBlack_PL/Practicals/PL3/B_08_network_ip_python/setIPnFTP.py)

Transfer the program to BBB using scp. Note down the IP address of your network. In the program make the following changes; Assign the IP address in the network to the

board IP_ADDR. For SERVER_IP give the IP address of your file server. In SERVER_USER give the login name of the PC and in SERVER_USER_PWD give the password of the login password of the user PC.

Execute:

python setIPnFTP.py

stepper.py Program: stepper.py (BeagleBoneBlack_PL/Practicals/PL3/ C_01_stepper_python/ stepper.py) Transfer the program to BBB using scp.

Execute:

python stepper.py

Page 11: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

3.4. Compiling and Executing PL-IV Assignments.

3.4.1. Parallel interface DAC-DAC08 .

The Parallel digital to analog converter DAC-08 is used for this conversion. Connect the CRO probe to Analog output connector (DAC out).

sine_wave_dac.py

Program: sine_wave_dac.py (PL4/Programs/PL4/Parallel/ sine_wave_dac.py) Transfer the program to BBB using scp.

Execute:

Python sine_wave_dac.py

sq_wave.py

Program sq_wave.py (Pl4/Programs/PL4/ Parallel / sq_wave.py) Transfer the program to BBB using scp.

Execute:

Python sq

adc_sampling .py

Program: adc_sampling.py. (Pl4/Programs/PL4/ Parallel / adc_sampling.py) Transfer the program to BBB using scp.

Execute:

Python sample

adc_sample_logs.py

Program: adc_sample_logs.py. (Pl4/Programs/PL4/ Parallel / adc_sample_logs.py) Transfer the program to BBB using scp.

Execute:

Python log

sobel.py

Program: sobel.py. (Pl4/Programs/PL4/sobel.py) Transfer the program to BBB using scp.

Connect the camera before executing this program.

Execute:

python sobel.py

After the program has executed it will create sobel_py.jpg and test_py.jpg files.

Copy these files from the BBB to the Host as in 2.2.

Open the files to see the effect of edge detection on the captured image.

Page 12: MicroEmbedded Technologies, Pune. A user manual for · PDF fileMicroEmbedded Technologies, Pune. A user ... which means that you can use many open‐ source software libraries and

MicroEmbedded Technologies: Using the BBB on Linux Platform

3.4.2. I2C ADC/DAC : PCF8591.

I2C based ADC / DAC PCF8591 is used for the conversion.

sinewave.c

Program: sinewave.c. (Pl4/Programs/PL4/I2C_ADC_DAC/sinewave.c) Compilation: gcc sinewave.c – o sine -lm

Execute:

./sine

sq_wave.c

Program: sq_wave.c. (Pl4/Programs/PL4/I2C_ADC_DAC/sq_wave.c) Compilation: gcc sq_wave.c – o sq -lm

Execute:

./sq

triangular.c

Program: triangular.c. (Pl4/Programs/PL4/I2C_ADC_DAC/ triangular.c) Compilation: gcc triangular.c – o tri -lm

Execute:

./tri

adc_sampling.c

Program: adc_sampling.c. (Pl4/Programs/PL4/I2C_ADC_DAC/ adc_sampling.c) Compilation: gcc adc_sampling.c – o sample -lm

Execute:

./sample

adc_log.c

Program: adc_log.c. (Pl4/Programs/PL4/I2C_ADC_DAC/ adc_log.c) Compilation: gcc adc_log.c – o log -lm

Execute:

./log