Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle compiler error in an empty project #1433

Closed
chinesefellow opened this issue Nov 9, 2020 · 3 comments
Closed

Particle compiler error in an empty project #1433

chinesefellow opened this issue Nov 9, 2020 · 3 comments
Labels
bug v6 ArduinoJson 6

Comments

@chinesefellow
Copy link

Tried including the ArduinoJson library today. Version 6.17.1. Without writing any additional code besides having an empty setup and loop function, a compiler error is generated.

I have another project/app in the Particle environment using version 6.14.1 and that one is still working.

Here's the raw error:

Processing  arduinojsonexample.ino
Checking library ArduinoJson...
Installing library ArduinoJson 6.17.1 to lib/ArduinoJson ...
Library ArduinoJson 6.17.1 installed.
make -C ../modules/argon/user-part all
make[1]: Entering directory '/firmware/modules/argon/user-part'

mkdir -p target/
make -f ../../../modules/shared/nRF52840/build_linker_script.mk PREBUILD=1
make[2]: Entering directory '/firmware/modules/argon/user-part'
Creating target/platform_user_ram.ld ...
make[2]: Leaving directory '/firmware/modules/argon/user-part'

make -C ../../../user 
make[2]: Entering directory '/firmware/user'
Building cpp file: src/arduinojsonexample.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-12-msrc/
arm-none-eabi-gcc -DSTM32_DEVICE -DnRF52840 -DNRF52840_XXAA -DPLATFORM_THREADING=1 -DPLATFORM_ID=12 -DPLATFORM_NAME=argon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD00C -DUSBD_PID_CDC=0xC00C -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DINCLUDE_PLATFORM=1 -DSOFTDEVICE_PRESENT=1 -DS140 -DPRODUCT_ID=12 -DPRODUCT_FIRMWARE_VERSION=65535 -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-config-project.h\" -DENABLE_FEM=1 -DNRF_802154_PROJECT_CONFIG=\"openthread-platform-config.h\" -DRAAL_SOFTDEVICE=1 -D_WIZCHIP_=W5500 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DLFS_CONFIG=lfs_config.h -DSYSTEM_VERSION_STRING=1.5.2 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/inc -I../hal/inc -I../hal/shared -I../hal/src/argon -I../hal/network/lwip/esp32 -I../hal/src/nRF52840 -I../hal/src/armv7 -I../hal/src/nRF52840 -I../hal/src/nRF52840/lwip -I../hal/src/nRF52840/freertos -I../hal/src/nRF52840/openthread -I../hal/src/nRF52840/mbedtls -I../hal/src/nRF52840/littlefs -I../hal -I../hal/network/api -I../hal/network/lwip -I../hal/network/lwip/posix -I../hal/network/openthread -I../hal/network/lwip/wiznet -I../hal/network/ncp -I../hal/network/ncp/at_parser -I../third_party/lwip/lwip/src/include -I../third_party/freertos/freertos/FreeRTOS/Source/include -I../third_party/nrf5_sdk/nrf5_sdk/external/freertos/portable/GCC/nrf52 -I../third_party/nrf5_sdk/nrf5_sdk/external/freertos/portable/CMSIS/nrf52 -I../third_party/openthread/openthread/include -I../third_party/openthread/openthread/src/core -I../third_party/openthread/openthread/examples/platforms -I../third_party/openthread/openthread/radio -I../third_party/openthread/openthread/radio/hal -I../third_party/openthread/openthread/radio/rsch -I../third_party/openthread/openthread/radio/rsch/raal -I../third_party/openthread/openthread/radio/rsch/raal/softdevice -I../third_party/wiznet_driver/wiznet_driver/Ethernet -I../gsm0710muxer/gsm0710muxer/include -I../platform/shared/inc -I../third_party/nrf5_sdk -I../third_party/nrf5_sdk/nrf5_sdk/components/toolchain/cmsis/include -I../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx -I../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/drivers -I../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/drivers/include -I../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/hal -I../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/mdk -I../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/hal -I../third_party/nrf5_sdk/nrf5_sdk/modules/nrfx/drivers/src/prs -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/util -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers/nrf52 -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/common -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/fstorage -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/experimental_section_vars -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/crc32 -I../third_party/nrf5_sdk/nrf5_sdk/integration/nrfx/legacy -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/delay -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/log -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/log -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/log/src -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/experimental_section_vars -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/delay -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/queue -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/common -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/mbr/nrf52840/headers -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140 -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers -I../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/headers/nrf52 -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/fifo -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic_fifo -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/strerror -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/fstorage -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/atomic_flags -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/usbd -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/usbd/class/cdc -I../third_party/nrf5_sdk/nrf5_sdk/components/libraries/usbd/class/cdc/acm -I../third_party/nrf5_sdk/nrf5_sdk/components/ble/common -I../third_party/nrf5_sdk/nrf5_sdk/components/ble/nrf_ble_gatt -I../third_party/nrf5_sdk/nrf5_sdk/components/ble/ble_advertising -I../third_party/nrf5_sdk/nrf5_sdk/components/nfc/t2t_lib -I../third_party/nrf5_sdk/nrf5_sdk/components/nfc/platform -I../third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/generic/message -I../third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/generic/record -I../third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/lauchapp -I../third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/text -I../third_party/nrf5_sdk/nrf5_sdk/components/nfc/ndef/uri -I../third_party/nrf5_sdk/nrf5_sdk/external/nrf_cc310/include -I../third_party/nrf5_sdk/nrf5_sdk/external/utf_converter -I../third_party/littlefs/littlefs -I../platform/MCU/nRF52840/inc -I../dynalib/inc -Isrc -I./libraries -Ilib/ArduinoJson/src -I. -MD -MP -MF ../build/target/user/platform-12-msrc/arduinojsonexample.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DSPARK_PLATFORM_NET=ESP32 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0xD4000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=6 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,1,1512 -DMODULE_DEPENDENCY2=0,0,0 -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++14 -c -o ../build/target/user/platform-12-msrc/arduinojsonexample.o src/arduinojsonexample.cpp
In file included from lib/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp:11:0,
                 from lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp:14,
                 from lib/ArduinoJson/src/ArduinoJson/Numbers/convertNumber.hpp:18,
                 from lib/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp:9,
                 from lib/ArduinoJson/src/ArduinoJson/Variant/SlotFunctions.hpp:8,
                 from lib/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp:7,
                 from lib/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp:8,
                 from lib/ArduinoJson/src/ArduinoJson.hpp:17,
                 from lib/ArduinoJson/src/ArduinoJson.h:9,
                 from arduinojsonexample.ino:2:
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In function 'typename ArduinoJson6171_F1::enable_if<ArduinoJson6171_F1::is_pointer<T>::value, T>::type ArduinoJson6171_F1::pgm_read(const void*)':
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:14:44: error: there are no arguments to 'pgm_read_ptr' that depend on a template parameter, so a declaration of 'pgm_read_ptr' must be available [-fpermissive]
   return reinterpret_cast<T>(pgm_read_ptr(p));
                                            ^
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:14:44: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In function 'typename ArduinoJson6171_F1::enable_if<(ArduinoJson6171_F1::is_floating_point< <template-parameter-1-1> >::value && (sizeof (T) == sizeof (float))), T>::type ArduinoJson6171_F1::pgm_read(const void*)':
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:23:26: error: there are no arguments to 'pgm_read_float' that depend on a template parameter, so a declaration of 'pgm_read_float' must be available [-fpermissive]
   return pgm_read_float(p);
                          ^
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In function 'typename ArduinoJson6171_F1::enable_if<ArduinoJson6171_F1::is_same<T, long unsigned int>::value, T>::type ArduinoJson6171_F1::pgm_read(const void*)':
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:29:26: error: there are no arguments to 'pgm_read_dword' that depend on a template parameter, so a declaration of 'pgm_read_dword' must be available [-fpermissive]
   return pgm_read_dword(p);
                          ^
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In instantiation of 'typename ArduinoJson6171_F1::enable_if<ArduinoJson6171_F1::is_pointer<T>::value, T>::type ArduinoJson6171_F1::pgm_read(const void*) [with T = const __FlashStringHelper*; typename ArduinoJson6171_F1::enable_if<ArduinoJson6171_F1::is_pointer<T>::value, T>::type = const __FlashStringHelper*]':
lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp:103:12:   required from here
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:14:42: error: 'pgm_read_ptr' was not declared in this scope
   return reinterpret_cast<T>(pgm_read_ptr(p));
                                          ^
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp: In instantiation of 'typename ArduinoJson6171_F1::enable_if<ArduinoJson6171_F1::is_same<T, long unsigned int>::value, T>::type ArduinoJson6171_F1::pgm_read(const void*) [with T = long unsigned int; typename ArduinoJson6171_F1::enable_if<ArduinoJson6171_F1::is_same<T, long unsigned int>::value, T>::type = long unsigned int]':
lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp:65:9:   required from 'static T ArduinoJson6171_F1::FloatTraits<T, 8u>::positiveBinaryPowerOfTen(int) [with T = double]'
lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp:36:40:   required from 'static T ArduinoJson6171_F1::FloatTraits<T, 8u>::make_float(T, TExponent) [with TExponent = int; T = double]'
lib/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp:134:64:   required from here
lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp:29:24: error: 'pgm_read_dword' was not declared in this scope
   return pgm_read_dword(p);
                        ^
../build/module.mk:274: recipe for target '../build/target/user/platform-12-msrc/arduinojsonexample.o' failed
make[2]: *** [../build/target/user/platform-12-msrc/arduinojsonexample.o] Error 1
make[2]: Leaving directory '/firmware/user'
../../../build/recurse.mk:11: recipe for target 'user' failed
make[1]: *** [user] Error 2
make[1]: Leaving directory '/firmware/modules/argon/user-part'
../build/recurse.mk:11: recipe for target 'modules/argon/user-part' failed
make: *** [modules/argon/user-part] Error 2
@bblanchon
Copy link
Owner

Hi @chinesefellow,

Thank you very much for reporting this bug.

The problem came from the fact that Particle defines some of the pgm_read_XXX macros in spark_wiring_arduino.h, like pgm_read_byte and pgm_read_word, but lacks pgm_read_ptr, pgm_read_float, and pgm_read_dword.
Particle does define these macros in avr/pgm_space.h, but I cannot include this header from ArduinoJson because the Arduino Core API deprecated it so it may not be available on every platform.

To fix this issue, I added a check before enabling support for PROGMEM in ArduinoJson: it now verifies that all macros are defined.

Moreover, I added Particle Argon to the Continuous Integration so this kind of problem never happens again.

Until the fix is published, you can simply define ARDUINOJSON_ENABLE_PROGMEM to 0.

Best regards,
Benoit

@chinesefellow
Copy link
Author

chinesefellow commented Nov 11, 2020 via email

@bblanchon
Copy link
Owner

The fix was published in version 6.17.2.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2021
@bblanchon bblanchon added the v6 ArduinoJson 6 label Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug v6 ArduinoJson 6
Projects
None yet
Development

No branches or pull requests

2 participants