Sprintf problems with Arduino AVR boards package by Arduino version 1.6.12

Sprintf problems with Arduino AVR boards package by Arduino version 1.6.12

Hello,

I use a custom board with an 32U4, compiling for board Arduino/Genuino Micro. When i compile my program with Arduino 1.6.10 IDE and Arduino AVR boards package by Arduino version 1.6.12 i get this error:

--- start log

Arduino: 1.6.10 (Windows 7), Board: "Arduino/Genuino Micro"


(cut down due to forum error : The message exceeds the maximum allowed length (9000 characters).)

\AppData\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp\libraries\CAN_BUS_Shield-master\mcp_can.cpp.o" "C:\Users\gast\AppData\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp\libraries\SPI\SPI.cpp.o" "C:\Users\gast\AppData

\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp\libraries\AD56X4\AD56X4.cpp.o" "C:\Users\gast\AppData\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp\libraries\ANSI_VT100\ANSI_VT100.cpp.o" "C:\Users\gast\AppData\Local\Temp

\builde6e65bc198dc82d61cc962b08dd66246.tmp/core\core.a" "-LC:\Users\gast\AppData\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp" -lm
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function 'main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'

 }

 ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: this is the insn:

(insn 1750 1747 1753 40 (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0  S1 A8])

        (subreg:QI (reg/f:HI 1232) 1)) g:\Arduino\libraries\PLC32U4v1\PLC32U4v1.cpp:1003 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 5 [0x5])

        (nil)))

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51: confused by earlier errors, bailing out

lto-wrapper: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

Using library PLC32U4v1 in folder: g:\Arduino\libraries\PLC32U4v1 (legacy)
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire 
Using library Adafruit_MCP23017_Arduino_Library at version 1.0.1 in folder: g:\Arduino\libraries\Adafruit_MCP23017_Arduino_Library 
Using library CAN_BUS_Shield-master in folder: g:\Arduino\libraries\CAN_BUS_Shield-master (legacy)
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Using library AD56X4 in folder: g:\Arduino\libraries\AD56X4 (legacy)
Using library ANSI_VT100 in folder: g:\Arduino\libraries\ANSI_VT100 (legacy)
exit status 1
Error compiling for board Arduino/Genuino Micro.

--- end log

When i revert to Arduino 1.6.10 IDE and Arduino AVR boards package by Arduino version 1.6.11 i get the normal compile succesfull:

--- start log

(cut down due to forum error : The message exceeds the maximum allowed length (9000 characters).)


\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp/Twizy_Emergency_Control.ino.elf" "C:\Users\gast\AppData\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp/Twizy_Emergency_Control.ino.eep"
"C:\Users\gast\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-objcopy" -O ihex -R .eeprom  "C:\Users\gast\AppData\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp/Twizy_Emergency_Control.ino.elf" "C:

\Users\gast\AppData\Local\Temp\builde6e65bc198dc82d61cc962b08dd66246.tmp/Twizy_Emergency_Control.ino.hex"
Using library PLC32U4v1 in folder: g:\Arduino\libraries\PLC32U4v1 (legacy)
Using library Wire at version 1.0 in folder: C:\Users\gast\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\libraries\Wire 
Using library Adafruit_MCP23017_Arduino_Library at version 1.0.1 in folder: g:\Arduino\libraries\Adafruit_MCP23017_Arduino_Library 
Using library CAN_BUS_Shield-master in folder: g:\Arduino\libraries\CAN_BUS_Shield-master (legacy)
Using library SPI at version 1.0 in folder: C:\Users\gast\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.11\libraries\SPI 
Using library AD56X4 in folder: g:\Arduino\libraries\AD56X4 (legacy)
Using library ANSI_VT100 in folder: g:\Arduino\libraries\ANSI_VT100 (legacy)

Sketch uses 24,790 bytes (86%) of program storage space. Maximum is 28,672 bytes.
Global variables use 1,826 bytes (71%) of dynamic memory, leaving 734 bytes for local variables. Maximum is 2,560 bytes.

--- end log

The problem seems to be:

        //debug message
        sprintf ( _PLC32U4v1.v_Terminal_Buffer, "-%08d EStop sw pressed.", ( millis() / 1000 ) );

When i remove this line it compiles. Or change it to

   sprintf ( _PLC32U4v1.v_Terminal_Buffer, "%08d", ( millis() / 1000 ) );

I cannot reproduce this in a small code example, seems it has something todo with the use of memory and class.

  • Tested working in IDE Arduino.cc :
  • arduino-1.6.6-windows
  • arduino-1.6.7-windows
  • arduino-1.6.10-windows with board version 1.6.11

Thank you for reading, wltue

No idea, but how big is your _PLC32U4v1.v_Terminal_Buffer?

Note that

sprintf ( _PLC32U4v1.v_Terminal_Buffer, "%08d", ( millis() / 1000 ) );

requires one character less storage space than

sprintf ( _PLC32U4v1.v_Terminal_Buffer, "-%08d EStop sw pressed.", ( millis() / 1000 ) );

So maybe a warning about a possible overflow?

Thank you for your response.

The current buffer is:

char v_Terminal_Buffer[40];

error messsage with Arduino AVR boards package by Arduino version 1.6.12

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function 'main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'

 }

 ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: this is the insn:

(insn 1758 1755 1761 42 (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0  S1 A8])

        (subreg:QI (reg/f:HI 1245) 1)) g:\Arduino\libraries\PLC32U4v1\PLC32U4v1.cpp:1003 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 5 [0x5])

        (nil)))

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51: confused by earlier errors, bailing out

lto-wrapper: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

changing to 80

char v_Terminal_Buffer[80];

puts out with Arduino AVR boards package by Arduino version 1.6.12:

:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function 'main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'

 }

 ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: this is the insn:

(insn 1761 1758 1764 42 (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0  S1 A8])

        (subreg:QI (reg/f:HI 1256) 1)) g:\Arduino\libraries\PLC32U4v1\PLC32U4v1.cpp:1003 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 5 [0x5])

        (nil)))

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51: confused by earlier errors, bailing out

lto-wrapper: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

Problem i am having seems to point to Arduino AVR boards package by Arduino version 1.6.12

Compiling with Arduino AVR boards package by Arduino version 1.6.11 seems fine..

I freed up some sram memory, by putting strings to eeprom. When compiling with old board version it puts out now.

Sketch uses 25,408 bytes (88%) of program storage space. Maximum is 28,672 bytes.
Global variables use 1,084 bytes (42%) of dynamic memory, leaving 1,476 bytes for local variables. Maximum is 2,560 bytes.

Tried Arduino IDE 1.6.11 Hourly Build 2016/08/12 and Arduino AVR Board version 1.16.13.

Still Errors with:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp: In function 'main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'

 }

 ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51:1: error: this is the insn:

(insn 1800 1797 1803 42 (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0  S1 A8])

        (subreg:QI (reg/f:HI 1260) 1)) g:\Arduino\libraries\PLC32U4v1\PLC32U4v1.cpp:1007 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 5 [0x5])

        (nil)))

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp:51: confused by earlier errors, bailing out

lto-wrapper: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

Reverting to Arduino AVR Board version 1.16.10. with same version IDE compiles fine.

Like euuuuhhhh help??? Someone? Please?

avr-gcc was updated from 4.8.1-arduino5 to 4.9.2-atmel3.5.3-arduino2. The compiler flags in platform.txt were also changed, mainly to use LTO(https://github.com/arduino/Arduino/commit/4cf3278ee0629151cedef6445e02722da1879737). I'm pretty sure the compiler update and/or the compiler flag changes are the cause of your issue. You could try replacing the platform.txt file from Arduino AVR Boards 1.6.11 to isolate the issue further(that will remove the compiler flags changes but still use the new avr-gcc version). Other than that I don't have any advice for you. Hopefully this might help put you on the right track to a solution.

Thank you for your help.

I reinstalled IDE, cleaned directory, rebooted, reinstalled arduino-1.6.10 on both computers.

On one pc .13 boards version other the .11 boards version.

I compared the platform.txt versions with total commander. Only difference found is the version number.

Strange to mention is, the .11 boards version has in line 9 version=1.6.12.

I will leave this problem as is for now. I will put arduino-1.6.10-windows.exe in the project archive.

wltue: Strange to mention is, the .11 boards version has in line 9 version=1.6.12.

No it doesn't you must be looking at the Arduino AVR Boards version(1.6.12) that comes bundled with Arduino IDE 1.6.10. When you install something via Tools > Board > Boards Manager it is installed in a different location. Do this: Click on the path shown after File > Preferences > More preferences can be edited directly in the file: From that folder navigate to the subfolder packages/arduino/hardware/avr/1.6.11 Open the file platform.txt Check the version listed on line 9 Compare that platform.txt to the 1.6.12 platform.txt located at {Arduino IDE installation folder}/hardware/arduino/avr you will see the LTO and other flags were added between the versions.

wltue: I reinstalled IDE, cleaned directory, rebooted, reinstalled arduino-1.6.10 on both computers.

On one pc .13 boards version

That doesn't make sense. There's no way to install Arduino AVR Boards 1.6.13 on Arduino IDE 1.6.10 unless you copied it over manually. You must either be using the hourly build of Arduino IDE 1.6.11 or you meant Arduino AVR Boards 1.6.12 instead of Arduino AVR Boards 1.6.13. However, you are correct that there have been no changes made to the Arduino AVR Boards platform.txt since the release of Arduino AVR Boards 1.6.12 other than the version number.

Thanks again for your time and answers. I am learning a lot.

Like you mentioned, i made a lot of mistakes, but finally;

  • changed the code so the includes were no libraries anymore, i can move it more easily to different computer setups.

  • Compared the difference between these platform.txt (1.6.11 and 1.6.12 ) are the addition of these flags, hopefully doing it right now:

23 compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects 24 compiler.c.elf.flags={compiler.warning_flags} -Os -flto -fuse-linker-plugin -Wl,--gc-sections 26 compiler.S.flags=-c -g -x assembler-with-cpp -flto 28 compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto 29 compiler.ar.cmd=avr-gcc-ar

Changing this file, reverting to the old flags, step at the time, to the old version didn't do anything (still same errors) until line 29, it didn't compile at all anymore.

I tried to make some small code for simulating the errors, even filling the memory. No success to simulate the errors. Maybe you are interested in the complete code?

That indicates the issue is caused by the avr-gcc update rather than the LTO(Link Time Optimization) that the new avr-gcc version allows. That doesn't tell you what the cause is but it does narrow down the cause. You know it wasn't caused by changes in the IDE/arduino-builder because you're using the same IDE version. It's not caused by changes in Wire or SPI libraries(which are included with Arduino AVR Boards) because Arduino AVR Boards 1.6.11 and 1.6.12 have the same versions of those libraries. The only other possible changes would be to the core files. You can see the history here: https://github.com/arduino/Arduino/commits/master/hardware/arduino/avr/cores/arduino.

My suspicion is it's caused by the new compiler version.

Ok thank you very much. I will check the history.

wltue: I tried to make some small code for simulating the errors, even filling the memory. No success to simulate the errors. Maybe you are interested in the complete code?

That's good at least you attempted to make a simplified demonstration sketch, most people don't bother even trying but it really does help when we don't have to wade through hundreds of lines of irrelevant code.. I wouldn't know where to start with your code but someone else might so it can't hurt to post it. If it's too long to post in code tags then you can attach it to your reply. Either click the "Reply" or the "Preview" button and you'll see an "Attachments and other options" link appear.

I saw just now the debug warnings were not on "ALL"

When changing this the IDE would output this:

258:96: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=] sprintf ( _PLC32U4v1.v_Terminal_Buffer, "-%08d EStop sw pressed.", ( millis() / 1000 ) );

Changing to sprintf ( _PLC32U4v1.v_Terminal_Buffer, "-%08d EStop sw pressed.", (unsigned int) ( millis() / 1000 ) );

It just removes the warning. The situation still the same.

I ran into this problem too.

I changed the buffer data type to char * from a char buffer[50] and now it works without a problem :)

mbari: I ran into this problem too.

I changed the buffer data type to char * from a char buffer[50] and now it works without a problem :)

Sp now you have a pointer pointing to nothing? Or did you mslloc?