B404x Failed to power on modem

I am using the M-SOM with particle B404x on the Eval Board on device OS 4.2.0 on USB with LiPO.

LED blinking green indefinitely.
SYSTEM_MODE(AUTOMATIC).

The firmware flashes normally through VSCode extension and runs normally on the first flash but seems to have the modem problem below when power cycled.

0000001728 [mux] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000001778 [mux] INFO: GSM07.10 muxer thread exiting
0000001778 [mux] INFO: GSM07.10 muxer stopped
0000001779 [mux] INFO: Starting GSM07.10 muxer
0000001779 [mux] INFO: GSM07.10 muxer thread started
0000002079 [mux] INFO: Stopping GSM07.10 muxer
0000002079 [mux] INFO: Gracefully stopping GSM07.10 muxer
0000002079 [mux] INFO: Closing all muxed channels
0000002079 [mux] INFO: Muxed channel 1 already closed
0000002080 [mux] INFO: Muxed channel 2 already closed
0000002080 [mux] INFO: Muxed channel 3 already closed
0000002080 [mux] INFO: Muxed channel 4 already closed
0000002080 [mux] INFO: Sending CLD (multiplexer close down)
0000002980 [mux] INFO: Received response to CLD or timed out, exiting multiplexed mode
0000003030 [mux] INFO: GSM07.10 muxer thread exiting
0000003030 [mux] INFO: GSM07.10 muxer stopped
0000010032 [ncp.client] ERROR: No response from NCP
0000010032 [ncp.client] ERROR: Cannot hard reset the modem, it's not on
0000010032 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -210
0000012632 [ncp.client] ERROR: Failed to power on modem
0000012632 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000015232 [ncp.client] ERROR: Failed to power on modem
0000015232 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000017832 [ncp.client] ERROR: Failed to power on modem
0000017832 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000020432 [ncp.client] ERROR: Failed to power on modem
0000020432 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160

Serial connection closed. Attempting to reconnect...
Serial monitor opened successfully:
0000002892 [ncp.client] ERROR: Failed to power on modem
0000002892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000005492 [ncp.client] ERROR: Failed to power on modem
0000005492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000008092 [ncp.client] ERROR: Failed to power on modem
0000008092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000010692 [ncp.client] ERROR: Failed to power on modem
0000010692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000013292 [ncp.client] ERROR: Failed to power on modem
0000013292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000015892 [ncp.client] ERROR: Failed to power on modem
0000015892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000018492 [ncp.client] ERROR: Failed to power on modem
0000018492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000021092 [ncp.client] ERROR: Failed to power on modem
0000021092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000023692 [ncp.client] ERROR: Failed to power on modem
0000023692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000026292 [ncp.client] ERROR: Failed to power on modem
0000026292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000028892 [ncp.client] ERROR: Failed to power on modem
0000028892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000031492 [ncp.client] ERROR: Failed to power on modem
0000031492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000034092 [ncp.client] ERROR: Failed to power on modem
0000034092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000036692 [ncp.client] ERROR: Failed to power on modem
0000036692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000039292 [ncp.client] ERROR: Failed to power on modem
0000039292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000041892 [ncp.client] ERROR: Failed to power on modem
0000041892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000044492 [ncp.client] ERROR: Failed to power on modem
0000044492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000047092 [ncp.client] ERROR: Failed to power on modem
0000047092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000049692 [ncp.client] ERROR: Failed to power on modem
0000049692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000052292 [ncp.client] ERROR: Failed to power on modem
0000052292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000054892 [ncp.client] ERROR: Failed to power on modem
0000054892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000057492 [ncp.client] ERROR: Failed to power on modem
0000057492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000060092 [ncp.client] ERROR: Failed to power on modem
0000060092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000062692 [ncp.client] ERROR: Failed to power on modem
0000062692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000065292 [ncp.client] ERROR: Failed to power on modem
0000065292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000067892 [ncp.client] ERROR: Failed to power on modem
0000067892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000070492 [ncp.client] ERROR: Failed to power on modem
0000070492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000073092 [ncp.client] ERROR: Failed to power on modem
0000073092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000075692 [ncp.client] ERROR: Failed to power on modem
0000075692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000078292 [ncp.client] ERROR: Failed to power on modem
0000078292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000080892 [ncp.client] ERROR: Failed to power on modem
0000080892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000083492 [ncp.client] ERROR: Failed to power on modem
0000083492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000086092 [ncp.client] ERROR: Failed to power on modem
0000086092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000088692 [ncp.client] ERROR: Failed to power on modem
0000088692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000091292 [ncp.client] ERROR: Failed to power on modem
0000091292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000093892 [ncp.client] ERROR: Failed to power on modem
0000093892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000096492 [ncp.client] ERROR: Failed to power on modem
0000096492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000099092 [ncp.client] ERROR: Failed to power on modem
0000099092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000101692 [ncp.client] ERROR: Failed to power on modem
0000101692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000104292 [ncp.client] ERROR: Failed to power on modem
0000104292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000106892 [ncp.client] ERROR: Failed to power on modem
0000106892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000109492 [ncp.client] ERROR: Failed to power on modem
0000109492 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000112092 [ncp.client] ERROR: Failed to power on modem
0000112092 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000114692 [ncp.client] ERROR: Failed to power on modem
0000114692 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000117292 [ncp.client] ERROR: Failed to power on modem
0000117292 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000119892 [ncp.client] ERROR: Failed to power on modem
0000119892 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000122493 [ncp.client] ERROR: Failed to power on modem
0000122493 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000125093 [ncp.client] ERROR: Failed to power on modem
0000125093 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000127693 [ncp.client] ERROR: Failed to power on modem
0000127693 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000130293 [ncp.client] ERROR: Failed to power on modem
0000130293 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000132893 [ncp.client] ERROR: Failed to power on modem
0000132893 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000135493 [ncp.client] ERROR: Failed to power on modem
0000135493 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000138093 [ncp.client] ERROR: Failed to power on modem
0000138093 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000140693 [ncp.client] ERROR: Failed to power on modem
0000140693 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160
0000143293 [ncp.client] ERROR: Failed to power on modem
0000143293 [net.pppncp] ERROR: Failed to initialize cellular NCP client: -160

Update: Device Doctor reset allows device to connect

Update: Blank code (below) also works. Something in my main code must be causing the modem to not be able to power on properly.

#include "Particle.h"
SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);

SerialLogHandler logHandler(LOG_LEVEL_INFO);
static unsigned long lastTime = 0;
int sequence = 0;
void setup() {
}

void loop() {
  if (millis() - lastTime >= 10000) {
    lastTime = millis();
    sequence++;
    Log.info("Sequence: %d", sequence);
  }
}

Still figuring out exact problem.
One step is removing the Particle.publish from set-up function. Especially when the device is in SYSTEM_THREAD(ENABLED) mode.

In Semi-automatic mode, still seems to have same issue of no power to modem.

You should not publish from setup() when threading is enabled. Depending on other factors it will either fail immediately, or block execution of setup until cloud connected, and neither is a good idea.

You should always check for Particle.connected() before Particle.publish() and generally only publish from loop(),

I think the problem stemmed from having Pin 19 set as an output and threading enabled on the B-SOM. My mistake but I believe this was the source of the problem.

On nRF52 devices that have NFC enabled, you definitely should not set a NFC pin as an output. There's a diode that kicks in when the voltage differential between NFC1 and NFC2 is greater than 2.0V. This is designed to protect the MCU from induced voltage from the NFC coils, but obviously would have bad side effects if using as GPIO.

On nRF52 devices with NFC disabled, including the E404X and Monitor One, NFC is disabled in the UICR bytes of the nRF52840, which disables the diode.