The “blink” example builds with atmelavr@1.11.0
.
Adding a check of the define for __FLASH
indicates it is not defined. Trying the GCC documentation’s example of declaration of a flash-stored fails to compile.
#include <avr/pgmspace.h>
as a long shot changes only the line numbers of the errors.
Edit:
_This functionality apparently works in AVR Studio as seen in https://www.avrfreaks.net/comment/2187486_
I have similar errors with the “known good” const __flash char MenuItem7[] = "Menu Item 7";
from that thread’s lead post.
(Side note: What is the best way to display the current component versions of platformio?)
$ pio run
Processing uno (platform: atmelavr@1.11.0; board: uno; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR > Arduino Uno
SYSTEM: ATMEGA328P 16MHz 2KB RAM (31.50KB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 24 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs/uno/src/main.cpp.o
src/main.cpp:10:2: warning: #warning __FLASH not defined here [-Wcpp]
#warning __FLASH not defined here
^
src/main.cpp:15:7: error: '__flash' does not name a type
const __flash int array[] = { 3, 5, 7, 11, 13, 17, 19 };
^
*** [.pioenvs/uno/src/main.cpp.o] Error 1
================================================================= [ERROR] Took 0.59 seconds =================================================================
/*
* Blink
* Turns on an LED on for one second,
* then off for one second, repeatedly.
*/
#include "Arduino.h"
#ifndef __FLASH
#warning __FLASH not defined here
#endif
// Example from
// https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html
const __flash int array[] = { 3, 5, 7, 11, 13, 17, 19 };
// Set LED_BUILTIN if it is not defined by Arduino framework
// #define LED_BUILTIN 13
void setup()
{
// initialize LED digital pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
// wait for a second
delay(1000);
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
// wait for a second
delay(1000);
}
[env:uno]
platform = atmelavr@1.11.0
board = uno
framework = arduino
$ pio update
Updating tool-scons @ 2.20501.4 [Up-to-date]
Updating tool-unity @ 1.20403.0 [Up-to-date]
Platform Manager
================
Platform Atmel AVR
--------
Updating atmelavr @ 1.12.0 [Up-to-date]
Updating toolchain-atmelavr @ 1.50400.0 [Up-to-date]
Updating framework-arduinoavr @ 1.10623.0 [Up-to-date]
Updating tool-avrdude @ 1.60300.2 [Up-to-date]
Platform Atmel AVR
--------
Updating atmelavr @ 1.11.0 [Detached]
Updating toolchain-atmelavr @ 1.40902.0 [Up-to-date]
Updating framework-arduinoavr @ 1.10623.0 [Up-to-date]
Updating tool-avrdude @ 1.60300.2 [Up-to-date]