The beauty of multiproject

Some days ago I've put my hands on a fairly complex Visual Studio project, with a project for each different DLL. The build system simply compiled all the projects with one click. This reminds me that Bertos' build system supports something very similar.

Why you may want to use such facility? Suppose you want to build a board with an auto-updating firmware. One solution is to use a small boot loader which will check for updates at each reboot, then will start the main application.

These two projects will share custom drivers developed for your hardware. To avoid code duplication you can create a multiproject.

Multiproject's creation is still not supported by the Wizard out of the box, but it will come useful nonetheless. A word of warning: you will lose the possibility to edit configuration files with the Wizard for all but one project.

I will refer to your project as top-secret (with its own directory top-secret/), while the bootloader project will be called boot (and will reside inside the boot/ directory).

Using Wizard assistance (recommended)

Using the Wizard create a new project, which we decided to call "top-secret". Then create another project, called "boot", and enter the directory. You will find the whole BeRTOS sources, the boot/ directory and various other files.

You need to copy the boot/boot/ directory, which contains the source code for the bootloader, inside the top-secret/ directory.

Now you just need to enable multiple builds. Open top-secret/Makefile and include the makefile fragment relative to the "boot" project. The makefile will look like this:

# Set to 1 for verbose build output, 0 for terse output
V := 0

default: all

include bertos/config.mk

#Include subtargets
include top-secret/top-secret.mk
include boot/boot.mk # <---- this is the line you need to add

include bertos/rules.mk

You are done. Now the build process will also build the boot loader. If you want to temporarily disable compilation of one of the projects, just put a '#' at the beginning of the line.

Handmade multiproject

I wouldn't recommend this procedure unless you want to delve into BeRTOS build system. Create your new "top-secret" project (I suggest using the Wizard at least for this step!) and enter the top-secret/ directory. There will be many files and directories, including BeRTOS sources and the top-secret/ dir. Copy such directory into boot/.

Now the sensitive part. Enter the newly created boot/ directory and replace in each file each occurrence of "top-secret" with "boot". If you miss one of them, probably you won't be able to compile or flash your target. Once you're done with it, edit the Makefile as described in the previous section.


Now you're done. Remember that if you want to build, flash or debug the bootloader only, you can issue the following commands:

make boot
make flash_boot
make debug_boot

See you next time!

Written by Luca Ottaviano in programming the 14 October 2009. Tag: HowTo, build system, multiproject, tips, visual studio, wizard,
 Download as PDF

Add a comment