Eclipse IDE for dsPIC & PIC24 development
Now that we have a working Linux cross-compiling toolchain for dsPIC & PIC24, it should be nice to see how we can develop with a cool & useful development environment such as the Eclipse IDE.
Note that other solutions exist if you don't like Eclipse (for any bad reason :-) ). You can take a look to the piklab project which is a multi-platform development environment dedicated to PIC development.
The following information is just a starting point, giving you some way to go to configure the Eclipse CDT to suit your needs. My goal here is not to detail all the pros (& cons) of using Eclipse instead of Mplab. The best way for you to discover the great features bring by the Eclipse IDE is to give it a try!
I used the Galileo release of the Eclipse IDE for C/C++ developers to write those notes.
Integrate the compiling tool chain
The objectives of an integration of the dsPIC & PIC24 coss-compiling tool chain into the Eclipse IDE are to:
- Bring the code completion into the editors
- Build your projects inside Eclipse
For such an integration, the CDT offers the possibility to bring your own builders. The PIC C builder plug-in try to bring such pre-configured builder for MPLAB C30.
As its default configuration mainly targets the "standard" Windows C30 distribution, it will require a couple more manual configuration in the project preferences to build the sources with our Linux tool chain .
Installation
For that step, we're using a plugin from AGT Soft. You can install it using the install software manager of Eclipse.
- You'll find the manager there : Help > Install new Software.
- Add the repository : http://agtsoft.ru/update
- Select CDT - MPLAB Microchip C18-C30 toolchain
- Install it.
Specific configuration
First on the global workspace properties (Window > Preferences > C/C++ > Build variables), add two variables with the following content:
- {$MRESOURCE} : -mresource=/usr/local/pic/info/c30_device.info.
- {PATH} : ${PATH}:/usr/local/pic/bin.(the path of your Pic30 executables)
Then apply the following configurations to your project properties (right click on your project, then Properties):
- under the C/C++ Builder category, select Builder Type : Internal Builder.
- under the setting sub-category, on the Tool Settings panel, update the command value of each items to the corresponding path: /usr/local/pic/bin/pic30-coff-*. For Assembler, Compiler and Linker use : pic30-coff-gcc, for Bin2Hex use pic30-coff-bin2hex.
- set the target device
- on the command line pattern under the Compiler item, add a call to the build variable we defined previously (In my case, I called it MRESOURCE): ${command} ${flags} ${MRESOURCE} -x c ${inputs} ${output_flag} ${output}.
- under Compiler/Directories?, add the paths to the Microchip header files. If you placed those non free files under the pic30-nonfree folder, set those paths like following:
- /usr/local/pic/pic30-nonfree/include
- /usr/local/pic/pic30-nonfree/support/dsPIC33F/h (if you target a dsPIC33F device, adapt it to the good folder otherwise)
- /usr/local/pic/pic30-nonfree/support/generic/h
- /usr/local/pic/pic30-nonfree/support/peripheral_30F_24H_33F
- under Linker/General?
- set the linker script to the gld file corresponding to your target device. For example: /usr/local/pic/pic30-nonfree/support/dsPIC33F/gld/p33FJ128MC804.gld
- under Library files, add the need linking options depending of the library used for your application. That's a constraining part that was automated under Mplab! Basically we will need to add pic30 and a few other options to link our binary with the specific Microchip libraries.
- under Linker/Directories?, add the paths to the non-free libraries the same way as for the compiler header paths:
- /usr/local/pic/pic30-nonfree/lib
- /usr/local/pic/pic30-nonfree/lib/dsPIC33F
That's it! This manual configuration is a bit fastidious, but as we made it once, to create other projects we just need to copy this first project and adapt the target device to the new project one.
Build the project
After the project configuration described previously, to effectively build the project right click on the project, then Build project. Or just click on the button (with the hammer icon) in the top of C/C++ perspective.
If everything goes right, the build should create a new folder on your project containing the generated Makefiles, the compiled object (.o) and the binary built (.hex). Some log information should also be printed in the Console view.
Some other optional configurations
To organize the project, we can configure the project source locations and build folder. Under the C/C++ General/Paths? and Symbols category of the project properties, we can set a folder called src as source location. To rename the build folder, by default called Hex target, we just need to rename the build configuration.
To manage multiple configurations with different project properties on the same project (for example if different compiling tool chain are used for the same project or with different locations), we can set different build configurations in the project properties.
Manage target from Eclipse
Now that we can build our binary from Eclipse, it should be nice if we could program the devices directly inside Eclipse.
This subject mainly depends on the way you program your target. For example, if you use a Pickit2, Microchip provides a command line interface that's seems to be working on a Linux system.
I personally use an ICD2 and there is no command line interface provided by Microchip. But the Piklab project bring such command line interface! As of today, it does not support every PIC devices but it is not too much work to help them to support new devices.
Now that we have a command line interface, we can make a few launchers inside Eclipse to call the external programming tools. It is not the best solution but it is a first step forward!
Program target with Pickit2
First you have to download and extract PK2CMD on your computer, then run and configure Eclipse :
- Go to Run/External? Tools/External? Tools Configuration...
- Click on new launch configuration and choose a name (like "Pickit2")
- In Location add the path to pk2cmd
- In Working Directory add the path to the folder which contain PK2DeviceFile.dat
- In Arguments, enter arguments you want to pass to pk2cmd. For example :
-PdsPIC33FJ128MC802 -M -R -F${project_loc}/Hex/${project_name}.hex"
This line will program the target (a PIC33FJ128MC802 here) with the file Nameofproject.hex. See the PK2CMD Readme file for more information on arguments.
- Now you can program by clicking on the green icon (the one with the toolbox)
Eclipse terminal
As we use a lot the rs232 communication for debugging our target devices, it should be great to have a terminal inside Eclipse.
The target management Eclipse subproject provides a basic terminal feature out of the box! So this part is quite simple, you just have to install it using the standard Galileo update sites.
Attachments
-
InstallPluginAGT.png
(89.9 KB) -
added by perrinni 2 years ago.
-
SetEnvironmentVariable.png
(96.5 KB) -
added by perrinni 2 years ago.
-
Settings.png
(111.3 KB) -
added by perrinni 2 years ago.
-
PicKitConf.png
(94.4 KB) -
added by perrinni 2 years ago.
