AD

Thursday, 25 June 2015

FreeRTOS on Arduino UNO using Eclipse IDE: Part 1

I have been playing with an Arduino UNO board during the last few days, and I wanted to see if it could do more than those "sketches". So I decided to try FreeRTOS on it. It turns out that I've got pretty good results!I am going to show how to port FreeRTOS to an Arduino UNOboard using Eclipse IDE. This tutorial is organized as follows:Part 1:

1. Install the arduino package

The complete name of this package is AVR development board IDE and built-in libraries. You would not really need to install everything from this package, but it is the easiest way to get what we need: the built-in libraries. Just type:

$ sudo apt-get install arduino

This will install the Arduino IDE on you system. It is OK for simple projects, but it is quite limited in features and certainly does not fit our needs.

2. Test the board

Lets test the board and the installation of the Arduino libraries by running a simple test in the Arduino IDE.

2.1. Open Arduino IDE (it will be added to the laucher in the Development group). A dialog will probably be presented asking to add your user to the group dialout. That is necessary to access the board via serial line.

2.3. Press the upload button (the second button on the tool bar). The software will be upload to the board and executed. You will see the onboard LED blinking. If it happens, everything is fine and you are ready to go on.

2.4. Things that may go wrong:

You may fail to access the board via serial line if you are not part of the dialout group. The Arduino IDE usualy verifies it and add your user to that group automatically. If that doesn't happen, you may need to add yourself to the group manually. In either case, you will need to logout and login again so the changes take effect.

You can verify the groups to which you belong by typing:

$ groups

You can add yourself to the dialout group by typing:

$ sudo usermod -a -G dialout username

3. Install and configure Eclipse IDE for C/C++ Developers

3.2. Extract it to the folder of your preference (let's say ~/deve/eclipse) and run it.

3.3. Install the AVR Eclipse Plugin. Access the menu Help / Marketplace, search for AVR, and click on “Install”. A next-next installation wizard will be presented. Just follow the presented instructions.

AVR Eclipse Plugin installation.

4. Test the Eclipse IDE

We are going the test out development environment by creating a simple application. This application will be an "Eclipse version" of the same "Blink" sketch we used to test the board before. You can follow the described steps or simply clone the project from my repository.4.1. Create a new C++ Project and select AVR Cross Target Application / Empty Project as project type. Press next.

Creating a project.

4.2. Deselect the Debug configuration. We don't need it as Arduino UNO board does not allow us to debug applications (please let me know if I am wrong about that). Press next.

We don't need the Debug configuration.

4.3. Select ATmega328p as MCU Type. Press finish.

Selecting the MCU type.

4.4. Add the following source file to the project. You can type it yourself or get the file here.

Source file.

4.4. Build the project (press Ctrl+B). You will probably not find any problem.4.5. Configure AVRDude. This step is necessary to tell the AVR Plugin how to access the board we are going to program.- Open the project properties;- Select AVR / AVRDude section;- On "Programmer" tab, create a new programmer configuration by pressing the button "New";- Programmer Hardware = Arduino- Override default port = /dev/ttyACM0- Don't you forget of selecting the created configuration on "Programmer" tab.

Creating a programmer configuration.

4.6. Upload the software by pressing the "AVR" button on the toolbar. Sometimes Eclipse "forgets" the project on which you are working and complains that no AVR project is selected. If that happens, just select the project on Project Explorer panel and try it again.

Well, now we have the tools we'll need to create our FreeRTOS static library and any FreeRTOS applications we want.