Skip to content

Users Guide Development

Beat Küng edited this page Jul 16, 2012 · 3 revisions

Table of Contents

Overview

Compiling an application on the leanXcam is a three step process:

  1. The software framework oscar needs to be compiled so the application can access the hardware of the camera over simple functions.
  2. The application is compiled and links to the framework library.
  3. The binary must be moved to the board to be executed.
It helps a lot to have some experience in linux and c-programming. Then you'll have a much easier access to the fun part of the camera. If not, start by learning how to use linux and how to write a c programm under linux. There are tons of howtos and documents about this on the net.

Work with the following description in the leanXcam SDK in the VirtualBox.

Oscar Software Framework

The framework is a static library and contains the abstraction of the hardware for applications running on the leanXcam platform. To improve testability the framework can be compiled for a host linux machine as well, allowing for the same code to be tested in a PC environment before making the step to the DSP. The framework consists of a number of modules, each of which represents a part of the hardware or a certain block of functionality.

For detailed documentation of the framework, see Oscar Software Framework Manual. Additionally, there exists a detailed function reference in HTML form, that can be compiled automatically from the doxygen-annotated code.

Compiling the framework

Before compiling the framework, the target platform needs to be configured:

 $ cd oscar
 ~/oscar$ make config
 Select the board you are using (INDXCAM/LEANXCAM), [LEANXCAM]: LEANXCAM
 Enter the path to the firmware you want to use, leave blank to disable cpld functionality []: 
 No firmware has been configured.

The default options of the dialogue are correct for the leanXcam, so you can just press enter twice. The path to the firmware is only required for the indXcam and thus not relevant. Now we are ready for compilation.

The framework features a number of make targets:

  • all: Compile for host and target platform
  • host: Compile for host platform only.
  • target: Compile for target platform only.
  • target_sim: Compile for the target platform, but do not use the hardware on the board directly but rather emulate it like on the DSP. For example, the camera module will not capture pictures from the CMOS sensor, but rather read them from the file system. This can be used to test your algorithm on a series of test images on the host and on the target and to compare the result.
  • clean: Delete all temporary binary files.
  • distclean: Same as clean, but also clears the configuration.
 ~/oscar$ make all

This compilation might take a minute and the compiler will echo plenty of messages in the console. The results of a compilation are the static libraries in staging/lib and the required header files for the application in staging/inc.

Your application

Application template

If you start a new application, it is recommended to download the web-view-cpp application, rename it and start working with this as your starting point. Web-view-cpp is a simple demonstration application that shows a live image stream in the browser. A more detailed description how to build, debug, run and adapt web-view-cpp you find on the associated page Web-View-Cpp.

uCLinux

Compiling the uCLinux sources

The sources the uCLinux leanXcam is shipped with are available from the Download page. A compiled image ready for use can also be found on the Download page. If you want to compile the uClinux sources yourself, the following must be done:

  • Download the most recent version of the uCLinux source code for leanXcam and extract it in your development environment.
  • Make sure you have installed the matching version of the cross-compiler toolchain, which can also be found on the Download page.
  • Depending on the age of your leanXcam SDK, some packages might be missing in your installation, which could lead to compiler errors. Make sure everything is installed by executing:
 uclinux$ sudo apt-get install liblzo2-dev g++
  • Enter the extracted uclinux directory, and apply the default configuration for leanXcam.
For uCLinux verision 1.x this can be done with:
 uclinux$ make SCS/BF537_LEANXCAM_config

and for uCLinux version 2.0 and higher with:

 uclinux$ make SCS/BF537_LEANXCAM_defconfig
  • Compile everything necessary for the uCLinux boot image:
 uclinux$ make
  • The resulting boot image can be found under images/uImage upon successful compilation

Changing the default uCLinux configuration

Since we can not put everything into the 4 MB on-board boot-flash, leanXcam is shipped with what we think is a sensible configuration that works for most applications out of the box. If your task at hand requires additional drivers or software packages, you can of course adapt this configuration to your requirements.

This section gives a brief quickstart on how to do this. For more detailed information, visit the official site of the uCLinux on Blackfin project documentation.

  • Download the most recent version of the uCLinux source code for leanXcam and extract it in your development environment.
  • Enter the extracted uclinux directory, and make a test compilation with the default configuration to ensure everything is working.
  • Adapt the default configuration to incorporate your new package. Configuration of uCLinux is split into kernel configuration an user-space configuration. If you need to add a hardware-driver or similar, this is a candidate for the kernel-configuration, if you would like to add a program that does not directly interface with hardware, you will find it in the user-space configuration. To change the kernel configuration, type:
 uclinux$ make linux_menuconfig

Consequently, to change the user-space configuration, use:

 uclinux$ make config_menuconfig

Both will bring up a selection dialog which allows you to tick on or off the different options.

  • After making your changes, recompile uImage with 'make', and, if successful, try it out on your camera. Since overwriting your operating system without knowing if it is going to work is risky, it might be wise to try out the new image by making the camera boot over TFTP from your host PC.
  • If you would ever like to go back to the default configuration, simply discard all configuration changes and reconfigure the target board:
 uclinux$ make distclean
 uclinux$ make SCS/BF537_LEANXCAM_config

Toolchain

A toolchain is needed to compile an application, the operation system or the bootloader. It contains a cross-compiler and everything else needed to generate the binaries, that can be executed on the leanXcam.
Depending on which uClinux you are using, you need a different version of the toolchain. You find the corresponding toolchain on the Downloads page. By default, the SDK contains already the matching toolchain and as long as you are not updating uClinux you don't need to care about the toolchain.

Update

Once you downloaded the toolchain archive, you have to extract it to the right folder. For every following command you need root rights, so type

 $ sudo su

and enter the password oscar to become root. Before you extract the archive you should backup your old toolchain by moving it:

 # mv /opt/toolchain-bin /opt/toolchain-bin_old

or you just remove it:

 # rm -rf /opt/toolchain-bin

Now you can extract the archive to the folder /opt:

 # tar -xvvzf toolchain-bin_<i><version></i>.tar.gz -C /opt

That's it. But before you recompile your applications, you should run a make clean to be sure that everything will be compiled with the new toolchain.

If you ever decide to use the old toolchain again, you can type:

 # mv /opt/toolchain-bin /opt/toolchain-bin_new
 # mv /opt/toolchain-bin_old /opt/toolchain-bin
Clone this wiki locally