arduino ide 功能過於簡單,連最基本的斷點調式功能都不提供。經過串口查看調式數據實在是很不便捷,經過某種方式遠程調式arduino是頗有必要的。html
此次嘗試是在64位fedora 22下進行,使用的arduino板子類型爲leonardo
.須要python 2 支持.python
bash$ uname -a >Linux heymind-laptop 4.0.5-300.fc22.x86_64 #1 SMP Mon Jun 8 16:15:26 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
PlatformIO is a cross-platform code builder and the missing library manager.linux
之前我在linux開放arduino時候使用的是ino
工具,PlatformIO
和它相似,只不過它功能更增強大,支持的芯片種類繁多,包括stm32,avr都有支持link.對於IDE 也有很好的配置教程link,甚至還提供庫管理(沒用過).redis
bashpip install platformio && pip install --egg scons
安裝很簡單。bash
bashplatformio platforms install atmelavr platformio platforms show atmelavr
這是一個相似於仿真器的程序,他能夠經過usb串口與單片機通訊,並模擬出一個gdb server
,能夠經過avr-gdb
或者其餘IDE進行debug.eclipse
下載源代碼:http://ftp.yzu.edu.tw/nongnu//simulavr/simulavr-1.0.0.tar.gzide
以後進入目錄./configure
,有可能報錯工具
Could not locate libbfd.so/libbfd.a and/or bfd.h.ui
解決依賴。this
bashdnf install binutils-devel
編譯有可能報錯,
systemclock.cpp:70:8: note: use ‘this->resize’ instead
只須要手動修改一下這個文件,按照提示修改便可。總體安裝流程以下:
bash./configure make make install
初始化工程
bashplatformio init --borad=leonardo
以後能夠在src
裏編輯代碼,將庫依賴放到lib
裏。
用platformio run
上傳到板子。
啓動gdb server
bashsimulavr --gdbserver -p 4242 --device atmega16
使用gdb進行調式(也能夠在 QT Creator , eclipse中進行,配置過程類似)
bash$ avr-gdb >GNU gdb (GDB) 7.1 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=avr". For bug reporting instructions, please see: ><http://www.gnu.org/software/gdb/bugs/>. (gdb) target remote localhost:4242 >Remote debugging using localhost:4242 >warning: Can not parse XML target description; XML support was disabled at compile time (gdb) add-symbol-file /home/exodus/workspace/arduino/platformio-try/.pioenvs/leonardo/firmware.elf 0 >add symbol table from file "/home/exodus/workspace/arduino/platformio-try/.pioenvs/leonardo/firmware.elf" at > .text_addr = 0x0 (y or n) y >Reading symbols from /home/exodus/workspace/arduino/platformio-try/.pioenvs/leonardo/firmware.elf...done. (gdb) list >23 int atexit(void (*func)()) { return 0; } 24 25 // Weak empty variant initialization function. 26 // May be redefined by variant files. 27 void initVariant() __attribute__((weak)); 28 void initVariant() { } 29 30 int main(void) >31 {
好了,就到這裏了,arduino從如今起調式就很美好了~ 往後有機會再寫寫如何在ide中進行調式,爭取配置出一個完美的IDE~