Arduino doubts

Go To Last Post
63 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ARDUINO 1.0 - 2011.11.30

[environment]

* The file extension for sketches has changed from .pde to .ino, to avoid
conflicts with the Processing software ("ino" are the last three letters
in "Arduino").

* There are a new set of toolbar icons, including a checkmark icon to
verify (compile) a sketch and an arrow for upload. The serial monitor
icon has moved to the right of the toolbar. Also, shift-clicking the
upload icon now uploads using a programmer (selected in the Tools menu).
You can still enable verbose output in the preferences dialog. (Icons
were designed by Nicholas Zambetti.)

Is this not the case then?

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For some reason, I missed this thread the first time around (not surprising, really). Did the issue with Arduino's ring buffer atomicity ever get fixed in their software?

If not, then please let me know....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Is this not the case then?

Yep, found it, thanks.

______
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is this not the case then?

Oh dear God - I looked at that very same dialog about 3 times but each time it was simply to click the link to where my preferences.txt is located. Completely missed/ignored the tick boxes for "verbose". What I was actually looking for (as a result of another thread here) was the linker invocation which I've finally found to be:

E:\arduino-1.0\hardware\tools\avr\bin\avr-gcc -Os -Wl,--gc-sections -mmcu=atmega8 -o C:\DOCUME~1\asl\LOCALS~1\Temp\build4243697076087149098.tmp\sketch_apr19a.cpp.elf C:\DOCUME~1\asl\LOCALS~1\Temp\build4243697076087149098.tmp\sketch_apr19a.cpp.o C:\DOCUME~1\asl\LOCALS~1\Temp\build4243697076087149098.tmp\core.a -LC:\DOCUME~1\asl\LOCALS~1\Temp\build4243697076087149098.tmp -lm 

The suggestion in the other thread was that "you cannot use floats in printf() when using Arduino". I guess with this default linker invocation that is true as there's no

-Wl,-u,vfprintf -lprintf_flt

but surely there's got to be some way for the user to over-ride default behaviour and ask for this instead? Again I couldn't see any reference in the preferences.txt so how does one change compiler or linker options. Or are these fixed and it's simply assumed the user always use Serial.print(floatvar)? But what about when they want to print (formatted) float to an LCD?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

but surely there's got to be some way for the user to over-ride default behaviour and ask for this instead? Again I couldn't see any reference in the preferences.txt so how does one change compiler or linker options. Or are these fixed and it's simply assumed the user always use Serial.print(floatvar)? But what about when they want to print (formatted) float to an LCD?

LCD inherits from print so it can also use the same method as Serial IE: LCD.print(floatvar). OK not ideal. Guess it's time to dig into the processing code and find where the linker options are hard coded.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well coincidentally I was looking at the print() over-loading for yet another thread today and notice that the float printing is done with:

size_t Print::printFloat(double number, uint8_t digits) 
{ 
  size_t n = 0;
  
  // Handle negative numbers
  if (number < 0.0)
  {
     n += print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i 0) {
    n += print("."); 
  }

  // Extract digits from the remainder one at a time
  while (digits-- > 0)
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    n += print(toPrint);
    remainder -= toPrint; 
  } 
  
  return n;
}

but that doesn't give you the control over formatting that (s)printf() would.

BTW I tried grepping the entire Arduino tree for the "gc-sections" that appears in the default linker invocation (in order to find where it could be modified) but while gc-sections appears a few places there's nothing obvious so I guess this is buried in a .jar or something that is not in obvious textual format.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well you could do a textual search in a binary file...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you download the source package from avrduino? It must be embedded in a java file.

http://arduino.googlecode.com/fi...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Did you download the source package from avrduino?

I didn't think I was going to have to. It surely cannot be an uncommon requirement for it to link with libprintf_flt.a?

What prompted this was a thread where someone said float in avr-gcc didn't work (clearly not true) but they then said that people on the Arduino forum where equally saying that Arduino could not produce anything but '?' for a float in sprintf() because of the fact that avr-gcc did not support float printing.

I fixed the first guy but I would like to correct that incorrect assertion for Arduino too. But to do so there has to be a user method to pass LDFLAGS so that the -Wl-u and -l can be passed to allow float printing.

As I noted elsewhere, Arduino is written to make the code easy to use not with any thought of efficiency so I'd have thought the 2K cost of always linking libprintf_flt.a would be a small price to pay.

(but the optimum solution would be a "preferences" entry to say "yes I'd like float support").

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BTW, I'm fighting a battle to get Arduino to run on an STK500/STK501 with an atmega2561 processor. I downloaded the latest Arduino IDE for Linux and created an entry in the boards.txt based on the existing mega2560 changing the fuses to be correct for the processor (I also left the jtag enabled). I modified the makefile for the stk500_v2 bootloader (there already was an entry for a m2561 but I specified a different led port = portG0). I built the bootloader and modified programmers.txt for support for the jtagmkII (they are using avrdude after all). BUT I couldn't download the bootloader from the IDE, it kept erroring out. SO I went back to windows and used avr studio with the jtag to set the fuses, then plugged the jtag into the linux box and used avrdude from the command line to burn the bootloader. That seemed to work. From the command line I ran avrdude to see if the bootloader was really there (-P/dev/ttyUSB0 -b57600 -cstk500v2 -pm2561) and I get a response from avrdude, it reads the device sig as 0x1e9802 and then hangs. Well I could try to debug the bootloader from avrstudio......

Wait a minute .... the same command on avrdude works on the windows box, only here it's -Pcom4 ????????

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Follow up.
I got the stk500 with the mega2561 to work with the Arduino IDE. I was using a USB to Serial converter (since the Linux computer doesn't have a real com port). It's not a dongle, but a Silicon Labs dev board. I soldered a .1uf cap from pin 4 of the DB9 (DTR) to the reset connector on the STK500. (I tried using the ttl output of the usb/serial chip, but as that was a 3v part it didn't work). Now the Arduino IDE can reset the board at just the right moment so the bootloader doesn't time out before the IDE is ready to start avrdude. Seems the IDE always compiles the sketch first when you hit the upload button, which means unless the bootloader waits long enough after reset before jumping to the user code you're screwed. I also found out I had NOT set the bootrst fuse, so I wasn't getting into the bootloader (except the first time when the app section was blank).
I used the stk500v2 bootloader source modified for my cpu, baud rate (57600) and cpu clock (8mhz).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
so there has to be a user method to pass LDFLAGS so that the -Wl-u and -l can be passed to allow float printing.

Nope. Nor for specifying compile-time constants for the C/C++ code (serial buffersize being the most common request.)

printf() and associated functions are surprisingly seldom used in ArduinoLand.

Now, the chipKit stuff has modified the IDE to be able to include changes to the compile-time decisions, and the "new" version of the IDE that will support "Due" (Atmel ARM Arduino) is supposed to be starting with that structure as well, so things may change in the future...

Pages