Problems with sprintf and avr compiler in arduino 1.6.10

Hello,

I am facing a problem with my arduino leonardo, when I try to compile I always get the NO_REGS error,

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc" -Wall -Wextra -Os -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega32u4  -o "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp/LoRaWAN_01a_configure_module_868.ino.elf" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp\sketch\LoRaWAN_01a_configure_module_868.ino.cpp.o" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp\libraries\LoRaWAN_library_arduino_v1_2\arduinoLoRaWAN.cpp.o" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp\libraries\LoRaWAN_library_arduino_v1_2\arduinoMultiprotocol.cpp.o" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp\libraries\LoRaWAN_library_arduino_v1_2\arduinoUART.cpp.o" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp\libraries\LoRaWAN_library_arduino_v1_2\arduinoUtils.cpp.o" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp\libraries\Wire\Wire.cpp.o" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp\libraries\Wire\utility\twi.c.o" "C:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp/core\core.a" "-LC:\Users\jjj~1.\AppData\Local\Temp\build529996e65abcfe66a66608b5c3347cab.tmp" -lm
C:\Users\jjj.M\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\cores\arduino\main.cpp: In function 'main':

C:\Users\jjj.M\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'

 }

 ^

C:\Users\jjj.M\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\cores\arduino\main.cpp:51:1: error: this is the insn:

(insn 1621 1618 1624 140 (set (mem:QI (post_dec:HI (reg/f:HI 32 __SP_L__)) [0  S1 A8])

        (subreg:QI (reg/f:HI 1255) 1)) \\M-SVR02\RedirectedFolders\jjj\My Documents\Arduino\libraries\LoRaWAN_library_arduino_v1_2\arduinoLoRaWAN.cpp:2305 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 9 [0x9])

        (nil)))

C:\Users\jjj.M\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.12\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

The line of code that seems to fail arduinoLoRaWAN.cpp:2305 is this

sprintf_P(_command,(char*)pgm_read_word(&(table_LoRaWAN_COMMANDS[20])),channel,freq);

where

const char* const table_LoRaWAN_COMMANDS[] PROGMEM=       
{        command_00,
          ...
          command_20,
          ...
          command_80
};

and

 const char command_20[]    PROGMEM =   "mac set ch freq %u %lu\r\n";

I have seen this other error reported, and I was wondering whether they are related or not. Any advise how to figure it out?

Thanks in advance,

Regards!

ndarkness:
I have seen this other error reported, and I was wondering whether they are related or not. Any advise how to figure it out?

I think so, I remembered that thread when I first started reading your post. Good job doing a search of the forum before posting!

I don't know what the real solution to this issue is but the finding in the other thread was the error is related to the new version of avr-gcc. If you install Arduino AVR Boards 1.6.11 using Boards Manager that should make it work. It would be much better to actually find out how to fix this so that you can use the up to date tool version.

pert:
I think so, I remembered that thread when I first started reading your post. Good job doing a search of the forum before posting!

I don't know what the real solution to this issue is but the finding in the other thread was the error is related to the new version of avr-gcc. If you install Arduino AVR Boards 1.6.11 using Boards Manager that should make it work. It would be much better to actually find out how to fix this so that you can use the up to date tool version.

I'm glad you replied pert. I was going to suggest changing to IDE V1.6.11 or even V1.6.9, (deleting Arduino15 in between), having remembered that thread myself, and seen that a fix wasn't mentioned at the end.

(And I too was impressed that he'd done a search and found that thread.)

Thanks pert, OldSteve for your reply and encouraging people to look for previous posts! :slight_smile:

I have installed the whole new arduino IDE v 1.6.11 and I have still the same issue, I will install Arduino AVR Boards 1.6.11 using Boards Manager as pert mentioned, otherwise I will revert to 1.6.9 to check.

I'll keep you posted

Kind regards

ndarkness:
Thanks pert, OldSteve for your reply and encouraging people to look for previous posts! :slight_smile:

I have installed the whole new arduino IDE v 1.6.11 and I have still the same issue, I will install Arduino AVR Boards 1.6.11 using Boards Manager as pert mentioned, otherwise I will revert to 1.6.9 to check.

I'll keep you posted
Kind regards

Did you delete the Arduino15 folder after uninstalling V1.6.10?

You should have tried pert's suggestion first. He's more knowledgable on these matters than I am. That's why I said I was glad he answered earlier.

RESOLVED:
I just stumbled across this after half a day - racking my brains...
1.6.11 sprintf() chews up (at least one of) the incoming values.

Even tho the comments suggest it's the avr-gcc tools...
I'll probably go back to 1.6.7 for now, as it worked fine - just trying to stay up to date. - sigh.

SOLUTION:
The bug arrived with Windows 10 Anniversary update (surprise!)
I restored back prior to the update, thence reinstalled 1.6.11
Everything working again as it is expected to!

OldSteve:
Did you delete the Arduino15 folder after uninstalling V1.6.10?

You should have tried pert's suggestion first. He's more knowledgable on these matters than I am. That's why I said I was glad he answered earlier.

Yes I did it and it didn't work, the solution for me was to install Arduino AVR Boards 1.6.9 using Boards Manager as Pert said.

Regarding to what lastchancename mentioned of W10, I am using W7 and I had that issue...