Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning BeagleBone

You're reading from  Learning BeagleBone

Product type Book
Published in Dec 2014
Publisher
ISBN-13 9781783982905
Pages 206 pages
Edition 1st Edition
Languages
Author (1):
Hunyue Yau Hunyue Yau
Profile icon Hunyue Yau

Table of Contents (18) Chapters

Learning BeagleBone
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Introducing the Beagle Boards Software in the BeagleBone Building an LED Flasher Refining the LED Flasher Connecting the BeagleBone to Mobile Devices Recovering from the Mistakes Interfacing with the BeagleBone Advanced Software Topics Expansion Boards and Options The Boot Process Terms and Definitions
Index

Chapter 4. Refining the LED Flasher

In the previous chapter, we completed the classic introductory exercises that started the LED flasher project. Building upon those exercises, we will improve the LED flasher and turn the BeagleBone into an LED flasher project.

In this chapter, we will cover the following topics:

  • The I2C bus

  • Accessing the I2C devices

  • Adding a user interface to our flasher

  • Starting the flasher when powered on

Just as before, no additional hardware is needed; the BeagleBone board alone will suffice. The difference between the BBB and BBW will be discussed. There are slight differences between the BeagleBone boards that run Debian and Angström.

The I2C bus


A common way to connect the peripherals that do not require a very high communication speed to an embedded system is using a protocol known as I2C.

Note

Inter-Integrated Circuit (I2C) is a protocol originally developed by Philips Semiconductors (now NXP). I2C is also known as IIC.

I2C is a simple serial protocol that uses two signal wires. In the simplest configuration used by many setups, there is one master and one or more slave devices. For the BeagleBone, the master will be the BeagleBone and the slave devices will be peripherals. Each slave device (we will shorten to just device) is uniquely identified by a 7-bit address.

Note

Later versions of the I2C protocol support an extended address that allows more devices on a single bus.

The serial bus, as originally defined, runs at 100 kHz; however, later revisions allowed 400 kHz and faster variations enabled all the devices on the bus to operate at the higher speed. So, a worst case speed figure is 100 kBits per second shared between...

The I2C devices on the BeagleBone


The BeagleBone by itself contains a few I2C devices as seen in the preceding exercise. These include the power management controller and an I2C EEPROM.

Note

Electrically Erasable Programmable Read Only Memory (EEPROM) is a type of nonvolatile memory often used to store configuration or identification information.

The PMIC generates the voltages applied to the SoC and other bits of hardware. A mistake in programming this device can cause permanent damage to the BeagleBone. We will avoid this device in our exercises.

The I2C EEPROM on the BeagleBone is used to identify the board to the software. This EEPROM can be written into but there are many safeguards in place to prevent corruption of the contents. A corrupt EEPROM can be repaired with software. This is the device we will use for our exercises.

Exercise 2

In this exercise, we will read the identification EEPROM on the BeagleBone and display it. From the preceding exercise, we know that the EEPROM is at the...

User interfaces


Until this point, the LED flasher has hardcoded parameters. It would be very nice to control the flashing with a user interface. The BeagleBone is naturally connected to the network. So far, all our accesses have been via a network over the USB interface. The BeagleBone also has an Ethernet interface that we have not used yet. Our next few exercises are to add an interface to change the behavior of the LED flasher.

Note

Up to this point, all our exercises were done using shell scripting. The BeagleBone ships with another language, BoneScript, which allows the BeagleBone to be programmed using a language similar to JavaScript. Shell script was chosen for exercises over BoneScript to provide an easier path for programmers who are not web oriented to transition to the BeagleBone environment.

Design

Our user interface will be accessed through a web browser. The web pages will be served using the same web server shipped with the BeagleBone that BoneScript uses. Communications between...

Loading your first web page


Once you have successfully loaded the default web page, you can move on to loading your first BeagleBone web page. Go to the browser and enter http://192.168.7.2/hello.html. The following page will appear:

Troubleshooting the BeagleBone web server access

If you see an Error 404 message, check whether you have used the correct location for your system software. The location to place the web page differs for Angström and Debian. The locations provided are correct at the time of writing this book. If the location appears to be correct, verify the permission on the file, as follows (it should be universally readable):

root@beaglebone:/usr/share/bone101# ls -l /usr/share/bone101/hello.html
-rw-r--r-- 1 root root 50 Jan  1 00:10 /usr/share/bone101/hello.html
root@beaglebone:/usr/share/bone101#

If the permissions differ, use chmod to change the permissions, as follows:

$ chmod 644 /usr/share/bone101/hello.html

Now that you have loaded your first web page, note the place...

Summary


In this chapter, you learned a few more features of the BeagleBone. Using what we wrote in Chapter 3, Building an LED Flasher, we improved it and turned our BeagleBone into a network-controlled LED flasher product.

We learned how to scan for I2C devices using low-level commands such as i2cdetect, read an I2C EEPROM using the Linux kernel I2C EEPROM driver, and served a web page from the BeagleBone. We also built a backend manager to support a user interface, used BoneScript to provide a web-based user interface to speak to the backend manager, and configured the Linux system software's systemd manager to automatically start our flasher manager on boot up.

While the LED flasher is an exercise to learn the BeagleBone, the same concepts are applicable in building other things with the BeagleBone. The important thing to remember is security considerations. They have been purposely left out to simplify the exercises. Many simple devices can be added to the BeagleBone using I2C. We will...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Learning BeagleBone
Published in: Dec 2014 Publisher: ISBN-13: 9781783982905
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}