beaglebone and linux

11
Page 1 BeagleBone and Linux 2012 BeagleBone and Linux July 19, 2012

Upload: do-minh-quoc

Post on 18-Apr-2015

408 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: BeagleBone and Linux

Page 1

BeagleBone and Linux 2012

BeagleBone and Linux

July 19, 2012

Page 2: BeagleBone and Linux

Page 2

BeagleBone and Linux 2012

1. BeagleBone Overview

The BeagleBone is the latest addition to the BeagleBoard.org family and like its’

predecessors, is designed to address the Open Source Community, early adopters, and anyone

interested in a low cost ARM Cortex A8 based processor. It has been equipped with a minimum

set of features to allow the user to experience the power of the processor and is not intended as a

full development platform as many of the features and interfaces supplied by the processor are

not accessible from the BeagleBone via onboard support of some interfaces.

Figure 1. BeagleBone Features

Page 3: BeagleBone and Linux

Page 3

BeagleBone and Linux 2012

Figure 2. System Block Diagram

Page 4: BeagleBone and Linux

Page 4

BeagleBone and Linux 2012

Figure 3. Processor Block Diagram

NOTE: Design information can be found on the SD card that ships with board. We can also

download the files from http://circuitco.com/support/index.php?title=BeagleBone

Page 5: BeagleBone and Linux

Page 5

BeagleBone and Linux 2012

2. Board Setup

1) Insert the SD card into the SD card connector

2) Plug the USB cable into the BeagleBone

3) Plug the other end of the USB cable into the PC USB port.

4) The power LED D1 should be on

5) After a few seconds, USER0 and USER1 LED should start flashing

6) After 10 seconds or so, the board should show up as a mass storage device on your PC

7) Open the new drive and click on the Readme.html file.

8) The file should open in your browser.

9) Follow the instructions on the HTML page.

Create SD card with provided image:

To initialize your card under Windows, do the following steps:

1. Download and install Ubuntu's Win32DiskImager (also known as the win32-image-writer).

2. Download and install 7-zip compression software.

3. Download the SD card image:

- Angstrom distribution: http://www.angstrom-distribution.org/demo/beaglebone/

- Ubuntu distribution: https://wiki.ubuntu.com/ARM/OMAP

4. Download the HP Formatting tool from http://www.pcworld.com/downloads/file/fid,64963-

page,1/description.html

5. Decompress the verification image file using 7-zip.

6. Insert the SD card writer/reader into the Windows machine.

7. Insert 4GB SD card into the reader/writer.

8. If this a fresh card, one that has never been used, skip to step 11.

9. Run the HPFormatter tool and format the SD card for FAT or FAT32 in order to remove the

second partition from the card.

10. Close the HPFormatter tool when done.

11. Start the Win32DiskImager.

12. Select the decompressed image file and correct SD card location. Click on 'Write'.

14. After the image writing is done, eject the SD card.

Page 6: BeagleBone and Linux

Page 6

BeagleBone and Linux 2012

NOTE: If you are trying to reuse an SD card that has already been used under the above process,

you will need to reformat the card to erase the second partition. Otherwise Windows will only

see the FAT32 partition.

3. TI - Linux EZSDK for BeagleBone

3.1 Linux Software Stack

Figure 4. Linux Software Stack

3.2 Download and Install:

Download Linux EZSDK for BeagleBone from

http://software-dl.ti.com/dsps/dsps_public_sw/am_bu/sdk/AM335xSDK/latest/index_FDS.html

Run the SDK Installer by double clicking on it within Linux host PC. Alternatively, bring up a

terminal window and change directories to the where the software is downloaded and run the

SDK Installer with the following command:

[prompt]:~$ ./ti-sdk-amxx-evm-x.x.x.x-Linux-x86-Install

Page 7: BeagleBone and Linux

Page 7

BeagleBone and Linux 2012

NOTE: You must source the environment-setup script to run commands below correctly. This is

as simple as:

$ sudo source linux-devkit/environment-setup

To know if the environment setup script has been sourced in your current shell, the shell prompt

will be changed to contain the [linux-devkit]: prefix in the command prompt.

3.3 Bootloaders – Build and Install

We strongly recommend the use of separate object directories when building. This is done with

O= parameter to make. This value can either be relative to your current directory or a full path.

Cleaning the Sources

If you did not use a separate object directory:

$ make CROSS_COMPILE=arm-arago-linux-gnueabi- ARCH=arm distclean

If you used 'O=am335x' as your object directory:

$ rm -rf ./am335x

Compiling MLO and u-boot

$ make O=object-directory CROSS_COMPILE=arm-arago-linux-gnueabi- ARCH=arm

am335x_evm

3.4 Build, Configure and Install the Linux Kernel

3.4.1 Prepare to build

In order to build the Linux kernel you will need a cross compiler installed on your system which

can generate object code for the ARM core in your Sitara device. In the case of the AMSDK this

compiler can be found inside of the SDK in the <sdk install dir>/linux-devkit/bin directory. If

you have not already done so you should add this compiler to your path by doing:

Page 8: BeagleBone and Linux

Page 8

BeagleBone and Linux 2012

export PATH="<sdk install dir>/linux-devkit/bin:$PATH"

Where <sdk install dir> should be replaced with the directory where the SDK was installed.

It is important that when using the GCC toolchain provided with the SDK or stand alone from TI

that you do NOT source the environment-setup file included with the toolchain when building

the kernel. Doing so will cause the compilation of host side components within the kernel tree to

fail.

The following commands are intended to be run from the root of the kernel tree unless otherwise

specified. The root of the kernel tree is the top-level directory and can be identified by looking

for the "MAINTAINERS" file.

3.4.2 Cleaning the Kernel Sources

The command to clean the kernel is:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- mrproper

For user's who are building the kernel from within the AMSDK you can also use the Makefile at

the root of the SDK installation at <sdk install dir>/Makefile to clean the kernel by doing:

cd <sdk install dir>

make linux_clean

3.4.3 Configuring the Kernel

Before compiling the Linux kernel it needs to be configured to select what components will

become part of the kernel image, which components will be built as dynamic modules, and

which components will be left out all together. This is done using the Linux kernel configuration

system.

Using Default Configurations

It is often easiest to start with a base default configuration and then customize it for you use case

if needed. In the Linux kernel a command of the form:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- <config>

Page 9: BeagleBone and Linux

Page 9

BeagleBone and Linux 2012

will look in the arch/arm/configs directory for the configuration file (<config> in the line above)

use that file to set default configuration options. The table below shows the default configuration

files for various platforms.

NOTE: The configuration file used to build the pre-built binaries found in the SDK can be found

in the arch/arm/configs directory as tisdk_<device>_config and can be used in place of the

config file given below to reproduce the SDK Linux kernel configuration settings. The

differences between these files generally revolve around enabing/disabling additional modules

for expected SDK use cases.

Device SDK config PSP config

AM335x/Beaglebone tisdk_am335x-evm_defconfig am335x_evm_defconfig

AM37x tisdk_am37x-evm_defconfig omap3_evm_defconfig

AM3517 tisdk_am3517-evm_defconfig am3517_evm_defconfig

Beagleboard tisdk_beagleboard_defconfig omap3_beagle_defconfig

AM180x tisdk_am180x-evm_defconfig da850_omapl138_defconfig

For example, to build the default PSP configuration for the AM335x the command would be:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- am335x_evm_defconfig

To build the SDK configuration for the AM335x the command would be:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- tisdk_am335x-

evm_defconfig

After the configuration step has run the full configuration file is saved to the root of the kernel

tree as .config. Any further configuration changes are based on this file until it is cleanup up by

doing a kernel clean as mentioned above.

Customizing the Configuration

When you want to customize the kernel configuration the easiest way is to use the built in kernel

configuration systems. Two of the most popular configuration systems are:

- menuconfig: an ncurses based configuration utility

- xconfig: a Qt based graphical configuration utility.

Page 10: BeagleBone and Linux

Page 10

BeagleBone and Linux 2012

NOTE: On some systems in order to use xconfig you may need to install the libqt3-mt-dev

package. For example on Ubuntu 10.04 this can be done using the command

sudo apt-get install libqt3-mt-dev

To invoke the kernel configuration you simply use a command like:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- <config type>

i.e. for menuconfig the command would look like

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- menuconfig

Whereas for xconfig the command would look like

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- xconfig

Once the configuration window is open you can then select which kernel components should be

included in the build. Exiting the configuration will save your selections to a file in the root of

the kernel tree called .config.

3.4.4 Compiling the Kernel

Once the kernel has been configured it must be compiled to generate the bootable kernel image

as well as any dynamic kernel modules that were selected. For u-boot the kernel should be built

with a u-boot header that the u-boot program can read. This is easily accomplished by using the

uImage build target in the kernel. In order to build the uImage target the command is:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- uImage

This will result in a kernel image file being created in the arch/arm/boot/ directory called

uImage. This file can be used by u-boot to boot your Sitara device.

If you selected any components of the kernel to be built as dynamic modules you must issue an

additional command to compile those modules. The command is:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- modules

Page 11: BeagleBone and Linux

Page 11

BeagleBone and Linux 2012

This will result in .ko (kernel object) files being placed in the kernel tree. These .ko files are the

dynamic kernel modules. The next section will cover how to install these modules.

NOTE: For user's who are building the kernel from within the AMSDK you can also use the

Makefile at the root of the SDK installation at <sdk install dir>/Makefile to configure the kernel

with the default SDK configuration and compile the uImage and kernel modules by doing:

cd <sdk install dir>

make linux

3.4.5 Installing the Kernel

Once the Linux kernel and modules have been compiled they must be installed. In the case of the

kernel image this can be installed by copying the uImage file to the location where it is going to

be read from. For example when using TFTP boot this may be the /tftpboot directory, whereas

when booting from SD card this may be the first partition of the SD card.

To install the kernel modules you use another make command similar to the others, but with an

additional parameter which give the base location where the modules should be installed. This

command will create a directory tree from that location like lib/modules/<kernel version> which

will contain the dynamic modules corresponding to this version of the kernel. The base location

should usually be the root of your target file system. The general format of the command is:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- INSTALL_MOD_PATH=<path

to root of file system> modules_install

For example if you are installing the modules to an NFS share located at /home/user/targetNFS

you would do:

make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi-

INSTALL_MOD_PATH=/home/user/targetNFS modules_install

NOTE: For user's who are building the kernel from within the AMSDK you can also use the

Makefile at the root of the SDK installation at <sdk install dir>/Makefile to install the kernel

modules into the location pointed to by DESTDIR in your Rules.make file by doing:

cd <sdk install dir>

make linux_install