Hi,
I am currently working on improving the OpenBSD arduino toolchain described here:
http://playground.arduino.cc/OpenBSD/CLII 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:
$ 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:
> 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/BSDmakefileThis 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.