The Particle Photon is an awesome dev board for prototyping IoT applications. It is based on the STM32F205 micro controller and the Broadcom BCM43362 WiFi chip. Here are the brief specs –
- Particle PØ Wi-Fi module
- Broadcom BCM43362 Wi-Fi chip
- 802.11b/g/n Wi-Fi
- STM32F205RGY6 120Mhz ARM Cortex M3
- 1MB flash, 128KB RAM
- On-board RGB status LED (ext. drive provided)
- 18 Mixed-signal GPIO and advanced peripherals
- Open source design
- Real-time operating system (FreeRTOS)
- Soft AP setup
- FCC, CE and IC certified
What makes this special is that it has an ARM Cortex M3 Processor with plenty of RAM and flash. It has plenty of pins to interface with Sensors and Actuators. It runs FreeRTOS and is Open Source. Yes! The hardware and software is completely Open Source. You can find their repositories here.
The development environment for Particle boards is fantastic. They have an awesome toolchain which allows you to OTA flash the firmware all through the IDE. This is especially nice for beginners who are unfamiliar with Serial, USB and other methods of flashing firmware.
I’ve also been playing around with the ESP8266 and am actively using MicroPython on it. As I’ve been developing on both platforms I’ve found a few features missing from the Particle toolchain that I really enjoy on MicroPython / ESP8266. In particular, I find that having a REPL is a very handy feature. On a ESP8266, I can simply connect to the serial terminal and issue Python commands. This is very useful when you’re prototyping and you need to quickly test out some features.
On the Particle IDE, I need to write code and have it OTA update the device for me to try it out. This creates minor friction in my workflow especially when I’m exploring new features or trying out functionality that I’ve not used before. I did learn recently that MicroPython can be loaded on to the Photon / Electron. But that replaces the whole firmware and you lose the nice IDE and OTA update features.
The other feature that I find missing is kind of a big one and is not really a “feature”. It’s the language used to write the Firmware. Until I started using MicroPython, I did not realize how much nicer it is to use Python instead of C/C++. For instance, I wanted to print out the MAC address of the WiFi chip. See how easy it is do it in Python compared to C/C++.
Building the Offline Toolchain
Now coming to the real meat of my post – building an Offline toolchain for Particle Photon / Electron. What does it mean and why is it important? Well, this is one of the nice features that the Particle has that I really am not very comfortable using. It forces the developer to compile their code in the Cloud. So every time you make an edit and want to try it out, the code gets sent over to Particle’s servers which build the binary and download it to your computer. This binary can then be manually flashed. However, if you’re using the OTA method, it is automatically sent over to the device via the Internet.
I have several concerns here. The top one being Privacy & Security. First, I think my code is my intellectual property and sending it over the wire to Particle just to compile is not a smart thing for me. I am not sure what their security practices are and how safe my code is with them. Next is Security. The issue here is that IoT appliances have been repeatedly used for Bot attacks. Particle’s Cloud services are deeply integrated into the Firmware to the point that it very hard to use it without it being connected to the cloud.
So here is a way to build a completely offline toolchain for the Particle Photon.
1. Clone the Spark repo
git clone https://github.com/spark/firmware
2. Install ARM toolchain & dfu-util
brew tap PX4/homebrew-PX4 brew update brew install gcc-arm-none-eabi-49 brew install dfu-util
3. Make sure you’re on the stable branch
git checkout release/stable
4. Build the Firmware
PARTICLE_SERIAL_DEV=/dev/tty.usbmodem1421 make clean program-dfu PLATFORM=photon
Note: Adding the PARTICLE_SERIAL_DEV variable allows us to automatically put the Particle Photon in DFU mode for flashing. Otherwise you need to manually put it in DFU mode.
5. Build your App
make PLATFORM=photon APPDIR=~/Particle/projects/MyApp TARGET_FILE=myapp
6. Flash your App
particle flash --serial ~/Particle/projects/MyApp/target/myapp.bin
Latest posts by Dinesh (see all)
- macOS with File Vault doesn’t automatically connect to the Internet on restart - December 1, 2020
- Online Communities and suppression of diverse viewpoints - July 31, 2019
- Reflections - July 29, 2019
Also published on Medium.