This is an old revision of the document!
The following guide describes the AVR development environment setup, if not used HomeLab precompiled installing package.
It is necessary to install the following software bundle:
1. CodeBlocks CodeBlocks IDE (Integrated Development Environment), for software writing and its loading into the microcontroller.
2. ATMEL AVR Toolchain
AVR Toolchain is GNU-GCC compiler for AVR microcontrollers. This is a freeware which can be found on Atmel's website.
3. HomeLab library
HomeLab library contains a various functsions to make AVR and HomeLab kit programming simpler. The last versions for this library can be found on HomeLab website.
4. DFU-Programmer
DFU-Programmer is for programming HomeLab III series controller and using its bootloader
Following guide describes HomeLab III (Controller v1 - ATxmega128A1U) development enviroment setup and use in Windows operating system.
First install CodeBlocks software.
No need to install CodeBlocks plugis.
Next choose correct location for CodeBlocks. All examples are in default location C:\HomelabCB
Then CodeBlocks software install on the computers.
When CodeBlocks are installed, then add: AVR Toolchain, HomeLab library, DFU-Programmer
First of all, you should choose the folder where you installed the CodeBlocks, because of all the extras installed in the same folder.
The first launch prompted compiler location. May be select *No Compiler*, because the choice of the compiler is set manually at a later, and it is dependent to the project template.
Then, the compiler should be set. Enter the menu Settings → Compiler…. In the opened window should be set to the following lines:
Observe that would be selected GNU GCC Compiler for AVR and show where to install the software. If the installed sowtware location is not C:\HomelabCB then should be made corresponding changes themselves.
Then configure the programmer to be able to download the code directly from CodeBlocks environment. In order to find the menu Tools → Configure tools… and choose Add. In the opened windows write the following rows dependent HomeLabs generation:
HomeLab III
HomeLab II (Atmega2561)
Install Codeblocks extras:
sudo apt-get install codeblocks-contrib
To run dfu-programmer with a normal user privileges, create udev rules file. Generate ruled.d folder a file with following content:
SUBSYSTEM=="usb",ACTION=="add",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="*",GROUP="plugdev"
It is also necessary to install the library. Typically AVR libraries are located in the folder /usr/lib/avr It is necessary to own administrator rights to add a folder for the new library.
Juhul kui AVR Toolchain ei ole repositooriumites veel uuendatud, siis võib ADC funktsioon anda veateate. Selle ellimineerimiseks võib käsitsi asendada avr kaustas oleva iox128a1u.h faili (sisaldub teegis).
If the AVR Toolchain repositorys not yet been updated, you may receive an error message for ADC function. To correct this replace manually in the avr folder iox128a1u.h file (included in the library).
To make programming simpler create a following batch file:
sudo nano /usr/bin/homelab-programmer
copy the content of the file:
#!/bin/bash dfu-programmer atxmega128a1u erase dfu-programmer atxmega128a1u flash $1 dfu-programmer atxmega128a1u start
crant execution permission:
sudo chmod 775 /usr/bin/homelab-programmer
Codeblocks Tools→Configure tools …
Set the programmer is as follows.
Go to menu File→New→Project. There should be selected a project according to HomeLab version and configure it as desired.
First, choose the name and location of the project. Avoid the use of umlauts.
Then select the project compiling folder. It is recommended to not change it.
Then choose a microcontroller and used frequency.
Lastly, AVR Toolchain installation folder should be set.
Kui projekt on loodud, ilmub vasakule projektipuusse uus projekt koos näitekoodiga. Kompileerimine käib CodeBlocksis ülal real olevate hammasratta ikoonidega. Kui kompilatsioon õnnestub kuvatakse all Build Log aknas kasutatud programmimälu maht ning ebaõnnestumise korral errorid.
Programmi peale laadimiseks, tuleb Kodulabor III kontrolleril käivitada buudilaadur hoides all S0 nuppu ja tehes kontrollerile reset. Varasemate Kodulaboritega seda teha vaja ei ole. Kui vajalikud draiverid on paigaldatud (Draiverid asuvad CodeBlocks/Programmer kaustas), siis saab kompileeritud hex faili peale laadida. Selleks tuleb käivitada programmaator menüüst Tools.