Bare Metal Programming Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Getting Started

bmptk

To start using bmptk you must first get bmptk itself and place it somwehere on your PC. It does not care where, but I'll assume you put it in C:\bmptk.

You can download the bleeding edge code from google code, or get it as a git repository:

git clone https://code.google.com/p/bmptk

Python

The bmptk font and image conversion tools can be used to convert images, fonts, or text, to code. These tools are Python scripts, and use the Pillow library (a Python Imaging Library fork).

Hence to use these tools you must install both Python and (a matching) Pillow, Note that not for all Python versions are ready-made Pillow version can be found. I use Python 3.3.2 (direct link) with the matching Pillow from (direct link).

Multiple Python versions can coexits on your machine. When your Python is not 3.3 or is not installed in it default directory (C:\Python33) the Makefile.local must be copied to Makefile.custom and edited to reflect the directory python is installed in.


Toolchains

Bmptk can generate executables for a number of targets. You need to install only the toolchains for the targets that you are interested in. The supported targets are:

for Windows

To create and run applications for Windows you must install the Orwell DevCpp IDE. Take the MinGW32 version, I used 4.7.2 (direct link).

Bmptk uses only the toolchain (compiler, linker, libraries) of this IDE, not the editor.

This target is not meant to be used to develop full-featured windows applications, but to test-run your code on a Windows platform.

The win target support a graphic screen (bmptk::graphics::target_screen) and a character output (std::cout). Don't expect real-time performance from the win target: your PC will do other things beside running the application.

for Nintendo DS

To create and run applications for the Nintendo DS game console you must install the DevKitARM version of the DevKitPro development environment, and (if you want to test-run on your PC) the DeSmuME emulator. I used the devkitProUpdater 1.5.3 (direct link). DeSmuME is a zip file, which you must unpack to the emulators\desmume subdirectory of your devkitPro installation. I used version 0.9.8 (direct link)

for ARM chips

To create and run applications for ARM chips (including the newer Cortex versions) you must install the MentorGraphics Sourcery CodeBench Lite Edition, EABI release, for ARM. To get this toolchain, you must create an account and log in.


bmptk configuration

Bmptk must be able to find the various tools (Python, compiler tool chain(s)) that it needs. By default bmptk assumes that thall tools are installed in their default locations on drive C. If this is the case for you, you can ignore this section.

When you have installed one or more tools in a different location (or for Python, you used a different version) you must do the following:

The purpose of this is that when you install a new version of bmptk over the old one, your Makefile.custom (which is not present in bmptk) will be preserved.

Depending on the Windows variety you have tools that have a Windows installer can install either in C:\Program Files or in C:\Program Files (x86). The Makefile.local file will take care of this.


Editors

You can use bmptk from the command line, but it is probably easier to use an editor, if only to jump to the source line where the compiler found an error. A number of editors are supported, choose your favourite and install it. I prefer PSPad, not because it is the world's best editor, but because the integration with bmptk is simple and reliable.


A first test

For a first test you can go to one of the examples, for instance

You can start the PSPad editor (assuming you have installed it) by double-clicking on the _project.ppr file. If that does not work immediately, associate the .ppr extension with the editor's executable.

In the editor, press CTRL-F9 or click the file-to-10101 icon to build the application. Next you can press SHIFT-F9 or click the file-with-lightningbolt icon and select run to run the application. For the win target this will run the application. For the nds target it will start the DesMuME emulator to run the application. For a microntroller target this will start the download tool to download the application to the microcontroller and run it.

If things don't work as expected, the window in which the action takes place often closes before you can read what has happened. In this case, try the install-command-line command line.


Start your own project: adapt the Makefile

To start a new bmptk project you can either copy an example, or copy the bmptk/Makefile.template to your_directory.

The Makefile contains the instructions for the make tool to build your project. The Makefile in your project directory contains only the project-specific aspects. As its last line it includes the bmptk/Makfile.inc, which does the real work.

The makefile must know where to find the bmptk files. The example directories are three directories deep in the bmptk tree, so the Mafiles in the examples have the line

BMPTK := ../../..

If you place your new project somewhere within the bmptk tree you might have to change the number of ../'s. If you place a bmptk project outside the bmptk tree you should probably specify an absolute path, like

BMPTK := C:/bmptk

By default the Makefile assumes that main.cpp (or main.c, or main.asm) is the one and only source file to be compiled. If you main file has a different name, you must mention it in the Makefile:

PROJECT := alarmclock.cpp

If your project has more source files than just the main file, you must add them in the makefile. You can specify the files explicty:

# Specify project-specific files (other than the main, if any)
SOURCES := display.cpp timer.cpp
HEADERS := display.h timer.h

The sources are the files that will be compiled. When any of the headers are changed, the makefile will re-compile all your source files. This is a bit conservative, but at least it is on the safe side.


Command line use

Bmptk is 'driven' by its makefile(s). Each project has its own makefile, that specifies