SlideShare a Scribd company logo
INTRODUCTION TO THE BOARD AND WORKSPACE SETUP
GOAL
The goal of this Lab is to introduceyou to the Raspberry Pi 3 board and to provideinstructions abouthowto set up
the workspaceused for the followinglabs.
PRE-REQUISITES
To followthis Lab,you will need:
1. Raspberry Pi 3 board full;
2. Micro USB cable;
3. 8 GB Micro SD card;
4. USB-to-Serial debug module for Raspberry Pi 3 or USB to TTL adapter;
5. Ethernet cable;
6. A PC with Ubuntu Desktop 14.04 LTS, or a virtual machinehostingUbuntu Desktop 14.04 LTS with at least
100 GB of free space;
7. A Micro SD card reader attached to the PC/virtual machine;
8. (Optional) Micro HDMI cable.
THE RASPBERRY PI 3
The Raspberry Pi 3 is the successor to the Raspberry Pi 2. It builds upon the Pi 2 by upgrading the Arm cores to
Cortex-A53 and addingan onboard single-band 2.4GHz-only wireless chipset.
The Raspberry Pi 3 measures the same 85.60mm x 53.98mm x 17mm, with a little overlap for the SD card and
connectors that project over the edges. The SoC is a Broadcom BCM2837. This contains a quad-core Cortex-A53
runningat 1.2GHz and a Videocore 4 GPU.
Front View
WORKPLACE SETUP
The setup is divided in two parts:PC setup and board setup.
PC SETUP
The following operations mustbe done once, to set up the Linux distribution you areusingto be ready for building
embedded Linux on the Raspberry Pi 3.
Install thefollowingpackages:
sudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib build-essential
sudo apt-get install chrpath socat libsdl1.2-dev xterm ncurses-dev lzop
sudo apt-get install minicom u-boot-tools curl
You will need to install the latestversion of python. Type python -–version to check, or usethe following
command to download it.
sudo apt-get install python
Install therepo utility:
mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=$PATH:~/bin
If you areusingGit for the firsttime in your system, you have to set your username and email address as follows:
git config --global user.name "username"
git config --global user.email “email@example.com”
Download the source code of embedded Linux for Raspberry Pi 3:
mkdir -p ~/raspberryPi3/sources
cd ~/raspberryPi3/sources
git clone -b krogoth git://git.yoctoproject.org/poky
git clone -b krogoth git://git.openembedded.org/meta-openembedded
git clone -b krogoth git://git.yoctoproject.org/meta-raspberrypi
NOTE: Be patient, this operation may take several minutes as several megabytes of sourcecode have to be
downloaded.
It is now time to define a specific network configuration for our lab experiments. For this purpose, let us create the
followingdirectory:
mkdir ~/raspberryPi3/sources/poky/meta/recipes-core/init-ifupdown/init-ifupdown-
1.0/raspberrypi3
In this directory, placea filenamed “interfaces” with the followingcontent:
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# The loopback interface
auto lo
iface lo inet loopback
# Wireless interfaces
iface wlan0 inet dhcp
wireless_mode managed
wireless_essid any
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
iface atml0 inet dhcp
# Wired or wireless interfaces
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1
# Bluetooth networking
iface bnep0 inet dhcp
Among the other activities,with this file,we set the IP address for the Ethernet device to 192.168.1.2.
Configure the environment to build the sourcejustdownloaded for the Raspberry Pi 3 and accept the license
agreement:
cd ~/raspberryPi3/
source sources/poky/oe-init-build-env rpi-build
Using your preferred editor program, edit the file“rpi-build/conf/local.conf”, remove the existing
content, and type/paste in the followingcontent, to includethe needed information to build embedded Linux for
the Raspberry Pi 3:
MACHINE ?= "raspberrypi3"
PREFERRED_VERSION_linux-raspberrypi = "4.%"
DISTRO_FEATURES_remove = "x11 wayland"
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
ENABLE_UART = "1"
Usingyour favoriteeditor program, edit the file “rpi-build/conf/bblayers.conf”, remove the existing
content, and type/paste in the followingcontent, to includethe needed information to build embedded Linux for
the Raspberry Pi 3 (ensure it is formatted exactly as shown, spaces and missingindents can causeparseerrors):
LCONF_VERSION = "6"
BBPATH = "${TOPDIR}"
BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"
BBFILES ?= ""
BBLAYERS ?= " 
${BSPDIR}/sources/poky/meta 
${BSPDIR}/sources/poky/meta-yocto 
${BSPDIR}/sources/poky/meta-yocto-bsp 
${BSPDIR}/sources/meta-openembedded/meta-oe 
${BSPDIR}/sources/meta-openembedded/meta-multimedia 
${BSPDIR}/sources/meta-raspberrypi 
"
Once this operation is completed, the environment is ready for buildingembedded Linux for the Raspberry Pi 3.
Ensure you are still in thebuild environment “rpi-build”.The Linux for the Raspberry Pi 3 can now be builtby
issuingthefollowingcommand:
bitbake rpi-basic-image
NOTE: Be patient, this operation may take up to two hours,depending on the PC you areusing,as several megabytes
of sourcecodehave to be compiled.If you are compilingtheimageon a virtual machine,this may takeseveral hours.
Once the build is completed, an SD card image for booting up the Raspberry Pi 3 can be found in the following
path:
raspberryPi3/rpi-build/tmp-glibc/deploy/images/raspberrypi3/rpi-basic-image-
raspberrypi3.rpi-sdimg
The image can be copied to a Micro SD usingsome Linux functionality (assumingtheMicro SD is availableto the PC
as /dev/sdN). Alternatively,and more easily,a flash programcould beused.
First,run the
sudo fdisk -l
command to determine which device to flash to (plugin and unplugthe SD card to determine which device itis).
For this example, the SD card is under the name “sdc” (this may be different in your environment). Next, ensure
that the device is unmounted. This can be done usingthe command:
sudo umount /dev/sdc*
Once this is done, the followingcommand can be used to copy the image across to the SD card (substituteany
folder names and device names to ensure they arerelevant to your specific environment).
sudo dd bs=1M if=/home/user/raspberryPi3/rpi-build/tmp-
glibc/deploy/images/raspberrypi3/rpi-basic-image-raspberrypi3.rpi-sdimg of=/dev/sdc
Note that if not done properly, the image being flashed across to the SD card may causeproblems when
attempting to turn on the board. If this is the case, itmay be worth retrying the process again and ensuringthatit
is done properly,or use a flash programto automate the process.
Whilethe SD card is still connected to the development host, use the followinglines to navigateto the etc folder
on the SD card (assumingthedevice has now been mounted).
cd /media/user/SD_name/etc – Use the ls command to find the name of the SD card in the user folder.
Then, use a terminal text editor to open the shadow file.
sudo vi shadow
Or
sudo gedit shadow
Check that there are no characters between the firsttwo colons in the firstline.If there is,remove it so that the
firstlinelooks likethis:
Root::17728:0:99999:7:::
Exit the text editor by entering :x or simply closingthe application!
MINICOM SETUP
Connect the USB-to-Serial debug module for Raspberry Pi 3 or USB to TTL adapter to J8 on the Raspberry Pi 3
board (pins 8 and 10 are UART0_TX and UART0_RX, which are the lines where the serial consoleof BCM2837 is
routed). And configurethe communication parameter to 1152008N1 in your preferred serial terminal emulation
program (under Linux uses the device /dev/ttyUSB0 or /dev/ttyUSB1).
Once the programming of the Micro SD is completed, we are ready to configure the communication program that
we will useto connect to the board: minicom. Issuethe followingcommand to start minicom in setup mode:
sudo minicom -s
Then, perform the followingsteps:
1. Select “Serial port setup” in the configuration menu;
2. Press A to modify the Serial Device and to set it to “/dev/ttyUSB0”;
3. Press F to set Hardware Flow Control to “No”;
4. Press enter to return to the previous menu;
5. Select “Save setup as dfl”, to savethe setup as default configuration;
6. Select “Exit” from Minicom.
Optional: Raspberry Pi 3 Ethernet interfaceis configured to acquirethe IP address via DHCP.In caseyou intend
to connect the board with your PC directly, you need to configure the Ethernet connection properly. It is
advisable to create a new Ethernet connection on your PC using the following statically assigned IPv4
configuration:
IP Address: 192.168.1.1
Netmask: 255.255.255.0
Gateway: 192.168.1.1
BOARD SETUP
1. Insertthe newly written Micro SD into the SD slotof the Raspberry Pi 3;
2. (Optional) connect the Micro HDMI cableto the Raspberry Pi 3 connector;
3. Connect a Micro USB cableto the PC and to the Micro USB connector of the Raspberry Pi 3;
4. Also connect the board with your hostdevice via an ethernet cable.
Once the Micro USB cableis connected, the board is powered up. In caseyou connected the Micro HDMI cable,you
will seea splash screen on the monitor, and a progression bar indicatingthe bootstrap is running.
Once the bootstrap is completed, a new device will beconnected to the PC: /dev/ttyUSB0. The deviceis the virtual
serial portthrough which you can access the Raspberry Pi 3, by issuingthefollowingcommand:
sudo minicom
In caseall previous steps have been completed successfully,you will see the followingmessages appearing on the
terminal:
Welcome to minicom2.7
OPTIONS: I18n
Compiled on Jan 1 2014, 17:13:19.
Port /dev/ttyUSB0, 10:22:24
Press CTRL-A Z for help on special keys
[ 0.000000] Booting Linux on physical CPU0x0
[ 0.000000] Initializingcgroup subsyscpuset
[ 0.000000] Initializingcgroup subsyscpu
[ 0.000000] Initializingcgroup subsyscpuacct
......
Poky (Yocto ProjectReference Distro) 2.1.2 raspberrypi3 ttyS0
raspberrypi3 login:
You can now login as “root” (no password required).
Note:
 To open the Minicommenu, press simultaneously ctrl +A and then Z (either l owercaseor uppercase).
Optional: Raspberry Pi 3 Ethernet interface is configured to acquirethe IP address via DHCP. In case you intend to
connect the board with your PC directly, you need to configure the Ethernet connection properly. It is advisableto
create a new Ethernet connection on the Raspberry Pi 3 by editing the file /etc/network/interfaces and to
modify the configuration of the network device eth0 as follows:
# Wired or wireless interfaces
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.255
Test to see if the network is configured properly using:
ifconfig
You should seean address of 19.168.1.2; however, if this is not the case,you can run the commands:
ifdown eth0
ifup eth0
After runningthese two commands, itshould be configured properly.
If you are usinga Linux virtual machine as the host, for the sole-purpose of communicating between the board and
the host,you may need to switch the “Network” settings to a “Bridged Adapter” and selectthe ethernet devicebeing
used.
Once the PC and the Raspberry Pi 3 are configured, you can test the connection with the followingcommand:
ping 192.168.1.1
If the configuration is correct,you will seea message appearingon the terminal similarto the following:
root@raspberrypi3:~# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.54 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.61 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.98 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.73 ms
POST-LAB PRACTICE
In this session,we have builtan initial version of Linux image with Yocto Project. One of the main benefits of using
Yocto Projectis that the Linux image can be flexibly customized to accommodate specific usage;the key to
manipulateitis by including differentlayers and recipes.
There are two files that determine the above feature, conf/local.conf and conf/bblayers.conf;to have a better
understandingof these two files and the customization feature of Yocto Project,we shall carry outadditional
practice.

More Related Content

PDF
Building RT image with Yocto
PDF
openPOWERLINK over Xenomai
PDF
A Journey to Boot Linux on Raspberry Pi
PPT
U Boot or Universal Bootloader
PDF
Jagan Teki - U-boot from scratch
PDF
Let's trace Linux Lernel with KGDB @ COSCUP 2021
PDF
Board Bringup
PDF
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
Building RT image with Yocto
openPOWERLINK over Xenomai
A Journey to Boot Linux on Raspberry Pi
U Boot or Universal Bootloader
Jagan Teki - U-boot from scratch
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Board Bringup
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job

What's hot (20)

PDF
RPM Building
PDF
Angelo Compagnucci - Upgrading buildroot based devices with swupdate
PDF
Tutorial: Cross-compiling Linux Kernels on x86_64
PDF
Bootloaders
PDF
References
PDF
Linux Kernel 개발참여방법과 문화 (Contribution)
PDF
Software Packaging for Cross OS Distribution
PDF
Shell Scripting
PDF
BeagleBoard-xM Bootloaders
PDF
Davide Berardi - Linux hardening and security measures against Memory corruption
PDF
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generator
PDF
Linux Internals Part - 3
PDF
PyCon Taiwan 2013 Tutorial
PDF
USB Drivers
PDF
Marco Cavallini @ LinuxLab 2018 : Workshop Yocto Project, an automatic genera...
PDF
Tensorflow in Docker
PPTX
eBPF Workshop
PDF
How to configure an environment to cross-compile applications for beagleboard-xM
RPM Building
Angelo Compagnucci - Upgrading buildroot based devices with swupdate
Tutorial: Cross-compiling Linux Kernels on x86_64
Bootloaders
References
Linux Kernel 개발참여방법과 문화 (Contribution)
Software Packaging for Cross OS Distribution
Shell Scripting
BeagleBoard-xM Bootloaders
Davide Berardi - Linux hardening and security measures against Memory corruption
Kernel Recipes 2013 - Crosstool-NG, a cross-toolchain generator
Linux Internals Part - 3
PyCon Taiwan 2013 Tutorial
USB Drivers
Marco Cavallini @ LinuxLab 2018 : Workshop Yocto Project, an automatic genera...
Tensorflow in Docker
eBPF Workshop
How to configure an environment to cross-compile applications for beagleboard-xM
Ad

Similar to Lab manual (20)

PDF
manual_2020_Cyber Physical System.pdf
PPTX
Raspberry Pi Free Session - 20_09_2014
PDF
Raspi_TOR_Access_Point_BenMoore
ODP
Raspberry Pi introduction
PPTX
Starting Raspberry Pi
PDF
Develop Smart Solutions with Raspberry Pi and EnableX Live Video API
PPTX
Raspberry Pi (Introduction)
PPT
Raspberry zero usb in linux
PDF
BeagleBone Black: Platform Bring-Up with Upstream Components
PPTX
Raspberry Pi Session - 22_11_2014
PDF
Raspberry Pi 3 Tutorial | Raspberry Pi 3 Projects | IoT Projects | IoT Tutori...
ODP
Rete di casa e raspberry pi - Home network and Raspberry Pi
PDF
Dependencies Managers in C/C++. Using stdcpp 2014
PDF
9 creating cent_os 7_mages_for_dpdk_training
PDF
Raspberry pi Board Hardware & Software Setup
PDF
Howto Pxeboot
PDF
Adafruit raspberry-pi-lesson-1-preparing-and-sd-card-for-your-raspberry-pi
PDF
DCEU 18: Tips and Tricks of the Docker Captains
PPTX
Tac Presentation October 72014- Raspberry PI
PDF
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
manual_2020_Cyber Physical System.pdf
Raspberry Pi Free Session - 20_09_2014
Raspi_TOR_Access_Point_BenMoore
Raspberry Pi introduction
Starting Raspberry Pi
Develop Smart Solutions with Raspberry Pi and EnableX Live Video API
Raspberry Pi (Introduction)
Raspberry zero usb in linux
BeagleBone Black: Platform Bring-Up with Upstream Components
Raspberry Pi Session - 22_11_2014
Raspberry Pi 3 Tutorial | Raspberry Pi 3 Projects | IoT Projects | IoT Tutori...
Rete di casa e raspberry pi - Home network and Raspberry Pi
Dependencies Managers in C/C++. Using stdcpp 2014
9 creating cent_os 7_mages_for_dpdk_training
Raspberry pi Board Hardware & Software Setup
Howto Pxeboot
Adafruit raspberry-pi-lesson-1-preparing-and-sd-card-for-your-raspberry-pi
DCEU 18: Tips and Tricks of the Docker Captains
Tac Presentation October 72014- Raspberry PI
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Ad

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Digital Logic Computer Design lecture notes
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Geodesy 1.pptx...............................................
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Well-logging-methods_new................
PPT
Project quality management in manufacturing
PPTX
CH1 Production IntroductoryConcepts.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
PPT on Performance Review to get promotions
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Operating System & Kernel Study Guide-1 - converted.pdf
OOP with Java - Java Introduction (Basics)
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Arduino robotics embedded978-1-4302-3184-4.pdf
Digital Logic Computer Design lecture notes
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Geodesy 1.pptx...............................................
Model Code of Practice - Construction Work - 21102022 .pdf
Well-logging-methods_new................
Project quality management in manufacturing
CH1 Production IntroductoryConcepts.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Mechanical Engineering MATERIALS Selection
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPT on Performance Review to get promotions
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

Lab manual

  • 1. INTRODUCTION TO THE BOARD AND WORKSPACE SETUP GOAL The goal of this Lab is to introduceyou to the Raspberry Pi 3 board and to provideinstructions abouthowto set up the workspaceused for the followinglabs. PRE-REQUISITES To followthis Lab,you will need: 1. Raspberry Pi 3 board full; 2. Micro USB cable; 3. 8 GB Micro SD card; 4. USB-to-Serial debug module for Raspberry Pi 3 or USB to TTL adapter; 5. Ethernet cable; 6. A PC with Ubuntu Desktop 14.04 LTS, or a virtual machinehostingUbuntu Desktop 14.04 LTS with at least 100 GB of free space; 7. A Micro SD card reader attached to the PC/virtual machine; 8. (Optional) Micro HDMI cable. THE RASPBERRY PI 3 The Raspberry Pi 3 is the successor to the Raspberry Pi 2. It builds upon the Pi 2 by upgrading the Arm cores to Cortex-A53 and addingan onboard single-band 2.4GHz-only wireless chipset. The Raspberry Pi 3 measures the same 85.60mm x 53.98mm x 17mm, with a little overlap for the SD card and connectors that project over the edges. The SoC is a Broadcom BCM2837. This contains a quad-core Cortex-A53 runningat 1.2GHz and a Videocore 4 GPU. Front View WORKPLACE SETUP The setup is divided in two parts:PC setup and board setup.
  • 2. PC SETUP The following operations mustbe done once, to set up the Linux distribution you areusingto be ready for building embedded Linux on the Raspberry Pi 3. Install thefollowingpackages: sudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib build-essential sudo apt-get install chrpath socat libsdl1.2-dev xterm ncurses-dev lzop sudo apt-get install minicom u-boot-tools curl You will need to install the latestversion of python. Type python -–version to check, or usethe following command to download it. sudo apt-get install python Install therepo utility: mkdir ~/bin curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo export PATH=$PATH:~/bin If you areusingGit for the firsttime in your system, you have to set your username and email address as follows: git config --global user.name "username" git config --global user.email “email@example.com” Download the source code of embedded Linux for Raspberry Pi 3: mkdir -p ~/raspberryPi3/sources cd ~/raspberryPi3/sources git clone -b krogoth git://git.yoctoproject.org/poky git clone -b krogoth git://git.openembedded.org/meta-openembedded git clone -b krogoth git://git.yoctoproject.org/meta-raspberrypi NOTE: Be patient, this operation may take several minutes as several megabytes of sourcecode have to be downloaded. It is now time to define a specific network configuration for our lab experiments. For this purpose, let us create the followingdirectory: mkdir ~/raspberryPi3/sources/poky/meta/recipes-core/init-ifupdown/init-ifupdown- 1.0/raspberrypi3
  • 3. In this directory, placea filenamed “interfaces” with the followingcontent: # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) # The loopback interface auto lo iface lo inet loopback # Wireless interfaces iface wlan0 inet dhcp wireless_mode managed wireless_essid any wpa-driver wext wpa-conf /etc/wpa_supplicant.conf iface atml0 inet dhcp # Wired or wireless interfaces auto eth0 iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1 network 192.168.1.0 # Ethernet/RNDIS gadget (g_ether) # ... or on host side, usbnet and random hwaddr iface usb0 inet static address 192.168.7.2 netmask 255.255.255.0 network 192.168.7.0 gateway 192.168.7.1 # Bluetooth networking iface bnep0 inet dhcp Among the other activities,with this file,we set the IP address for the Ethernet device to 192.168.1.2. Configure the environment to build the sourcejustdownloaded for the Raspberry Pi 3 and accept the license agreement: cd ~/raspberryPi3/ source sources/poky/oe-init-build-env rpi-build Using your preferred editor program, edit the file“rpi-build/conf/local.conf”, remove the existing content, and type/paste in the followingcontent, to includethe needed information to build embedded Linux for the Raspberry Pi 3: MACHINE ?= "raspberrypi3" PREFERRED_VERSION_linux-raspberrypi = "4.%" DISTRO_FEATURES_remove = "x11 wayland" DISTRO_FEATURES_append = " systemd" VIRTUAL-RUNTIME_init_manager = "systemd" ENABLE_UART = "1"
  • 4. Usingyour favoriteeditor program, edit the file “rpi-build/conf/bblayers.conf”, remove the existing content, and type/paste in the followingcontent, to includethe needed information to build embedded Linux for the Raspberry Pi 3 (ensure it is formatted exactly as shown, spaces and missingindents can causeparseerrors): LCONF_VERSION = "6" BBPATH = "${TOPDIR}" BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}" BBFILES ?= "" BBLAYERS ?= " ${BSPDIR}/sources/poky/meta ${BSPDIR}/sources/poky/meta-yocto ${BSPDIR}/sources/poky/meta-yocto-bsp ${BSPDIR}/sources/meta-openembedded/meta-oe ${BSPDIR}/sources/meta-openembedded/meta-multimedia ${BSPDIR}/sources/meta-raspberrypi " Once this operation is completed, the environment is ready for buildingembedded Linux for the Raspberry Pi 3. Ensure you are still in thebuild environment “rpi-build”.The Linux for the Raspberry Pi 3 can now be builtby issuingthefollowingcommand: bitbake rpi-basic-image NOTE: Be patient, this operation may take up to two hours,depending on the PC you areusing,as several megabytes of sourcecodehave to be compiled.If you are compilingtheimageon a virtual machine,this may takeseveral hours. Once the build is completed, an SD card image for booting up the Raspberry Pi 3 can be found in the following path: raspberryPi3/rpi-build/tmp-glibc/deploy/images/raspberrypi3/rpi-basic-image- raspberrypi3.rpi-sdimg The image can be copied to a Micro SD usingsome Linux functionality (assumingtheMicro SD is availableto the PC as /dev/sdN). Alternatively,and more easily,a flash programcould beused. First,run the sudo fdisk -l command to determine which device to flash to (plugin and unplugthe SD card to determine which device itis). For this example, the SD card is under the name “sdc” (this may be different in your environment). Next, ensure that the device is unmounted. This can be done usingthe command: sudo umount /dev/sdc* Once this is done, the followingcommand can be used to copy the image across to the SD card (substituteany folder names and device names to ensure they arerelevant to your specific environment). sudo dd bs=1M if=/home/user/raspberryPi3/rpi-build/tmp- glibc/deploy/images/raspberrypi3/rpi-basic-image-raspberrypi3.rpi-sdimg of=/dev/sdc
  • 5. Note that if not done properly, the image being flashed across to the SD card may causeproblems when attempting to turn on the board. If this is the case, itmay be worth retrying the process again and ensuringthatit is done properly,or use a flash programto automate the process. Whilethe SD card is still connected to the development host, use the followinglines to navigateto the etc folder on the SD card (assumingthedevice has now been mounted). cd /media/user/SD_name/etc – Use the ls command to find the name of the SD card in the user folder. Then, use a terminal text editor to open the shadow file. sudo vi shadow Or sudo gedit shadow Check that there are no characters between the firsttwo colons in the firstline.If there is,remove it so that the firstlinelooks likethis: Root::17728:0:99999:7::: Exit the text editor by entering :x or simply closingthe application! MINICOM SETUP Connect the USB-to-Serial debug module for Raspberry Pi 3 or USB to TTL adapter to J8 on the Raspberry Pi 3 board (pins 8 and 10 are UART0_TX and UART0_RX, which are the lines where the serial consoleof BCM2837 is routed). And configurethe communication parameter to 1152008N1 in your preferred serial terminal emulation program (under Linux uses the device /dev/ttyUSB0 or /dev/ttyUSB1). Once the programming of the Micro SD is completed, we are ready to configure the communication program that we will useto connect to the board: minicom. Issuethe followingcommand to start minicom in setup mode: sudo minicom -s Then, perform the followingsteps: 1. Select “Serial port setup” in the configuration menu; 2. Press A to modify the Serial Device and to set it to “/dev/ttyUSB0”; 3. Press F to set Hardware Flow Control to “No”; 4. Press enter to return to the previous menu; 5. Select “Save setup as dfl”, to savethe setup as default configuration; 6. Select “Exit” from Minicom. Optional: Raspberry Pi 3 Ethernet interfaceis configured to acquirethe IP address via DHCP.In caseyou intend to connect the board with your PC directly, you need to configure the Ethernet connection properly. It is advisable to create a new Ethernet connection on your PC using the following statically assigned IPv4 configuration:
  • 6. IP Address: 192.168.1.1 Netmask: 255.255.255.0 Gateway: 192.168.1.1 BOARD SETUP 1. Insertthe newly written Micro SD into the SD slotof the Raspberry Pi 3; 2. (Optional) connect the Micro HDMI cableto the Raspberry Pi 3 connector; 3. Connect a Micro USB cableto the PC and to the Micro USB connector of the Raspberry Pi 3; 4. Also connect the board with your hostdevice via an ethernet cable. Once the Micro USB cableis connected, the board is powered up. In caseyou connected the Micro HDMI cable,you will seea splash screen on the monitor, and a progression bar indicatingthe bootstrap is running. Once the bootstrap is completed, a new device will beconnected to the PC: /dev/ttyUSB0. The deviceis the virtual serial portthrough which you can access the Raspberry Pi 3, by issuingthefollowingcommand: sudo minicom In caseall previous steps have been completed successfully,you will see the followingmessages appearing on the terminal: Welcome to minicom2.7 OPTIONS: I18n Compiled on Jan 1 2014, 17:13:19. Port /dev/ttyUSB0, 10:22:24 Press CTRL-A Z for help on special keys [ 0.000000] Booting Linux on physical CPU0x0 [ 0.000000] Initializingcgroup subsyscpuset [ 0.000000] Initializingcgroup subsyscpu [ 0.000000] Initializingcgroup subsyscpuacct ...... Poky (Yocto ProjectReference Distro) 2.1.2 raspberrypi3 ttyS0 raspberrypi3 login: You can now login as “root” (no password required). Note:  To open the Minicommenu, press simultaneously ctrl +A and then Z (either l owercaseor uppercase). Optional: Raspberry Pi 3 Ethernet interface is configured to acquirethe IP address via DHCP. In case you intend to connect the board with your PC directly, you need to configure the Ethernet connection properly. It is advisableto create a new Ethernet connection on the Raspberry Pi 3 by editing the file /etc/network/interfaces and to modify the configuration of the network device eth0 as follows: # Wired or wireless interfaces auto eth0
  • 7. iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.255 Test to see if the network is configured properly using: ifconfig You should seean address of 19.168.1.2; however, if this is not the case,you can run the commands: ifdown eth0 ifup eth0 After runningthese two commands, itshould be configured properly. If you are usinga Linux virtual machine as the host, for the sole-purpose of communicating between the board and the host,you may need to switch the “Network” settings to a “Bridged Adapter” and selectthe ethernet devicebeing used. Once the PC and the Raspberry Pi 3 are configured, you can test the connection with the followingcommand: ping 192.168.1.1 If the configuration is correct,you will seea message appearingon the terminal similarto the following: root@raspberrypi3:~# ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.54 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.61 ms 64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.98 ms 64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.73 ms POST-LAB PRACTICE In this session,we have builtan initial version of Linux image with Yocto Project. One of the main benefits of using Yocto Projectis that the Linux image can be flexibly customized to accommodate specific usage;the key to manipulateitis by including differentlayers and recipes. There are two files that determine the above feature, conf/local.conf and conf/bblayers.conf;to have a better understandingof these two files and the customization feature of Yocto Project,we shall carry outadditional practice.