Write and install the Arduino program on Eclipse Helios

Source: Internet
Author: User

Just getting started with Arduino, very good.

Arduino ide I used version 0022 at the beginning, and its editor was really uncomfortable. I didn't prompt that auto-completion was not completed. Because I have been using eclipse for development, I am looking for a solution.

My board is Arduino uno ..

According to the official method, there is no result ....

According to the arduino.tw method, there is no result...

 

Finally, I finally found a way to solve the problem. The following describes the configuration steps of Arduino uno:

 

Preparations:

* Eclipse CPP(My version is eclipse-cpp-helios-SR2-win32)

* AVR eclipse plugin(My version is avreclipse-p2-repository-2.3.4.20100807PRD)

* Winavr(My version is WinAVR-20100110)

* Arduino ide(My version is arduino-0022)


 

Step 1 -- configure the Arduino compiling environment:

  Step 1:

  (Skip to step 2 if it is too troublesome)

Install winavr and eclipse-CPP in sequence, decompress the downloaded AVR eclipse plugin package, and put it in the eclipse/dropins directory. After you restart eclipse, there will be the AVR option.

First, go to the eclipse attribute settings:

  

  

Then, the path option in the AVR will be like this. The path is your installation path ,,AVR-GCC, GNU make, AVR header filesAll are winavr paths.

  

  

 

Then, import the project to simplify the configuration of various GCC parameters. If you start from scratch, the configuration is very troublesome and direct import is easy, as long as a few changes are required. Second, this project is to compile the Arduino core library file. when compiling the Arduino project later, you do not need to manually import so many files.

 

  Download: Arduinocore.rar

 

After importing the project, you need to make some changes to the project properties, project-> right-click-> Properties

Configure the target hardware parameters as follows:

    MCU type: Atmega328p

MCU clock frequency:16000000(6〇)

  

  

Then set the library file introduced by the project, or in the property settings of the project.C/C ++ build->Setting

To pairAVR complierAndAvr c ++ complierOfDirectoriesThe directory is the relevant path under the Arduino ide. See the figure below:

  

The two path settings are the same

 

Now you can compile the program. Click project> make all. Eclipse should be able to compile successfully and the output is as follows:

**** Clean-only build of configuration Release for project Blinky ****

make clean
rm -rf ./main.o Blinky.eep Blinky.hex Blinky.lss ./main.d sizedummy Blinky.elf


**** Build of configuration Release for project Blinky ****

make all
Building file: ../main.cpp
Invoking: AVR C++ Compiler
avr-g++ -I"D:\Program Files\arduino-0022\hardware\arduino\cores\arduino" -Wall -Os -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"main.d" -MT"main.d" -c -o"main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: Blinky.elf
Invoking: AVR C++ Linker
avr-gcc --cref -s -Os -o"Blinky.elf" ./main.o -lArduinoCore -lm -Wl,-Map,Blinky.map,--cref -L"C:\Users\hang\Desktop\Blinky" -mmcu=atmega328p
Finished building target: Blinky.elf

Invoking: AVR Create Extended Listing
avr-objdump -h -S Blinky.elf >"Blinky.lss"
Finished building: Blinky.lss

Create Flash image (ihex format)
avr-objcopy -R .eeprom -O ihex Blinky.elf "Blinky.hex"
Finished building: Blinky.hex

Create eeprom image (ihex format)
avr-objcopy -j .eeprom --no-change-warnings --change-section-lma .eeprom=0 -O ihex Blinky.elf "Blinky.eep"
Finished building: Blinky.eep

Invoking: Print Size
avr-size --format=avr --mcu=atmega328p Blinky.elf
AVR Memory Usage
----------------
Device: atmega328p

Program: 7594 bytes (23.2% Full)
(.text + .data + .bootloader)

Data: 202 bytes (9.9% Full)
(.data + .bss + .noinit)


Finished building: sizedummy

 

A libarduinocore. A file is generated in the project's release directory. This is the compiled library file and will be used later.

    

Step 2:

  Download: Blinky.rar

  !!! Note that the main. cpp of this project is the same as the method in Arduino. You can change the setup () loop () and other content on your own for testing in a convenient way.

As with the above method, import it to eclipse and put the libarduinocore generated above. copy A to this project and overwrite it. Then, configure the compilation parameters. You just need to change several paths. The method is the same as above.

Finally, make all is compiled successfully. The output is similar to the above. The target file Blinky. Elf is displayed in the release directory.

The rest is burned.

 

Step 2 -- configure the burning environment:

Go to the attribute settings of eclipse (see the step diagram), and set the parameters for your local address.

  

  

Then, set the path of the avrdude configuration file, change it to your own arduinoide directory, and add an avrdude Configuration:

  

 

Avrdude configuration parameters: the serial port is set as your own, my com3, after you plug in the board, you will see the Arduino uno in the system's settings manager, and the serial port will be displayed later

  

 

Finally, OK. The compiled elf will be burned. Click this button and the output will be roughly as follows:

Launching D:\Program Files\arduino-0022\hardware\tools\avr\bin\avrdude -pm328p -cstk500v1 -Pcom3 -b115200 -F -Uflash:w:Blinky.hex:a "-CD:\Program Files\arduino-0022\hardware\tools\avr\etc\avrdude.conf" 
Output:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "Blinky.hex"
avrdude: input file Blinky.hex auto detected as Intel Hex
avrdude: writing flash (7594 bytes):

Writing | ################################################## | 100% 1.23s

avrdude: 7594 bytes of flash written
avrdude: verifying flash memory against Blinky.hex:
avrdude: load data flash data from input file Blinky.hex:
avrdude: input file Blinky.hex auto detected as Intel Hex
avrdude: input file Blinky.hex contains 7594 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.98s

avrdude: verifying ...
avrdude: 7594 bytes of flash verified

avrdude done. Thank you.

avrdude finished

 

Finally:

I didn't write a program in the future. I just need to copy the blinky project and change the code in the related methods in Main. cpp. It is very convenient. Compared with the editor of arduinoide, it is already enjoyable.

After paying a salary, configuring a bluetooth module and building it slowly, you can use android to remotely control it and do whatever you want.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.