Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Codes and command lines
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "To get the preceding kernel messages, we can use both the dmesg
and tail -f /var/log/kern.log
commands."
A block of code is set as follows:
CREATE TABLE status ( n VARCHAR(64) NOT NULL, v VARCHAR(64) NOT NULL, PRIMARY KEY (n) ) ENGINE=MEMORY;
Any command line input or output given on the BeagleBone Black is written as follows:
root@beaglebone:~# make CFLAGS="-Wall -O2" helloworldcc -Wall -O2 helloworld.c -o helloworld
Any command line input or output given on my host computer as a non-privileged user is written as follows:
$ tail -f /var/log/kern.log
When I need to give a command as a privileged user (root) on my host computer the command line input or output is then written as follows:
# /etc/init.d/apache2 restart
The reader should notice that all the privileged commands can also be executed by a normal user by using the sudo
command with the form:
$ sudo <command>
So, the preceding command can be executed by a normal user as:
$ sudo /etc/init.d/apache2 restart
Kernel and logging messages
On several GNU/Linux distributions, a kernel message has the following form:
Oct 27 10:41:56 hulk kernel: [46692.664196] usb 2-1.1: new high-speed USB device number 12 using ehci-pci
This is a quite long line for this book, which is why the characters from the beginning of the line until the point where the real information begins are dropped. So, in the preceding example, the line's output will be reported as follows:
usb 2-1.1: new high-speed USB device number 12 using ehci-pci
Long outputs and repeated or less important lines in a terminal are dropped by replacing them with three dots (...), as follows:
output begin output line 1 output line 2 ... output line 10 output end
File modifications
When the reader should modify a text file, I'm going to use the unified context diff
format, since this is a very efficient and compact way to represent a text modification. This format can be obtained by using the diff
command with the -u
option argument.
As a simple example, let's consider the following text in file1.old
:
This is first line This is the second line This is the third line ... ... This is the last line
Suppose we have to modify the third line, as highlighted in the following snippet:
This is first line
This is the second line
This is the new third line modified by me
...
...
This is the last line
The reader can easily understand that reporting the whole file each time for a simple modification is quite obscure and space consuming; however, by using the unified context diff
format, the preceding modification can be written as follows:
$ diff -u file1.old file1.new --- file1.old 2015-03-23 14:49:04.354377460 +0100 +++ file1.new 2015-03-23 14:51:57.450373836 +0100 @@ -1,6 +1,6 @@ This is first line This is the second line -This is the third line +This is the new third line modified by me ... ... This is the last line
Now, the modification is very clear and is written in a compact form! It starts with a two-line header where the original file is preceded by ---
and the new file is preceded by +++
, then there are one or more changed hunks that contain the line differences in the file. The preceding example has just one hunk where the unchanged lines are preceded by a space character, while the lines to be added are preceded by a +
character, and the lines to be removed are preceded by a –
character.
Serial and network connections
In this book, I'm going to mainly use two different kinds of connections to interact with the BeagleBone Black board: the serial console and an SSH terminal. The former can be accessed directly via the connector J1 (never used in this book) or via an emulated way over the same USB connection that is used to power up the board, while the latter can be used via the the USB connection above or via an Ethernet connection.
The serial console is mainly used to manage the system from the command line. It's largely used to monitor the system, especially to take the kernel messages under control.
An SSH terminal is quite similar to the serial console even if is not exactly the same (for example, kernel messages do not automatically appear on a terminal); however, it can be used in the same manner as a serial console to give commands and edit files from the command line.
In the following chapters, I'm going to use a terminal on the serial console or over an SSH connection indifferently to give most of the commands and configuration settings needed to implement all the prototypes explained in this book.
To get access to the USB emulated serial console from your host PC, you can use the minicon
command as follows:
$ minicom -o -D /dev/ttyACM0
Note that on some systems, you may need root privileges to get access to the /dev/ttyACM0
device (in this case, you can use the sudo
command to override it).
As stated above, to get access to the SSH terminal, you can use the emulated Ethernet connection over the same USB cable that was used for the serial console. In fact, if your host PC is well configured, when you plug in the USB cable to power up your BeagleBone Black board, after a while, you should see a new cable connection with the IP address 192.168.7.1
. Then, you can use this new connection to get access to your BeagleBone Black by using the following command:
$ ssh root@192.168.7.2
The last available communication channel is the Ethernet connection. It is used mainly to download files from the host PC or the Internet, and it can be established by connecting an Ethernet cable to the BeagleBone Black's Ethernet port and then configuring the port according to your LAN settings.
However, it's quite important to point out that you can also get connected to the Internet by using the emulated Ethernet connection that was presented before. In fact, by using the following commands on the host PC (obviously GNU/Linux based), you'll be able to use it as a router, allowing your BeagleBone Black board to surf the Internet as if it was connected to its real Ethernet port:
# iptables --table nat --append POSTROUTING --out- interface eth1 -j MASQUERADE # iptables --append FORWARD --in-interface eth4 -j ACCEPT # echo 1 >> /proc/sys/net/ipv4/ip_forward
Then, on the BeagleBone Black, we should set the gateway through the USB cable by using the following command:
root@beaglebone:~# route add default gw 192.168.7.1
Note that the eth1
device is the preferred Internet connection on my host system, while the eth4
device is the BeagleBone Black's device as viewed on my host system so you have to modify the command accordingly in order order to suite your needs.
Other conventions
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.