---
# System prepended metadata

title: Raingers

---

# Tech Stack Next steps

1. Wo sind wir?
    - bis Juni raspberry pi
    - camera lösung mit imx462
    - mit blues communication
2. Was mach Ich
    - Zephyr ausprobieren
    - auf phytech board M7
    - mit CSI schnittstelle
3. Wo wollen wir hin?
    - langfristig MCU wie [i.MX RT1170](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/i-mx-rt-crossover-mcus/i-mx-rt1170-1-ghz-crossover-mcu-with-arm-cortex-cores:i.MX-RT1170)
    - mit CSI schnittstelle
    - SOM
    - carrier board as tech stack
    - phytec kann "kosten effektiv" carrier herstellen: [PhyTec](https://www.phytec.eu/en/leistungen/custom-sbc/)


### Tech Stack

- Vor allem software lösung die dynamisch deployed werden kann
    - Zephyr bietet sich an
    - Entwicklung von verschiedenen Tasks in Zephyr welche verschiedene module darstellen
    - art baukasten
    - verwendung von C / C++
    - Beisp
- AI fokus mit bild/sensor input


## Zephyr

- [Zephyr Board Support](https://docs.zephyrproject.org/latest/boards/phytec/mimx8mp_phyboard_pollux/doc/index.html)

## Camera

### Camera interfaces

#### DCMI 

DCMI is a parallel camera interface. 8 to 14 image input lanes. Pixel clock. Following data format is supported:
- 8-bit progressive video: either monochrome or raw Bayer
- YCbCr 4:2:2 progressive video
- RGB565 progressive video
- compressed data (JPEG)

[DCMI Application Note by STM32](https://www.st.com/content/ccc/resource/technical/document/application_note/group0/c0/ef/15/38/d1/d6/49/88/DM00373474/files/DM00373474.pdf/jcr:content/translations/en.DM00373474.pdf)

#### CSI 

CSI is a serial interface using differential pair. Can transfer with much higher data rates -> differential pair.

[CSI Application note by NXP](https://www.nxp.com/docs/en/application-note/AN13573.pdf)


#### CSI to DCMI bridge

There are ICs available which convert CSI to DCMI. But DCMI has lower data through put so lower framerates are neccessary.

![image](https://hackmd.io/_uploads/S1yM9-NbA.png)

From [application note](https://www.st.com/resource/en/application_note/dm00693021-stm32mp15x-series-interfacing-with-a-mipi-csi2-camera-stmicroelectronics.pdf)

### OS04C10 and IMX462

Both sensors rely on the CSI interface. 
This interface is not widly available on microcontrollers.
But some have it:
- [i.MX RT1170](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/i-mx-rt-crossover-mcus/i-mx-rt1170-1-ghz-crossover-mcu-with-arm-cortex-cores:i.MX-RT1170)
- [SAMA7G54](https://www.microchip.com/en-us/product/SAMA7G54)

It is more common in micro processors running Linux or similliar.

## RemoteProc Peripherals

## Copilot
Certainly! To program the Resource Domain Controller (RDC) on the i.MX 8MP Family, you'll need to configure it appropriately to manage peripheral access between different cores. Let's break down the steps:
- Understanding RDC:
    - The RDC is a hardware feature that allows you to control access to peripherals (such as CSI interfaces) based on the core that requests it.
    - It ensures that each core can only access the peripherals it is allowed to use, enhancing security and resource management.
- Configuration Steps:
    - Device Tree (DTS): The RDC configuration is typically done in the device tree (DTS) files. These files describe the hardware configuration of the system.
    - Locate the relevant DTS file for your board (usually found in the Linux kernel source tree).
- Identify the CSI Interface:
    - Find the CSI (Camera Serial Interface) peripheral in the DTS file. It should be defined under the appropriate node (e.g., imx8mp-csi).
- Assign RDC Permissions:
    - Within the CSI node, you'll need to specify which cores are allowed to access it.
    - Use the rdc-domains property to define the resource domains (cores) that can access the CSI.
    - For example:

```
imx8mp-csi {
    compatible = "fsl,imx8mp-csi";
    rdc-domains = <&rdc_m7>; // Allow M7 core to access CSI
};
```

- Define Resource Domains:
    - In the same DTS file, define the resource domains (cores) using the rdc-domains property.
    - For example:

```
rdc_m7: rdc_m7 {
    compatible = "fsl,imx8mp-rdc";
    rdc-id = <1>; // Unique ID for the M7 core
};
```

- Kernel Configuration:
    - Ensure that your Linux kernel configuration includes support for the RDC (usually found under "Device Drivers" -> "Resource Domain Controller").
    - Build the kernel with the necessary options.
- Testing:
    - Boot your Linux system on the i.MX 8MP board.
    - Verify that the CSI interface is accessible from the M7 core.
    - You can use tools like cat /proc/iomem or cat /proc/interrupts to check if the CSI resources are correctly assigned.
- Debugging:
    - If you encounter issues, check kernel logs (dmesg) for any RDC-related messages.
    - Ensure that the RDC configuration matches your expectations.
Remember that this is a high-level overview, and you'll need to adapt it to your specific board and use case. Consult the i.MX 8MP Reference Manual and the Linux kernel documentation for detailed information on RDC configuration and usage1 2 3. Additionally, community forums (such as NXP Community) can be helpful for troubleshooting specific issues1 5.
Good luck with your application development! 🚀


## Arducopter

### Living Room Changes - No GPS

- GPS: Serial6
- GPS_TYPE=Auto
- AHRS_GPS_USE for DCM
- BATT_FS_LOW_ACT SmartRTL
- FS_THR_ENABLE 4


## Telemetry 

### Raspberry Pi - mavlink-router

- install mavlink router
    see [GitHub mavlink-router](https://github.com/mavlink-router/mavlink-router)
    build on RaspberryPi Zero 2 did not work properly. Had to build on Raspberry Pi 4. Prebuild via pip could also be available?
- create file `/etc/mavlink-router/main.conf` with content

```
[UartEndpoint alpha]
Device = /dev/serial0
Baud = 115200

[UdpEndpoint Broadcast]
Mode = Normal
Address = 192.168.8.255
Port = 14550

# When using Pi as access point add this as well
[UdpEndpoint AP-Broadcast]
Mode = Normal
Address = 192.168.4.255
Port = 14550

```
- enable service

```sudo systemctl enable mavlink-router.service```

- start service

```sudo systemctl start mavlink-router.service```

### Raspberry Pi Access Point

Enabeling the RaspberryPi to not only be client in a network, but also to create an access point. Devices can log into that access point to get access to the RaspberryPi and to the Flight computer.

For the flight computer, the mavlink-router service must be set up.

- use virtual device as access point.
    - Create it with temporary:

    ```
    sudo iw dev wlan0 interface add wlan1 type __ap
    ``` 
    - Create it permanent:
    1. Create script in
    `sudo nano /usr/local/bin/create_ap_interface.sh`

        ```
        #!/bin/bash
        # Check if the virtual interface already exists
        if ! ip a show wlan1 > /dev/null 2>&1; then
            # Create the virtual interface wlan1 for AP mode
            iw dev wlan0 interface add wlan1 type __ap
        fi
        ```
    2. Make it executable
    `sudo chmod +x /usr/local/bin/create_ap_interface.sh`
    3. Create systemd service file
    `sudo nano /etc/systemd/system/create_ap_interface.service`
    
        ```
        [Unit]
        Description=Create AP Virtual Interface
        After=network.target

        [Service]
        ExecStart=/usr/local/bin/create_ap_interface.sh

        [Install]
        WantedBy=multi-user.target
        ```
    4. Enable and start service
    `sudo systemctl enable create_ap_interface.service`
    `sudo systemctl start create_ap_interface.service`
    

- show devices with 

    ```
    ip link show
    ```

    should now also list a wlan1 interface

- configure network manager to create access point

    ```
    sudo nmcli con add type wifi ifname wlan1 con-name RaingersDrone autoconnect yes ssid RaingersDrone mode ap ip4 192.168.4.1/24

    Credentials:

    nmcli con modify RaingersDrone 802-11-wireless-security.key-mgmt wpa-psk
    nmcli con modify RaingersDrone 802-11-wireless-security.psk "YourPassword"

    Activate:

    nmcli con up RaingersDrone
    ```

- install `dnsmasq`

    `sudo apt install dnsmasq`
    
-  configure dnsmasq
    `sudo nano /etc/dnsmasq.conf`
    
    ```
    interface=wlan1      # Use interface wlan1
    dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
    ```
- start and enable dnsmasq
    `sudo systemctl enable dnsmasq.service`
    `sudo systemctl start dnsmasq.service`
    
- enable IP forwarding in Kernel:
    `sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"`
    Permanently enable it:
    `sudo nano /etc/sysctl.conf`
    `net.ipv4.ip_forward=1`
    
- install iptables
    `sudo apt install iptables`
    `sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE`
    `sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"`


## Telemetry over additional hardware

[mLRS GitHub](https://github.com/olliw42/mLRS)

### 2in1 Setup

Autopilot -> R9X -> 868MHz -> XX in Radio -> serial -> ESP32 -> Wifi -> QGroundcontrol

## Sik replacement R9 mini

- mLRS
- [RPi Pico UART to USB bridge](https://github.com/Noltari/pico-uart-bridge)
- Problem:
    - mLRS R9MM or R9Mini only has rx-firmware
    - I think it is fairly easy to compile tx-firmware for receiving.
    - alternative would be using a r9 receiver

## Future

Use E77 module and design own hardware (very small SMD solution)