Arduino IDE

From Attie's Wiki
(Difference between revisions)
Jump to: navigation, search
m
Line 29: Line 29:
 
</source>
 
</source>
  
If you are programming wirelessly and using serial comms, for some reason you <font color="red">MUST</font> select the same baud rate as the arduino bootloader otherwise you will have to directly program the arduino.<br>
+
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>
 
ATmega168 uses 19200<br>
 
ATmega328 uses 57600
 
ATmega328 uses 57600

Revision as of 18:22, 23 May 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)));
 
...

See also: http://www.arduino.cc/playground/Linux/Fedora

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox