Electron Tinker USB Debugging App

Overview

Sometimes it may be required to have a look at the system log output on an Electron running Tinker. This will show a bunch of processes that are happening on the Electron as it turns on the modem and makes a connection to the cellular network and Particle Cloud.

Note: It is important that your Electron be running v0.4.6-rc.8 system firmware or newer for this. FYI: All factory fresh Electrons are running this version.

Install

To enable debugging you can download a version of Tinker that has USB serial debugging enabled:

https://github.com/spark/firmware/releases/download/v0.4.8-rc.6/tinker-usb-debugging-v0.4.8-rc.6-electron.bin

Then you can flash this to your electron with the Particle CLI with your electron in DFU mode:

particle flash --usb tinker-usb-debugging-v0.4.8-rc.6-electron.bin

Or if you have v1.12.0 or greater of the CLI you can use this command without needing to download the binary:

particle flash --usb tinker-usb-debugging


How to Use

Because we only need to read information from the Electron, we can use the CLI which has a read-only serial command. Be ready to open a serial terminal with the CLI:

particle serial monitor

Now completely disconnect power and reapply it (or Soft Power Down the Electron by double tapping the MODE button, and RESET to power back up). This will ensure a full connection to the tower so we can see all of the little details.

Now open the serial terminal just after the Electron boots. It should look similar to this if you catch it right at the beginning:

[ Modem::powerOn ] = = = = = = = = = = = = = =
   
1.426 AT send       4 "AT\r\n"
   
2.749 AT send       4 "AT\r\n"
   
4.072 AT send       4 "AT\r\n"
   
4.085 AT read UNK   3 "AT\r"
   
4.098 AT read OK    6 "\r\nOK\r\n"
   
4.102 AT send       7 "AT E0\r\n"
   
4.116 AT read UNK   6 "AT E0\r"
   
4.130 AT read OK    6 "\r\nOK\r\n"
   
4.134 AT send      11 "AT+CMEE=2\r\n"
   
4.148 AT read OK    6 "\r\nOK\r\n"
   
4.152 AT send      19 "AT+CMER=1,0,0,2,1\r\n"
   
4.167 AT read OK    6 "\r\nOK\r\n"
   
4.171 AT send      15 "AT+IPR=115200\r\n"
   
4.186 AT read OK    6 "\r\nOK\r\n"
   
4.290 AT send      10 "AT+CPIN?\r\n"
   
4.304 AT read ERR  37 "\r\n+CME ERROR: operation not allowed\r\n"
   
5.311 AT send      10 "AT+CPIN?\r\n"
   
5.325 AT read  +   16 "\r\n+CPIN: READY\r\n"
   
5.340 AT read OK    6 "\r\nOK\r\n"

[ Modem::init ] = = = = = = = = = = = = = = =
   
5.349 AT send       9 "AT+CGSN\r\n"

Copy and paste the log output over the course of the first 6 minutes or so. This is usually enough information to understand what is happening on your Electron. Please put this in a TXT file and attach it to an email reply or Community PM to a Particle employee.

Note: Please do not post logs on the forum as they contain ID numbers that are sensitive for your Electron.

Thanks!

After we are done with inspecting logs on your Electron, please remember to disable logs with this CLI command (device in DFU mode):

particle flash --usb tinker

3rd Party SIMs / APNs

If you are using a 3rd party SIM and are adding credentials to your app, you must enable debugging with the local toolchain.

Essentially you would add these two things (in a global space) to your app, or to Tinker.

1. Debugging instance

There are two different handlers you can use, the first one is the old logging API and requires adding DEBUG_BUILD=y to the make command line with a local build.  The second one can be compiled in the Web IDE if you are using firmware version >= 0.6.0.  Do not include both!

// Adds debugging output over Serial USB
SerialDebugOutput debugOutput(9600, ALL_LEVEL); // < 0.6.0 firmware

SerialLogHandler logHandler(LOG_LEVEL_ALL); // >= 0.6.0 firmware

void setup() {
   
// your setup code
}
void loop() {
   
// your loop code
}

2. Cellular Credentials

APN info in the docs here

// EXAMPLE - an AT&T APN with no username or password in AUTOMATIC mode.  See docs above if you need username and/or password options.

#include "cellular_hal.h"

STARTUP(cellular_credentials_set(
"broadband", "", "", NULL));

void
setup() {
   
// your setup code
}
void
loop() {
   
// your loop code
}

After your application is ready to compile locally, you can compile just the user app from the firmware/main $ directory and flash it to your Electron over USB DFU with the following command:

make clean all PLATFORM_ID=10 APP=tinker-debugging-with-apn COMPILE_LTO=n DEBUG_BUILD=y PARTICLE_DEVELOP=1 -s program-dfu

A copy of Tinker with debugging should be located here:

firmware/user/applications/tinker-debugging-with-apn/tinker.cpp