Support for Linter in Particle Dev

I have Linter with the linter-gcc plugin installed on Atom 1.20.1 x64

It works well for regular c++ projects.

When I try to use it while working on Particle projects, it seems to have a problem with the

#include "Particle.h"

directive. I have the Particle firmware github repo cloned and have linter setup to

#include "\user\inc"

, which contains “Particle.h”

This fixes the “can’t find Particle.h” problem in linter, but replaces it with an unspecified error with no details.

Is there a trick I’m missing? Does including “Particle.h” work the same way that a regular include statement does?

If not, is there a version of the Particle firmware that would be like a traditional C/C++ library that linter could use to run on-the-fly error checking while I’m developing?

1 Like

Or alternatively, if anyone knows of any other options that are out there for coding using the Particle ecosystem that supports on-the-fly error checking, then I’m all ears.

1 Like

This interests me. I’m curious to see if I could get this worked into po-util.

UPDATE:
It looks like linter-gcc isn’t trying to build my code.

1 Like

I tried getting this to work with the same issues.

I am trying this again but linter-gcc appears to be really broken.

Having this feature for local development would be killer.

@rickkas7 any ideas?

These are the settings I use in Microsoft Visual Studio however they should work to allow other compilers to process the Particle header files.

There are two major sections, one for the Photon and one for the Electron.

In those, you can find incudePaths. Note that you not only need the firmware repository, but also the gcc-arm 5.3.1 header files!

In defines are the various defines that you probably need to compile. Not all of them are probably necessary, but that’s what’s defined for a build on that platform in a real build.

Finally, compilerSwitches. These might not be necessary for a linter-type compiler, except maybe enabling C++11.

{
	"configurations":[
		{
			"name":"Particle photon",
			"includePath":[
				"${workspaceRoot}\\..\\firmware\\communication\\src",
				"${workspaceRoot}\\..\\firmware\\dynalib\\inc",
				"${workspaceRoot}\\..\\firmware\\hal\\inc",
				"${workspaceRoot}\\..\\firmware\\hal\\shared",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\api",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\include",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\libraries\\crypto",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\WWD\\include\\",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\platform\\GCC\\",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\platform\\include\\",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\security\\BESL",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\security\\BESL\\crypto",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\security\\BESL\\host\\WICED\\",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\security\\BESL\\include",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\photon\\wiced\\security\\BESL\\supplicant\\",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\stm32",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\stm32f2xx",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\CMSIS\\Device\\ST\\Include",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\CMSIS\\Include",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\SPARK_Firmware_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_StdPeriph_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_USB_Device_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_USB_Host_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_USB_OTG_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\shared\\STM32\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\shared\\inc",
				"${workspaceRoot}\\..\\firmware\\services\\inc",
				"${workspaceRoot}\\..\\firmware\\system\\inc",
				"${workspaceRoot}\\..\\firmware\\user\\inc",
				"${workspaceRoot}\\..\\firmware\\wiring\\inc",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1\\arm-none-eabi",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1\\arm-none-eabi\thumb",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1\\ext",
				"${workspaceRoot}\\..\\gcc-arm\\lib\\gcc\\arm-none-eabi\\5.3.1\\include",
				"${workspaceRoot}\\src"
			],
			"defines":[
				"BOOTLOADER_SDK_3_3_0_PARTICLE",
				"DFU_BUILD_ENABLE",
				"INCLUDE_PLATFORM=1",
				"LOG_INCLUDE_SOURCE_INFO=1",
				"LOG_MODULE_CATEGORY=\"\\\"app\\\"\"",
				"MODULAR_FIRMWARE=1",
				"MODULE_DEPENDENCY2=0,0,0",
				"MODULE_DEPENDENCY=4,2,207",
				"MODULE_FUNCTION=5",
				"MODULE_INDEX=1",
				"MODULE_VERSION=5",
				"PARTICLE=1",
				"PARTICLE_DCT_COMPATIBILITY",
				"PARTICLE_USER_MODULE",
				"PLATFORM_ID=6",
				"PLATFORM_NAME=photon",
				"PLATFORM_THREADING=1",
				"PRODUCT_FIRMWARE_VERSION=65535",
				"PRODUCT_ID=6",
				"RELEASE_BUILD",
				"SPARK=1",
				"SPARK_PLATFORM",
				"SPARK_PLATFORM_NET=BCM9WCDUSI09",
				"START_DFU_FLASHER_SERIAL_SPEED=14400",
				"START_YMODEM_FLASHER_SERIAL_SPEED=28800",
				"STM32F2XX",
				"STM32_DEVICE",
				"SYSTEM_VERSION_STRING=0.7.0",
				"USBD_PID_CDC=0xC006",
				"USBD_PID_DFU=0xD006",
				"USBD_VID_SPARK=0x2B04",
				"USER_FIRMWARE_IMAGE_LOCATION=0x80A0000",
				"USER_FIRMWARE_IMAGE_SIZE=0x20000",
				"USE_STDPERIPH_DRIVER",
				"_GNU_SOURCE",
				"_WINSOCK_H"
			],
			"compilerSwitches":"-Wall -Wno-error=deprecated-declarations -Wno-switch -Wundef -fcheck-new -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin-free -fno-builtin-malloc -fno-builtin-realloc -fno-exceptions -fno-rtti -fno-strict-aliasing -mcpu=cortex-m3 -mthumb -std=gnu++11 ",
			"intelliSenseMode":"linux-gcc-arm"
		},
		{
			"name":"Particle electron",
			"includePath":[
				"${workspaceRoot}\\..\\firmware\\communication\\src",
				"${workspaceRoot}\\..\\firmware\\dynalib\\inc",
				"${workspaceRoot}\\..\\firmware\\hal\\inc",
				"${workspaceRoot}\\..\\firmware\\hal\\shared",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\electron",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\stm32",
				"${workspaceRoot}\\..\\firmware\\hal\\src\\stm32f2xx",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\CMSIS\\Device\\ST\\Include",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\CMSIS\\Include",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\SPARK_Firmware_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_StdPeriph_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_USB_Device_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_USB_Host_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\STM32F2xx\\STM32_USB_OTG_Driver\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\MCU\\shared\\STM32\\inc",
				"${workspaceRoot}\\..\\firmware\\platform\\shared\\inc",
				"${workspaceRoot}\\..\\firmware\\services\\inc",
				"${workspaceRoot}\\..\\firmware\\system\\inc",
				"${workspaceRoot}\\..\\firmware\\user\\inc",
				"${workspaceRoot}\\..\\firmware\\wiring\\inc",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1\\arm-none-eabi",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1\\arm-none-eabi\thumb",
				"${workspaceRoot}\\..\\gcc-arm\\arm-none-eabi\\include\\c++\\5.3.1\\ext",
				"${workspaceRoot}\\..\\gcc-arm\\lib\\gcc\\arm-none-eabi\\5.3.1\\include",
				"${workspaceRoot}\\src"
			],
			"defines":[
				"DFU_BUILD_ENABLE",
				"INCLUDE_PLATFORM=1",
				"LOG_INCLUDE_SOURCE_INFO=1",
				"LOG_MODULE_CATEGORY=\"\\\"app\\\"\"",
				"MODULAR_FIRMWARE=1",
				"MODULE_DEPENDENCY2=0,0,0",
				"MODULE_DEPENDENCY=4,2,207",
				"MODULE_FUNCTION=5",
				"MODULE_INDEX=1",
				"MODULE_VERSION=5",
				"PARTICLE=1",
				"PARTICLE_USER_MODULE",
				"PLATFORM_ID=10",
				"PLATFORM_NAME=electron",
				"PLATFORM_THREADING=1",
				"PRODUCT_FIRMWARE_VERSION=65535",
				"PRODUCT_ID=10",
				"RELEASE_BUILD",
				"SPARK=1",
				"SPARK_PLATFORM",
				"SPARK_PLATFORM_NET=UBLOXSARA",
				"START_DFU_FLASHER_SERIAL_SPEED=14400",
				"START_YMODEM_FLASHER_SERIAL_SPEED=28800",
				"STM32F2XX",
				"STM32_DEVICE",
				"SYSTEM_VERSION_STRING=0.7.0",
				"USBD_PID_CDC=0xC00A",
				"USBD_PID_DFU=0xD00A",
				"USBD_VID_SPARK=0x2B04",
				"USER_FIRMWARE_IMAGE_LOCATION=0x8080000",
				"USER_FIRMWARE_IMAGE_SIZE=0x20000",
				"USE_STDPERIPH_DRIVER",
				"_GNU_SOURCE",
				"_WINSOCK_H"
			],
			"compilerSwitches":"-Wall -Wno-error=deprecated-declarations -Wno-switch -Wundef -fcheck-new -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin-free -fno-builtin-malloc -fno-builtin-realloc -fno-exceptions -fno-rtti -fno-strict-aliasing -mcpu=cortex-m3 -mthumb -std=gnu++11 ",
			"intelliSenseMode":"linux-gcc-arm"
		}
	]
}

But this wouldn’t work within Atom right?

Probably not, but if you’re trying to get anything to process Particle.h, those are all of the directories that contain the header files that you’ll need to successfully compile or pre-process the file and all the files it includes.

1 Like