Show Posts
Pages: [1]
1  Using Arduino / Installation & Troubleshooting / Re: Image too big for flash or avrdude problem? on: May 04, 2013, 09:06:32 am
It turns out I'm using 1.0.2, but I don't think this is the problem.

I recently added -ffunction-sections -fdata-sections to CFLAGS and linked with -Wl,--gc-sections. This should strip anything unused. It makes the binary a little smaller, but not small enough. Oddly, if i remove the SD.begin() so that the sources contain no reference to the SD library, the binary is much much smaller.

Maybe, like you say, sd.begin() erroneously pulls in the whole library. Perhaps I am missing a linker/objcopy flag? Any ideas anyone?
2  Using Arduino / Installation & Troubleshooting / Image too big for flash or avrdude problem? on: May 04, 2013, 05:19:14 am
Hi,

I am currently working on improving the OpenBSD arduino toolchain described here:
http://playground.arduino.cc/OpenBSD/CLI

I have managed to fix a few things that will make the makefile more user-friendly, however, I have noticed an issue with the SD library.

If I build a simple program with just SD.begin() in setup() I get a hex file like so:
Code:
$ make
test -d applet || mkdir applet
echo '#include "Arduino.h"' > applet/test.cpp
echo '#ifdef __cplusplus' >> applet/test.cpp
echo 'extern "C" void __cxa_pure_virtual(void) { while(1); }'  >> applet/test.cpp
echo '#endif\n' >> applet/test.cpp
cat test.ino >> applet/test.cpp
cat /usr/local/share/arduino//cores/arduino/main.cpp >> applet/test.cpp
mkdir -p utility
/usr/local/bin/avr-gcc -c -mmcu=atmega328p -I. -gstabs -DF_CPU=16000000 -I/usr/local/share/arduino//cores/arduino -I/usr/local/share/arduino//libraries/SD -I/usr/local/share/arduino//libraries/File -I/usr/local/share/arduino//libraries/utility/SdFile -I/usr/local/share/arduino//libraries/utility/SdVolume -I/usr/local/share/arduino//libraries/utility/Sd2Card -I/usr/local/share/arduino//libraries/SD/utility/ -I/usr/local/share/arduino//libraries/File/utility/ -I/usr/local/share/arduino//libraries/utility/SdFile/utility/ -I/usr/local/share/arduino//libraries/utility/SdVolume/utility/ -I/usr/local/share/arduino//libraries/utility/Sd2Card/utility/ -I/usr/local/share/arduino//variants/standard -I/usr/local/share/arduino//variants/standard -Os -Wall -Wstrict-prototypes  -std=gnu99  -ffunction-sections -fdata-sections /usr/local/share/arduino//cores/arduino/wiring.c -o wiring.o
...

   text    data     bss     dec     hex filename
      0   30670       0   30670    77ce applet/test.hex
$ du -h applet/test.hex                                                                             
86.0K   applet/test.hex

Notice that the reported size (dec) is close to 32K, the size of a standard arduino flash.

If I now try to upload this with avrdude-5.11 (or avrdude-5.10), this happens:

Code:
> sudo make upload
/usr/local/bin/avrdude -V -F -C /etc/avrdude.conf -p atmega328p -P /dev/cuaU0  -c arduino -b 115200 -U flash:w:applet/test.hex

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 "applet/test.hex"
avrdude: input file applet/test.hex auto detected as Intel Hex
avrdude: writing flash (30670 bytes):

Writing | ###############################################    | 93% 5.48savrdude: stk500_recv(): programmer is not responding
*** Error 1 in /home/edd/source/test (BSDmakefile:198 'upload')

Uploading gets to 93% every time before stalling. This does not happen with an arduino mega.

My question is, does the program not fit in the 32K flash, or is this an avrdude issue?

I speculate that the image is too big for the flash, if that is the case then why? The SD library should fit on 32K flash.

The makefile I am using (with my changes) is here:
https://github.com/jasperla/openbsd-wip/blob/master/devel/arduino/files/BSDmakefile

This problem was not introduced by my changes.

Any ideas? Removing -gstabs does not help. I have experimented with stripping the intermediate core.a; this makes the .a much smaller but presumably in a section which is not present in the resulting hex file. The hex file remains the same size.
3  Development / Other Software Development / SD Library Docs on: May 02, 2013, 10:35:49 am
Hi,

Just a small matter. Would it be possible to list the default pin meanings on the SD card library page:
http://arduino.cc/en/Reference/SD

So we know which pins are the default for SPI, but we are not told the meaning. You can figure this out from the example code, but it someone new to the site has to go digging.

Thanks
4  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino Uno Serial Problems (57600 baud is broken) on: December 21, 2010, 01:02:47 pm
I have also been having serial port issues, but I am not using the IDE. It seems the Uno's USART baud doubler may be on by default. See here:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1292954023
5  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Possible Arduino Uno USART Bug on: December 21, 2010, 03:11:30 pm
OK more info. I am using the unix command cu to connect to the serial line on the arduino. To use cu, i do `cu -l cuaU0 -s 9600`.

The above code untouched on the duemianove works fine, the string is sent at 9600 to the terminal emulator.

The same again on an Uno, you get junk because the board is sending at twice the baud rate it should. If you reconnect cu at speed 19200 (2 * 9600), you get the correct outcome.

The reason the Uno trasmits at 19200 instead of 9600 is that U2X0 (serial baud speed doubler) is ON. So the UART baud rate is doubled. In order to make the above program work as expected we turn U2X0 off, hence NOT doubling the serial baud rate.

So something (bootloader?) is setting U2X0 on by default on an Uno, whereas that is off by default on a Deumilanove.

I really can't spell it out more than that.
6  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Possible Arduino Uno USART Bug on: December 21, 2010, 02:20:52 pm
ah sorry. You get junk out of the serial line on the Uno because it is transmitting at double the expected baud rate. This is due to the USART doubler being enabled for some reason.

So, if you set the baud rate to 9600, the Uno transmits at 19200, unless you explicitely turn off the doubler.

Cheers
7  Forum 2005-2010 (read only) / Bugs & Suggestions / Possible Arduino Uno USART Bug on: December 21, 2010, 12:53:43 pm
Hi,

After hours of trying to figure out why my serial comms dont work on the Uno, but did on the Duemilanove, myself and Tricia from #sparkfun have discovered something most odd.

It seems the Uno has the USART baud doubler ON by default where as the Duemilanove does not.

Test case:
Code:
#include <avr/io.h>
#include <util/delay.h>

#define BAUD 9600
//#include <util/setbaud.h>

void serial_init()
{
        uint16_t                        ubbr;

        /* set the baud, the traditional way */
        ubbr = 103;
        UBRR0H = ubbr >> 8;
        UBRR0L = ubbr & 0xff;

        /* Set the baud rate - the setbaud.h way */
#if 0
        UBRR0H = UBRRH_VALUE;
        UBRR0L = UBRRL_VALUE;
#endif

        /* set the framing to 8N1 */
        UCSR0C = (3 << UCSZ00);
        /* Engage! */
        UCSR0B = (1 << RXEN0) | (1 << TXEN0);

        /* doubler off  - Only needed on Uno XXX */
        //UCSR0A &= ~(1 << U2X0);

        return;
}

void serial_write(unsigned char c)
{
        while ( !(UCSR0A & (1 << UDRE0)) );
        UDR0 = c;
}

int main (void)
{
        char i = 0;
        char *str = "the quick brown fox jumps over the lazy dog. 1234567890\r\n";
        unsigned char rd;

        serial_init();

        while (1) {
                serial_write(str[i++]);
                if (str[i] == '\0') {
                        i = 0;
                        _delay_ms(500);
                }
        }
        return 0;
}

This is plain C. I am not using the IDE. To build this I have a Makefile which does:

avr-gcc -Wall -Os -DF_CPU=16000000UL -mmcu=atmega328p -o serial.elf serial.c
avr-objcopy -O ihex -R .eeprom serial.elf serial.hex

NOTE: the correctly set F_CPU value of 16MHz. Both the Uno and Duemilanove are 16Mhz.

I then upload the binary using avrdude in the normal way.

This code works on the Duemilanove out of the box, but on the Uno we must explicitely force the USART baud doubler off (uncomment the line marked by XXX).

You can use either setbaud.h or the manual method to set the baud rate register, it makes no difference.

I think this is a bug, but can someone confirm this. Anything wrong with the technique? Reproducable? A bug?

Cheers  :-/

Edd
8  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Arduino Uno serial speed issue on: December 21, 2010, 01:06:33 pm
Is this related?:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1292954023
Pages: [1]