scripts: P4-Nano probe app and C6 esp-hosted OTA tools
p4-probe identifies the P4 and its C6 over esp-hosted SDIO. c6-ota holds the C6 coprocessor build and the two host updaters (3.1 and the 2.x one that moved the factory C6 firmware to esp-hosted 3.1). Also the pending graphify output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
edf35e9c71
commit
ba8e160aee
104 files changed
+8674
-204
No files matched your search
@@ -0,0 +1,66 @@
|
||||
# Test Server Tools
|
||||
|
||||
This directory contains tools for testing HTTPS OTA functionality with self-signed certificates.
|
||||
|
||||
## Files
|
||||
|
||||
- `create_self_signed_certs.sh` - Generates self-signed certificates for testing
|
||||
- `create_https_server.py` - Simple HTTPS server for serving OTA files
|
||||
- `README.md` - This file
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Generate Test Certificates
|
||||
|
||||
```bash
|
||||
cd test_server
|
||||
bash create_self_signed_certs.sh
|
||||
```
|
||||
|
||||
### 2. Start HTTPS Server
|
||||
|
||||
```bash
|
||||
cd test_server
|
||||
python3 create_https_server.py
|
||||
```
|
||||
|
||||
### 3. Configure ESP32
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
eh.py menuconfig
|
||||
```
|
||||
|
||||
Enable in menuconfig:
|
||||
|
||||
- `Component config` → `HTTPS OTA Configuration` → `Use self-signed certificate (Testing Only)` → **YES**
|
||||
- Update `OTA Server URL` to the URL shown by the server
|
||||
|
||||
## Important Notes
|
||||
|
||||
- **Testing Only**: Self-signed certificates should only be used for testing
|
||||
- **Security**: For production, use proper CA-signed certificates
|
||||
- **IP Address**: The certificate is generated for your current IP address
|
||||
- **Regenerate**: If your IP changes, regenerate certificates
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Certificate not found error
|
||||
|
||||
```bash
|
||||
# Make sure you're in test_server directory
|
||||
cd test_server
|
||||
bash create_self_signed_certs.sh
|
||||
```
|
||||
|
||||
### Server won't start
|
||||
|
||||
- Check if port 8443 is available
|
||||
- Ensure certificates exist in `../certs/`
|
||||
|
||||
```
|
||||
ls ../certs/
|
||||
server_cert.pem server_key.pem
|
||||
```
|
||||
|
||||
- Run from `test_server/` directory
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import http.server
|
||||
import ssl
|
||||
import socket
|
||||
import os
|
||||
import sys
|
||||
|
||||
def get_local_ip():
|
||||
"""Get the local IP address of this machine"""
|
||||
try:
|
||||
# Connect to a remote address (doesn't actually send data)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
s.connect(("8.8.8.8", 80))
|
||||
return s.getsockname()[0]
|
||||
except Exception:
|
||||
return "127.0.0.1"
|
||||
|
||||
# Check if certificates exist (relative to component certs)
|
||||
cert_path = '../certs/server_cert.pem'
|
||||
key_path = '../certs/server_key.pem'
|
||||
|
||||
if not os.path.exists(cert_path) or not os.path.exists(key_path):
|
||||
print("ERROR: Certificates not found!")
|
||||
print(f"Please run: bash create_self_signed_certs.sh")
|
||||
print(f"Looking for: {cert_path} and {key_path}")
|
||||
print(f"Note: Run this server from components/ota_https/test_server/ directory")
|
||||
sys.exit(1)
|
||||
|
||||
# Get local IP
|
||||
local_ip = get_local_ip()
|
||||
port = 8443
|
||||
|
||||
# Create HTTPS server
|
||||
class CORSHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def end_headers(self):
|
||||
self.send_header('Access-Control-Allow-Origin', '*')
|
||||
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
|
||||
self.send_header('Access-Control-Allow-Headers', '*')
|
||||
super().end_headers()
|
||||
|
||||
def log_message(self, format, *args):
|
||||
"""Enhanced logging"""
|
||||
print(f"[{self.date_time_string()}] {format % args}")
|
||||
|
||||
server_address = ('0.0.0.0', port)
|
||||
httpd = http.server.HTTPServer(server_address, CORSHTTPRequestHandler)
|
||||
|
||||
# Configure SSL with proper settings for ESP32
|
||||
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||
ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
|
||||
ssl_context.set_ciphers('ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20:!aNULL:!MD5:!DSS')
|
||||
ssl_context.load_cert_chain(cert_path, key_path)
|
||||
|
||||
# Wrap socket with SSL
|
||||
httpd.socket = ssl_context.wrap_socket(httpd.socket, server_side=True)
|
||||
|
||||
print("=" * 60)
|
||||
print("HTTPS OTA Server Started Successfully!")
|
||||
print("=" * 60)
|
||||
print(f"Server running on: https://{local_ip}:{port}")
|
||||
print(f"Serving files from: {os.getcwd()}")
|
||||
print(f"Using certificates:")
|
||||
print(f" Cert: {cert_path}")
|
||||
print(f" Key: {key_path}")
|
||||
print("")
|
||||
print("ESP32 Configuration:")
|
||||
print(f" Set OTA_HTTP_URL to: https://{local_ip}:{port}/firmware.bin")
|
||||
print("")
|
||||
print("To test, place your firmware.bin file in this directory")
|
||||
print("Press Ctrl+C to stop the server")
|
||||
print("=" * 60)
|
||||
|
||||
try:
|
||||
httpd.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\n🛑 Server stopped by user")
|
||||
httpd.server_close()
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create certificates for HTTPS OTA testing
|
||||
# This script should be run from the component's test_server directory
|
||||
|
||||
# Create a directory for certificates in the component's certs folder
|
||||
mkdir -p ../certs
|
||||
cd ../certs
|
||||
|
||||
# Get your machine's IP address
|
||||
IP_ADDRESS=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "192.168.1.100")
|
||||
echo "Creating certificate for IP: $IP_ADDRESS"
|
||||
echo "If this IP is incorrect, please update the CN field manually"
|
||||
|
||||
# Generate private key
|
||||
openssl genrsa -out server_key.pem 2048
|
||||
|
||||
# Generate self-signed certificate (valid for 365 days)
|
||||
# Use your actual IP address as Common Name
|
||||
openssl req -new -x509 -key server_key.pem -out server_cert.pem -days 365 \
|
||||
-subj "/C=US/ST=State/L=City/O=ESP-OTA/CN=$IP_ADDRESS" \
|
||||
-extensions v3_req \
|
||||
-config <(cat <<EOF
|
||||
[req]
|
||||
distinguished_name = req_distinguished_name
|
||||
req_extensions = v3_req
|
||||
prompt = no
|
||||
|
||||
[req_distinguished_name]
|
||||
C = US
|
||||
ST = State
|
||||
L = City
|
||||
O = ESP-OTA
|
||||
CN = $IP_ADDRESS
|
||||
|
||||
[v3_req]
|
||||
basicConstraints = CA:FALSE
|
||||
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
||||
subjectAltName = @alt_names
|
||||
|
||||
[alt_names]
|
||||
IP.1 = $IP_ADDRESS
|
||||
IP.2 = 127.0.0.1
|
||||
DNS.1 = localhost
|
||||
EOF
|
||||
)
|
||||
|
||||
# View certificate details
|
||||
echo "Certificate created with the following details:"
|
||||
openssl x509 -in server_cert.pem -text -noout | grep -A 5 "Subject:"
|
||||
openssl x509 -in server_cert.pem -text -noout | grep -A 10 "Subject Alternative Name"
|
||||
|
||||
echo ""
|
||||
echo "IMPORTANT: Your HTTPS server must run on IP: $IP_ADDRESS"
|
||||
echo "Update your Kconfig OTA_HTTP_URL to: https://$IP_ADDRESS:8443/firmware.bin"
|
||||
Reference in new issue
Block a user