OpenIPC Firmware

repository·master·Indexed 24 days ago

https://github.com/openipc/firmware

An open-source firmware project based on Buildroot providing an alternative operating system for various IP camera SoCs. Includes utilities for PTZ motor control (gpio-motors, gpiostep-openipc), mDNS service announcement and discovery (herald), a prototype Matter-compatible IP camera server, and an MQTT-based command bot (mqtt-bot).

Tokens
27K
Snippets
59
Records
128
Agent score
81%

What's inside openipc-firmware

  1. Overview of netblink

    master

    netblink is a minimal Linux command-line utility designed for embedded systems (like routers and IP cameras) to monitor network connectivity or traffic. It uses a GPIO-driven LED via the sysfs interface to indicate status through specific blink patterns.

    It supports two primary modes:

    • Ping mode: Periodically pings a host; the blink pattern reflects the Round Trip Time (RTT).
    • Traffic mode: Monitors a network interface; the blink rate reflects the combined transmit (tx) and receive (rx) throughput.
  2. What is gpiostep-openipc?

    master

    gpiostep-openipc is an in-kernel GPIO half-step stepper driver and userspace CLI designed for PTZ (Pan/Tilt/Zoom) cameras. It is specifically intended for cameras using 4-wire stepper motors wired directly to GPIO pins (such as the Goke GK7205V510).

    Compared to the userspace gpio-motors tool, gpiostep provides steadier timing and lower CPU usage because it executes gpio_set_value() directly within the kernel context rather than toggling /sys/class/gpio from userspace. It implements the same 8-phase half-step sequence and command signature as gpio-motors.

  3. Overview of OpenIPC firmware

    master

    OpenIPC is an open-source alternative firmware for IP cameras, built on Buildroot. It is designed to provide a stable, flexible, and open IP Network Camera Framework.

    Supported SoC (System on Chip) manufacturers include:

    • HiSilicon
    • Ambarella
    • Anyka
    • Fullhan
    • Goke
    • GrainMedia
    • Ingenic
    • MStar
    • Novatek
    • SigmaStar
    • XiongMai
  4. Overview of OpenIPC Matter IP Camera Server

    master

    The OpenIPC Matter IP Camera Server is a minimal, self-contained Matter-compatible server written in C (POSIX / C99). It implements a subset of the Matter 1.2 specification, allowing IP cameras to be discoverable and controllable by Matter controllers like Apple Home, Google Home, and Amazon Alexa without requiring the official Matter SDK.

    Key characteristics:

    • Matter Interaction Model: Operates over TCP on port 5540.
    • mDNS Announcement: Broadcasts _matter._tcp.local every 30 seconds on port 5353.
    • RTSP Integration: Exposes the camera's RTSP stream URL as a Matter attribute.
    • Zero Dependencies: Written in pure C99 / POSIX.
    • Prototype Status: This is a prototype implementation where PASE/CASE cryptography (SPAKE2+) is stubbed out. It accepts commissioning requests but does not perform real cryptographic handshakes.
  5. Kernel module directory structure for xiongmai-osdrv-xm530

    master

    The kernel modules for the xiongmai-osdrv-xm530 package are organized into several functional directories. Depending on your hardware configuration (e.g., RAM size or WiFi module type), you will need to interact with specific subdirectories.

    Key Directories and Components:

    • modules/: Contains core system modules including:
      • loadxm530_128M / loadxm530_64M: Loading scripts for 128MB or 64MB RAM systems.
      • acodec.ko, mmz.ko, xm530_h264.ko, xm530_isp.ko, etc.: Core multimedia and hardware abstraction modules.
      • mve_base.ko & mve_rsrc.ko: Required for H265 encoding.
      • log.ko: Logging module.
    • firmware/: Contains necessary firmware files. For H265 encoding, the file /lib/firmware/hevcenc.fwb is required.
    • rtl8188/: Modules for Realtek 8188 WiFi chips.
    • usb/: Modules for USB-based WiFi modules (e.g., RTL8188 on XM711).
    • xm711/ & xm712/: Specific modules for XM711 and XM712 chipsets.
  6. Configure command whitelisting with -w

    master

    For security, mqtt-bot only executes commands explicitly defined in the whitelist using the -w flag. Each entry follows the format <command_name>:<path_to_executable>[:<arg1>[:<arg2>...]].

    Constraints:

    • You can define up to 64 whitelist entries.
    • Each command can have up to 8 argv entries.
    • Unknown commands are rejected and logged without execution.

    Example: Basic command and arguments

    # Basic command
    # Triggering 'reboot' via MQTT topic will run /sbin/reboot
    mqtt-bot -h mqtt.local -w reboot:/sbin/reboot
    
    # Command with arguments
    # Triggering 'snap_hq' will run ffmpeg with specific arguments
    mqtt-bot -h mqtt.local -w snap_hq:/usr/bin/ffmpeg:-i:rtsp://cam/s:-frames:1:/tmp/snap.jpg
    mqtt-bot -h mqtt.local -u admin -P secret -t cam/cmds \
             -w snap_hq:/usr/bin/ffmpeg:-i:rtsp://cam/s:-frames:1:/tmp/snap.jpg
  7. Understand ntfy output formats

    master

    The output format depends on whether you use the quiet flag -q.

    Default (verbose)

    Includes timestamp, topic, priority, and tags:

    [2024-01-15 08:15:23] alerts [HIGH] Warning: CPU at 98%
      tags: warning,cpu
    [2024-01-15 08:16:01] alerts Backup completed

    Quiet (-q)

    Outputs only the raw message body, ideal for shell pipes:

    CPU at 98%
    Backup completed
  8. Compile ISP libraries for 400W sensors (X50)

    master

    To support a 400W sensor (e.g., X50), follow the same procedure as the 200W sensor, but select the X50 sensor during configuration:

    1. Navigate to mpp\isp\ispsample.
    2. Run ./mkconfig.
    3. In the interactive menu:
      • Select SOC: XMSDK
      • Select Sensor: X50
      • Confirm with OK.
    4. Compile: make clean; make.
    5. Replace the libraries in mpp\lib\isp with those from mpp\isp\ispsample\output.
    6. Recompile the program in mpp\sample\venc using make clean; make.
  9. Install the webface authentication system

    master

    To install the webface authentication module, create the necessary directory structure in /var/www/, copy the component files, and set the appropriate permissions for CGI scripts and static assets.

    1. Create directories

    mkdir -p /var/www/cgi-bin /var/www/assets/css /var/www/assets/js

    2. Place files

    Copy the following files to /var/www/:

    • index.html $\rightarrow$ /var/www/index.html
    • login.html $\rightarrow$ /var/www/login.html
    • assets/css/webface.css $\rightarrow$ /var/www/assets/css/webface.css
    • assets/js/login.js $\rightarrow$ /var/www/assets/js/login.js
    • cgi-bin/auth_common.sh $\rightarrow$ /var/www/cgi-bin/auth_common.sh
    • cgi-bin/auth.cgi $\rightarrow$ /var/www/cgi-bin/auth.cgi
    • cgi-bin/index.cgi $\rightarrow$ /var/www/cgi-bin/index.cgi
    • cgi-bin/logout.cgi $\rightarrow$ /var/www/cgi-bin/logout.cgi
    • cgi-bin/session_guard.sh $\rightarrow$ /var/www/cgi-bin/session_guard.sh

    3. Set permissions

    chmod 755 /var/www/cgi-bin/auth.cgi /var/www/cgi-bin/index.cgi /var/www/cgi-bin/logout.cgi
    chmod 644 /var/www/cgi-bin/auth_common.sh /var/www/cgi-bin/session_guard.sh
    chmod 644 /var/www/index.html /var/www/login.html /var/www/assets/css/webface.css /var/www/assets/js/login.js
    # Create target directories
    mkdir -p /var/www/cgi-bin /var/www/assets/css /var/www/assets/js
    
    # Place files
    cp index.html /var/www/index.html
    cp login.html /var/www/login.html
    cp assets/css/webface.css /var/www/assets/css/webface.css
    cp assets/js/login.js /var/www/assets/js/login.js
    cp cgi-bin/auth_common.sh /var/www/cgi-bin/auth_common.sh
    cp cgi-bin/auth.cgi /var/www/cgi-bin/auth.cgi
    cp cgi-bin/index.cgi /var/www/cgi-bin/index.cgi
    cp cgi-bin/logout.cgi /var/www/cgi-bin/logout.cgi
    cp cgi-bin/session_guard.sh /var/www/cgi-bin/session_guard.sh
    
    # Set permissions
    chmod 755 /var/www/cgi-bin/auth.cgi /var/www/cgi-bin/index.cgi /var/www/cgi-bin/logout.cgi
    chmod 644 /var/www/cgi-bin/auth_common.sh /var/www/cgi-bin/session_guard.sh
    chmod 644 /var/www/index.html /var/www/login.html /var/www/assets/css/webface.css /var/www/assets/js/login.js
  10. Quick start guide for ZeroTier One

    master

    To set up ZeroTier One on your camera, follow these steps:

    1. Register an account at my.zerotier.com.
    2. Create a network and obtain its Network ID. Ensure the network is configured as Private.
    3. Access your camera's console (via web console or SSH) and join the network using the zerotier-cli join command with your Network ID: zerotier-cli join <network_id> A successful join will return the status: <200 join OK>.
    4. Go to the my.zerotier.com web interface and authorize the newly connected camera by checking the box next to the corresponding peer.

    Note: All configuration data is stored in /var/lib/zerotier-one.

  11. Read DS18B20 sensors using w1-ds18b20

    master

    The w1-ds18b20 application enables reading temperature from DS18B20 sensors using bitbang mode via direct GPIO memory access.

    Requirements:

    • A pull-up resistor must be connected to the sensor.
    • Currently, only HiSilicon-style GPIO offsets are supported.
    • You must identify the correct GPIO base address and GPIO number for your specific hardware (e.g., by consulting the datasheet or using ipctool).

    Usage: Run the binary with the -base flag specifying the GPIO memory base address and the -gpio flag specifying the GPIO pin number.