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:
jimmyandClaude Opus 5.5 committed 2026-11-24 13:52:12 +13:00
1 parent edf35e9c71
commit ba8e160aee
104 files changed
+8674 -204

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
idf_component_register(SRCS "main.c" INCLUDE_DIRS "."
PRIV_REQUIRES esp_wifi nvs_flash esp_netif esp_event)
+3
View File
@@ -0,0 +1,3 @@
dependencies:
espressif/esp_wifi_remote: "*"
espressif/esp_hosted: "*"
+113
View File
@@ -0,0 +1,113 @@
// Waveshare ESP32-P4-Nano probe: brings up the ESP32-C6 co-processor over SDIO (esp-hosted),
// prints what the C6 runs, then does a Wi-Fi scan through it. Console is UART0 (the CH343 USB-C port).
#include <stdio.h>
#include <string.h>
#include "esp_log.h"
#include "esp_chip_info.h"
#include "esp_mac.h"
#include "esp_event.h"
#include "esp_netif.h"
#include "esp_wifi.h"
#include "nvs_flash.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_hosted.h"
static const char *TAG = "p4-probe";
static char summary[512];
static void print_p4(void)
{
esp_chip_info_t ci;
esp_chip_info(&ci);
uint8_t mac[6];
esp_read_mac(mac, ESP_MAC_BASE);
ESP_LOGI(TAG, "P4: rev v%d.%d, %d cores, base MAC " MACSTR, ci.revision / 100, ci.revision % 100,
ci.cores, MAC2STR(mac));
}
static bool probe_c6(void)
{
int rc = esp_hosted_connect_to_slave();
if (rc != 0) {
ESP_LOGE(TAG, "C6: esp_hosted_connect_to_slave failed (%d)", rc);
snprintf(summary, sizeof summary, "C6: NOT CONNECTED (rc=%d)", rc);
return false;
}
uint32_t chip_id = 0;
char target[24] = "?";
esp_hosted_get_cp_info(&chip_id, target, sizeof target);
esp_hosted_coprocessor_fwver_t v = {0};
int vr = esp_hosted_get_coprocessor_fwversion(&v);
esp_hosted_app_desc_t d = {0};
esp_err_t dr = esp_hosted_get_coprocessor_app_desc(&d);
ESP_LOGI(TAG, "C6: connected over SDIO, target %s (chip id %lu)", target, (unsigned long)chip_id);
if (vr == 0)
ESP_LOGI(TAG, "C6: esp-hosted slave firmware %lu.%lu.%lu", (unsigned long)v.major1,
(unsigned long)v.minor1, (unsigned long)v.patch1);
else
ESP_LOGW(TAG, "C6: firmware version query failed (%d)", vr);
if (dr == ESP_OK)
ESP_LOGI(TAG, "C6: app '%.32s' version '%.32s' built %.16s %.16s with IDF %.32s", d.project_name,
d.version, d.date, d.time, d.idf_ver);
else
ESP_LOGW(TAG, "C6: app description not available (%s)", esp_err_to_name(dr));
snprintf(summary, sizeof summary, "C6: OK target=%s fw=%lu.%lu.%lu idf=%.32s", target,
(unsigned long)v.major1, (unsigned long)v.minor1, (unsigned long)v.patch1,
dr == ESP_OK ? d.idf_ver : "?");
return true;
}
static void scan(void)
{
esp_netif_create_default_wifi_sta();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
uint8_t mac[6] = {0};
if (esp_wifi_get_mac(WIFI_IF_STA, mac) == ESP_OK)
ESP_LOGI(TAG, "C6: Wi-Fi STA MAC " MACSTR, MAC2STR(mac));
if (esp_wifi_scan_start(NULL, true) != ESP_OK) {
ESP_LOGE(TAG, "Wi-Fi scan failed");
return;
}
uint16_t n = 0;
esp_wifi_scan_get_ap_num(&n);
static wifi_ap_record_t aps[20];
uint16_t max = sizeof aps / sizeof aps[0];
esp_wifi_scan_get_ap_records(&max, aps);
ESP_LOGI(TAG, "Wi-Fi scan through C6: %u networks", n);
for (int i = 0; i < max; i++)
ESP_LOGI(TAG, " ch %2d %4d dBm %s", aps[i].primary, aps[i].rssi, (char *)aps[i].ssid);
size_t len = strlen(summary);
snprintf(summary + len, sizeof summary - len, " scan=%u networks", n);
}
void app_main(void)
{
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
nvs_flash_erase();
nvs_flash_init();
}
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
print_p4();
if (probe_c6())
scan();
for (;;) { // repeat the result so a late serial read still sees it
ESP_LOGI(TAG, "SUMMARY %s", summary);
vTaskDelay(pdMS_TO_TICKS(5000));
}
}