This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
stryd_one_codeblocks [2006/05/21 15:08] stryd_one |
stryd_one_codeblocks [2007/10/05 23:29] stryd_one |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Developing MIOS Applications with Code::Blocks ====== | ||
- | |||
- | This is a walkthrough on the process of developing [[MIOS]] Applications primarily in C [[how_to_mix_c_and_asm|but also in ASM]] utilising the [[http://www.ucapps.de/mios_c.html|MIOS C Wrapper]]. The platform used will be [[http://www.codeblocks.org|Code::Blocks IDE]] on[[http://microsoft.com/windowsxp|Microsoft Windows XP]], and the applications will be built for both [[mios_c_simulator_-_debugger|AC-Sim (AudioCommander's C Simulator)]] compiled with [[http://gcc.gnu.org|GCC]] for [[http://www.mingw.org|MinGW]], and for the [[home#mbhpmidibox_hardware_platform|MIDIBox Hardware Platform (MBHP)]] compiled for [[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2042¶m=en020453&pageId=74|PIC18F]] with [[http://sourceforge.net/projects/sdcc|SDCC]], assembled with [[http://sourceforge.net/projects/gputils|GPUtils]], using [[http://www.activestate.com|ActiveState]] [[http://www.activestate.com/Products/ActivePerl/?mp=1|ActivePerl]] to generate, and parse files for, the DOS-Console-based make batch file scripts, and [[http://miosstudio.midibox.org|MIOS Studio]] will be used for debugging on MBHP. | ||
- | |||
- | |||
- | ====== Install and Configure Applications ====== | ||
- | |||
- | |||
- | ===== GNU PIC Utilities (GPUtils) ===== | ||
- | |||
- | * [[https://sourceforge.net/project/showfiles.php?group_id=41924|Download gputils-win32]] | ||
- | * Install the complete application using the 'Complete' option. | ||
- | * When the installer asks you, click 'Yes' to add the installation directory to the PATH environment variable. | ||
- | |||
- | ===== ActiveState ActivePerl ===== | ||
- | |||
- | * [[http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl|Download ActivePerl]] | ||
- | * Install using defaults, I recommend changing the path to c:\program files\activestate\perl | ||
- | * If you are prompted to restart your computer, then do so. | ||
- | |||
- | ===== Small Device C Compiler (SDCC) ===== | ||
- | |||
- | * [[http://sourceforge.net/project/showfiles.php?group_id=599|Download SDCC]] | ||
- | * Install using defaults | ||
- | |||
- | ==== 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: | ||
- | |||
- | * Minimise any open windows so that you can see the desktop. | ||
- | * Right-click on 'My Computer', select 'Properties'. | ||
- | * Click on the 'Advanced' tab, then click 'Environment Variables' | ||
- | * Under either User or System variables, select the variable 'PATH' and click 'Edit' | ||
- | * Add these entries if they don't exist: | ||
- | * ;C:\Program Files\ActiveState\PERL\bin\ | ||
- | * ;C:\Program Files\SDCC\bin | ||
- | * ;C:\Program Files\gputils\bin | ||
- | |||
- | ===== Sun Java J2SE ===== | ||
- | |||
- | * [[http://www.java.com/getjava/|Download J2SE]] | ||
- | * Install with defaults or whatever meets your requirements. I recommend disabling automatic updates. | ||
- | |||
- | |||
- | ===== Code::Blocks IDE ===== | ||
- | |||
- | ==== Installer ==== | ||
- | * [[http://www.codeblocks.org/downloads.shtml|Download Code::Blocks RC2 Full Installer package]] | ||
- | * Install using defaults | ||
- | |||
- | ==== Upgrade ==== | ||
- | For our purposes, CodeBlocks should be updated to the latest nightly build. Required features are unavailable in RC2 which has been installed above. | ||
- | * Download a [[http://download.berlios.de/codeblocks/wxmsw26u_gcc_cb.7z|newer wxwidgets dll]] and extract to the CodeBlocks Program Directory, for example C:\Program Files\CodeBlocks\ | ||
- | * Get link for Nightly Build from the [[http://forums.codeblocks.org/index.php?board=20.0|CB Forum]] | ||
- | * Delete share\ dir, for example C:\Program Files\CodeBlocks\share\*.* | ||
- | * Unzip downloaded file to Program Directory, for example C:\Program Files\CodeBlocks\, and overwrite where prompted. | ||
- | * Start Code:Blocks, it will detect and configure installed compilers. Accept defaults. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ====== Project Setup ====== | ||
- | |||
- | A 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. | ||
- | |||
- | If you are creating a new application, you can simply [[http://can.you.host.this.23kb.file/please|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. | ||
- | |||
- | === Create Empty Project === | ||
- | * Start Code::Blocks | ||
- | * Open a new project ('File... New Project') | ||
- | * Tick the checkbox 'Show File-based Templates' | ||
- | * Click 'SDCC Application' from the list. You may need to scroll down to see it. If it is not there, ensure you have performed the previous step | ||
- | * In the box labelled 'Project Path and Name', browse to the directory containing your MIOS Application or Skeleton, and add the name of your Project | ||
- | * In the box labelled 'Options', tick the box labelled 'Do not create any files' | ||
- | * Click 'OK' | ||
- | * Click 'Yes' on dialog(s) stating that the directory already exists | ||
- | |||
- | === Add Application files to project === | ||
- | |||
- | * Select 'Project... Add Files', Select All of the files in your Project directory, Click 'Add' | ||
- | |||
- | === Configure Build Targets === | ||
- | |||
- | * Select 'Project... Properties', Select the 'Targets' tab, Click 'Add' | ||
- | * Name the target 'MBHP', and Click OK | ||
- | * In the box labelled 'Selected build target options', select 'Commands Only' from the drop-down list labelled 'Type' | ||
- | * In the box labelled 'Selected build target files', Tick ONLY 'main.c' | ||
- | * Returning to 'Project... Properties', 'Targets' tab, Click 'Add' | ||
- | * Name the target 'MB-ACSim', and Click OK | ||
- | * In the box labelled 'Selected build target options', select 'Console Application' from the drop-down list labelled 'Type' | ||
- | * In the box labelled 'Selected build target files', Tick ONLY 'debug.c' | ||
- | * Click 'OK' to close project properties | ||
- | * Select 'Project... Properties', Select the 'Targets' tab (Yes, again. It is necessary to apply the previous settings first) | ||
- | * select target 'Default', click 'Delete', Click 'Yes' to confirm deletion | ||
- | * select target 'MBHP', click 'Build Options' | ||
- | * In the box labelled 'Selected Compiler' Select 'SDCC Compiler' from the dropdown list, Click 'OK' (until this point both targets will be using C::B's default of GCC) | ||
- | * In the box labelled 'Selected build target files', select file 'main.c' and then click 'Selected File Properties' | ||
- | * Select the 'Advanced' tab, in the box labelled 'Custom Build', Select 'SDCC Compiler' from the dropdown list labelled 'For this compiler' | ||
- | * Tick 'Use Custom Command to build this file' | ||
- | * Type into the textbox "make.bat" | ||
- | * Click OK | ||
- | * Click OK | ||
- | |||
- | === 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 common library for pic16 derivatives is not compatible to MIOS, therefore I've created a special one. [[http://www.ucapps.de/mios_c.html|Click here for more information]] | ||
- | |||
- | * Download the [[http://www.ucapps.de/mios/mios_libsdcc_v2_5_0.zip|MIOS-Specific SDCC Libraries]] | ||
- | * Create a 'lib' directory within the root directory of your project | ||
- | * Copy the 'libsdcc.lib' file from the above zip file into this directory | ||
- | * Open the "project.lkr" file of your project and add following line below the "LIBPATH" entry: | ||
- | |||
- | '' | ||
- | FILES lib/libsdcc.lib | ||
- | '' | ||
- | |||
- | === AC-Sim Setup === | ||
- | |||
- | Follow the instructions at [[mios_c_simulator_-_debugger|the AC-Sim WIKI page]] | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | //The following is yet to be documented by me.... | ||
- | |||
- | debug (simulated) | ||
- | |||
- | upload | ||
- | |||
- | debug (core) | ||
- | |||
- | http://www.midibox.org/mios_studio/ | ||
- | |||
- | |||
- | |||
- | done! Make music! | ||