Search by Tags

Embedded Linux Sample Code

 

Compare with Revision




Subscribe for this article updates

Some Embedded Linux sample code can be found in the Samples folder of our file download server:

Samples

For a cross toolchain see [Build U-Boot and Linux Kernel from Source Code]](da46258c-27ab-11e1-8146-0021cc5d255c)

GTK+ Example

A make file project which compiles the scribble-simple.c from http://developer.gnome.org/gtk-tutorial .

Download gtk_scribble_V2.zip from our Samples page.

Makefile.ExtToolchain_Rootfs is a makefile suitable for use with an external cross toolchain and the rootfs contained in our image.
Set OECORE_TARGET_SYSROOT and CROSS_COMPILE to your needs.

Makefile.OE_Sysroot is a makefile suitable if you have built openembedded yourself. It uses the OpenEmbedded built cross toolchain, headers and target libraries.
Set OECORE_NATIVE_SYSROOT, OECORE_TARGET_SYSROOT and CROSS_COMPILE to your needs.

Make a symlink 'Makefile' pointed to the flavour you want to use. e.g.

ln -s Makefile.ExtToolchain_Rootfs Makefile

To use it from within eclipse:

In the Project Explorer:
- right click and chose import
- General/Existing Projects into Workspace
- Browse for the archive file gtk_scribble.zip
- Finish

In the Make Targets View you get make targets to compile for ARM and for x86.
'all' for x86 Linux,
'all.arm' for the Colibri T20.

To use it from the command line:

unzip the archive
for x86 Linux:

make CROSS_COMPILE=  all

for Colibri T20:

make all

OpenGL ES Samples

NVIDIA OpenGL ES 2.0 Samples

(for NVIDIA Vibrante based V1.x BSPs)

Sample programs from NVIDIA, download nvsamples from our Samples page.
Check nvsamples/make/nvdefs.mk for settings of paths, the following need probably adjustments
NV_TOPDIR
ROOTFS_LIB_DIR
CROSSBIN

ARM's OpenGL ES 1.1 and 2.0 emulator

While searching for some OpenGL ES samples and only getting Android/iOS hits I finally wanted to implement something on my own and while doing that I found ARM's OpenGL ES 1.1 and 2.0 emulator for Linux/Windows (http://www.malideveloper.com/developer-resources/tools/opengl-es-11-emulator.php). Note that on the Tegra no emulation is required at all as NVIDIA's L4T R15 supports both OpenGL ES 1.1 and 2.0 natively. Trying that emulator I discovered that it actually ships with plenty sample code even for X as well. So I gave this a try:

First extract emulator downloaded from above URL:

user@host:~$ tar xzvf ~/Downloads/OpenGL_ES_Emulator_1.3.1.8377_Linux.tar.gz

OpenGL ES 1.1

Please note that our NVIDIA Vibrante based V1.x BSPs do not support OpenGL ES 1.1. Only the newer NVIDIA L4T R15 and later based V2.x BSPs do support OpenGL ES 1.1.

Change into the OpenGL ES 1.1 simple application example folder:

user@host:~$ cd ARM/Mali_Developer_Tools/OpenGL_ES_Emulator_1.3.1/examples/OpenGLES_11/simpApp11/

Modify the Makefile to use the ARM cross-compiler:

user@host:~/ARM/Mali_Developer_Tools/OpenGL_ES_Emulator_1.3.1/examples/OpenGLES_11/simpApp11$ vi Makefile

CC = ~/arm-2009q3/bin/arm-none-linux-gnueabi-gcc

Compile the sample (just ignore warnings about potential incompatible GLESv1_CM and/or libEGL found):

user@host:~/ARM/Mali_Developer_Tools/OpenGL_ES_Emulator_1.3.1/examples/OpenGLES_11/simpApp11$ make

Copy compiled sample to the targets root file system and start the OpenGL ES 1.1 sample application:

root@colibri-t20:~# ./simpApp11                                                 
Native Display createdCreated native window.                                    
EGLContext = 0x4e7a40c4

OpenGL ES 2.0

OpenGL ES 2.0 is supported both on our NVIDIA Vibrante based V1.x BSPs as well as on the newer NVIDIA L4T R15 and later based V2.x BSPs.

Change into the OpenGL ES 2.0 simple application example folder:

user@host:~$ cd ARM/Mali_Developer_Tools/OpenGL_ES_Emulator_1.3.1/examples/OpenGLES_20/cube/

Modify the Makefile to use the ARM cross-compiler:

user@host:~/ARM/Mali_Developer_Tools/OpenGL_ES_Emulator_1.3.1/examples/OpenGLES_20/cube$ vi Makefile

CC = ~/arm-2009q3/bin/arm-none-linux-gnueabi-gcc

Add the math library to the linker options:

LIBS     = -lX11 -lGLESv2 -lEGL -lm

And replace gcc by $(CC) to actually use above specified cross-compiler:

cube:
    $(CC) -o cube $(SOURCES) -I$(KHRONOS_HEADERS) -I$(INCLUDES) $(LIBPATHS) $(LIBS)

Compile the sample (just ignore warnings about potential incompatible GLESv1_CM and/or libEGL found):

user@host:~/ARM/Mali_Developer_Tools/OpenGL_ES_Emulator_1.3.1/examples/OpenGLES_20/cube$ make

Copy compiled sample including shader files to the targets root file system and start the OpenGL ES 2.0 cube application:

root@colibri-t20:~# ./cube                                                      

NXP/Freescale's i.MX6 Graphics SDK

NXP/Freescale provides a GPU SDK. We will build the samples from it for use on top of X11.

Download the gpu_sdk_v1.00.tar.gz tarball from NXP/Freescale's website. (Look for the Snippets section) Software & Tools
Additionally we need an oe-core build for the development headers and cross-compiler: OpenEmbedded (core)

Create a directory and extract the tarball.

cd
mkdir gpu_sdk_v1.00
cd gpu_sdk_v1.00
tar xf ../gpu_sdk_v1.00.tar.gz

We're going to build the samples contained in the subdirectory 'Samples'.

The makefiles create executables for the softfp float ABI which is incompatible with our images. Thus change the CFLAGS in all makefiles to allow setting the ABI from the outside and also pass this information in the link step.

cd; cd gpu_sdk_v1.00/Samples
find . -name "Makefile*" -exec sed -i 's/softfp/\$\(FLOATABI\)/' {} \;
find . -name "Makefile*" -exec sed -i 's/\-lstdc/\$\(CFLAGS_TUT\) -lstdc/' {} \;

Use the toplevel makefiles to set the cross-compiler, float ABI and sysroot directory (Adjust the paths to your system). Add the following three lines to the top of gpu_sdk_v1.00/Samples/GLES1.1/Makefile.x11 and gpu_sdk_v1.00/Samples/GLES2.0/Makefile.x11:

export CROSS_COMPILE = /home/krm/oe-core/build/out-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-
export FLOATABI = hard
export ROOTFS = /home/krm/oe-disk/oe-core/build/out-glibc/sysroots/colibri-imx6

OpenGL ES 1.1

The toplevel makefile references two unavailable subprojects 18_VertexBufferObjects and 19_Beizer. Remove them from the SUB_PROJECTS variable.

Build the examples as follows:

cd; cd gpu_sdk_v1.00/Samples/GLES1.1
make -f Makefile.x11
make -f Makefile.x11 install

The executables can be found in gpu_sdk_v1.00/Samples/GLES1.1/bin/GLES11_x11/ ready for copying to your module.

OpenGL ES 2.0

The sample 05_PrecompiledShader does not link because the linker can not directly link the function glProgramBinaryOES. Adding the following to Samples/GLES2.0/05_PrecompiledShader/PrecompiledShader.c fixes this:

@@ -99,3 +99,5 @@ static GLuint LoadProgram(const char *programName)
        long flength;M
+       // get the glProgramBinaryOES function
+       PFNGLPROGRAMBINARYOESPROC glProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC)eglGetProcAddress("glProgramBinaryOES");
  
        // create the program objectM

Build the examples as follows:

cd; cd gpu_sdk_v1.00/Samples/GLES2.0
make -f Makefile.x11
make -f Makefile.x11 install

The executables can be found in gpu_sdk_v1.00/Samples/GLES2.0/bin/GLES20_x11/ ready for copying to your module.

OpenVG

The makefiles for the OpenVG samples are missing. Add them with the following patch:

cd; cd gpu_sdk_v1.00/Samples
wget http://docs.toradex.com/102840-openvg_x11_patch.bz2
tar xf 102840-openvg_x11_patch.bz2
patch -p 1 < openvg_x11.patch

Change the paths according to your system in the toplevel OpenVG/Makefile.x11.

Build the examples as follows:

cd; cd gpu_sdk_v1.00/Samples/OpenVG
make -f Makefile.x11
make -f Makefile.x11 install

The executables can be found in gpu_sdk_v1.00/Samples/OpenVG/bin/OpenVG_x11/ ready for copying to your module.