|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Bring the ESP32-C6's Wi-Fi station up through the ra8_c6link facade. More...
#include <stdint.h>#include "c6_wifi.h"#include "esp_hosted_host_fw_ver.h"#include "esp_hosted_transport.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_c6link.h"#include "ra8_c6link_wifi.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_esp_hosted_c6link.h"#include "ra8_esp_hosted_port.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_time.h"#include "transport_drv.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | c6_wifi_expect_t : uint32_t { k_c6_wifi_expect_chip = (uint32_t)ESP_PRIV_FIRMWARE_CHIP_ESP32C6 , k_c6_wifi_drain_polls = 8U } |
| What a passing run must observe from the co-processor. More... | |
Functions | |
| static void | c6_wifi_panic_halt (void) |
| Park the CPU forever after an unrecoverable bring-up failure. | |
| static void | c6_wifi_setup_or_halt (void) |
| Bring clocks, module-stop state, SysTick and the console up. | |
| static void | c6_wifi_on_event (void *ctx, const ra8_c6link_event_t *ev) |
| Narrate one announcement the co-processor volunteered. | |
| 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 bool | c6_wifi_phase_station (void) |
| Start the station, read its address, then stop it again. | |
| static ra8_err_t | c6_wifi_open_link (void) |
| Open the link over the port's transport seam. | |
| 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 void | c6_wifi_worker_entry (ULONG thread_input) |
| Worker thread: open the link, run both phases, judge, heartbeat. | |
| void | tx_application_define (void *first_unused_memory) |
| ThreadX define hook: bring the port up and start the worker. | |
| void | main (void) |
| Application entry: clocks, console, banner, then ThreadX. | |
Variables | |
| static uint32_t | s_c6_wifi_cpuclk_hz |
| Cached CPUCLK0 rate, used to programme SysTick. | |
| static uint32_t | s_c6_wifi_pclka_hz |
| Cached PCLKA rate, the SCI baud-clock source the port divides. | |
| static ra8_err_t | s_c6_wifi_init_err = k_ra8_err_not_initialized |
| Exact result of ra8_esp_hosted_port_init. | |
| static TX_THREAD | s_c6_wifi_worker |
| Control block of the single application thread. | |
| static CHAR | s_c6_wifi_worker_name [] = "c6_wifi_link" |
| Thread name handed to ThreadX. | |
| static UCHAR | s_c6_wifi_worker_stack [k_c6_wifi_worker_stack] |
| Stack backing s_c6_wifi_worker. | |
| static uint8_t | s_c6_wifi_arena [k_c6_wifi_arena_bytes] |
| Decode arena the facade hands to the generated protobuf codec. | |
| static ra8_c6link_t | s_c6_wifi_link |
| The one link this application drives. | |
| static uint32_t | s_c6_wifi_events |
| Count of announcements the co-processor volunteered. | |
Bring the ESP32-C6's Wi-Fi station up through the ra8_c6link facade.
The third application on port/esp-hosted/, and the first that uses libs/ra8_c6link rather than hand-building the protocol. c6_spi_probe established the physical link, c6_hosted_init established the framed transaction and c6_fw_version established one RPC round-trip. This one establishes the facade – and, with it, the only part of the control plane a host test cannot settle:
No network is joined here. Association needs an AP in range and belongs to #492; this stops at "the radio is up and has an address", which is exactly the state an IP driver starts from.
Definition in file main.c.
| enum c6_wifi_expect_t : uint32_t |
What a passing run must observe from the co-processor.
The chip id is upstream's own enumerator, so a board carrying some other Espressif part fails here by name rather than by silence.
|
static |
Print a liveness line forever, never returning.
| [in] | passed | Verdict the run reached, echoed on every beat. |
Definition at line 398 of file main.c.
References c6_wifi_put_u32(), c6_wifi_puts(), k_c6_wifi_heartbeat_ms, and tx_thread_sleep.
Referenced by c6_wifi_worker_entry().
|
static |
Narrate one announcement the co-processor volunteered.
| [in] | ctx | Unused; this application has one link. |
| [in] | ev | The decoded announcement; never null. |
ev is valid only for the duration of this call. Definition at line 211 of file main.c.
References c6_wifi_put_i32(), c6_wifi_put_text(), c6_wifi_put_u32(), c6_wifi_puts(), ra8_c6link_event::kind, ra8_c6link_event::reason, s_c6_wifi_events, ra8_c6link_event::ssid, ra8_c6link_event::ssid_len, and ra8_c6link_event::wifi_event_id.
Referenced by c6_wifi_open_link().
|
static |
Open the link over the port's transport seam.
| k_ra8_ok | The link is open and ready to pump. |
| k_ra8_err_not_initialized | The port did not come up. |
| k_ra8_err_null_ptr | The seam came back incomplete. |
| k_ra8_err_invalid_size | The arena is smaller than the facade accepts. |
Definition at line 372 of file main.c.
References ra8_c6link_cfg::arena, ra8_c6link_cfg::arena_bytes, c6_wifi_on_event(), ra8_c6link_cfg::cb_ctx, ra8_c6link_cfg::event_cb, k_ra8_ok, ra8_c6link_open(), ra8_esp_hosted_c6link_bind(), s_c6_wifi_arena, s_c6_wifi_link, and ra8_c6link_cfg::transport.
Referenced by c6_wifi_phase_ready().
|
static |
Park the CPU forever after an unrecoverable bring-up failure.
Definition at line 157 of file main.c.
Referenced by c6_wifi_setup_or_halt(), and main().
|
static |
Check the identity the readiness probe already brought back.
| [in] | fw_in | Identity ra8_c6link_await_ready answered with; must be non-null. Copied to a local before use so the printing below reads the same whether the caller's record moves or not. |
| true | The host/co-processor version lock holds. |
| false | A field did not match what this host was built against. |
fw was populated by a real answer. Definition at line 273 of file main.c.
References c6_wifi_put_hex(), c6_wifi_put_text(), c6_wifi_put_u32(), c6_wifi_puts(), ra8_c6link_fw_version::chip_id, k_c6_wifi_expect_chip, k_c6_wifi_hex_byte, ra8_c6link_fw_version::major, ra8_c6link_fw_version::minor, ra8_c6link_fw_version::patch, ra8_c6link_fw_version::target, and ra8_c6link_fw_version::target_len.
Referenced by c6_wifi_worker_entry().
|
static |
Open the link and prove the co-processor is answering.
Opening the handle only binds a transport; it clocks nothing and therefore says nothing about the far side. This phase follows it with ra8_c6link_await_ready, which announces this host and then asks the co-processor who it is. Deliberately not a wait for the boot event: that fires once when the CO-PROCESSOR boots, and the C6 has its own supply, so it does not reboot when this board is reset.
| [out] | out | Receives the identity the readiness probe answered with; must be non-null. |
| true | out holds a real answer; every later phase may proceed. |
| false | The link would not open, or nothing answered. Fatal: nothing below this can work if the far side is silent. |
Definition at line 431 of file main.c.
References c6_wifi_open_link(), c6_wifi_puts(), c6_wifi_report_fault(), k_ra8_c6link_announce_transfers, k_ra8_ok, ra8_c6link_await_ready(), ra8_err_to_str(), and s_c6_wifi_link.
Referenced by c6_wifi_worker_entry().
|
static |
Start the station, read its address, then stop it again.
| true | The co-processor accepted the whole start sequence. |
| false | A step was refused; the co-processor's own code is on the console. |
Definition at line 325 of file main.c.
References c6_wifi_print_stats(), c6_wifi_put_mac(), c6_wifi_puts(), c6_wifi_report_fault(), k_c6_wifi_drain_polls, k_ra8_ok, ra8_c6link_poll(), ra8_c6link_wifi_mac(), ra8_c6link_wifi_start(), ra8_c6link_wifi_stop(), and s_c6_wifi_link.
Referenced by c6_wifi_worker_entry().
|
static |
Print the co-processor's own error code for the last failed request.
| [in] | what | Short name of the step that failed; must be non-null. |
| [in] | err | What the facade returned. |
Definition at line 240 of file main.c.
References c6_wifi_put_i32(), c6_wifi_put_u32(), c6_wifi_puts(), ra8_c6link_last_fault(), ra8_err_to_str(), ra8_c6link_fault::resp, ra8_c6link_fault::rpc_id, and s_c6_wifi_link.
Referenced by c6_wifi_phase_ready(), and c6_wifi_phase_station().
|
static |
Bring clocks, module-stop state, SysTick and the console up.
Definition at line 176 of file main.c.
References c6_wifi_panic_halt(), k_c6_wifi_uart_baud, k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), s_c6_wifi_cpuclk_hz, and s_c6_wifi_pclka_hz.
Referenced by main().
|
static |
Worker thread: open the link, run both phases, judge, heartbeat.
| [in] | thread_input | ThreadX entry argument; unused. |
Definition at line 474 of file main.c.
References c6_wifi_heartbeat(), c6_wifi_phase_identity(), c6_wifi_phase_ready(), c6_wifi_phase_station(), c6_wifi_put_u32(), c6_wifi_puts(), k_c6_wifi_boot_wait_ms, k_ra8_ok, ra8_delay_ms(), ra8_err_to_str(), ra8_esp_hosted_mem_dump(), s_c6_wifi_events, and s_c6_wifi_init_err.
Referenced by tx_application_define().
| void main | ( | void | ) |
Application entry: clocks, console, banner, then ThreadX.
The application entry point Reset_Handler hands control to.
Definition at line 561 of file main.c.
References c6_wifi_panic_halt(), c6_wifi_print_banner(), c6_wifi_puts(), c6_wifi_setup_or_halt(), ra8_isr_globals_enable(), s_c6_wifi_cpuclk_hz, and s_c6_wifi_pclka_hz.
| void tx_application_define | ( | void * | first_unused_memory | ) |
ThreadX define hook: bring the port up and start the worker.
| [in] | first_unused_memory | Free RAM handed over by the ThreadX port; unused, every object here is static. |
Definition at line 525 of file main.c.
References c6_wifi_puts(), c6_wifi_worker_entry(), k_c6_wifi_edge_poll_ms, k_c6_wifi_sck_hz, k_c6_wifi_worker_prio, k_ra8_board_pmod1_sci_channel, ra8_esp_hosted_port_init(), s_c6_wifi_init_err, s_c6_wifi_pclka_hz, s_c6_wifi_worker, s_c6_wifi_worker_name, s_c6_wifi_worker_stack, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
|
static |
Decode arena the facade hands to the generated protobuf codec.
Static because this image has no heap; the facade bump-allocates from it and empties it after every message, which is what keeps the whole control plane inside NASA Power of 10 Rule 3.
Definition at line 130 of file main.c.
Referenced by c6_wifi_open_link().
|
static |
Cached CPUCLK0 rate, used to programme SysTick.
Definition at line 93 of file main.c.
Referenced by c6_wifi_setup_or_halt(), and main().
|
static |
Count of announcements the co-processor volunteered.
Printed with the verdict. A station that starts and says nothing is a different situation from one that starts and raises WIFI_EVENT_STA_START, and the difference matters to whoever debugs #492.
Definition at line 145 of file main.c.
Referenced by c6_wifi_on_event(), and c6_wifi_worker_entry().
|
static |
Exact result of ra8_esp_hosted_port_init.
Definition at line 99 of file main.c.
Referenced by c6_wifi_worker_entry(), and tx_application_define().
|
static |
The one link this application drives.
Definition at line 133 of file main.c.
Referenced by c6_wifi_open_link(), c6_wifi_phase_ready(), c6_wifi_phase_station(), and c6_wifi_report_fault().
|
static |
Cached PCLKA rate, the SCI baud-clock source the port divides.
Definition at line 96 of file main.c.
Referenced by c6_wifi_setup_or_halt(), main(), and tx_application_define().
|
static |
Control block of the single application thread.
Definition at line 102 of file main.c.
Referenced by tx_application_define().
|
static |
Thread name handed to ThreadX.
A mutable array rather than a string literal: ThreadX takes a non-const CHAR*, and casting the qualifier away would trip the project's -Wcast-qual.
Definition at line 114 of file main.c.
Referenced by tx_application_define().
|
static |
Stack backing s_c6_wifi_worker.
Definition at line 117 of file main.c.
Referenced by tx_application_define().