Difference between revisions of "BeagleBoardAndOpenEmbeddedGit"

From eLinux.org
Jump to: navigation, search
 
(Booting)
 
(76 intermediate revisions by 26 users not shown)
Line 1: Line 1:
This guide briefly describes the steps that need to be taken in order to create an OpenEmbedded based image for the BeagleBoard.
+
[[Category: Linux]]
It was created while performing an install on ubuntu804jeos (a minimal console only vmware appliance). This guide differs in that the official GettingStarted uses monotone while we will be using git. The second difference is that this guide only focuses on running on Ubuntu and developing for beagle.
+
[[Category: OMAP]]
 +
[[Category:Development Boards]]
 +
[[Category: BeagleBoard]]
  
The first step is to get a working Open Embedded installation. This can seam a daunting task at first but the rewards are great so here we go. This guide tried to be self containing we therefore will not push you to use google or Read the other Manuals.
 
  
=== Prerequisites ===
+
== NOTE: ==
OE tries to be as self supporting as possible. OE will booth compile the cross compiler and the tools needed to compile a whole system. Still some dependencies are to be met using the "host" system. During the install we will be able to run almost all the commands as normal user but right now we will install the basic set of packages that are required to make OE to be happy.
+
These instructions are unofficial and their correctness can not be guaranteed. The '''only''' site that has up-to-date official instructions is [http://www.angstrom-distribution.org/building-angstrom http://www.angstrom-distribution.org/building-angstrom]. Before making any support requests be sure that you have followed those instructions precisely.
  
Host tools to install:
+
== Build instructions ==
sudo apt-get install ccache sed wget cvs subversion git-core coreutils unzip texi2html texinfo libsdl1.2-dev docbook-utils gawk help2man diffstat gtk-doc-tools  file
 
  
 +
Please refer to  [http://www.angstrom-distribution.org/building-angstrom http://www.angstrom-distribution.org/building-angstrom], putting instructions into this wiki only brings confusion and bugs. If you find the angstrom instructions to be lacking in some way, please that that up with angstrom people instead of putting stuff in here.
  
OE and many tools and scripts that are used contain bashisms. We therefore want to change the default  "/bin/sh" to point to bash.
+
== Preparing the system for booting ==
ln -s /bin/sh
+
The output of the bitbake command will ultimately be found under the $OE_HOME/angstrom-dev/deploy/glibc/images/beagleboard. In there you can find at least two interesting files:
sudo dpkg-reconfigure dash
+
* console-image-beagleboard.tar.bz2
#and select no
+
* uImage-beagleboard.bin
ln -s /bin/sh
 
  
An other change need need to perform as root is to change some default settings of the kernel.
+
The console image represents of a full and self-contained file system, *including* a kernel. The uImage is a Linux kernel image suitable for loading by the U-boot bootloader.  
sudo vi /etc/sysctl.conf
 
vm.vdso_enabled = 0
 
vm.mmap_min_addr = 0
 
  
Run
+
We are going to use the U-boot that is already provided in the NAND flash of the beagleboard as that one already support the MMC can load kernel images from a fat file system.
sudo sysctl  -p
+
What we will do is to format a SD-card to hold both a fat and an ext2 file system. We will put the kernel in the fat file system as U-boot failed to load the image from a ext2 file system. We will unpack the console-image under the ext2 file system.
  
== The effective install ==
+
===Create partitions and format the SD-card ===
We are going install the OpenEmbedded system under the user's home directory in a directory called "oe". We will need about 10 gig of free disk space. Under that
+
We usually create two partitions, the first one has a FAT partition type and the second one a Linux file system type . We then format them and put content on them.
we will be putting the different components of the OE system. Those components are Bitbake, the OpenEmbedded meta-data and The beagle configuration.
+
We are not going the describe the formating other then briefly because it just if to easy to format the wrong partition. There are a few reasons for having a first partition as FAT but his is not the scope of this document ( Think of U-boot, windows , mass-storage ). Instruction for formatting the SD-card correctly can be found at: [http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat Boot Disk Format]
The Bitbake task executor will be put under "opt".  The OpenEmbedded meta-data ( Bitbake recipes ), classes ( Bitbake extentions) and configuration (machine and arch setup)  will be located under the "org.openembedded.dev" directory. The BeagleBoard configuration will be placed under "org.beagleboard.dev" directory.
 
  
=== OpenEmbedded and Bitbake install ===
+
Here is the output of the fdisk -l  command after creating the new partitions.
This part really is not that difficult after all.
+
Disk /dev/mmcblk0: 2032 MB, 2032664576 bytes
 +
1 heads, 16 sectors/track, 248128 cylinders
 +
Units = cylinders of 16 * 512 = 8192 bytes
 +
Disk identifier: 0x2f3dffc4
  
Create the "oe" diirectory
+
        Device Boot      Start        End      Blocks  Id  System
  mkdir -p $HOME/oe
+
  /dev/mmcblk0p1              2      12209      97664    b  W95 FAT32
  export OE_HOME=$HOME/oe
+
  /dev/mmcblk0p2          12210      248128    1887352  83  Linux
  
Install Bitbake
+
We now format the file systems ext2 file system under /mnt. Some system will perform a automount of the newly created file system. Try to disable this automount feature if possible (it is not easy) or use gparted
  mkdir -p $OE_HOME/opt
+
  mkfs.vfat /dev/mmcblk0p1
cd  $OE_HOME/opt
+
  mkfs.ext2 /dev/mmcblk0p2
  svn co svn://svn.berlios.de/bitbake/branches/bitbake-1.8/ bitbake
 
  
Install the OpenEmbedded meta-data using git
+
Mount the ext2 file system and unpack the archive. Do not forget the -C option.
  cd $OE_HOME
+
  mount /dev/mmcblk0p2 /mnt
git clone git://git.openembedded.net/org.openembedded.dev/
+
  tar xvjpf $OE_HOME/angstrom-dev/deploy/glibc/images/beagleboard/console-image-beagleboard.tar.bz2 -C /mnt
 +
  umount /mnt
  
=== Creating the BeagleBoard configuration and profile ===
+
Mount the fat file system and copy the kernel image to there.
We now need to tweak OpenEmbedded to fit our Beagle needs. We create a profile script that
+
  mount /dev/mmcblk0p1  /mnt
we can run whenever we feel like playing with beagle. This script will perform a few tasks.
+
  cp system/angstrom/deploy/glibc/images/beagleboard/uImage-beagleboard.bin /mnt/uImage
It will add bitbake to our PATH so we can run the bitbake command from anywhere. It will
+
  umount /mnt
then export the BBPATH and BBFILES this tels bitbake where to find it's meta-data. BBPATH
 
Will booth point to our own org.beagleboard.dev files and org.openembedded.dev.
 
  
But first we create a local.conf containing the most important choices we need to make. Change at least the MACHINE to beagleboard. Comment the BBFILES variable
+
== Booting ==
as we will defines then in our profile script do select angstrom-2008.1 as distro. Remove the last line after that
+
We can put the SD-card in the beagleboard and wait for the U-boot prompt. The kernel we compiled only gave serial output if we first ran the coninfo command we therefore type coninfo and ask U-Boot to initialise
 +
the mmc stack. After that we set the kernel command line telling what the console is and where our root file system is located. We then load the image from the fat file system into memory and boot the kernel
  
  mkdir -p $OE_HOME/org.beagleboard.dev/beagleboard/conf
+
coninfo
  cp org.openembedded.dev/conf/local.conf.sample $OE_HOME/org.beagleboard.dev/beagleboard/conf/local.conf
+
  mmc init
  vi $OE_HOME/org.beagleboard.dev/beagleboard/conf/local.conf
+
  setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1'
  27c27
+
fatload mmc 0:1 0x80300000 uImage
  < BBFILES := "${@bb.fatal('Edit your conf/local.conf: BBFILES')}"
+
saveenv
  ---
+
bootm 0x80300000
  > #BBFILES := "${@bb.fatal('Edit your conf/local.conf: BBFILES')}"
 
  62a63
 
  > TMPDIR = "${OE_HOME}/system/angstrom"
 
  67a69
 
  > MACHINE = "beagleboard"
 
  87a90
 
  > DISTRO = "angstrom-2008.1"
 
  97c100
 
  < # ENABLE_BINARY_LOCALE_GENERATION = "0"
 
  ---
 
  > ENABLE_BINARY_LOCALE_GENERATION = "0"
 
  157c160
 
  < REMOVE_THIS_LINE:="${@bb.fatal('Read the comments in your conf/local.conf')}"
 
  ---
 
  > # REMOVE_THIS_LINE:="${@bb.fatal('Read the comments in your conf/local.conf')}"
 
  
Now we create our profile
+
===One very important note:=== 
  
  cd $OE_HOME
+
It's important to have an X-Loader on your Beagleboard that uses the uBoot on the SD Card that goes with the Angstrom uImage. The B5 Beagleboards do not appear to come with such an X-Loader / U-Boot combination (i.e. the B5 standard uBoot will lead to problems with the sound driver and other things, but will not tell you that it's creating a problem).
  mkdir -p org.beagleboard.dev/beagleboard
 
  vi org.beagleboard.dev/beagleboard/profile.sh
 
  #================content=======================
 
  export OE_HOME=$HOME/oe
 
  export MY_OE_CONF="beagleboard"
 
  export BBPATH=$OE_HOME/org.beagleboard.dev/:$OE_HOME/org.beagleboard.dev/$MY_OE_CONF:$OE_HOME/org.openembedded.dev
 
  export BBFILES="$OE_HOME/org.openembedded.dev/packages/*/*.bb"
 
  export PATH=$OE_HOME/opt/bitbake/bin:$PATH
 
  if [ "$PS1" ]; then
 
    if [ "$BASH" ]; then
 
      export PS1="\[\033[01;32m\]OE:$MY_OE_CONF\[\033[00m\] ${PS1}"
 
    fi
 
  fi
 
  #============end content=======================
 
  chmod +x  org.beagleboard.dev/beagleboard/profile.sh
 
  
== Running ==
+
The fix is to load a new X-Loader which will in turn automatically load the uBoot from the SD card, which again in turn will load the uImage properly.
We now have finished the installation. If everything goes well we can now create images for the beagleboard
 
  
  source org.beagleboard.dev/beagleboard/profile.sh
+
So you likely will have to upgrade the X-LoaderHere's what to do:
  bitbake console-image
 
  
If this goes well your computer will be compiling for a long time. Perhaps you should have started with a minimal-image.
+
  * Make an SD Card with the [http://www.angstrom-distribution.org/demo/beagleboard Angstrom Demo files].  See the [http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat Beagleboard Wiki Page] for more info on making the SD Card.
Either way now it a good time to make changes to this document!
+
  * Put the SD Card in the Beagle, and boot up to the U-Boot Prompt.
 +
  * Do the first six instructions in the [http://code.google.com/p/beagleboard/wiki/BeagleNANDFlashing Flashing Commands with U-Boot] section. 
 +
  * Reboot the Beagle to see that the new X-Loader is properly loaded.
 +
 
 +
This will update the X-Loader to a newer version that will automatically load uBoot from the SD card, and then load uImage from the SD card, rather than always using the uBoot in the Beagleboard NAND.
 +
 
 +
===Setting the video resolution:===
 +
 
 +
The Angstrom kernels since 2.6.27 have used "DSS2", which is a candidate for replacing the OMAP framebuffer driver in the mainline Linux kernel.  It provides greater flexibility for support of the S-Video port on the BeagleBoard and more monitor resolutions than previous mainline kernels.  Documentation for the driver is in the kernel source at [Documentation/arm/OMAP/DSS http://groups.google.com/group/beagleboard/msg/4c64b2c614622053].
 +
 
 +
Below is one example:
 +
 
 +
setenv bootargs console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootwait omap-dss.def_disp=lcd omapfb.video_mode=640x480MR-16@60
 +
 
 +
== Using the OpenEmbedded Environment ==
 +
 
 +
If you have not used bitbake / OpenEmbedded before, a helpful example for creating packages that can be installed on a beagle linux install (such as the one created above) can be found at [http://www.gumstix.net/Software/view/Build-system-overview/Hello-world-tutorial/111.html Hello World Tutorial for Gumstix].
 +
 
 +
See also Open Embedded User's Manual (these links point to nightly builds of the documentation and so should always be up to date):
 +
* [http://docs.openembedded.org/usermanual/html/ HTML Format]
 +
* [http://docs.openembedded.org/usermanual/usermanual.pdf PDF Format]
 +
and bitbake User's Manual:
 +
* [http://bitbake.berlios.de/manual/ HTML Format]
 +
 
 +
==OpenEmbedded development==
 +
 
 +
See [[BeagleBoardOpenEmbeddedDevelopment|OpenEmbedded development guide]] for one way how to modify and build packages contained within OpenEmbedded (OE) for the BeagleBoard.

Latest revision as of 16:29, 10 December 2009


NOTE:

These instructions are unofficial and their correctness can not be guaranteed. The only site that has up-to-date official instructions is http://www.angstrom-distribution.org/building-angstrom. Before making any support requests be sure that you have followed those instructions precisely.

Build instructions

Please refer to http://www.angstrom-distribution.org/building-angstrom, putting instructions into this wiki only brings confusion and bugs. If you find the angstrom instructions to be lacking in some way, please that that up with angstrom people instead of putting stuff in here.

Preparing the system for booting

The output of the bitbake command will ultimately be found under the $OE_HOME/angstrom-dev/deploy/glibc/images/beagleboard. In there you can find at least two interesting files:

  • console-image-beagleboard.tar.bz2
  • uImage-beagleboard.bin

The console image represents of a full and self-contained file system, *including* a kernel. The uImage is a Linux kernel image suitable for loading by the U-boot bootloader.

We are going to use the U-boot that is already provided in the NAND flash of the beagleboard as that one already support the MMC can load kernel images from a fat file system. What we will do is to format a SD-card to hold both a fat and an ext2 file system. We will put the kernel in the fat file system as U-boot failed to load the image from a ext2 file system. We will unpack the console-image under the ext2 file system.

Create partitions and format the SD-card

We usually create two partitions, the first one has a FAT partition type and the second one a Linux file system type . We then format them and put content on them. We are not going the describe the formating other then briefly because it just if to easy to format the wrong partition. There are a few reasons for having a first partition as FAT but his is not the scope of this document ( Think of U-boot, windows , mass-storage ). Instruction for formatting the SD-card correctly can be found at: Boot Disk Format

Here is the output of the fdisk -l command after creating the new partitions.

Disk /dev/mmcblk0: 2032 MB, 2032664576 bytes
1 heads, 16 sectors/track, 248128 cylinders
Units = cylinders of 16 * 512 = 8192 bytes
Disk identifier: 0x2f3dffc4
        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               2       12209       97664    b  W95 FAT32
/dev/mmcblk0p2           12210      248128     1887352   83  Linux

We now format the file systems ext2 file system under /mnt. Some system will perform a automount of the newly created file system. Try to disable this automount feature if possible (it is not easy) or use gparted

mkfs.vfat /dev/mmcblk0p1
mkfs.ext2 /dev/mmcblk0p2

Mount the ext2 file system and unpack the archive. Do not forget the -C option.

 mount /dev/mmcblk0p2  /mnt
 tar xvjpf $OE_HOME/angstrom-dev/deploy/glibc/images/beagleboard/console-image-beagleboard.tar.bz2 -C /mnt
 umount /mnt

Mount the fat file system and copy the kernel image to there.

 mount /dev/mmcblk0p1  /mnt
 cp system/angstrom/deploy/glibc/images/beagleboard/uImage-beagleboard.bin /mnt/uImage
 umount /mnt

Booting

We can put the SD-card in the beagleboard and wait for the U-boot prompt. The kernel we compiled only gave serial output if we first ran the coninfo command we therefore type coninfo and ask U-Boot to initialise the mmc stack. After that we set the kernel command line telling what the console is and where our root file system is located. We then load the image from the fat file system into memory and boot the kernel

coninfo
mmc init
setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1'
fatload mmc 0:1 0x80300000 uImage
saveenv
bootm 0x80300000

One very important note:

It's important to have an X-Loader on your Beagleboard that uses the uBoot on the SD Card that goes with the Angstrom uImage. The B5 Beagleboards do not appear to come with such an X-Loader / U-Boot combination (i.e. the B5 standard uBoot will lead to problems with the sound driver and other things, but will not tell you that it's creating a problem).

The fix is to load a new X-Loader which will in turn automatically load the uBoot from the SD card, which again in turn will load the uImage properly.

So you likely will have to upgrade the X-Loader. Here's what to do:

 * Make an SD Card with the Angstrom Demo files.  See the Beagleboard Wiki Page for more info on making the SD Card.
 * Put the SD Card in the Beagle, and boot up to the U-Boot Prompt.
 * Do the first six instructions in the Flashing Commands with U-Boot section.  
 * Reboot the Beagle to see that the new X-Loader is properly loaded.

This will update the X-Loader to a newer version that will automatically load uBoot from the SD card, and then load uImage from the SD card, rather than always using the uBoot in the Beagleboard NAND.

Setting the video resolution:

The Angstrom kernels since 2.6.27 have used "DSS2", which is a candidate for replacing the OMAP framebuffer driver in the mainline Linux kernel. It provides greater flexibility for support of the S-Video port on the BeagleBoard and more monitor resolutions than previous mainline kernels. Documentation for the driver is in the kernel source at [Documentation/arm/OMAP/DSS http://groups.google.com/group/beagleboard/msg/4c64b2c614622053].

Below is one example:

setenv bootargs console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootwait omap-dss.def_disp=lcd omapfb.video_mode=640x480MR-16@60

Using the OpenEmbedded Environment

If you have not used bitbake / OpenEmbedded before, a helpful example for creating packages that can be installed on a beagle linux install (such as the one created above) can be found at Hello World Tutorial for Gumstix.

See also Open Embedded User's Manual (these links point to nightly builds of the documentation and so should always be up to date):

and bitbake User's Manual:

OpenEmbedded development

See OpenEmbedded development guide for one way how to modify and build packages contained within OpenEmbedded (OE) for the BeagleBoard.