Difference between revisions of "Building Apps and Kernels"

From WebOS Internals
Jump to navigation Jump to search
(Fixed link to the How_To_Build_Xecutah)
 
(15 intermediate revisions by 4 users not shown)
Line 2: Line 2:
  
 
== '''Setup''' ==
 
== '''Setup''' ==
depending on what you're building you might need some of the prereq's from here.
+
Depending on what you're building you might need some of the prereq's from [[WebOS Internals PDK]] installation.
http://www.webos-internals.org/wiki/WebOS_Internals_PDK
 
  
 
Create the directory structure for the source:
 
Create the directory structure for the source:
Line 37: Line 36:
 
Package up UberKernel.
 
Package up UberKernel.
 
<pre>
 
<pre>
cd /srv/preware/kernels/uber-kernel-touchpad
+
cd /srv/preware/build/kernels/uber-kernel-touchpad
 
make package
 
make package
 
</pre>
 
</pre>
 +
 +
Testing your kernel
 +
you will find your kernel in
 +
<pre>
 +
build/src-3.0.2-22/linux-2.6.35/arch/arm/boot
 +
</pre>
 +
you can boot it using memboot. to do this do the following <br>
 +
1) turn off the touchpad<br>
 +
2) connect it to your machine<br>
 +
3) press the Volume Up key and power on the device, you should see a giant USB logo on the device<br>
 +
4) novacom boot mem:// < uImage
 +
 +
== '''Libraries''' ==
 +
Once you have your toolchain configured and you have had a chance to get your SB2 cross compiler working with one of the applications above, you might be looking to add libraries or compile libraries and "stage" them into your cross compiler /usr directory. The /usr directory in your toolchain is the directory that contains the lib files and include files necessary to compile libraries or applications against the toolchain. Since the TouchPad is targeting armv7, we have to compile libraries to target the armv7 architecture and stage them into the architecture's root /usr/lib and include directories.
 +
 +
Don't worry, once you get the hang of it, it's pretty straight forward. You just have to trust that this is the fastest and easiest way to pull down code, compile dependencies, and get the ball rolling on your own library or application.
 +
 +
You might also be interested in using additional libraries in your projects. Your best bet for getting the latest source is to look in the locations of the existing libraries used in other packages. 
 +
 +
It's a good idea to first take a look at the directories for all of the common libraries that were downloaded when you setup your toolchain:
 +
<pre>
 +
cd /srv/preware/cross-compile/packages/common/x
 +
ls
 +
</pre>
 +
Each directory here is a separate library. The library folder contains a Makefile, which links to other Makefiles.  The Makefiles download source for the library and compile the various dependencies of the library that kicked off the make command. 
 +
 +
Let's start by simply compiling libxcb and take a look at the different pieces involved in getting the library to compile properly.  If you crack open the Makefile for libxcb:
 +
<pre>
 +
nano /srv/preware/cross-compile/packages/common/x/libxcb/Makefile
 +
</pre>
 +
 +
You should see the name of the project, the version number for libxcb (this is used to download the package from the tar) and the SRC_BZ2 url.  The SRC_BZ2 url can be changed to point to the package that you're looking to compile.
 +
<pre>
 +
NAME = libxcb
 +
VERSION = 1.7
 +
 +
DEPENDS = x/xcbproto        \
 +
                  x/libpthread-stubs \
 +
                  x/xau
 +
 +
SRC_BZ2 = http://xcb.freedesktop.org/dist/${NAME}-${VERSION}.tar.bz2
 +
...
 +
</pre>
 +
 +
For most instances, the above text is the only text you will need to modify (for most cases where you need to compile your own library folder in the packages directory).  The process is pretty straight forward from here. Keep in mind, any folder you list in the DEPENDS section will need to exist and have a Makefile containing similar logic as the makefile you created for the library that lists it in its Makefile depends section.
 +
 +
If you want to test out compiling and staging (installing the library into your target architecture /usr/lib and include folder like we mention above), just type:
 +
<pre>
 +
make stage package
 +
</pre>
 +
'''Note:''' some packages might need additional work to compile (e.g. compiling libxcb requires that you create the full path for the documentation before it will install properly /usr/local/share/doc/libxcb/tutorial).
 +
 +
Now when you want to configure your own application or library outside of the toolchain or preware directory (such as a library or application you downloaded or are using Eclipse to develop) simply cd into that source directory and enter the toolchain:
 +
<pre>
 +
sb2 -M /srv/preware/cross-compile/staging/mapping-armv7
 +
./configure
 +
make all
 +
</pre>
 +
or
 +
<pre>
 +
cmake .
 +
make
 +
</pre>
 +
 +
Making and packaging builds the goods, packages them for you in a neat little ipkg and places the code where it needs to go for other apps and libraries to link to.  That's about all there is to it!
  
 
== '''Notes''' ==
 
== '''Notes''' ==
  
if you already have the correct version of the toolchain installed for the device you are targeting you can symlink it to the proper location
+
If you already have the correct version of the toolchain installed for the device you are targeting you can symlink it to the proper location (e.g. the touchpad needs the Sourcery G++ Lite 2009q1-203 toolchain).
ie the touchpad needs the Sourcery G++ Lite 2009q1-203 toolchain. if it is already installed you can symlink it to
+
 
 +
If it is already installed you can symlink it into the build area:
 +
 
 
<pre>
 
<pre>
 
cd toolchain/cs09q1armel
 
cd toolchain/cs09q1armel
Line 51: Line 117:
 
ln -s <location of toolchain> arm-2009q1
 
ln -s <location of toolchain> arm-2009q1
 
</pre>
 
</pre>
 +
 +
== '''Samples''' ==
 +
 +
After you run through the WIDK and setup your toolchain, take a look at [[How_To_Build_Xecutah]] for details on building X Server and the process for building an application.

Latest revision as of 23:29, 23 September 2011

If you are looking for instructions for building apps and kernels for WebOS, you have come to the right place. If you have not run through the WebOS Internals PDK wiki page, you should start there.

Setup

Depending on what you're building you might need some of the prereq's from WebOS Internals PDK installation.

Create the directory structure for the source:

sudo mkdir -p /srv/preware
cd /srv/preware
sudo chmod 777 .

Pull down the app source with git.

git clone git://git.webos-internals.org/preware/build.git

After you have the source, you need to build the toolchain — this can take some time or if you already have the toolchain installed, please see below

cd build
make toolchain

Please see the notes if you already have the correct toolchain installed and do not want to download it again.

Apps

Package up preware.

cd /srv/preware/build/apps/preware
make package

Kernels

Package up UberKernel.

cd /srv/preware/build/kernels/uber-kernel-touchpad
make package

Testing your kernel you will find your kernel in

build/src-3.0.2-22/linux-2.6.35/arch/arm/boot

you can boot it using memboot. to do this do the following
1) turn off the touchpad
2) connect it to your machine
3) press the Volume Up key and power on the device, you should see a giant USB logo on the device
4) novacom boot mem:// < uImage

Libraries

Once you have your toolchain configured and you have had a chance to get your SB2 cross compiler working with one of the applications above, you might be looking to add libraries or compile libraries and "stage" them into your cross compiler /usr directory. The /usr directory in your toolchain is the directory that contains the lib files and include files necessary to compile libraries or applications against the toolchain. Since the TouchPad is targeting armv7, we have to compile libraries to target the armv7 architecture and stage them into the architecture's root /usr/lib and include directories.

Don't worry, once you get the hang of it, it's pretty straight forward. You just have to trust that this is the fastest and easiest way to pull down code, compile dependencies, and get the ball rolling on your own library or application.

You might also be interested in using additional libraries in your projects. Your best bet for getting the latest source is to look in the locations of the existing libraries used in other packages.

It's a good idea to first take a look at the directories for all of the common libraries that were downloaded when you setup your toolchain:

cd /srv/preware/cross-compile/packages/common/x
ls

Each directory here is a separate library. The library folder contains a Makefile, which links to other Makefiles. The Makefiles download source for the library and compile the various dependencies of the library that kicked off the make command.

Let's start by simply compiling libxcb and take a look at the different pieces involved in getting the library to compile properly. If you crack open the Makefile for libxcb:

nano /srv/preware/cross-compile/packages/common/x/libxcb/Makefile

You should see the name of the project, the version number for libxcb (this is used to download the package from the tar) and the SRC_BZ2 url. The SRC_BZ2 url can be changed to point to the package that you're looking to compile.

NAME = libxcb
VERSION = 1.7

DEPENDS = x/xcbproto         \
                  x/libpthread-stubs \
                  x/xau

SRC_BZ2 = http://xcb.freedesktop.org/dist/${NAME}-${VERSION}.tar.bz2
...

For most instances, the above text is the only text you will need to modify (for most cases where you need to compile your own library folder in the packages directory). The process is pretty straight forward from here. Keep in mind, any folder you list in the DEPENDS section will need to exist and have a Makefile containing similar logic as the makefile you created for the library that lists it in its Makefile depends section.

If you want to test out compiling and staging (installing the library into your target architecture /usr/lib and include folder like we mention above), just type:

make stage package

Note: some packages might need additional work to compile (e.g. compiling libxcb requires that you create the full path for the documentation before it will install properly /usr/local/share/doc/libxcb/tutorial).

Now when you want to configure your own application or library outside of the toolchain or preware directory (such as a library or application you downloaded or are using Eclipse to develop) simply cd into that source directory and enter the toolchain:

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7
./configure
make all

or

cmake .
make

Making and packaging builds the goods, packages them for you in a neat little ipkg and places the code where it needs to go for other apps and libraries to link to. That's about all there is to it!

Notes

If you already have the correct version of the toolchain installed for the device you are targeting you can symlink it to the proper location (e.g. the touchpad needs the Sourcery G++ Lite 2009q1-203 toolchain).

If it is already installed you can symlink it into the build area:

cd toolchain/cs09q1armel
mkdir build
cd build
ln -s <location of toolchain> arm-2009q1

Samples

After you run through the WIDK and setup your toolchain, take a look at How_To_Build_Xecutah for details on building X Server and the process for building an application.