I am working on a simple Java virtual machine for my Arduino Mega 2560. My Arduino sketch has a somewhat large (~800 byte) block of Java bytecode stored in PROGMEM. The rest of my code is pretty standard and does not use any fancy libraries. When I try to compile my sketch, I get the following error:
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/
avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o:
In function `__vector_default':
(.vectors+0x68): relocation truncated to fit: R_AVR_13_PCREL against
symbol `__vector_26' defined in .text.__vector_26 section in
core.a(HardwareSerial.cpp.o)
If I remove ~20 bytes from the block of Java bytecode, the code compiles without any problem. Another way to make compilation succeed is to remove a Serial.println statement. Strangely, the sketch can also be compiled if I choose the board "Arduino UNO" instead of "Arduino Mega".
Here is a pastebin of the code: Failing Arduino Mega 2560 Sketch - Pastebin.com
I am using Arduino IDE 1.0.5 on Mac OS Mavericks.
Does anyone know what is going on here? I really want to continue working on the Java virtual machine! Thanks.
(I also submitted this problem to www.reddit.com/r/arduino, but with no replies.)