Can't find string.h or pgmspace.h

Trying to use FirmwareUpdater and get this error:

Arduino: 1.8.16 (Mac OS X), Board: "Arduino Uno WiFi Rev2, ATMEGA328"

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/k7kz/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/k7kz/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/k7kz/Documents/Arduino/libraries -fqbn=arduino:megaavr:uno2018:mode=on -vid-pid=03EB_2145 -ide-version=10816 -build-path /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_704714 -warnings=default -build-cache /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_cache_237368 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.arduinoOTA.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /Users/k7kz/Documents/Arduino/libraries/WiFiNINA-1.8.13/examples/Tools/FirmwareUpdater/FirmwareUpdater.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/k7kz/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/k7kz/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/k7kz/Documents/Arduino/libraries -fqbn=arduino:megaavr:uno2018:mode=on -vid-pid=03EB_2145 -ide-version=10816 -build-path /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_704714 -warnings=default -build-cache /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_cache_237368 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.arduinoOTA.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /Users/k7kz/Documents/Arduino/libraries/WiFiNINA-1.8.13/examples/Tools/FirmwareUpdater/FirmwareUpdater.ino
Using board 'uno2018' from platform in folder: /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7
Using core 'arduino' from platform in folder: /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7
Detecting libraries used...
/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10816 -DARDUINO_AVR_UNO_WIFI_REV2 -DARDUINO_ARCH_MEGAAVR -DUNO_WIFI_REV2_328MODE -DMILLIS_USE_TIMERB3 -I/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/deprecated -I/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino -I/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/variants/uno2018 /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_704714/sketch/FirmwareUpdater.ino.cpp -o /dev/null
Alternatives for avr/pgmspace.h: []
ResolveLibrary(avr/pgmspace.h)
-> candidates: []
In file included from /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/IPAddress.h:24:0,
from /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/ArduinoAPI.h:30,
from /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/Arduino.h:23,
from /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_704714/sketch/FirmwareUpdater.ino.cpp:1:
/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/String.h:31:10: fatal error: avr/pgmspace.h: No such file or directory
#include "avr/pgmspace.h"
^~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.

Is UNO megaAVR?

Yes. UNO WiFi Rev2

I looked up the spec for Uno WIFI rev2, the processor it is using is ATmega4809. Not an expert on UNO but that’s a different architecture

Well, you are absolutely correct. Thank you. I looked at the chip on the board. I don't know where I got the idea that it was the Mega328. Still acting the same, however.

Arduino: 1.8.16 (Mac OS X), Board: "Arduino Uno WiFi Rev2, None (ATMEGA4809)"

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/k7kz/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/k7kz/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/k7kz/Documents/Arduino/libraries -fqbn=arduino:megaavr:uno2018:mode=off -vid-pid=03EB_2145 -ide-version=10816 -build-path /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_416720 -warnings=default -build-cache /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_cache_675798 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /Users/k7kz/Documents/Arduino/libraries/WiFi101/examples/FirmwareUpdater/FirmwareUpdater.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/k7kz/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/k7kz/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/k7kz/Documents/Arduino/libraries -fqbn=arduino:megaavr:uno2018:mode=off -vid-pid=03EB_2145 -ide-version=10816 -build-path /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_416720 -warnings=default -build-cache /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_cache_675798 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Users/k7kz/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -verbose /Users/k7kz/Documents/Arduino/libraries/WiFi101/examples/FirmwareUpdater/FirmwareUpdater.ino
Using board 'uno2018' from platform in folder: /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7
Using core 'arduino' from platform in folder: /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7
Detecting libraries used...
/Users/k7kz/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10816 -DARDUINO_AVR_UNO_WIFI_REV2 -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -I/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/deprecated -I/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino -I/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/variants/uno2018 /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_416720/sketch/FirmwareUpdater.ino.cpp -o /dev/null
Alternatives for avr/pgmspace.h: []
ResolveLibrary(avr/pgmspace.h)
-> candidates: []
In file included from /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/IPAddress.h:24:0,
from /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/ArduinoAPI.h:30,
from /Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/Arduino.h:23,
from /var/folders/rw/kv9fdr1d34j6yw0x670tf8wm0000gp/T/arduino_build_416720/sketch/FirmwareUpdater.ino.cpp:1:
/Users/k7kz/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/String.h:31:10: fatal error: avr/pgmspace.h: No such file or directory
#include "avr/pgmspace.h"
^~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.

This part of the messages shows that the compiler cannot find the file avr/pgmspace.h which quite likely depends on the hardware configuration.

There is a rude solution to it mentioned here

https://github.com/Seeed-Studio/OLED_Display_96X96/issues/7

to comment out the lines "#include <avr/pgmspace.h>" in the libraries and sketches where it is used ... And hope for success ... :innocent:

I

I assume you did follow the steps of the Quickstartguide

https://docs.arduino.cc/hardware/uno-wifi-rev2

to install the megaAVR core?

I did. Yes. Thanks.

That's bad ... It would have been the most likely solution to it ... :wink:

Unfortunately I do not have an Uno WiFi Rev2, so cannot try it myself. However, I found a pgmspcace.h file in my Arduino IDE folder

C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\avr

Do not know if this may help you to further investigate ...

Thanks for your effort.
I did find a copy of the pgmspcace.h file on my machine but it's not where it needs to be. I could copy it and place it where I think it needs to be and try it.

The common places where the IDE is looking for are

  • the libraries folder in the Sketch Location (what you read under "Preferences" in the IDE
  • the libraries folder where the Arduino IDE is placed (usually like C:\Program Files (x86)\Arduino\libraries)

Good luck ...

I found a copy of pgmspace.h in my Mac inside the Arduino app package:

71,262 bytes, dated May 26, 2020 8:35am

I installed the Arduino Mega AVR boards v1.87 using the Boards Manager, and compiled a sample sketch for the Arduino Uno WiFi Rev 2. Did not have problems using Registers emulation: "None (ATMEGA4809)"

I do not have that board, but this just a compilation (of a very simple sketch), not an upload...

Where did you find yours?

Using a computer running linux here,

pgmspace.h is located at

~/.arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/deprecated-avr-comp/avr/pgmspace.h

String.h is located at:

~/.arduino15/packages/arduino/hardware/megaavr/1.8.7/cores/arduino/api/String.h

Not sure what your problem is, I have no problem compiling FirmwareUpdater from WiFININA version 1.8.13.


Odd, looking at String.h at the line where the error is being flagged, the compiler should not be using line 31, but instead line 33.

The compiler is using line 31, but there does not seem to be any problem locating the file on my computer.

 27 #include <stdlib.h>
 28 #include <string.h>
 29 #include <ctype.h>
 30 #if defined(__AVR__)
 31 #include "avr/pgmspace.h"
 32 #else
 33 #include "deprecated-avr-comp/avr/pgmspace.h"
 34 #endif
 35 

@k7kz, your topic has been moved to a more suitable location on the forum as it has nothing to do with Avrdude, stk500 or Bootloader issues.

The 328P in "Arduino Uno WiFi Rev2, ATMEGA328" is what is called emulation mode. I haven't figured out the exact details (yet) but it adds a layer to modify some functions.

Thanks all who responded to this. I fixed it today by uninstalling SAMD Boards. It is working perfectly now.