Latest Particle CLI compiler gives "Usage" after a failed compile


I recently updated to the latest version of the CLI with the ‘npm -g update particle’ command.

Since then, the output from simple compiles of code with syntax errors, ALSO giving the ‘Usage’ message, even though the command line usage is correct. For example compiling this simple program:

void loop() {}

void setup() {}

this is a syntax error;

Results in this output:

$ particle compile photon .

Compiling code for photon

attempting to compile firmware 
Compile failed. Exiting.
Processing  foo.ino
make -C ../modules/photon/user-part all
make[1]: Entering directory '/firmware/modules/photon/user-part'
make -C ../../../user 
make[2]: Entering directory '/firmware/user'
Building cpp file: foo.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-6-m
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=0.7.0 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../services/inc -I../communication/src -I../hal/inc -I../hal/shared -I../hal/src/photon -I../hal/src/stm32f2xx -I../hal/src/stm32 -I../hal/src/photon/api -I../hal/src/photon/include -I../hal/src/photon/wiced/security/BESL/host/WICED/ -I../hal/src/photon/wiced/security/BESL/include -I../hal/src/photon/wiced/security/BESL -I../hal/src/photon/wiced/security/BESL/crypto -I../hal/src/photon/wiced/WWD/include/ -I../hal/src/photon/wiced/platform/include/ -I../hal/src/photon/wiced/platform/GCC/ -I../hal/src/photon/wiced/security/BESL/supplicant/ -I../hal/src/photon/libraries/crypto -I../platform/shared/inc -I../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F2xx/CMSIS/Include -I../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../dynalib/inc -I -I./libraries -I. -MD -MP -MF ../build/target/user/platform-6-mfoo.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 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DSPARK_PLATFORM_NET=BCM9WCDUSI09 -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=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=5 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,207 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++11 -c -o ../build/target/user/platform-6-mfoo.o foo.cpp
foo.ino:5:1: error: expected unqualified-id before 'this'
 this is a syntax error;
../build/ recipe for target '../build/target/user/platform-6-mfoo.o' failed
make[2]: *** [../build/target/user/platform-6-mfoo.o] Error 1
make[2]: Leaving directory '/firmware/user'
../../../build/ recipe for target 'user' failed
make[1]: Leaving directory '/firmware/modules/photon/user-part'
make[1]: *** [user] Error 2
../build/ recipe for target 'modules/photon/user-part' failed
make: *** [modules/photon/user-part] Error 2
Compile a source file, or directory using the cloud compiler
Usage: particle compile [options] <deviceType> [files...]

Global Options:
  -v, --verbose  Increases how much logging to display                                                                                                  [count]
  -q, --quiet    Decreases how much logging to display                                                                                                  [count]

  --target  The firmware version to compile against. Defaults to latest version, or version on device for cellular.
  --saveTo  Filename for the compiled binary

  particle compile photon                                  Compile the source code in the current directory in the cloud for a Photon
  particle compile electron project --saveTo electron.bin  Compile the source code in the project directory in the cloud for a Electron and save it to

Param deviceType can be: core, photon, p1, electron, etc

I understand all of the output about the deliberate error I placed in the code, but why then go on to report "Usage: " etc?. It never did that before.

Thank you

CLI is currently undergoing some reworks - especially being more open about which commands are available and how to use them - but in the process of doing that, it got a bit too chatty :wink:

However, Particle is aware of the issue and will target it in some of the future minor releases.

1 Like

Thanks. It is good to know things continue to improve, even if there are the occasional bumps in the road like this.

BTW: I love the CLI for building projects. It works perfectly for me. I wish that local compiling could be made as seamless and easy.

1 Like

It’s on the list of features the Elites try to push up the priority list :wink:
It’ll come, but good things take their time :blush:

1 Like