Arduino Nicla storage wiped when connecting over MAVLink

Hello,

I am having a strange issue when trying to trying to use the Arduino Nicla over MAVLink. Some times when I power off and power back on the Nicla, it is wiped or corrupted (can be either).

Setup:
I am connecting it to a Cube Orange Plus with ADSB carrier Board (Reference here for Serial 2 pinout Mini Carrier Board | CubePilot)
Pinout:
pin 9 (VIN) - VCC_5V
pin 6 (GND) - GND
pin 3 (UART_TX) - SERIAL_2_RX
pin4 (UART_RX) - SERIAL_2_TX

Detailed issues:

  1. When the Arduino Nicla is only powered through the Cube, it sometimes does not function as expected. The LED lights indicate the script is running, but I do not see MAVLink messages.
  2. If issue 1 happens and I plug the Nicla in to my PC with the USB cable, the MAVLink messages will start to come through the Cube. This loosely indicates to me some sort of power issue, but I am not sure.
  3. Sometimes, when I power cycle the Nicla, it will erase and corrupt the flash and then enter DFU mode.

All of these issues are very hard to reproduce, they happen once every 5 or 10 runs. It might not be worth checking out. An important thing that might be related (although I’m 99% sure this was happening before this) is that the reset button is broken. It has no clickyness to it at all, maybe it is jammed in the down position? IDK, it doesn’t seem to manifest anywhere else.

Here’s a limited code example.

import time
from machine import UART

# ---- UART Setup ----
uart = UART(9, 256000)
uart.init(256000, bits=8, parity=None, stop=1)


while True:
    packet = b'\xfd\t\x00\x00\x00\x01\xc5\x00\x00\x00\x00\x00\x00\x00\x12\x08\x00\x04\x03\x1e\xe4'
    uart.write(packet)
    time.sleep(1)

Thanks for your time!

Hi, are you writing to the internal uPy flash disk in your script? This can cause issues like this when power is lost as the camera has a FAT file system onboard which doesn’t support journaling. So, power loss during writing can be catastrophic.