-
Notifications
You must be signed in to change notification settings - Fork 0
Setup Development Environment
- CentOS 6.2 installed with development packages
- This project will adhere to the MISRA C++ 2008 Coding Standards.
- Coding style adheres to the "BSD/Allman" profile in Eclipse.
- No tabs. White space are spaces only.
- Install Eclipse IDE for C/C++ Development from http://www.eclipse.org/downloads/.
- Install AVR for Eclipse using instructions at http://interactive-matter.eu/how-to/developing-software-for-the-atmel-avr-with-avr-eclipse-avr-gcc-avrdude/.
- Install EGit from http://www.eclipse.org/egit/download/.
- Install the Arduino IDE and source code from http://arduino.cc/en/Main/Software.
- Start Eclipse.
- Create workspace.
- Click "File->New->C++ Project".
- Click "AVR Cross Target Static Library->Empty Project".
- Project name: ArduinoCore
- Click "Next".
- Check both "Debug" and "Release".
- Click "Next".
- Fill in the MCU type and frequency for your Arduino. For this project, I'm using: MCU Type: ATmega328P MCU Frequency (Hz): 16000000
- Click "Finish".
- Right click "ArduinoCore" in the Project Explorer pane.
- Click "Properties".
- In the left pane, click "C/C++ General->Paths and Symbols".
- In "Languages" tab, click "GNU C".
- In the right pane, click "Add".
- Click "File system..." and navigate to the Arduino platform specific source code at /hardware/arduino/variants/. I used "standard" for this project.
- Click "Ok".
- Check "Add to all configurations".
- In "Languages" tab, click "GNU C++".
- In the right pane, click "Add".
- Click "File system..." and navigate to the Arduino source at /hardware/arduino/cores/arduino.
- Click "Ok".
- Check "Add to all configurations".
- Click "Ok".
- In the right pane, click "Add".
- Click "File system..." and navigate to the Arduino platform specific source code at /hardware/arduino/variants/. I used "standard" for this project.
- Click "Ok".
- Check "Add to all configurations".
- Click "Ok".
- In the left pane, click "C/C++ General->Paths and Symbols".
- In the right pane, click the "Source Location" tab.
- In the right pane, click the "Link Folder..." button.
- Folder name: src
- If the advanced pane is not visible, click "Advanced >>".
- Check "Link to folder in the file system".
- Click the "Browse..." button.
- Navigate to the Arduino source code at /hardware/arduino/cores/arduino.
- Click the "OK" button.
- Click the "OK" button.
- In the right pane, click "/ArduinoCore".
- In the right pane, click the "Delete" button.
- Click the "OK" button.
- Click "Project->Build Configurations->Set Active->Debug".
- Click "Project->Build Project". You should see a bunch of text scroll by in the console and end with:
**** Build Finished ****
If so and you see no errors, congratulations. You've just built the Arduino static library you will be using for most of the remainder of the project. This is the debug version of the static library that will allow us to debug and step through even the low level Arduino code.
- Click "Project->Build Configurations->Set Active->Release".
- Click "Project->Build Project". You should see the same bunch of text scroll by in the console. This is the release version of the static library. We'll use this version of the static library for release versions of this project.
Most users wilL NOT have to perform these steps. This is a one time procedure to create the initial project that is checked into the Git repo. It is documented here for archival purposes and for anybody that wants to create a similar project. For those that are joining this project, skip ahead to "Clone the VW-Bugbox Project from Github".
- The ArduinoCore project will also always reside in the same workspace as the VW_Bugbox project.
- Start Eclipse and load workspace with the ArduinoCore project.
- Click "File->New->C++ Project".
- Click "AVR Cross Target Application->Empty Project".
- Project name: VW-Bugbox
- Click "Next".
- Check both "Debug" and "Release".
- Click "Next".
- Fill in the MCU type and frequency for your Arduino. For this project, I'm using: MCU Type: ATmega328P MCU Frequency (Hz): 16000000
- Click "Finish".
Add the paths for the header files so we can compile it.
- Right click "VW-Bugbox" in the Project Explorer pane.
- Click "Properties".
- In the left pane, click "C/C++ General->Paths and Symbols".
- In "Languages" tab, click "GNU C".
- In the right pane, click "Add".
- Click "File system..." and navigate to the Arduino platform specific source code at /hardware/arduino/variants/. I used "standard" for this project.
- Click "Ok".
- Check "Add to all configurations".
- Click "Ok".
- In "Languages" tab, click "GNU C++".
- In the right pane, click "Add".
- Click "File system..." and navigate to the Arduino platform specific source code at /hardware/arduino/variants/. I used "standard" for this project.
- Click "Ok".
- Check "Add to all configurations".
- Click "Ok".
- In the right pane, click "Add".
- Click "Workspace..." and click "ArduinoCore->src"
- Click "Ok".
- Check "Add to all configurations".
- Click "Ok".
Add the library so we can link it. Also, add a reference to the ArduinoCore so Eclipse will ensure that it rebuilds ArduinoCore if necessary. In case we decide to make tweaks to the Arduino code.
- In the left pane, click "C/C++ Build->Settings".
- In the right pane, click the "Tool Settings" tab.
- In the right pane, select "Debug" in the "Configuration" drop down.
- In the right pane, click "AVR C++ Linker->Libraries".
- In "Libraries Path (-L)" pane, click the add button.
- Click "Workspace...".
- Click "ArduinoCore->Debug".
- Click the "OK" button.
- In the right pane, select "Release" in the "Configuration" drop down.
- In the right pane, click "AVR C++ Linker->Libraries".
- In "Libraries Path (-L)" pane, click the add button.
- Click "Workspace...".
- Click "ArduinoCore->Debug".
- Click the "OK" button.
- Click the "OK" button.
- In "Libraries (-l)" pane, click the add button.
- Enter "ArduinoCore".
- Click the "OK" button.
- Click the "OK" button.
Now, our project has both the debug and release versions of the Arduino static library so we can debug or build for release just by selecting "Debug" or "Release". Lets make Eclipse always ensure that the ArduinoCore project is compiled.
- In the left pane, click "C/C++ General->Paths and Symbols".
- In the right pane, select "Debug" in the "Configuration" drop down.
- In the right pane, click the "References" tab.
- In the right pane, check the "Arduino->Debug" checkbox.
- In the right pane, select "Release" in the "Configuration" drop down.
- In the right pane, click the "References" tab.
- In the right pane, check the "Arduino->Release" checkbox.
- Click the "OK" button.
Now we're going to add a separate directory for all the source code, then configure Eclipse to ONLY parse the code in that source code directory when compiling code. This will allow us to include non-source code artifacts like documentation in our project without confusing Eclipse.
- In the Project Explorer pane, right click "VW-Bugbox".
- Click "New->Folder".
- Folder name: src
- Click the "Finish" button.
- Click "Add Folder...".
- In the Project Explorer pane, right click "VW-Bugbox".
- Click "Properties".
- In the left pane, click "C/C++ General->Paths and Symbols"
- In the right pane, click the "Source Location" tab.
- In the right pane, click the "Add Folder..." button.
- Click "src".
- Click "OK".
- In the right pane, click "/VW-Bugbox".
- In the right pane, click the "Delete" button.
Add our first source code.
- In the Project Explorer pane, right click "VW-Bugbox/src".
- Click "New->Other".
- Click "C/C++->Source File".
- Click the "Next >" button.
- Source file: setup.cpp
- Click the "Finish" button.
- In the Project Explorer pane, right click "VW-Bugbox/src".
- Click "New->Other".
- Click "C/C++->Source File".
- Click the "Next >" button.
- Source file: loop.cpp
- Click the "Finish" button.
Add some stub code to test our new build environment.
- In the setup.cpp file, add the following:
` #include <Arduino.h>
void setup() { } `
- In the loop.cpp file, add the following:
` #include <Arduino.h>
void loop() { } `
Test our new build environment.
- In the Project Explorer pane, click "VW-Bugbox".
- In the top menu, click "Project->Build Project".
- If you don't see any errors, congratulations. Your build environment is now ready for coding.