ECE597 Lab 1 Wiring and Running the Beagle

From eLinux.org
Revision as of 09:11, 13 March 2010 by Yoder (talk | contribs)
Jump to: navigation, search

Here's what you need to do to get your Beagle running for the first time.

  • Write you Beagle as shown
  • Insert the SD card
  • Plug in the 5V power

Hookem.png

  • Login and look around. Left-click on the background to get a menu.

Beagle starting x-term.png

  • Try starting an XTerm.
  • Try some basic Linux commands
ls, cd, less
mplayer
ls /proc
ls /sys

<code?/proc and /sys are files that map to the hardware.

  • Try
cd /sys/class/leds
ls
cd beagleboard::usr0
ls
cat trigger
echo none > trigger
echo 1 > brightness

cat trigger tells you what options you can set trigger to. Try some of them. Explore /sys and /proc is see what else you can find.

Homework

There are many interesting programs already compiled for the Beagle that aren't on the SD card we gave you. New applications can be easily installed using the opkg package manager. When you are back home and connected to the network try:

opkg list | less
opkg install gcc

The first command lists the packages you can install. The second command installs the gcc C compiler. With a compiler installed you can take your favorite C program and compile and run it on the Beagle. Here is the embedded version of Hello World as presented in The Embedded Linux Primer.

#include <stdio.h>

int bss_var;        /* Uninitialized global variable */

int data_var = 1;   /* Initialized global variable */

int main(int argc, char **argv)
{
  void *stack_var;            /* Local variable on the stack */
  
  stack_var = (void *)main;   /* Don't let the compiler */
                              /* optimize it out */

  printf("Hello, World! Main is executing at %p\n", stack_var);
  printf("This address (%p) is in our stack frame\n", &stack_var);

  /* bss section contains uninitialized data */
  printf("This address (%p) is in our bss section\n", &bss_var);

  /* data section contains initializated data */
  printf("This address (%p) is in our data section\n", &data_var);

  return 0;
}
Compile and run it
<pre>
yoder@beagleboard:~$ gcc helloBeagle.c
yoder@beagleboard:~$ ./a.out
Hello, World! Main is executing at 0x8380
This address (0xbefa1cf4) is in our stack frame
This address (0x10670) is in our bss section
This address (0x10668) is in our data section

This is a program I use what talking about the address spaces on the Beagle and virtual memory.

Try some of your own C programs. See how well they run. If you come up with something interesting, add them to the wiki.