Sleep.h error after 1.6.3 to 1.6.7 update

Hey guys!

I made a board and defined it back in version 1.6.3, which worked fine. I just updated to 1.6.7 and sleep is broken for it.

I'm calling sleep the usual way:

set_sleep_mode(SLEEP_MODE_PWR_DOWN);

But the IDE reports the following warning when compiling:

In file included path_to_file:1:0:
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/sleep.h:634:6: error: #error "No SLEEP mode defined for this device."
     #error "No SLEEP mode defined for this device."
      ^

My board definition is pasted at the end, but I don't know what changed in 1.6.7! I'm guessing it has to do with the line

wsx328p.build.board=AVR_ATMEGA328P
##############################################################
wsx328p.name = WSX w/ ATmega328P @ 4MHz

wsx328p.upload.protocol=arduino
wsx328p.upload.maximum_size=32256
#wsx328p.upload.speed=19200
wsx328p.upload.speed=9600

wsx328p.bootloader.low_fuses=0xfd
wsx328p.bootloader.high_fuses=0xde
wsx328p.bootloader.extended_fuses=0x05
wsx328p.bootloader.file=optiboot/optiboot_atmega328p_4mhz.hex
wsx328p.bootloader.unlock_bits=0x3F
wsx328p.bootloader.lock_bits=0x2F
wsx328p.bootloader.tool=arduino:avrdude

wsx328p.build.mcu=atmega328p
wsx328p.build.f_cpu=4000000L
wsx328p.build.core=arduino
wsx328p.build.variant=standard
wsx328p.build.board=AVR_ATMEGA328P

wsx328p.upload.tool=arduino:avrdude
##############################################################

Thank you all in advance!

That shouldn't break anything. avr/sleep.h is not dependent on anything arduino related, it just looks at compiler defines. Looking at the source for avr/sleep.h, it looks like it's not seeing the compiler defines for the chip, which should always be there. You're setting the right build.mcu and all..

Does the code work if you select the Uno board?

I've avoided upgrading beyond 1.6.5r5 because of all the bugs introduced by the changes in the build process ("arduino builder") added with 1.6.6; there are still a lot of bugs not fixed in 1.6.7.

DrAzzy: That shouldn't break anything. avr/sleep.h is not dependent on anything arduino related, it just looks at compiler defines. Looking at the source for avr/sleep.h, it looks like it's not seeing the compiler defines for the chip, which should always be there. You're setting the right build.mcu and all..

Does the code work if you select the Uno board?

I've avoided upgrading beyond 1.6.5r5 because of all the bugs introduced by the changes in the build process ("arduino builder") added with 1.6.6; there are still a lot of bugs not fixed in 1.6.7.

DrAzzy: That shouldn't break anything. avr/sleep.h is not dependent on anything arduino related, it just looks at compiler defines. Looking at the source for avr/sleep.h, it looks like it's not seeing the compiler defines for the chip, which should always be there. You're setting the right build.mcu and all..

Does the code work if you select the Uno board?

I've avoided upgrading beyond 1.6.5r5 because of all the bugs introduced by the changes in the build process ("arduino builder") added with 1.6.6; there are still a lot of bugs not fixed in 1.6.7.

Upon further investigation it indeed is a builder error on the newer versions. I found the same issue for another core on GitHub.

As suggested in the link, defining AVR_ATMEGA328P at the top of my sketch doesn't work for me either. Compiling for an UNO works no issues. I also tried changing build.board to AVR_UNO (since my board is basically an UNO at a lower freq and other fuses), to no avail.

I'll just stay with 1.6.3 for now.

Thanks a lot!

garvamel: I'll just stay with 1.6.3 for now.

Yeah. 1.6.5r5 is the good one 1.6.0 and 1.6.1 were buggy as hell, 1.6.2 had an apocalyptically serious bug, 1.6.3 was OK. 1.6.4 was worse, but 1.6.5 got those working, and supports the board manager for third party hardware (added in 1.6.4, but was buggy in that version).

1.6.5r5 established a solid foundation in time for them to dynamite it with arduino builder in 1.6.6.

Here's the bug that's probably causing this: https://github.com/arduino/arduino-builder/issues/106 The problem is that in 1.6.5 and previous the default recipe.preproc.macros recipe had -mmcu but they forgot it in arduino-builder so if your board package doesn't define recipe.preproc.macros in platform.txt then the processor specific macro is not defined so it breaks any libraries that require it. DrAzzy, this was the cause of the same issue that happened with ATTinyCore. I was meaning to put a reference to arduino/arduino-builder/#106 in that issue in case someone ran across the same issue with a different project.

Thanks guys! I'll update to 1.6.5r5 asap then!