博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Eclipse helios 上编写arduino程序并进行烧录
阅读量:7174 次
发布时间:2019-06-29

本文共 4590 字,大约阅读时间需要 15 分钟。

  刚接触arduino,很不错。

  arduino 的ide我一开始使用的是0022版本,它的编辑器实在是难受,没有提示没有自动补全,由于一直使用eclipse开发,就找找办法了。

  我的板子是 Arduino UNO..

  按照官方的办法,无果。。。。

  按照arduino.tw的办法,无果...

 

  最终,终于找到一个办法,在无尽的折腾中,终于搞定了,下面是Arduino UNO的配置步骤:

 

准备工作:

  * Eclipse CPP  (我的版本是 eclipse-cpp-helios-SR2-win32)

  * AVR Eclipse Plugin (我的版本是 avreclipse-p2-repository-2.3.4.20100807PRD)

  * WinAVR (我的版本是 WinAVR-20100110)

  * Arduino IDE (我的版本是 arduino-0022)

 

Step 1 --配置arduino编译环境:

  第一步:

  (嫌麻烦,可以直接跳到第二步)

  依次装好winAvr和eclipse-cpp后,把下载到的avr eclipse plugin这个压缩包解压,放到 eclipse/dropins这个目录里,重启eclipse后,就会有avr的选项了。

  首先进入eclipse的属性设置:

  

  

  然后在avr的path选项,会像这样,路径是你的安装路径,如图,AVR-GCC,GNU make,AVR header files 都是winavr的路径,自己推算

  

  

 

  然后导入这个工程,首先是为了各种gcc 参数的简化配置,自己从头来的话,配置很麻烦,直接导入很省事,只要少量更改。其次,这个工程是编译arduino core这个库文件,以后编译arduino工程的时候,就不用手动导入那么多头文件了。

 

  下载

 

  import导入工程后,要对工程属性进行一些更改,工程->右键->属性 

  把target hardware的参数配置成这样:

    MCU type: ATmega328P

    MCU Clock Frequency:16000000 (六个〇)  

  

  

  然后设置工程引入的库文件, 还是在工程的属性设置里  C/C++ Build -> Setting

  将要对 AVR ComplierAVR C++ ComplierDirectories设置,目录就是Arduino IDE下面相关的路径,请看图:  

  

  两个路径设置是相同的

 

  至此,就可以编译了,点击 project -> make all ,eclipse应该可以编译成功,输出如下:  

**** 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

 

  在工程的 Release目录下会有一个 libArduinoCore.a 文件生成,这个就是编译好的库文件,以后用得着。

    

  第二步:

  下载

  !!!注意,这个工程的main.cpp中,和arduino中的方法雷同,自行更改setup() loop()等等内容,以便以自己方便的方式来测试。

  和上面的方法一样,将他导入eclipse,并把上面生成的 libArduinoCore.a 复制到这个工程中并且覆盖,然后就是配置编译参数了,只是更改几个路径而已,方法同上。

  最后 make all,成功编译,输出和上面的差不多,会在release目录中看到目标文件 Blinky.elf。

  剩下就是烧录了。

 

Step 2 --配置烧录环境:

  进入eclipse 的属性设置里面(看step的图),设置下图中的参数为你本机相应地址  

  

  

  然后,设置AvrDude的配置文件的路径,更改为自己的arduinoIDE目录下,最后就是添加一个AVRDude的配置了:  

  

 

  AVRDude配置参数:其中串口设置为自己的,我的com3,插上板子后,在系统的设别管理器里面就会看到 arduino uno,后面会显示出是哪个串口  

  

 

  最后,ok,将编译好后的elf烧录,点击这个自动完成,输出大致如下:

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:

  以后没写一个程序,只需复制Blinky这个工程,并更改main.cpp中相关方法内的代码就行了,很方便,与ArduinoIDE的编辑器比,已经算是享受了。

  等发了工资,配个蓝牙模块,慢慢搭建,就可以用Android遥控它了,随心所欲的干各种geek的那些事了

 

 

转载地址:http://smfzm.baihongyu.com/

你可能感兴趣的文章
AES&FEC GPON中的加密与纠错
查看>>
python 字典嵌套
查看>>
Android系统名词解释汇总
查看>>
推荐开发工具系列之--PyF5(自动刷新)
查看>>
Nginx配置
查看>>
Josephus问题的不同实现方法与总结
查看>>
linux监控系统_Zabbix概念(2)
查看>>
JMM & synchronized概述
查看>>
路由器改交换机设置
查看>>
nagios系列(八)之nagios通过nsclient监控windows主机
查看>>
Eclipse SVN插件设置
查看>>
Java中private、protected、public和default的区别-001
查看>>
CCF NOI1123 A-B
查看>>
Ubuntu的默认root密码
查看>>
Vue+Element+Select获取选中的对象
查看>>
Ubuntu下Tomcat连接MySql数据库
查看>>
WPF Summary 系列指导(连载中…^_^)
查看>>
feof()的实现
查看>>
VS中Debug与Release、_WIN32与_WIN64的区别
查看>>
真正通用的SQL分页存储过程
查看>>