Appendix 5. Setting Up the Embedded Linux Development Environment

In this appendix, we present the procedure for setting up a Linux host development environment to build the example applications from Chapter 12 for embedded Linux residing on the Arcom board. These GNU tools are different from the GNU tools covered in Appendix B.

Depending on the version of the Arcom board you ordered, embedded Linux comes preinstalled in flash memory. When the Arcom board is powered up, RedBoot executes a boot script to execute the Linux kernel residing in flash.

Tip

The procedure in this appendix is based on the Arcom board instructions found in the Arcom Embedded Linux Technical Manual, which is included in the development kit CD-ROM. Refer to the section titled “Installing the AEL Host Environment,” where AEL stands for Arcom Embedded Linux.

The install procedure has been verified on a Celeron computer running Linux Fedora Core 5. If you encounter problems installing the host build environment, we suggest you contact Arcom directly. For technical support in Europe, send email to . For technical support in the United States, send email to .

Linux Build Environment Setup

To ensure that applications you develop run properly on the Arcom board, you must compile and link your source code using the libraries present on the target board’s version of Linux.

Tip

Building applications for Linux using a Windows (and Cygwin) host is beyond the scope of this book. The Internet is replete with how-to instructions for configuring Cygwin build environments.

The Linux distribution running on the host system must be compatible with the Linux Standard Base (LSB) version 1.3 (see http://www.linuxbase.org for more information). We used Fedora Core 5 (http://fedora.redhat.com) on our host development system.

Warning

You will need permission to become superuser (root) to perform the installation procedure successfully.

The following commands are executed from a terminal window with the Arcom board development CD-ROM inserted in the drive.

  1. Mount the CD-ROM where the Arcom board development CD-ROM is located using the following command:

  2. # mount /dev/cdrom /mnt
  3. Run the install script:

  4. # perl /mnt/install
  5. At this point, the installation program outputs a message similar to the following:

  6. Host Distribution Type: Red Hat Linux
    Host Environment: /mnt/host
    Packages: /mnt/packages
    Temporary Storage: /tmp
    
    Checking for Linux Standard Base version 1
      lsb_release -- /usr/bin/lsb_release
      lsb_release reports version Q:core-3.0-ia32:core-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch' -- LSB version >= 2 detected
    
    Use of uninitialized value in pattern match (m//) at /mnt/install line 700.
        core-3.0-ia32
        core-3.0-noarch
        graphics-3.0-ia32
        graphics-3.0-noarch
    
    Several LSB components were found, however none of them appear to provide
    version 1 as required.
    
    If possible it is recommended that a host distribution that natively
    supports LSB version 1 is used, there may be an additional package for LSB
    version 1 support availble for the host distribution. However if your
    distribution only supports a different LSB version it may be possible to
    install using these LSB components however this is not guaranteed.
    
    Shall I attempt to install using this version of LSB? [y/N]y
    
    
    Checking for the LSB dynamic linker
      /lib/ld-lsb.so.1 -- ok
    
    Checking for required binaries in $PATH...
      rpm -- /bin/rpm
    
    Checking for required packages...
      lsb version 1.3 -- 3.0-9.2 ok (did not check version)
      rpm -- 4.4.2-15.2 ok
      rpm-build -- 4.4.2-15.2 ok
      wget -- 1.10.2-3.2.1 ok
    
    Checking available disk space
      /opt/arcom -- 4095 megabytes -- ok
      /tmp -- 4095 megabytes -- ok
      /var/tmp -- 4095 megabytes -- ok
    
    Installation of the Arcom Embedded Linux Host Environment will now begin.
    This may take some time to complete.
    
    Installing Base Arcom Embedded Linux Host Environment
    
    Checking that a simple LSB application can be executed
      ok
    
    Preparing Arcom Embedded Linux Host Environment
    
    Installing Arcom Embedded Linux Host Environment
  7. Once the installation is successfully completed, the following message will be output:

  8. Installation complete.
    
    You should add Q/opt/arcom/bin'' to your PATH. You can do this for the
    current login session with the following command:
            export PATH=/opt/arcom/bin:$PATH
    or you can modify the path for all login sessions for this user by adding
    the same statement to Q$HOME/.bash_profile'' or for all users by adding it
    to Q/etc/profile''.
  9. In order to ensure the path is set correctly each time you open a terminal shell, edit the $HOME/.bash_profile file (where $HOME is specific to your environment) by adding the following line:

  10.                   PATH=/opt/arcom/bin:$PATH ; export PATH

The directory /opt/arcom should be populated with various files. The executable files, such as arm-linux-gcc, are contained under the /opt/arcom/bin directory.

To test that you installed the tools correctly and set up the path properly, close the existing terminal window. Open a new terminal window (to ensure the path is set properly) and enter the command:

# arm-linux-gcc -v

You should see a response similar to the following:

Reading specs from /opt/arcom/lib/gcc/arm-linux/3.4.4/specs
Configured with: ../gcc-3.4.4/configure --with-gxx-include-dir=/opt/arcom/arm-linux/include/c++/3.4.4 --target=arm-linux --host=i386-pc-linux-gnu --enable-cross-toolchain --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --prefix=/opt/arcom --mandir=/opt/arcom/share/man --with-slibdir=/opt/arcom/arm-linux/lib --enable-symvers=gnu --enable-c99 --enable-long-long --program-prefix=arm-linux- --program-suffix=-3.4 --with-headers=/opt/arcom/arm-linux/include --without-newlib --enable-threads --enable-shared --enable-__cxa_atexit --with-arch=armv4t --with-float=hard
Thread model: posix
gcc version 3.4.4

Embedded Linux Examples

The Linux examples are contained in the book’s compressed file under the ProgEmbSys/chapter12 directory. If you followed the installation instructions in Appendix B, the files should be located in the proper directory. Otherwise, these files can be extracted into any directory, but we recommend installing the example source code files in the /opt/ProgEmbSys/chapter12 directory.

Tip

We do not cover building the Linux kernel that runs on the Arcom board. For additional information about building the Linux kernel, refer to the Arcom Embedded Linux Technical Manual.

Building the Linux Examples

To build any of the Chapter 12 Linux examples, proceed as follows.

  1. Open a terminal window and change to the directory of the examples you would like to build. For instance, to build the blink example, enter the command:

  2. # cd /opt/ProgEmbSys/chapter12/blink
  3. Then build the example code using the makefile with the following command:

  4. # make
  5. This should produce two executable files named blink and blinkdbg.

Downloading and Running the Linux Examples

To download the examples and run them on the Arcom board, first boot embedded Linux. Make sure you connect the Arcom board’s COM1 port to your PC’s serial port and are running a console program, such as minicom.

Tip

Ensure you have the Arcom board’s Ethernet board connected to the main board. Then connect an Ethernet cable between the Arcom board and your computer (either directly or via a hub). The instructions for connecting the Ethernet board are shown in the Arcom VIPER Technical Manual and the VIPER-I/O Technical Manual.

The following instructions also assume that a Dynamic Host Configuration Protocol (DHCP) server is present on your network. This allows the Arcom board to obtain a dynamic Internet Protocol (IP) address. If you do not have a DHCP server on your network, refer to the Arcom Embedded Linux Technical Manual section on statically configuring a network interface.

Power up the Arcom board and allow RedBoot to run the Linux boot script. You should see output similar to the following once Linux begins its boot process:

RedBoot> clock -l 27 -m 2 -n 10
mem:99.532MHz run:199.065MHz turbo:199.065MHz. cccr 0x141 (L=27 M=1 N=1.0)
RedBoot> mount -t jffs2 -f filesystem
RedBoot> load -r -b %{FREEMEMLO} %{kernel}
Using default protocol (file)
Raw file loaded 0x00400000-0x004d4c3f, assumed entry at 0x00400000
RedBoot> exec -c %{cmdline}
Using base address 0x00400000 and length 0x000d4c40
Uncompressing Linux............

After Linux has successfully booted, you should see the Arcom board’s login prompt:

viper login:

You can then download and run the Linux examples by following these steps:

  1. At the board’s login prompt, enter root for the login name and arcom for the password. The Arcom board should then output a command prompt:

  2. root@viper root#
  3. Next, download the program from the host computer to the Arcom board. For instance, to download the blink example, open a terminal window on the host Linux system and enter the following commands:

  4. # cd /opt/ProgEmbSys/chapter12/blink
    # scp blink 192.168.0.4:/tmp/blink
  5. You may need to replace the IP address (192.168.0.4) with the IP address appropriate for your Arcom board.

  6. You are then prompted to enter the password for the board as shown here:

  7. [email protected]'s password:
  8. Enter the password arcom. The download will take place and the terminal should show output similar to the following:

  9. blink                                100% 3620     3.5KB/s   00:00
  10. To execute the downloaded program, enter the following at the Arcom board’s prompt:

  11. root@viper root# /tmp/blink
  12. If the program downloaded properly, the green LED should be toggling.

The Linux examples take control over the Arcom board and are intended to run forever. In order to terminate a specific example, press Ctrl-C at the console; the Arcom board should abort the program and return to the VIPER-Lite prompt.

Debugging Embedded Linux Examples

This section gets you started with remote debugging; additional instructions for debugging embedded Linux applications are contained in the Arcom Embedded Linux Technical Manual. The embedded Linux debug procedure takes place over the Ethernet connection rather than via a serial connection.

After you have downloaded a program, as previously shown, you can start a gdb debug session. The following example shows how to debug the blink example.

  1. Start the debug session by launching the gdb server process on the Arcom board using the command:

  2. root@viper root# gdbserver :9000 /tmp/blink "blink"
  3. The Arcom board will then wait for you to connect your host to the target, indicating that it is waiting by outputting the following message:

  4. Process /tmp/blink created; pid = 706
    Listening on port 9000
  5. Begin a gdb session on the host by entering the following in a terminal window:

  6. # arm-linux-gdb blinkdbg
  7. You should then see the familiar gdb prompt (as we covered in Chapter 5), similar to the following:

  8. GNU gdb 6.1.1
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "--host=i386-redhat-linux-gnu --target=arm-linux"...
    (gdb)
  9. Connect the host to the target by entering the following command at the host’s gdb prompt:

  10. (gdb) target remote 192.168.0.4:9000
  11. You need to change the IP address (192.168.0.4) to the IP address appropriate for your Arcom board.

  12. Upon successful connection, the Arcom board outputs the following message (the following IP address may be different for your host):

  13. Remote debugging from host 192.168.0.3

You are now ready to start debugging! For additional information about debugging with gdb, refer to Chapter 5.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
107.23.157.16