Skip to content

JW-Albert/aws_ggc-gpio-DIO_Fintek_F8196x_F8186x

Repository files navigation

imPHM AWS Greengrass GPIO DIOFintekF8196xF8186x Component

AWS Greengrass Greengrass Core Runtime Java Runtime OS Python Fintek CI (Lint, Validate, Test) Release, Build, Publish

High-performance AWS Greengrass v2 component for industrial GPIO control using Fintek F81866 DIO chips with real-time data acquisition capabilities for the imPHM platform.

Table of Contents

Overview

The imPHM GPIO DIOFintekF8196xF8186x component is a high-performance AWS Greengrass v2 component designed for industrial GPIO control using Fintek F81866 DIO chips. It provides real-time digital input/output control, advanced signal processing, and seamless integration with AWS IoT Device Shadow for remote configuration management on iBase AGS103T devices.

Key Features

  • High-Speed GPIO Control: Real-time digital I/O operations with minimal latency
  • Multi-Channel Support: Simultaneous control of multiple GPIO channels (GPIO_0 to GPIO_3)
  • AWS Integration: Native AWS IoT Device Shadow integration for remote configuration
  • Real-time Data Acquisition: Configurable sampling rates up to 100 Hz
  • Robust Architecture: Event-driven design with comprehensive error handling
  • Industrial Grade: Designed for 24/7 operation in harsh industrial environments

Features

GPIO Control Capabilities

  • Digital I/O Control: Support for digital input and output operations
  • Multi-Channel: Simultaneous control of up to 4 GPIO channels
  • Configurable Sampling: Software-controlled sampling rates (1-100 Hz)
  • Real-Time Processing: Low-latency GPIO state monitoring and control
  • Data Buffering: Circular buffering with configurable publish intervals

Hardware Support

  • Fintek F81866: Direct support for F81866 DIO chip
  • iBase AGS103T: Optimized for iBase AGS103T industrial computers
  • GPIO Channels: 4 configurable digital I/O channels
  • Signal Types: TTL digital signals (0V/3.3V or 0V/5V)
  • Isolation: Industrial-grade signal isolation support

AWS Integration

  • Device Shadow: Remote configuration via AWS IoT Device Shadow
  • IPC Communication: Native Greengrass IPC for data streaming
  • Status Reporting: Real-time status and health monitoring
  • Configuration Management: Dynamic configuration updates without restart

Real-time Processing

  • Configurable Sampling: Adjustable sampling rates (1-100 Hz)
  • Data Validation: GPIO state validation and error detection
  • Timestamp Precision: High-precision timestamping for data correlation
  • Provenance Tracking: Complete data lineage tracking

Architecture

┌─────────────────┐    ┌───────────────────┐    ┌─────────────────┐
│   Fintek F81866 │───▶│   GPIO Component  │───▶│  Data Consumer  │
│   DIO Hardware  │    │   (Acquisition)   │    │   (Output)      │
└─────────────────┘    └───────────────────┘    └─────────────────┘
                              │
                       ┌─────────────────┐
                       │   Device Shadow │
                       │  (Configuration)│
                       └─────────────────┘

Core Components

  1. DIO Module (src/lib/dio_module.py)

    • Fintek F81866 driver interface and hardware abstraction
    • GPIO direction configuration (input/output)
    • Real-time GPIO state reading and writing
    • Permission management and initialization
    • Signal conditioning and processing
  2. Shadow Manager (src/shadow_manager.py)

    • AWS IoT Device Shadow integration for configuration management
    • Real-time configuration updates and synchronization
    • Status reporting and health monitoring
    • Secure configuration validation and delta processing
  3. Main Service (src/main.py)

    • Component lifecycle management and orchestration
    • IPC communication setup and data streaming
    • Signal handling and graceful shutdown
    • Performance monitoring and logging

Data Flow

  1. Hardware Initialization: Configure F81866 chip and GPIO channels
  2. Configuration Management: Receive configuration from device shadow
  3. Data Acquisition: Continuous GPIO state sampling at configured rate
  4. Data Processing: Buffer and batch GPIO state data
  5. Data Streaming: Publish processed data via Greengrass IPC
  6. Status Monitoring: Report acquisition status to device shadow

Prerequisites

Hardware Requirements

  • iBase AGS103T Device: Industrial computer with Fintek F8196x-F8186x DIO chip
  • Processor: x86_64 architecture (Intel/AMD)
  • Memory: Minimum 1GB RAM (2GB+ recommended for optimal performance)
  • Storage: Sufficient space for logs and temporary buffers
  • GPIO Interface: Direct access to F81866 DIO chip

Software Requirements

  • Operating System: Linux amd64 (tested on Ubuntu 20.04+ LTS)
  • Python: 3.10 or higher
  • Fintek F81866 Driver: Compatible driver library (libf81866.so)
  • AWS Greengrass Core: Nucleus Classic v2.15.0 or higher
  • Root Privileges: Required for GPIO hardware access

Supported Hardware

  • iBase AGS103T: Industrial computer series with Fintek DIO
  • Fintek F81866: Digital I/O controller chip

Install Fintek F81866 DIO Driver

F81866 Driver Installation

The component includes a pre-compiled driver library (libf81866.so) that provides low-level access to the F81866 DIO chip. This library handles:

  • Chip initialization and configuration
  • Register read/write operations
  • GPIO direction control
  • I/O permission management

Check Compatibility

Verify your hardware compatibility:

# Check system architecture
uname -a

# Verify F81866 chip presence (requires root)
sudo lspci | grep -i fintek

Permission Requirements

The component requires root privileges to access GPIO hardware:

  1. I/O Port Access: Direct access to hardware I/O ports
  2. Memory Mapping: Low-level hardware register access
  3. Kernel Modules: Loading required kernel drivers
# Set I/O permissions (handled automatically by component)
sudo iopl 3

# Verify GPIO device access
ls -la /dev/gpio*

Development

Local Development

# Clone the repository
git clone <repository-url>
cd <repository-name>

# Setup development environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 -m pip install -U git+https://github.com/aws-greengrass/aws-greengrass-gdk-cli.git@v1.6.2
# Deploy locally (for dev & testing)
./local_deploy.sh

# Remove local deployment
./remove_local_deploy.sh

Building

# Build component package
gdk component build

Manual Publish to AWS (Not Recommended, Use CI/CD instead)

gdk component publish

Subscribe to Greengrass Topic

sudo /greengrass/v2/bin/greengrass-cli pubsub sub -t /TOPIC_NAME/

Where TOPIC_NAME is the name of the topic you want to subscribe to.

Git Flow

Branch model (left to right = promotion path): feature branch → dev → staging → main

Environments and version patterns:

  • feature branches: isolated feature / fix work (no version tagging)
  • dev: integration / active development (pre-release versions vX.Y.Z-alpha.N)
  • staging: pre-production verification (pre-release versions vX.Y.Z-beta.N)
  • main: production (stable releases vX.Y.Z)

Rules:

  • Only merge into dev via PR from feature branches
  • staging only receives squash merges from dev
  • main only receives fast-forward or squash from staging (no direct commits)
  • Hotfix (critical) may branch from main, then merge back to staging and dev

Automated Release Workflow

semantic-release (single source of truth) runs on push to dev, staging, main:

  1. Analyze commits (Conventional Commits) to determine version bump:
    • BREAKING CHANGE: / feat! → major
    • feat: → minor
    • fix / perf / refactor: → patch
    • Other types (docs, chore, ci, style, test) → no version bump
  2. Prepare phase writes the computed version to:
    • gdk-config.json (component version)
    • recipe.yaml (ComponentVersion)
  3. Generate changelog + Git tag:
    • dev → vX.Y.Z-alpha.N
    • staging → vX.Y.Z-beta.N
    • main → vX.Y.Z
  4. Create GitHub Release / Pre-release with artifacts
  5. Build & publish to AWS Greengrass ONLY for staging and main
  6. No separate version-bump workflow; remove any legacy bumps

Code Quality & Compliance Checks

ci.yml (runs on every PR and push):

  • Formatting / style: black, isort, flake8
  • (Soft) typing: mypy (non-blocking initially)
  • JSON / YAML schema & syntax validation
  • Greengrass component structure & recipe consistency checks
  • (Soft) security & secret scanning (upgradeable to blocking later)
  • Fails fast on critical structural or syntax errors

Conventional Commit Guidelines

Format: [optional scope]:

[optional body]

[optional footer(s)]

Common types:

  • feat: new feature (triggers minor)
  • fix: bug fix (patch)
  • perf: performance improvement (patch)
  • refactor: code change w/o behavior change (patch)
  • docs, style, test, chore, ci: no version bump by default

Breaking changes:

  • Use feat! / refactor! suffix OR
  • Add footer: BREAKING CHANGE: explanation

Recommended workflow:

  • Use squash merge
  • Ensure PR title is a valid Conventional Commit (final squashed commit = PR title)

Examples: feat: add new sensor data filtering algorithm fix: resolve memory leak in data processing loop feat!: change API response format feat: change API response format BREAKING CHANGE: response changed from array to object

Release & Publishing Process

Automated (preferred):

  1. Develop on feature branch → open PR to dev
  2. Ensure commits / PR title comply with Conventional Commits
  3. Merge → semantic-release assigns pre-release (alpha) on dev
  4. Promote dev → staging → beta release (build + publish to Greengrass)
  5. Promote staging → main → stable release (build + publish)

Manual trigger (if needed):

  1. Go to Actions: "Release (semantic-release → build → publish)"
  2. Select target branch (dev / staging / main)
  3. Workflow auto-detects:
    • dev: pre-release alpha (no publish to AWS)
    • staging: pre-release beta (publish)
    • main: stable (publish)

Safeguards:

  • Never edit versions manually
  • All version sources are derived; commit modified version files produced by workflow only
  • Avoid tagging manually to prevent semantic-release drift

Operational Notes:

  • alpha churn is expected; do not pin production to alpha/beta
  • Consumers should pin only stable main releases unless testing
  • Monitor release notes for BREAKING CHANGE sections

License

Copyright (c) 2025 imCloud Co., Ltd. All rights reserved.

This software is proprietary and confidential. Unauthorized copying, modification, distribution, or use of this software is strictly prohibited.

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors