52#include "esp_hosted_host_fw_ver.h"
53#include "esp_hosted_transport.h"
65#include "transport_drv.h"
83typedef enum : uint32_t {
160 __asm__
volatile(
"wfi");
275 if (fw_in ==
nullptr) {
299 const bool matched = (fw.
major == (uint32_t)ESP_HOSTED_VERSION_MAJOR_1) &&
300 (fw.
minor == (uint32_t)ESP_HOSTED_VERSION_MINOR_1) &&
301 (fw.
patch == (uint32_t)ESP_HOSTED_VERSION_PATCH_1) &&
304 c6_wifi_puts(
"c6_wifi: coprocessor identity is not the one this host was built against\r\n");
332 c6_wifi_puts(
"c6_wifi: station started (WifiInit + SetWifiMode + WifiStart accepted)\r\n");
354 c6_wifi_puts(
"c6_wifi: station stopped (WifiStop + WifiDeinit accepted)\r\n");
404 c6_wifi_puts(passed ?
" verdict=PASS\r\n" :
" verdict=FAIL\r\n");
433 if (out ==
nullptr) {
434 c6_wifi_puts(
"c6_wifi: FAIL no identity record to fill\r\n");
443 c6_wifi_puts(
"c6_wifi: FAIL could not open the link\r\n");
454 c6_wifi_puts(
"c6_wifi: FAIL the coprocessor did not answer the readiness probe\r\n");
482 c6_wifi_puts(
"c6_wifi: FAIL port init failed -- no transaction attempted\r\n");
502 c6_wifi_puts(
"c6_wifi: PASS ra8_c6link drove the coprocessor station up and read its "
505 c6_wifi_puts(
"c6_wifi: FAIL station bring-up through ra8_c6link did not complete\r\n");
527 (void)first_unused_memory;
547 c6_wifi_puts(
"c6_wifi: worker thread creation failed\r\n");
567 c6_wifi_puts(
"c6_wifi: entering ThreadX; port init runs from tx_application_define\r\n");
void main(void)
Secure fallback main entry point.
Shared contract for the ra8_c6link facade bring-up application.
void c6_wifi_put_u32(uint32_t value)
Emit an unsigned 32-bit value in decimal.
void c6_wifi_print_stats(const char *label, const ra8_c6link_stats_t *stats)
Print what one facade poll did, as one console line.
@ k_c6_wifi_hex_byte
Hex digits printed for a byte-wide field.
void c6_wifi_put_i32(int32_t value)
Emit a signed 32-bit value in decimal.
void c6_wifi_put_hex(uint32_t value, uint8_t digits)
Emit a value as a fixed-width lower-case hexadecimal field.
void c6_wifi_puts(const char *text)
Write a NUL-terminated string to the board console.
void c6_wifi_put_text(const char *text, size_t len)
Emit a NUL-terminated co-processor string as printable text.
void c6_wifi_put_mac(const ra8_c6link_mac_t *mac)
Emit an IEEE 802 address as six colon-separated hexadecimal octets.
@ k_c6_wifi_sck_hz
SPI bit rate; the rate the RPC round-trip ran at on silicon.
@ k_c6_wifi_uart_baud
Console rate, 8N1, over the J-Link OB VCOM.
@ k_c6_wifi_boot_wait_ms
Settling delay before the first transaction.
@ k_c6_wifi_arena_bytes
Decode arena handed to the facade.
@ k_c6_wifi_worker_prio
Worker priority and preemption threshold.
@ k_c6_wifi_heartbeat_ms
Heartbeat gap after the verdict, in milliseconds and therefore in ThreadX ticks.
@ k_c6_wifi_edge_poll_ms
Poll period for a side-band pin with no ICU channel.
@ k_c6_wifi_worker_stack
Worker-thread stack, in bytes.
void c6_wifi_print_banner(uint32_t cpuclk_hz, uint32_t pclka_hz)
Print the banner: identity, clocks and link parameters.
void tx_application_define(void *first_unused_memory)
ThreadX system-define hook: build worker thread + byte pool.
static void c6_wifi_on_event(void *ctx, const ra8_c6link_event_t *ev)
Narrate one announcement the co-processor volunteered.
static ra8_c6link_t s_c6_wifi_link
The one link this application drives.
c6_wifi_expect_t
What a passing run must observe from the co-processor.
@ k_c6_wifi_expect_chip
Firmware chip id the answering co-processor must report.
@ k_c6_wifi_drain_polls
Transactions clocked after the station starts, so the Wi-Fi events the co-processor raises on its own...
static CHAR s_c6_wifi_worker_name[]
Thread name handed to ThreadX.
static TX_THREAD s_c6_wifi_worker
Control block of the single application thread.
static ra8_err_t c6_wifi_open_link(void)
Open the link over the port's transport seam.
static uint32_t s_c6_wifi_events
Count of announcements the co-processor volunteered.
static void c6_wifi_setup_or_halt(void)
Bring clocks, module-stop state, SysTick and the console up.
static ra8_err_t s_c6_wifi_init_err
Exact result of ra8_esp_hosted_port_init.
static void c6_wifi_worker_entry(ULONG thread_input)
Worker thread: open the link, run both phases, judge, heartbeat.
static bool c6_wifi_phase_station(void)
Start the station, read its address, then stop it again.
static UCHAR s_c6_wifi_worker_stack[k_c6_wifi_worker_stack]
Stack backing s_c6_wifi_worker.
static uint32_t s_c6_wifi_cpuclk_hz
Cached CPUCLK0 rate, used to programme SysTick.
static void c6_wifi_panic_halt(void)
Park the CPU forever after an unrecoverable bring-up failure.
static void c6_wifi_report_fault(const char *what, ra8_err_t err)
Print the co-processor's own error code for the last failed request.
static bool c6_wifi_phase_identity(const ra8_c6link_fw_version_t *fw_in)
Check the identity the readiness probe already brought back.
static uint8_t s_c6_wifi_arena[k_c6_wifi_arena_bytes]
Decode arena the facade hands to the generated protobuf codec.
static void c6_wifi_heartbeat(bool passed)
Print a liveness line forever, never returning.
static bool c6_wifi_phase_ready(ra8_c6link_fw_version_t *out)
Open the link and prove the co-processor is answering.
static uint32_t s_c6_wifi_pclka_hz
Cached PCLKA rate, the SCI baud-clock source the port divides.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
@ k_ra8_board_pmod1_sci_channel
Pmod1 (J26) Simple-SPI is SCI2.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
The single integration boundary between this firmware and the ESP32-C6.
struct ra8_c6link_fault ra8_c6link_fault_t
@ k_ra8_c6link_announce_transfers
Transactions ra8_c6link_await_ready spends on the announcement before it probes.
struct ra8_c6link_mac ra8_c6link_mac_t
ra8_err_t ra8_c6link_last_fault(const ra8_c6link_t *link, ra8_c6link_fault_t *out)
Report the last request that failed on this link.
ra8_err_t ra8_c6link_open(ra8_c6link_t *link, const ra8_c6link_cfg_t *cfg)
Bind a transport to a link handle and make it usable.
ra8_err_t ra8_c6link_await_ready(ra8_c6link_t *link, uint16_t max_transactions, ra8_c6link_fw_version_t *out)
Announce this host and prove the co-processor is answering.
struct ra8_c6link_cfg ra8_c6link_cfg_t
ra8_err_t ra8_c6link_poll(ra8_c6link_t *link, uint16_t max_transactions, ra8_c6link_stats_t *stats)
Clock transactions, delivering whatever the co-processor sends.
struct ra8_c6link_stats ra8_c6link_stats_t
struct ra8_c6link_event ra8_c6link_event_t
struct ra8_c6link_fw_version ra8_c6link_fw_version_t
struct ra8_c6link ra8_c6link_t
Wi-Fi station bring-up and association over the C6 link.
ra8_err_t ra8_c6link_wifi_mac(ra8_c6link_t *link, ra8_c6link_mac_t *out)
Read the station interface's MAC address.
ra8_err_t ra8_c6link_wifi_stop(ra8_c6link_t *link)
Stop the radio and release the co-processor's Wi-Fi resources.
ra8_err_t ra8_c6link_wifi_start(ra8_c6link_t *link)
Start the co-processor's Wi-Fi radio in station mode.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
@ k_ra8_clock_id_pclka
PCLKA.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
const char * ra8_err_to_str(ra8_err_t err)
Human-readable string for an error code.
Binds the ra8_c6link transport seam to this port's OS vtable.
ra8_err_t ra8_esp_hosted_c6link_bind(ra8_c6link_transport_t *out)
Fill a ra8_c6link transport seam with this port's implementations.
Public entry point of the RA8D2 + ThreadX port of esp-hosted.
struct ra8_esp_hosted_port_cfg ra8_esp_hosted_port_cfg_t
ra8_err_t ra8_esp_hosted_port_init(const ra8_esp_hosted_port_cfg_t *cfg)
Bring the esp-hosted port up and publish the OS-abstraction vtable.
void ra8_esp_hosted_mem_dump(const char *label)
Report transport pool occupancy at a named point.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
char CHAR
ThreadX-compatible CHAR (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque thread stand-in for the host build.
ra8_c6link_transport_t transport
The hardware seam; every row required.
uint32_t arena_bytes
Bytes available at arena.
uint8_t * arena
Protobuf decode arena.
void * cb_ctx
Context handed to both callbacks.
ra8_c6link_event_cb_t event_cb
Announcement sink, or null to count.
uint16_t reason
802.11 reason code, sta_disconnected.
ra8_c6link_event_kind_t kind
Which announcement this is.
char ssid[k_ra8_c6link_ssid_max+1U]
AP SSID, NUL-terminated.
int32_t wifi_event_id
Raw id, wifi.
uint8_t ssid_len
Octets of ssid the C6 supplied.
uint32_t rpc_id
RPC_ID__Req_* of the request that failed, or zero.
int32_t resp
The co-processor's result code, or zero if none.
uint32_t major
Firmware major version.
char target[16]
CONFIG_IDF_TARGET, NUL-terminated.
uint32_t patch
Firmware patch version.
uint32_t chip_id
Co-processor chip identifier.
uint32_t minor
Firmware minor version.
uint8_t target_len
Characters in target, excluding the NUL.