C Language Development Kit/Application development/Building an application

From OptiWiki

Jump to: navigation, search

All terminals, except the OPH100x, H13, PXxx and OPN200x

When your application is ready to be build, invoke the compiler and linker. The batch file Mxxx.BAT that was built during the installation of the development system can do this for you. (The batch file called MCBG.bat, MCBH.bat, etc. is described in the paragraph 'Batch file that builds the applications'). Be sure that you have specified the correct directories for the compiler and assembler when you installed the development system, otherwise Mxxx.BAT will not work correctly. Mxxx.BAT needs one parameter: the filename of the C source file without the .C extension. So, for example the following command in MS-DOS™ will build the application DEMO.S2 from the C source file DEMO.C.

C:\«path»> MCBW DEMO

Note that the extension .C was not added to the name of the source file (DEMO).

The Mxxx.BAT batch file starts the compiler with as many checks as possible. If you want to change this, you need to modify Mxxx.BAT. For a description of the parameters, see the compiler manual. When the compiler is finished, Mxxx.BAT starts the linker.

The linker is a program that extracts the used routines from the library file, and places your code, together with the start-up code into one file, (with an ".S2" or ".S32" extension) and this file can be downloaded to the terminal using Appload.

The .S2 file is the executable for the PHL and DWT handheld terminals, the .S32 file is the executable for the OPL97xx and DCL153x handheld terminals.

Building for the OPH1004, H13, PXxx and OPN200x

It is (almost) a must to place your source file(s) in a separate directory (e.g. Source). The Makefile will create another directory where the compiler can put temporary files (usually called Obj). So when you start a new project it is best to make a directory structure like this:

<project directory>\
<project directory>\Source

The open source build tools for this terminal provide a very powerfull make utility. A template makefile for this make utility is provided (called Makefile) that you should copy into your project directory. In this directory, you should also copy the linker command file (linker.ld) and the startup code. (startup.o) Next thing you should do, is to copy the header file that contains definitions and function prototypes of the operating system. This file is called lib.h

When you start a new project, you need to change a few things in the makefile:

# Target file name, defines the version and the name of the output file.
TARGET = demo

Change the TARGET definition to set the name of the output file, the 'executable' file that can be installed on the terminal. Do NOT specify the extention (.HEX), since this is automatically added

List C source files here that are part of your project.

# C dependencies are automatically generated.
CSRC = main.c

Change the CSRC definition and list the c-source files that are part of your project. Use a single space to separate the files. (do not use comma's or tabs). The include files that you might use, are added automatically, there is no need to list them here or anywhere else in this file.

The lines below are only for the PX 30

# If you want to add BMP, JPG or GIF files to your application, you can specify them here.
BMPFILE =
JPEGFILE =
GIFFILE =

When you want to add JPG, BMP or GIF pictures to your application, you can specify them here. They will be linked to your application and the start address of the picture is converted as follows: FileName.ext => _binary_Source_FileName_ext_start. The lines above are only for the PX 30

# Project directories
OUT = obj
SRC = Source
EXTRAINCDIRS = Inc

These variables define the various directories of your project, relative to the root of your project (where the makefile is located). When a variable is empty, the project root is used.

OUT: The directory where all kinds of temporary files are stored. This directory MUST exist, or otherwise your project will not be build.
SRC: The directory where your c-source files are located.
EXTRAINCDIRS: The directory/directories where you can place extra include files.

To build your application, call the file 'MAKE' from your project directory.

C:\«project directory»> MAKE

Note: The file MAKE.EXE is located in the installation directory of the WinArm compiler. Normally that would be 'C:\<WinARM\utils\bin\make.exe'. It should not be necessary to call MAKE.EXE with that full path, since that path should already be set in your command prompt.

Building for the OPH1003

Although not really required, it is good practice to place your source file(s) in a separate directory (e.g. Sources) and to make another directory where the compiler can put temporary files (e.g. Obj). So when you start a new project it is best to make a directory structure like this:

<project directory>\
<project directory>\Sources
<project directory>\Obj

The open source build tools for this terminal provide a very powerful make utility. A template makefile for this make utility is provided (called makefile) that you should copy into your project directory. In this directory, you should also copy the linker command file (linker.ld) and the OPH1003 library (libOPH100x.a) Next thing you should do, is to copy two files into your Sources directory: lib.h and tp_info.c The header file contains definitions and function prototypes of the OPH1003 operating system and tp_info.c is a required file, that defines a 16-character wide version. string. It is advised to change this string to an unique version.

When you start a new project, you need to change a few things in the makefile:

  • Line 8/9:
    # Target file name, defines the version and the name of the output file.
    TARGET = demo

    Change the TARGET definition to set the name of the output file, the 'executable' file that can be installed on the OPH1003. Do NOT specify the extension (.HEX), since this is automatically added

  • Line 11/12/13
    # List C source files here that will be compiled using the ARM instruction set.
    # C dependencies are automatically generated.
    CSRC = tp_info.c main.c

    Change the CSRC definition and list the c-source files that are part of your project. Use a single space to separate the files. (do not use comma's or tabs). The include files that you might use, are added automatically, there is no need to list them here or anywhere else in this file.

  • Line 70 .. 74
    # Project directories
    OUT = obj
    SRC = Sources
    ASM = Sources
    EXTRAINCDIRS = Sources/inc

    These variables define the various directories of your project, relative to the root of your project (where the makefile is located). When a variable is empty, the project root is used. :

    OUT: The directory where all kinds of temporary files are stored. This directory MUST exist, or otherwise your project will not be build.
    SRC: The directory where your c-source files are located.
    ASM: The directory where your assembly source files are located.
    EXTRAINCDIRS: The directory/directories where you can place extra include files.
  • To build your application, call the file 'MAKE' from your project directory.

    C:\«project directory»> MAKE
    Note: The file MAKE.EXE is located in the installation directory of the WinArm compiler. Normally that would be 'C:\<WinARM\utils\bin\make.exe'. It should not be necesarry to call MAKE.EXE with that full path, since that path should already be set in your command prompt.
Views
Personal tools