User Tools

Site Tools


stryd_one_codeblocks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
stryd_one_codeblocks [2006/05/24 12:52]
stryd_one
stryd_one_codeblocks [2007/10/05 23:29] (current)
stryd_one
Line 1: Line 1:
 +:!: :!: :!: :!: :!: 
 +====== This document has been superseded and is kept for archival purposes only!!! Please see the new version! ======
 +
 +
 +    * Part 1 - [[windows_toolchain_core|Setup the core software toolchain for MIOS application development on Windows]] - These are the minimal Windows applications you need, to write a MIOS Application in C for your MIDIbox.
 +    * Part 2 - [[windows_toolchain_ASM_ACSim|Extend your toolchain with MinGW to build the AC-Sim DOS C Simulator, or MPASM for ASM coding]] - These lesser-used options are both still important in certain situations. You will need MPASM if you would like to write applications in PIC ASM, or if you want to edit TK's ASM apps. MinGW is used to build the AC-Sim simulator, which is helpful for testing complex algorithms within your applications,​ without the need to upload to your MIDIbox. If you are likely to use this, it is recommended that you install MinGW prior to Code::​Blocks.
 +    * Part 3 - [[windows_toolchain_codeblocks|Extend your toolchain with Code::​Blocks and GDB]] - Code::​Blocks is an IDE which has several helpful features when developing applications,​ such as code highlighting,​ code completion, and debugging.
 +\\
 +:!: :!: :!: :!: :!: 
 +
 +
 ====== Developing MIOS Applications with Code::​Blocks ====== ====== 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 [[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&​param=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. 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&​param=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.
  
Line 12: Line 29:
 ====== Install and Configure Applications ====== ====== Install and Configure Applications ======
  
 +===== Sun Java J2SE =====
 +
 +Chances are you already have this... I don't recommend upgrading the existing version if you do.
 +  * [[http://​www.java.com/​getjava/​|Download J2SE]]
 +  * Install with defaults or whatever meets your requirements. I recommend disabling automatic updates.
 +
 +===== 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.
 +  * [[http://​www.7-zip.org/​|Download 7zip]]
 +  * Install the complete application using the defaults
  
 ===== GNU PIC Utilities (GPUtils) ===== ===== GNU PIC Utilities (GPUtils) =====
Line 18: Line 46:
   * Install the complete application using the '​Complete'​ option.   * 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.   * When the installer asks you, click '​Yes'​ to add the installation directory to the PATH environment variable.
 +
 +
 +
 +
  
 ===== ActiveState ActivePerl ===== ===== ActiveState ActivePerl =====
  
-  * [[http://​www.activestate.com/​Products/Download/​Download.plex?id=ActivePerl|Download ActivePerl]] +  * [[http://​www.activestate.com/​store/download.aspx?prdGUID=81fbce82-6bd5-49bc-a915-08d58c2648ca|Download ActivePerl]] 
-  * Install using defaults, I recommend changing the path to c:\program files\activestate\perl +  * Install using defaults 
-  * If you are prompted to restart your computer, then do so.+  * If you are prompted to restart your computer, then do so (yes, now... I know it's annoying!).
  
 ===== Small Device C Compiler (SDCC) ===== ===== Small Device C Compiler (SDCC) =====
  
-  * [[http://​sourceforge.net/​project/​showfiles.php?​group_id=599|Download SDCC]] +  * [[http://​sourceforge.net/​project/​showfiles.php?​group_id=599|Download SDCC.]] 2.50 is officially supported or you can [[http://​sdcc.sourceforge.net/​snap.php#​Windows|get the latest snapshot]] if you're more experienced. Some PIC compiler routines have been improved in 2.6.0+ so this may be beneficial. 
-  * Install using defaults+  * Install using defaults ​(Note that this installs the PDF doc as well which can be very useful) 
 + 
 + 
 +===== MinGW ===== 
 +MinGW contains GCC which is used to compile the simulator  
 + 
 +  * [[http://​sourceforge.net/​project/​showfiles.php?​group_id=2435&​package_id=240780&​release_id=529741|Download the installer]]. Version 5.1.3 has tested OK. 
 +  * Install, taking the '​Download and Install'​ option, and select the '​Candidate'​ package (use '​Current'​ if you have problems) and the '​Minimal'​ install type. It may be best to accept the default install path as MinGW doesn'​t like paths with spaces. 
 +  * If the installer crashes while downloading just keep repeating the above until it completes. 
 + 
 + 
 +===== GDB (GNU DeBugger) ===== 
 +GDB is used to debug apps and is a must-have for MIOS development. 
 + 
 +  * [[http://​sourceforge.net/​project/​showfiles.php?​group_id=2435&​package_id=20507|Download the installer]]  
 +  * Install, taking the same default install path as MinGW (above). 
  
 ==== Environment Variables ==== ==== Environment Variables ====
Line 38: Line 86:
   * Click on the '​Advanced'​ tab, then click '​Environment Variables'​   * Click on the '​Advanced'​ tab, then click '​Environment Variables'​
   * Under either User or System variables, select the variable '​PATH'​ and click '​Edit'​   * Under either User or System variables, select the variable '​PATH'​ and click '​Edit'​
-  * Add these entries if they don't exist:+  * Add these entries if they don't exist (Entries should be separated by semicolons):
     * ;C:\Program Files\ActiveState\PERL\bin\     * ;C:\Program Files\ActiveState\PERL\bin\
     * ;C:\Program Files\SDCC\bin     * ;C:\Program Files\SDCC\bin
     * ;C:\Program Files\gputils\bin     * ;C:\Program Files\gputils\bin
- +    ​;C:\MinGW\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 ====== ====== Code::​Blocks IDE ======
Line 53: Line 96:
 ===== Install ===== ===== Install =====
  
-  * [[http://​www.codeblocks.org/downloads.shtml|Download Code::Blocks RC2 Full Installer package]] <​sup>​See below</sup> +Full Installer package is //no longer recommended // unless you're an expert. We now need to manually install and configure ​[[http://​www.gnu.org/software/​gdb/​|GDB (GNU DeBugger)]] and [[http://​www.mingw.org|MinGW]], which contains [[http://​gcc.gnu.org|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:
-  * Install using defaults+
  
-Full Installer package is //highly// recommended unless you're an expert. This will also install and configure [[http://​www.gnu.org/​software/​gdb/​|GDB (GNU DeBugger)]] and [[http://​www.mingw.org|MinGW]]which contains [[http://​gcc.gnu.org|GCC]] - the GNU C Compiler. ​GDB is used to debug your application in the simulator, which is compiled with GCC.+<​trivia>​ GCC actually stands for GNU Compiler Collectionnot GNU C Compiler. ​In addition ​to C, it supports heaps of other stuff so the name changed.</​trivia>​
  
-<​trivia>​ GCC actually stands for GNU Compiler Collection. It supports heaps of other stuff so the name changed.</​trivia>​ 
  
-===== Upgrade ​===== +===== Code::​Blocks ​===== 
-For our purposes, CodeBlocks ​should be updated to the latest nightly build. Features required to build the applications are unavailable in version ​1.0RC2 which has been installed ​above.+For our purposes, CodeBlocks latest nightly build version ​should be installed.
  
-  * 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\+  * If there is an existing version then delete ​the share\ dir, for example C:\Program Files\CodeBlocks\share\*.* before upgrading
   * Get link for Nightly Build from the [[http://​forums.codeblocks.org/​index.php?​board=20.0|CB Forum]]   * 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.   * Unzip downloaded file to Program Directory, for example C:\Program Files\CodeBlocks\,​ and overwrite where prompted.
-  * Start Code:Blocksit will detect and configure installed compilers. Accept defaults.+  ​* Download a [[http://​prdownload.berlios.de/​codeblocks/​wxmsw26u_gcc_cb_wx2.6.3p2AndCbPatch.7z|patched wxwidgets dll]] and extract to the CodeBlocks Program Directory, for example C:\Program Files\CodeBlocks\ 
 +  ​* Start Code:Blocks. If it generates an error about mingwm10.dll missing, ensure the above path variabless are set. 
 +  * Code:​Blocks ​will detect and configure installed compilers. It should find 'GNU GCC Compiler'​ and 'SDCC Compiler'​. Accept defaults.
  
 ===== Configure ===== ===== Configure =====
Line 77: Line 119:
   * Select the tab labelled '​Compiler'​ and then the tab labelled '​Compiler Flags'   * Select the tab labelled '​Compiler'​ and then the tab labelled '​Compiler Flags'
   * From the dropdown box labelled '​Categories:',​ select <All categories>​   * From the dropdown box labelled '​Categories:',​ select <All categories>​
-  * Tick the box labelled '​Produce debugging symbols ​ [-g]'+  * Tick the box labelled '​Produce debugging symbols ​ [-g]' ​(Sometimes there'​s no box, just click in the space to the left of the text and you'll see the tick.
  
 This should be all that is needed to have all the applications ready to go. This should be all that is needed to have all the applications ready to go.
Line 90: Line 132:
  
 ==== Project Setup - New Application ==== ==== Project Setup - New Application ====
 +
 +FIXME The template needs updating
  
 If you are creating a new application,​ you can simply [[http://​haskey.com/​johnh/​midibox/​SDCC+AC-Sim+CBP_Skeleton_v1.9.zip|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:​ If you are creating a new application,​ you can simply [[http://​haskey.com/​johnh/​midibox/​SDCC+AC-Sim+CBP_Skeleton_v1.9.zip|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:​
Line 99: Line 143:
   * Writing your code is up to you but once you're done, jump to the section on Compiling and Debugging for either [[#​ac-sim_simulator|AC-SIM]] or [[#​MBHP|MBHP]]   * Writing your code is up to you but once you're done, jump to the section on Compiling and Debugging for either [[#​ac-sim_simulator|AC-SIM]] or [[#​MBHP|MBHP]]
  
-==== Project Setup - Existing Application ====+==== Project Setup - Existing Application ​or Skeleton Creation ​====
  
 I plan to write a small application which will automatically convert a MIOS application (as downloaded from [[http://​www.ucapps.de|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. I plan to write a small application which will automatically convert a MIOS application (as downloaded from [[http://​www.ucapps.de|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 ==== ==== Create Empty Project ====
 +  * Copy all files from either the [[http://​ucapps.de/​mios/​sdcc_skeleton_v1_9a.zip|C Skeleton]] or your app to a directory where you would like to store the project.
   * Start Code::​Blocks   * Start Code::​Blocks
   * Open a new project ('​File... New Project'​)   * Open a new project ('​File... New Project'​)
-  ​* Tick the checkbox 'Show File-based Templates'​ +  * Click 'Console ​Application'​ from the list. 
-  ​* 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 '​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' +  * Ensure GCC Compiler is selected ​ 
-  * Click '​OK'​ +  * If you are prompted to select a language to use, select ​'C'
-  * Click 'Yes' ​on dialog(s) stating that the directory already exists+
  
 ==== Add Application files to project ==== ==== Add Application files to project ====
  
-  * Select '​Project... Add Files',​ Select All of the files in your Project directory, Click '​Add'​+  ​* The automatically created main.c needs to be deleted 
 +  ​* Select '​Project... Add Files',​ Select All of the source code files in your Project directory, Click 'Add
 +  * If you are prompted to select which build target should be used, click '​Select All'
  
  
Line 123: Line 168:
 //Skip this section if you do not need to use the simulator// //Skip this section if you do not need to use the simulator//
  
-  * Select '​Project... Properties',​ Select the '​Targets'​ tab, Click 'Add+  ​* Ensure AC-SIM files are added to the project. Follow the instructions at [[mios_c_simulator_-_debugger#​setup_guide|the AC-Sim WIKI page Setup Guide]] 
-  * Name the target 'MB-ACSim', and Click OK+  ​* Select '​Project... Properties',​ Select the '​Targets'​ tab, you should see two targets preconfigured ('Debug' ​and '​Build'​) 
 +  * Select ​the target 'Debug'
   * 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 options',​ select '​Console Application'​ from the drop-down list labelled '​Type'​
-  * In the box labelled '​Selected build target files',​ Tick ONLY 'debug.c'+  * In the box labelled '​Selected build target files',​ Tick ONLY 'ACSim_console.c',​ '​ACSim_mios.c'​ and '​ACSim_toolbox.c' ​
  
 === MBHP Build Target === === MBHP Build Target ===
 //Perform the following sections to build the application for MBHP// //Perform the following sections to build the application for MBHP//
  
-  * Returning to '​Project... Properties',​ '​Targets'​ tab, Click '​Add'​ +  * Returning to '​Project... Properties',​ '​Targets'​ tab, select ​the build target 'Release'
-  * 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 options',​ select '​Commands Only' from the drop-down list labelled '​Type'​
   * In the box labelled '​Selected build target files',​ Tick ONLY '​main.c'​   * In the box labelled '​Selected build target files',​ Tick ONLY '​main.c'​
Line 138: Line 183:
  
   * Select '​Project... Properties',​ Select the '​Targets'​ tab (Yes, again. It is necessary to apply the previous settings first)   * 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 'Release', click 'Build Options'​ 
-  * select ​target 'MBHP', click 'Build Options'​ +  * In the box labelled '​Selected Compiler'​ Select 'SDCC Compiler'​ from the dropdown list (until this point both targets will be using C::B's default of GCC), Click '​OK'​ and return to the '​Targets'​ tab 
-  * 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' ​(bottom right), select file '​main.c'​ and then click '​Selected File Properties'​
-  * 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'​   * 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'   * Tick 'Use Custom Command to build this file'
Line 147: Line 191:
   * Click OK   * Click OK
   * Click OK   * Click OK
 +
  
 ==== MIOS-Specific SDCC Libraries ==== ==== MIOS-Specific SDCC Libraries ====
  
 TK says: 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]]+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. [[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]]   * Download the [[http://​www.ucapps.de/​mios/​mios_libsdcc_v2_5_0.zip|MIOS-Specific SDCC Libraries]]
Line 162: Line 213:
 ''​ ''​
 \\ \\
 +
 +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 :)
 +
 \\ \\
 \\ \\
 \\ \\
 \\ \\
- 
- 
-//Coming real soon (like tomorrow)// 
  
 ===== AC-Sim Simulator ===== ===== AC-Sim Simulator =====
Line 175: Line 226:
  
 Follow the instructions at [[mios_c_simulator_-_debugger|the AC-Sim WIKI page]] Follow the instructions at [[mios_c_simulator_-_debugger|the AC-Sim WIKI page]]
- 
  
 ==== Compile ==== ==== Compile ====
 +
 +Select the '​Debug'​ target, Click '​Build',​ and you're done!
  
 ==== Debug ==== ==== Debug ====
 +
 +Follow the instructions at [[mios_c_simulator_-_debugger|the AC-Sim WIKI page]]
 +
  
 ===== MBHP ===== ===== MBHP =====
  
 ==== Compile ==== ==== Compile ====
 +
 +Select the '​Release'​ target, Click '​Build',​ and you're done!
  
 ==== Debug ==== ==== Debug ====
Line 190: Line 247:
 \\ \\
 \\ \\
-//The following is yet to be documented by me.... 
- 
-upload 
-http://​www.midibox.org/​mios_studio/​ 
- 
  
  
 done! Make music! done! Make music!
  
stryd_one_codeblocks.1148475159.txt.gz · Last modified: 2006/10/15 09:35 (external edit)