Camera Service Management Planning

Status: PLANNING COMPLETE - Ready for Implementation
Date: 2026-02-19

Overview

This document outlines the plan to:

  1. Disable rkipc autostart in firmware boot
  2. Start and manage rkaiq_3A_server via init.d script

Current State

  1. start-seedsigner.sh (line 16, 24):
    • Already kills rkipc on startup: killall rkipc 2>/dev/null
    • This is a reactive approach (kills after it starts)
  2. S99seedsigner init script:
    • Runs late in boot sequence (S99)
    • Calls start-seedsigner.sh
  3. File installation (os-build.sh line 608-611):
    [[ -f "/build/files/S99seedsigner" ]] && cp -v "/build/files/S99seedsigner" "$ROOTFS_DIR/etc/init.d/"
    
  4. RkLunch.sh location:
    • Generated by LuckFox SDK
    • Located at: /oem/usr/bin/RkLunch.sh in final image
    • Contains: rkipc -a /oem/usr/share/iqfiles & line

Required Changes

1. Disable rkipc Autostart

Approach: Post-Build sed Modification (RECOMMENDED)

Why this approach:

  • Simple and maintainable
  • No SDK source modifications required
  • Easy to verify
  • Non-destructive (comments out, doesn’t delete)

Implementation:

Add to buildroot/os-build.sh after line 606:

# Disable rkipc autostart in RkLunch.sh (camera management conflict)
if [[ -f "$ROOTFS_DIR/oem/usr/bin/RkLunch.sh" ]]; then
    print_info "Disabling rkipc autostart in RkLunch.sh"
    sed -i 's/^\(.*rkipc -a.*\)$/#\1  # Disabled for SeedSigner camera management/' "$ROOTFS_DIR/oem/usr/bin/RkLunch.sh"
    print_success "rkipc autostart disabled"
else
    print_info "RkLunch.sh not found at expected location"
fi

Also update:

  • buildroot/build-local.sh with identical changes

Alternative approaches considered:

  • SDK patch: Too complex, requires finding source
  • File replacement: Requires maintaining full RkLunch.sh copy
  • Deletion: Too aggressive, may break other functionality

2. Start rkaiq_3A_server

Approach: Create S50rkaiq init script

Why S50:

  • Runs before most services (50 is early/mid boot)
  • Runs before SeedSigner (S99)
  • Provides camera ISP service for SeedSigner to use

Implementation:

Step 1: Create buildroot/files/S50rkaiq:

#!/bin/sh
#
# Start/stop rkaiq_3A_server for camera ISP management
#
# This service manages the camera Image Signal Processor (ISP)
# and should run before applications that use the camera.
#

case "$1" in
    start)
        echo "Starting rkaiq_3A_server..."
        /usr/bin/rkaiq_3A_server &
        ;;
    stop)
        echo "Stopping rkaiq_3A_server..."
        killall rkaiq_3A_server 2>/dev/null
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac

exit 0

Step 2: Make executable in repository:

chmod +x buildroot/files/S50rkaiq

Step 3: Update buildroot/os-build.sh after line 611:

# Install rkaiq_3A_server init script
if [[ -f "/build/files/S50rkaiq" ]]; then
    print_info "Installing rkaiq_3A_server init script"
    cp -v "/build/files/S50rkaiq" "$ROOTFS_DIR/etc/init.d/"
    chmod +x "$ROOTFS_DIR/etc/init.d/S50rkaiq"
    print_success "rkaiq_3A_server init script installed"
fi

Step 4: Update buildroot/build-local.sh with identical changes

Boot Sequence

Before Changes:

  1. System init
  2. RkLunch.sh runs → starts rkipc
  3. S99seedsigner runs → kills rkipc, starts SeedSigner
  4. Camera ISP in unknown state

After Changes:

  1. System init
  2. S50rkaiq runs → starts rkaiq_3A_server (camera ISP ready)
  3. RkLunch.sh runs → rkipc line commented (no action)
  4. S99seedsigner runs → starts SeedSigner (camera ISP already available)

Files to Create

  1. buildroot/files/S50rkaiq - New init script

Files to Modify

  1. buildroot/os-build.sh:
    • Add RkLunch.sh modification (after line 606)
    • Add S50rkaiq installation (after line 611)
  2. buildroot/build-local.sh:
    • Same changes as os-build.sh

Verification Steps

Build-Time Verification:

  1. Check that S50rkaiq is created in repository
  2. Verify S50rkaiq is executable
  3. After build, verify:
    • RkLunch.sh has commented rkipc line
    • /etc/init.d/S50rkaiq exists in rootfs
    • /etc/init.d/S50rkaiq is executable

Runtime Verification:

  1. Boot device
  2. Check running processes:
    ps aux | grep rkaiq     # Should show rkaiq_3A_server running
    ps aux | grep rkipc     # Should be empty (not running)
    
  3. Test camera with SeedSigner
  4. Test service management:
    /etc/init.d/S50rkaiq stop
    /etc/init.d/S50rkaiq start
    /etc/init.d/S50rkaiq restart
    

Dependencies Check

Required Binaries:

  • /usr/bin/rkaiq_3A_server - Must exist in SDK build
  • Location verified: SDK should provide this in buildroot

Required Libraries:

  • rkaiq_3A_server may depend on ISP libraries
  • Should be included in SDK by default

Risk Assessment

Low Risk:

  • ✅ Init script creation (standard pattern)
  • ✅ sed modification (non-destructive)
  • ✅ File copying (standard build process)

Medium Risk:

  • ⚠️ RkLunch.sh path may vary between SDK versions
  • ⚠️ rkaiq_3A_server binary location may vary
  • ⚠️ Need to verify camera still works after changes

Mitigation:

  • Add path verification before sed
  • Add binary existence check before starting service
  • Test on actual hardware before release

Benefits

  1. Proper service lifecycle - Start/stop/restart capability
  2. Clean boot sequence - Services start in correct order
  3. No process conflicts - rkipc prevented from starting
  4. Maintainable - Standard init.d pattern
  5. Persistent - Works across reboots

Testing Plan

Phase 1: Build Testing

  • Create S50rkaiq file
  • Build completes successfully
  • Verify files in output image

Phase 2: Boot Testing

  • Flash image to device
  • Device boots successfully
  • rkaiq_3A_server is running
  • rkipc is NOT running

Phase 3: Functional Testing

  • Camera works in SeedSigner
  • QR code scanning works
  • Service stop/start/restart works
  • No errors in system logs

Phase 4: Edge Case Testing

  • Reboot device - services start correctly
  • Kill rkaiq manually - init script can restart
  • Multiple rapid restarts work correctly

Implementation Checklist

When ready to implement:

  • Create buildroot/files/S50rkaiq with init script content
  • Make S50rkaiq executable: chmod +x buildroot/files/S50rkaiq
  • Add RkLunch.sh modification to buildroot/os-build.sh
  • Add S50rkaiq installation to buildroot/os-build.sh
  • Add same changes to buildroot/build-local.sh
  • Commit changes with appropriate message
  • Build and test on Mini hardware
  • Build and test on Max hardware
  • Document results

References

  • LuckFox forum recommendation: Comment out rkipc in RkLunch.sh
  • Original issue: Camera service management
  • Related file: docs/CAMERA_DEBUG.md
  • Init script pattern: Standard SysVinit

Status

✅ PLANNING COMPLETE
⏳ READY FOR IMPLEMENTATION


Planning completed: 2026-02-19
Document author: AI Agent (Copilot)


Released under the MIT License. The SeedSigner OS section is mirrored from the seedsigner-os repository at the pinned release commit.

This site uses Just the Docs, a documentation theme for Jekyll.