Arduino IDE
From Attie's Wiki
(Difference between revisions)
(Created page with 'To use the Arduino IDE on Fedora 12 you must do a few things: <pre> $ um install uisp avr-libc avr-gcc-c++ rxtx avrdude $ cd <path to arduino>/lib $ rm librxtxSerial.so RXTXco…') |
m |
||
(19 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
<pre> | <pre> | ||
− | $ | + | $ yum install uisp avr-libc avr-gcc-c++ rxtx avrdude |
$ cd <path to arduino>/lib | $ cd <path to arduino>/lib | ||
$ rm librxtxSerial.so RXTXcomm.jar | $ rm librxtxSerial.so RXTXcomm.jar | ||
$ ln -s /usr/share/java/RXTXcomm.jar | $ ln -s /usr/share/java/RXTXcomm.jar | ||
− | $ ln -s /usr/ | + | $ ln -s /usr/lib/rxtx/librxtxSerial.so |
− | $ cd <path to arduino>/hardware/tools | + | $ cd <path to arduino>/hardware/tools |
− | $ ln -s /usr/bin/avrdude | + | $ rm avrdude |
+ | $ ln -s /usr/bin/avrdude ./avrdude2 | ||
</pre> | </pre> | ||
+ | |||
+ | Then put the following in <code>./avrdude</code> and give it execute permissions | ||
+ | <source lang="bash"> | ||
+ | #!/bin/bash | ||
+ | cd `echo $0|rev|cut -d / -f2-|rev` | ||
+ | cla=$@ | ||
+ | while [ "$1" != "" ]; do | ||
+ | if [ "`echo $1|cut -b-2`" == "-P" ]; then | ||
+ | serprt=$(echo $1 | cut -b3-) | ||
+ | break | ||
+ | fi | ||
+ | shift | ||
+ | done | ||
+ | stty hup -F $serprt | ||
+ | ./avrdude2 $cla | ||
+ | </source> | ||
+ | |||
+ | If you are programming wirelessly and using serial comms, for some reason your 'sketch' <font color="red">MUST</font> use the same baud rate as the arduino bootloader otherwise you will have to directly program the arduino after the first time (or you can press reset at the correct time)<br> | ||
+ | ATmega168 uses 19200<br> | ||
+ | ATmega328 uses 57600 | ||
+ | |||
+ | Feel free to use this hack: (<code><path to arduino>/hardware/arduino/cores/arduino/HardwareSerial.cpp</code>) | ||
+ | <source lang="cpp"> | ||
+ | ... | ||
+ | |||
+ | void HardwareSerial::begin(long baud) | ||
+ | { | ||
+ | uint16_t baud_setting; | ||
+ | bool use_u2x; | ||
+ | |||
+ | // **** Attie's Hack! - Start **** | ||
+ | baud = 57600; | ||
+ | // **** Attie's Hack! - End **** | ||
+ | |||
+ | // U2X mode is needed for baud rates higher than (CPU Hz / 16) | ||
+ | if (baud > F_CPU / 16) { | ||
+ | use_u2x = true; | ||
+ | } else { | ||
+ | // figure out if U2X mode would allow for a better connection | ||
+ | |||
+ | // calculate the percent difference between the baud-rate specified and | ||
+ | // the real baud rate for both U2X and non-U2X mode (0-255 error percent) | ||
+ | uint8_t nonu2x_baud_error = abs((int)(255-((F_CPU/(16*(((F_CPU/8/baud-1)/2)+1))*255)/baud))); | ||
+ | uint8_t u2x_baud_error = abs((int)(255-((F_CPU/(8*(((F_CPU/4/baud-1)/2)+1))*255)/baud))); | ||
+ | |||
+ | ... | ||
+ | </source> | ||
+ | |||
+ | See also: | ||
+ | http://www.arduino.cc/playground/Linux/Fedora |
Latest revision as of 20:24, 20 December 2010
To use the Arduino IDE on Fedora 12 you must do a few things:
$ yum install uisp avr-libc avr-gcc-c++ rxtx avrdude $ cd <path to arduino>/lib $ rm librxtxSerial.so RXTXcomm.jar $ ln -s /usr/share/java/RXTXcomm.jar $ ln -s /usr/lib/rxtx/librxtxSerial.so $ cd <path to arduino>/hardware/tools $ rm avrdude $ ln -s /usr/bin/avrdude ./avrdude2
Then put the following in ./avrdude
and give it execute permissions
#!/bin/bash cd `echo $0|rev|cut -d / -f2-|rev` cla=$@ while [ "$1" != "" ]; do if [ "`echo $1|cut -b-2`" == "-P" ]; then serprt=$(echo $1 | cut -b3-) break fi shift done stty hup -F $serprt ./avrdude2 $cla
If you are programming wirelessly and using serial comms, for some reason your 'sketch' MUST use the same baud rate as the arduino bootloader otherwise you will have to directly program the arduino after the first time (or you can press reset at the correct time)
ATmega168 uses 19200
ATmega328 uses 57600
Feel free to use this hack: (<path to arduino>/hardware/arduino/cores/arduino/HardwareSerial.cpp
)
... void HardwareSerial::begin(long baud) { uint16_t baud_setting; bool use_u2x; // **** Attie's Hack! - Start **** baud = 57600; // **** Attie's Hack! - End **** // U2X mode is needed for baud rates higher than (CPU Hz / 16) if (baud > F_CPU / 16) { use_u2x = true; } else { // figure out if U2X mode would allow for a better connection // calculate the percent difference between the baud-rate specified and // the real baud rate for both U2X and non-U2X mode (0-255 error percent) uint8_t nonu2x_baud_error = abs((int)(255-((F_CPU/(16*(((F_CPU/8/baud-1)/2)+1))*255)/baud))); uint8_t u2x_baud_error = abs((int)(255-((F_CPU/(8*(((F_CPU/4/baud-1)/2)+1))*255)/baud))); ...