Custom Firmware Issue: Flight Controller Auto Disconnects

After uploading a custom firmware from linux and connecting to the mission planner, the flight controller disconnects after few minutes.

I even tried with a fresh git repo with Copter 4.5 branch. Compiled and Uploaded but still the same.

MissionPlanner logs shows following messages:
MissionPlanner-latest/plugins/example18-externalapi.cs(313,28): error CS0433: The type 'ReadOnlySpan<T>' exists in both 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

ERROR MissionPlanner.MainV2 - System.TimeoutException: The operation has timed-out
  at System.IO.Ports.SerialPortStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00051] in <a8a996a78a804d888710c9e2575d78c8>:0 
  at System.IO.Ports.SerialPort.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0003a] in <a8a996a78a804d888710c9e2575d78c8>:0 
  at MissionPlanner.Comms.WinSerialPort.MissionPlanner.Comms.ICommsSerial.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000] in <6dc2ac4fbe3d4280b63b2c85bf82d10e>:0 
  at MissionPlanner.Comms.SerialPort.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00001] in <6dc2ac4fbe3d4280b63b2c85bf82d10e>:0 
  at MissionPlanner.MAVLinkInterface.generatePacket (System.Int32 messageType, System.Object indata, System.Int32 sysid, System.Int32 compid, System.Boolean forcemavlink2, System.Boolean forcesigning) [0x004e7] in <0895b35ced494309b7b5822c5a2314fb>:0 
  at MissionPlanner.MAVLinkInterface.sendPacket (System.Object indata, System.Int32 sysid, System.Int32 compid) [0x00048] in <0895b35ced494309b7b5822c5a2314fb>:0 
  at MissionPlanner.MainV2.SerialReader () [0x00ed1] in <91ac89d2443e43b68c8e690d54351a73>:0 
INFO MissionPlanner.Utilities.TerrainFollow - OnPacketReceived remove to packets
INFO MissionPlanner.MAVLinkInterface - set giveComport Thread Pool Worker current False new False
INFO MissionPlanner.Comms.WinSerialPort - Closing port /dev/serial/by-id/usb-CubePilot_CubeOrange+_36003F001451323031393637-if00

Hi @wkpatil,

I guess this issues doesn’t occur if you use the official build instead of one that you’ve built yourself?

If this is the case then I’d suspect the submodules haven’t been updated or the wrong compiler is being used.

Yes. It only happens when I upload a firmware that is built locally.

Compiler: gcc-13.2.1-1.1
Git Install Command: git clone --recursive https://github.com/ArduPilot/ardupilot.git

Hi @wkpatil,

You’ve setup your build environment according to the wiki instructions?

For Ubuntu (and WSL under Windows) there are install scripts that should be run to ensure everything is correctly installed including the special compiler.

Yes I am following the mentioned link.
Specifically: Setting up the Build Environment (Linux/Ubuntu) — Dev documentation
and I’ve made sure that I followed each and every step.

Hi @wkpatil,

I can ask if any other devs have any ideas but I think the issue may be that you’re using the wrong compiler.

When I type “gcc --version” I see the following

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

… and when I look in our STM32 tools which is where the compiler should have been downloaded from when using the build environment setup scripts, I don’t see GCC 13 in there.

Okay I solved it. Turns out the Tools/environment_install/install-prereqs-ubuntu.sh -y was not getting completed due to some reason.

I made the necessary fixes and now the firmware is stable.

This step should return ---------- Tools/environment_install/install-prereqs-ubuntu.sh end ---------- at the end, marking it’s completion.

1 Like

@wkpatil,

Great stuff! Thanks for the update.