# FMU Debugging

On Skynode S the FMU is tightly integrated with AOS including access to the serial console of PX4 and debug access for GDB.

## PX4 shell access via SSH

The PX4 shell (NSH) is connected to the Linux companion via UART and can be accessed from inside AOS with picocom:

```bash
picocom -b 57600 /dev/ttymxc1
```

This allows you to access the PX4 shell even when the Mavshell is not working.

```
nsh> reboot
[boot] Rev 0x15 : Ver 0x12 V6S015
[boot] Fault Log info File No 4 Length 3177 flags:0x01 state:1
[boot] Fault Log is Armed
HW arch: AUTERION_FMU_V6S
HW type: V6S
HW FMUM ID: 0x015
HW BASE ID: 0x012
```

You can exit picocom with Ctrl-a-x.

## GDB access via SSH

{% hint style="danger" %}
Debugging via GDB halts the FMU, which can lead to unpredictable behavior. **Only use this method to debug the FMU without any motors attached! NEVER DEBUG IN FLIGHT!**
{% endhint %}

The SWD lines of the FMU are also connected to the Linux companion and can be bit-banged via OpenOCD. This connection can be exposed as a GDB Server on the USB-C ethernet interface:

```bash
openocd -f board/px4_fmu-v6s.cfg \
    -c "bindto 10.41.1.1" -c init
```

{% hint style="info" %}
Adapt the IP address for other connected links to debug over radios.
{% endhint %}

Connecting GDB to this server requires setting the correct IP address too:

```bash
arm-none-eabi-gdb auterion_fmu-v6s_default.elf \
	-ex "target extended-remote 10.41.1.1:3333"
```

For better GDB integration with PX4, we recommend using the [Auterion Embedded Debug Tools](https://auterion.github.io/embedded-debug-tools/emdbg.html):

```bash
python3 -m emdbg.bench.fmu --remote 10.41.1.1:3333 \
    --target auterion_fmu-v6s_default
```
