System.enterSafeMode();
https://docs.particle.io/reference/device-os/firmware/boron/#entersafemode-
By USB, as long as the device is running 0.9.0 or later and you have an up-to-date Particle CLI:
particle usb safe-mode
https://docs.particle.io/reference/developer-tools/cli/#particle-usb-safe-mode
By USB serial, connecting at 28800 baud will go into listening mode, then sending the L (uppercase) command by serial will cause it to go into safe listening mode. It will look like listening mode (blinking dark blue), but it’s running safe mode underneath it.