Next revision | Previous revision |
en:examples:setup:codeblocksmanual [2015/03/23 16:56] – created heikopikner | en:examples:setup:codeblocksmanual [2020/07/20 09:00] (current) – external edit 127.0.0.1 |
---|
====== IDE CodeBlocks manual setup ====== | ====== IDE CodeBlocks manual setup ====== |
| |
Järgnev juhend kirjeldab AVR arenduskeskkonna seadistamist, juhul kui ei kasutata Kodulabori eelkompileeritud paigalduspaketti. | The following guide describes the AVR development environment setup, if not used HomeLab precompiled installing package. |
| |
===== Installing software ===== | ===== Installing software ===== |
| |
Vaja on paigaldada järgnev tarkvarakomplekt: | It is necessary to install the following software bundle: |
| |
**1. CodeBlocks ** | **1. CodeBlocks ** |
CodeBlocks on IDE (inglise keeles //Integrated Development Environment//), milles toimub tarkvara kirjutamine ja mikrokontrollerisse laadimine. | CodeBlocks IDE (Integrated Development Environment), for software writing and its loading into the microcontroller. |
| |
**2. ATMEL AVR Toolchain** | **2. ATMEL AVR Toolchain** |
| |
AVR Toolchain on GNU-GCC kompilaator AVR mikrokontrolleritele. See on vabavara, mille leiab Atmeli veebilehelt. | AVR Toolchain is GNU-GCC compiler for AVR microcontrollers. This is a freeware which can be found on Atmel's website. |
| |
**3. Kodulabori teek** | **3. HomeLab library** |
| |
Kodulabori teek sisaldab programmi lihtsustavaid funktsioone AVR ja Kodulabori komplekti osade kasutamiseks. Teegi viimase versiooni leiab Kodulabori veebilehelt. | 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** | **4. DFU-Programmer** |
| |
DFU-Programmeri kaudu saab programmeerida Kodulabor III seeria kontrollerit kasutades sellel olevat buudilaadurit. | DFU-Programmer is for programming HomeLab III series controller and using its bootloader |
| |
---- | ---- |
| |
=== CodeBlocks paigaldus === | === CodeBlocks installation === |
| |
Järgnev juhend kirjeldab Kodulabor III (Kontroller v1 - ATxmega128A1U) arenduskeskkonna paigaldamist ja kasutamist Windows operatsioonisüsteemis. | Following guide describes HomeLab III (Controller v1 - ATxmega128A1U) development enviroment setup and use in Windows operating system. |
| |
Esimese asjana paigaldatakse CodeBlocks tarkvara. | First install CodeBlocks software. |
CodeBlocks pluginate paigaldamine ei ole vajalik. | No need to install CodeBlocks plugis. |
{{ :et:examples:setup:codeblocks:1_cb_install.png?400 |}} | {{ :et:examples:setup:codeblocks:1_cb_install.png?400 |}} |
| |
Järgnevalt valida CodeBlocksile sobiv asukoht. Kõik näited on toodud asukohaga //C:\HomelabCB// | Next choose correct location for CodeBlocks. All examples are in default location //C:\HomelabCB// |
{{ :et:examples:setup:codeblocks:2_cb_dir.png?400 |}} | {{ :et:examples:setup:codeblocks:2_cb_dir.png?400 |}} |
Seejärel paigaldatakse CodeBlocks tarkvara | Then CodeBlocks software install on the computers. |
| |
=== Kodulabori lisade paigaldus === | === Adding Homelabs extras === |
Pärast CodeBlocksi paigaldamist paigaldada lisad: AVR Toolchain, Kodulabori teek, DFU-Programmer | When CodeBlocks are installed, then add: AVR Toolchain, HomeLab library, DFU-Programmer |
| |
Kõigepealt tuleks valida kaust, kuhu paigaldati CodeBlocks tarkvara, sest kõik lisad paigaldatakse samasse kausta. | First of all, you should choose the folder where you installed the CodeBlocks, because of all the extras installed in the same folder. |
{{ :et:examples:setup:codeblocks:3_homelab_dir.png?400 |}} | {{ :et:examples:setup:codeblocks:3_homelab_dir.png?400 |}} |
| |
===== CodeBlocks seadistamine ===== | ===== CodeBlocks setup ===== |
Esimesel käivitamisel küsitakse kompilaatorite asukohta. Sealt võib valida //*No Compiler*//, sest kompilaatori valik seadistatakse hiljem käsitsi üle ning on seotud projektiga. | 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. |
{{ :et:examples:setup:codeblocks:4_cb_firstrun.png?400 |}} | {{ :et:examples:setup:codeblocks:4_cb_firstrun.png?400 |}} |
| |
Seejärel tuleks ära seadistada kompilaator. Selleks tuleks liikuda menüüdes //Settings -> Compiler...//. Avanenud aknas tuleks seadistada järgmised read: | Then, the compiler should be set. Enter the menu //Settings -> Compiler...//. In the opened window should be set to the following lines: |
Jälgida, et oleks valitud **GNU GCC Compiler for AVR** ning näidata, kuhu paigaldati tarkvara. Juhul, kui paigaldati mujale, kui C:\HomelabCB, tuleks teha ka vastavad muudatused ise. | 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. |
{{ :et:examples:setup:codeblocks:5_cb_compiler1.png?400 |}} | {{ :et:examples:setup:codeblocks:5_cb_compiler1.png?400 |}} |
{{ :et:examples:setup:codeblocks:6_cb_compiler2.png?400 |}} | {{ :et:examples:setup:codeblocks:6_cb_compiler2.png?400 |}} |
{{ :et:examples:setup:codeblocks:8_cb_compiler4.png?400 |}} | {{ :et:examples:setup:codeblocks:8_cb_compiler4.png?400 |}} |
| |
Seejärel tuleb seadistada programmaator, et oleks võimalik koodi peale laadida otse CodeBlocks keskkonnast. Selleks tuleb menüüs leida //Tools -> Configure tools...// ning sealt vajutada //Add//. Avanenud aknasse kirjutada vastavalt kasutatavale kodulaborile järgmised read: | 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: |
| |
** Kodulabor III puhul ** | ** HomeLab III ** |
* Homelab III | * Homelab III |
* C:\HomelabCB\Programmer\Program.bat | * C:\HomelabCB\Programmer\Program.bat |
{{ :et:examples:setup:codeblocks:9_cb_tool.png?400 |}} | {{ :et:examples:setup:codeblocks:9_cb_tool.png?400 |}} |
| |
** Kodulabor II (Atmega2561) puhul ** | ** HomeLab II (Atmega2561) ** |
* Homelab 2561 | * Homelab 2561 |
* C:\HomelabCB\Programmer\HL Flash\hlflash.exe | * C:\HomelabCB\Programmer\HL Flash\hlflash.exe |
{{ :et:examples:setup:codeblocks:9_cb_tool2.png?400 |}} | {{ :et:examples:setup:codeblocks:9_cb_tool2.png?400 |}} |
| |
===== Linux/Ubuntu seadistamine ===== | ===== Linux/Ubuntu setup===== |
| |
Paigaldada Codeblocks lisad: | Install Codeblocks extras: |
sudo apt-get install codeblocks-contrib | sudo apt-get install codeblocks-contrib |
| |
dfu-programmer-i tavakasutaja õigustes käivitamiseks on vaja luua udev reeglite fail | To run dfu-programmer with a normal user privileges, create under /etc/udev/ folder a ruled.d file with following content: |
Genereerida ruled.d kataloogi fail sisuga: | |
<code> | <code> |
SUBSYSTEM=="usb",ACTION=="add",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="*",GROUP="plugdev" | SUBSYSTEM=="usb",ACTION=="add",ATTRS{idVendor}=="03eb",ATTRS{idProduct}=="*",GROUP="plugdev" |
</code> | </code> |
Samuti on vaja paigaldada teek. | It is also necessary to install the library. |
Tüüpiliselt asuvad avr-i teegid kausta /usr/lib/avr | Typically AVR libraries are located in the folder /usr/lib/avr |
Sinna kausta uute teekide lisamiseks on vaja administraatori õigusi. | 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). |
| |
Programmeerimise lihtsustamiseks võib luua järgmise batch faili: | To make programming simpler create a following batch file: |
sudo nano /usr/bin/homelab-programmer | sudo nano /usr/bin/homelab-programmer |
| |
faili sisuks kopeerida: | copy the content of the file: |
<code> | <code> |
#!/bin/bash | #!/bin/bash |
</code> | </code> |
| |
loodud failile anda käivitamise õigused: | crant execution permission: |
| |
sudo chmod 775 /usr/bin/homelab-programmer | sudo chmod 775 /usr/bin/homelab-programmer |
| |
Codeblocks //Tools->Configure tools ...// | Codeblocks //Tools->Configure tools ...// |
Seadistada programmaator järgmiselt. | Set the programmer is as follows. |
{{ :et:examples:setup:codeblocks:codeblokcs_programmer_linux.png?400 |}} | {{ :et:examples:setup:codeblocks:codeblokcs_programmer_linux.png?400 |}} |
| |
Lisada projekti teegi tugi | Add library support |
//Settings -> Compiler ...// | //Settings -> Compiler ...// |
{{ :et:examples:setup:codeblocks:compiler_path.png?400 |}} | {{ :et:examples:setup:codeblocks:compiler_path.png?400 |}} |
| |
| |
===== CodeBlocks projekti loomine ===== | ===== CodeBlocks creating a project ===== |
Projekti loomine käib menüüst //File->New->Project//. Sealt tuleks valida vastavalt Kodulabori versioonile projekt ning konfigureerida see vastavalt soovile. | Go to menu //File->New->Project//. There should be selected a project according to HomeLab version and configure it as desired. |
| |
Kõigepealt valida projektile nimi ning asukoht. **Vältida täpitähtede kasutamist.** | First, choose the name and location of the project. **Avoid the use of umlauts.** |
{{ :et:examples:setup:codeblocks:10_project1.png?400 |}} | {{ :et:examples:setup:codeblocks:10_project1.png?400 |}} |
Seejärel valida projekti kompileerimiskaust. Soovitatav jätta selleks, mis on. | Then select the project compiling folder. It is recommended to not change it. |
{{ :et:examples:setup:codeblocks:11_project2.png?400 |}} | {{ :et:examples:setup:codeblocks:11_project2.png?400 |}} |
Seejärel valida mikrokontroller ning kasutatav taktsagedus. | Then choose a microcontroller and used frequency. |
{{ :et:examples:setup:codeblocks:12_cb_project3.png?400 |}} | {{ :et:examples:setup:codeblocks:12_cb_project3.png?400 |}} |
Viimaseks tuleks määrata ära //AVR Toolchain//i installatsioonikataloog. | Lastly, //AVR Toolchain// installation folder should be set. |
{{ :et:examples:setup:codeblocks:13_cb_project4.png?400 |}} | {{ :et:examples:setup:codeblocks:13_cb_project4.png?400 |}} |
| |
===== CodeBlocks kasutamine ===== | ===== Using the CodeBlocks ===== |
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. | Once the project is created, then the new project appears in the left tree with example code. To compile press the gear icon in the toolbar. If the compilation succeeds then in the bottom //Build Log// window the user program memory count are displayed or if not, then error messages in the event of failure. |
{{ :et:examples:setup:codeblocks:14_cb_compile.png?400 |}} | {{ :et:examples:setup:codeblocks:14_cb_compile.png?400 |}} |
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//. | When loading the program into the microcontroller, in case HomeLab III, first should be entered into the bootloader by holding down the button S0 on the Controller module and at the same time, press the reset button to restart. In previous HomeLabs a bootloader mode is not available. If all the necessary drivers are installed (drivers are in CodeBlocks / Programmer folder), then can be download compiled hex file. To start programmer, go to //Tools// menu. |
| |
{{ :et:examples:setup:codeblocks:15_cb_programming.png?400 |}} | {{ :et:examples:setup:codeblocks:15_cb_programming.png?400 |}} |