Table of Contents

:!: :!: :!: :!: :!:

This document has been superseded and is kept for archival purposes only!!! Please see the new version!


:!: :!: :!: :!: :!:

Developing MIOS Applications with Code::Blocks

Note Updated 18/01/07 Please check to be sure you are doing this right, c::b changed a lot since the first version of this doc - stryd_one

The technical jargon: This is a walkthrough on the process of developing MIOS Applications primarily in C but also in ASM utilising the MIOS C Wrapper. The platform used will be Code::Blocks IDE onMicrosoft Windows XP, and the applications will be built for both AC-Sim (AudioCommander's C Simulator) compiled with GCC for MinGW, and for the MIDIBox Hardware Platform (MBHP) compiled for PIC18F with SDCC, assembled with GPUtils, using ActiveState ActivePerl to generate, and parse files for, the DOS-Console-based make batch file scripts, and MIOS Studio will be used for debugging on MBHP.

Please don't be put off by all that mumbo jumbo. If you're totally newbie then this document is also for you :) I've included everything you need to do, step-by-step, for everything except for actually coding the app. I hope this will not only make it easier for newbies to get started, but for ASM coders like myself to transfer their skills into C development (which seems to be the future of MIOS) or as a reference point for the experienced. In order to do this, I've included as much information as possible, but I have created links to jump through the document for those who don't need all that detail.

I hope you find this document helpful and that you will feel free to make suggestions or criticism or corrections or any kind of modifications as you see fit :)



Install and Configure Applications

Sun Java J2SE

Chances are you already have this… I don't recommend upgrading the existing version if you do.

7zip

This tool is needed to extract compressed files. If you already have winzip or winrar then you won't need this. I recommend the latest version MSI installer for ease of use.

GNU PIC Utilities (GPUtils)

ActiveState ActivePerl

Small Device C Compiler (SDCC)

MinGW

MinGW contains GCC which is used to compile the simulator

GDB (GNU DeBugger)

GDB is used to debug apps and is a must-have for MIOS development.

Environment Variables

Normally, the necessary directories are added to you PATH environment variable during the above installations. Sometimes, they aren't. Here's how to check it:

Code::Blocks IDE

Install

Full Installer package is no longer recommended unless you're an expert. We now need to manually install and configure GDB (GNU DeBugger) and MinGW, which contains GCC - the GNU C Compiler. GDB is used to debug your application in the simulator, which is compiled with GCC. Once those are installed we can get C::B ready. Here's how:

<trivia> GCC actually stands for GNU Compiler Collection, not GNU C Compiler. In addition to C, it supports heaps of other stuff so the name changed.</trivia>

Code::Blocks

For our purposes, CodeBlocks latest nightly build version should be installed.

Configure

In order to use the GDB (GNU DeBugger) debugging features of Code::Blocks with AC-Sim (AudioCommander's C Simulator) you need to configure GCC to produce debugging symbols when compiling as follows:

This should be all that is needed to have all the applications ready to go.

Project Setup

Full instructions are below, but you may jump to the required section based on your requirements:

Project Setup - New Application

FIXME The template needs updating

If you are creating a new application, you can simply download the MIOS SDCC Skeleton Application Template, extract it to your template directory, and start with that, and none of the below steps are necessary. This zip file does not change any of the functionality of the normal SDCC Skeleton App, so you can use it as normal, as well as with C::B. Here is a walkthrough:

Project Setup - Existing Application or Skeleton Creation

I plan to write a small application which will automatically convert a MIOS application (as downloaded from UcApps) into a Code::Blocks Project complete with AC-Sim sources for pre-MBHP debugging. In the meantime, the C::B Project can be setup from either an existing MIOS C Application or the SDCC_Skeleton App as follows. You should have your application/skeleton in a dedicated folder.

Create Empty Project

Add Application files to project

Configure Build Targets

AC-SIM Build Target

Skip this section if you do not need to use the simulator

MBHP Build Target

Perform the following sections to build the application for MBHP

MIOS-Specific SDCC Libraries

TK says: If multiplications, divisions, pointer operations, etc. are used in the .c code, the linker may fail due to missing functions, which are part of the “libsdcc.lib” library. The error message will be:

Linking project
lib/libsdcc.lib: No such file or directory
ERROR!

The common library for pic16 derivatives is not compatible to MIOS, therefore I've created a special one. Click here for more information

FILES lib/libsdcc.lib

At this point, I highly recommend selecting 'File… Save Project as user template', then you can use it as a quick starting point for all your awesome projects :)





AC-Sim Simulator

Setup

Follow the instructions at the AC-Sim WIKI page

Compile

Select the 'Debug' target, Click 'Build', and you're done!

Debug

Follow the instructions at the AC-Sim WIKI page

MBHP

Compile

Select the 'Release' target, Click 'Build', and you're done!

Debug




done! Make music!