|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Join the bench Wi-Fi over the ESP32-C6 and get an IP by DHCP (#492). More...
#include <stdint.h>#include "c6_join.h"#include "nx_ether_driver_c6.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_net_provision.h"#include "ra8_secure.h"#include "ra8_time.h"#include "tx_api.h"Go to the source code of this file.
Functions | |
| static void | c6_join_panic_halt (void) |
| Halt the processor after an unrecoverable start-up failure. | |
| static void | c6_join_setup_or_halt (void) |
| Initialize platform services required by the join application. | |
| static void | c6_join_on_event (void *ctx, const ra8_c6link_event_t *ev) |
| Record one C6 announcement and update association latches. | |
| static void | c6_join_report_fault (const char *what, ra8_err_t err) |
| Report one failed C6 join stage without revealing credentials. | |
| static ra8_err_t | c6_join_open_link (void) |
| Bind ESP-hosted transport and open the application C6 link. | |
| static bool | c6_join_phase_ready (ra8_c6link_fw_version_t *out) |
| Open the C6 link and establish co-processor readiness. | |
| static bool | c6_join_wait_connected (void) |
| Poll until station association succeeds, fails, or times out. | |
| static bool | c6_join_phase_associate (ra8_c6link_mac_t *mac_out, const ra8_net_credentials_t *credentials) |
| Start Wi-Fi and associate using one runtime credential record. | |
| static bool | c6_join_phase_ip (const ra8_c6link_mac_t *mac) |
| Bring up NetX, print the lease, and judge address acquisition. | |
| static void | c6_join_heartbeat (bool passed) |
| Preserve the terminal verdict as a periodic console heartbeat. | |
| static void | c6_join_worker_entry (ULONG thread_input) |
| Run provisioning, C6 readiness, association, DHCP, and 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_cpuclk_hz |
| Cached CPUCLK0 rate. | |
| static uint32_t | s_pclka_hz |
| Cached PCLKA rate. | |
| static ra8_err_t | s_init_err = k_ra8_err_not_initialized |
| Port-init result from tx_application_define. | |
| static TX_THREAD | s_worker |
| Application worker thread. | |
| static CHAR | s_worker_name [] = "c6_wifi_join" |
| Worker thread name. | |
| static UCHAR | s_worker_stack [k_c6_join_worker_stack] |
| Worker thread stack. | |
| static uint8_t | s_arena [k_c6_join_arena_bytes] |
| Decode arena handed to the facade. | |
| static ra8_c6link_t | s_link |
| The one C6 link handle this app owns. | |
| static volatile uint32_t | s_events |
| Count of co-processor announcements seen. | |
| static volatile uint8_t | s_connected |
| Non-zero once a station-connected event arrived. | |
| static volatile uint8_t | s_disconnected |
| Non-zero once a station-disconnected event arrived. | |
| static volatile uint16_t | s_reason |
| Last 802.11 disconnect reason code. | |
| static const ra8_net_provision_uart_t | s_provision_uart |
| Board-console binding for the shared runtime provisioner. | |
Join the bench Wi-Fi over the ESP32-C6 and get an IP by DHCP (#492).
The first application on this board that takes a network all the way up over the ESP32-C6: it associates the co-processor's Wi-Fi station with a bench access point through ra8_c6link, then runs a NetX Duo DHCP client over the nx_ether_driver_c6 link driver to obtain a lease, and finally pings the gateway to prove the path carries traffic.
Two threads share the C6 link once the IP is up: the NetX IP thread transmits through the driver, and the driver's own RX poll worker pumps the link for received frames. Both are serialised behind the driver's wire mutex, so the application worker does no direct ra8_c6link calls after c6_join_net_up begins – the driver owns the wire from there.
The image contains no network credential. Its worker receives one bounded, versioned provisioning record over the board console after boot and erases that record immediately after the synchronous association request.
Definition in file main.c.
|
static |
Preserve the terminal verdict as a periodic console heartbeat.
Emits the immutable pass or fail line and sleeps for the fixed heartbeat period forever after the network journey completes.
| [in] | passed | Final application verdict. |
Definition at line 400 of file main.c.
References c6_join_puts(), k_c6_join_heartbeat_ms, and tx_thread_sleep.
Referenced by c6_join_worker_entry().
|
static |
Record one C6 announcement and update association latches.
Counts every non-null event and records connected or disconnected station state while preserving the last disconnect reason.
| [in] | ctx | Unused callback context. |
| [in] | ev | Event to record; null is ignored. |
Definition at line 147 of file main.c.
References k_ra8_c6link_event_sta_connected, k_ra8_c6link_event_sta_disconnected, ra8_c6link_event::kind, ra8_c6link_event::reason, s_connected, s_disconnected, s_events, and s_reason.
Referenced by c6_join_open_link().
|
static |
Bind ESP-hosted transport and open the application C6 link.
Builds the fixed-arena link configuration with event and NetX RX callbacks, then delegates transport ownership to ra8_c6link_open.
| k_ra8_ok | The transport was bound and link opened. |
| other | The bind or link-open error propagated unchanged. |
Definition at line 203 of file main.c.
References ra8_c6link_cfg::arena, ra8_c6link_cfg::arena_bytes, c6_join_on_event(), ra8_c6link_cfg::cb_ctx, ra8_c6link_cfg::event_cb, k_ra8_ok, nx_ether_driver_c6_rx(), ra8_c6link_open(), ra8_esp_hosted_c6link_bind(), ra8_c6link_cfg::rx_cb, s_arena, s_link, and ra8_c6link_cfg::transport.
Referenced by c6_join_phase_ready().
|
static |
Halt the processor after an unrecoverable start-up failure.
Executes wait-for-interrupt forever so a failed kernel or platform initialization cannot fall through into partially configured code.
Definition at line 92 of file main.c.
Referenced by c6_join_setup_or_halt(), and main().
|
static |
Start Wi-Fi and associate using one runtime credential record.
Starts station mode, reads the local MAC, builds a transient C6 station request, submits it synchronously, erases that request, and waits for the association event without logging the SSID or PSK.
| [out] | mac_out | Destination for the station MAC. |
| [in] | credentials | Validated runtime SSID and PSK record. |
| true | The station associated within the fixed poll budget. |
| false | Start, MAC, config, join, or association failed. |
Definition at line 307 of file main.c.
References c6_join_put_mac(), c6_join_put_u32(), c6_join_puts(), c6_join_report_fault(), c6_join_wait_connected(), k_ra8_ok, ra8_net_credentials::psk, ra8_c6link_sta_cfg_set(), ra8_c6link_wifi_join(), ra8_c6link_wifi_mac(), ra8_c6link_wifi_start(), ra8_secure_memzero(), s_link, s_reason, and ra8_net_credentials::ssid.
Referenced by c6_join_worker_entry().
|
static |
Bring up NetX, print the lease, and judge address acquisition.
Delegates DHCP binding to c6_join_net_up and emits only address, gateway, server, and reachability status fields.
| [in] | mac | Associated station MAC address. |
| true | A non-zero lease address was bound. |
| false | Network bring-up failed or returned a zero address. |
Definition at line 362 of file main.c.
References c6_join_net_up(), c6_join_put_ip(), c6_join_puts(), c6_join_lease::dhcp_server, c6_join_lease::gateway, c6_join_lease::ip, k_ra8_ok, c6_join_lease::mask, c6_join_lease::ping_ok, ra8_err_to_str(), and s_link.
Referenced by c6_join_worker_entry().
|
static |
Open the C6 link and establish co-processor readiness.
Opens the application link, waits for the bounded ready announcement, and emits only non-secret firmware and chip identity fields.
| [out] | out | Firmware-version destination. |
| true | The link opened and readiness completed. |
| false | Link open or readiness failed. |
Definition at line 233 of file main.c.
References c6_join_open_link(), c6_join_put_hex(), c6_join_put_u32(), c6_join_puts(), c6_join_report_fault(), ra8_c6link_fw_version::chip_id, k_c6_join_hex_byte, k_ra8_c6link_announce_transfers, k_ra8_ok, ra8_c6link_fw_version::major, ra8_c6link_fw_version::minor, ra8_c6link_fw_version::patch, ra8_c6link_await_ready(), ra8_err_to_str(), and s_link.
Referenced by c6_join_worker_entry().
|
static |
Report one failed C6 join stage without revealing credentials.
Snapshots the link fault for diagnostic retention, then prints only the caller-supplied stage name and repository error description.
| [in] | what | NUL-terminated non-secret stage name. |
| [in] | err | Repository error returned by that stage. |
Definition at line 178 of file main.c.
References c6_join_puts(), ra8_c6link_last_fault(), ra8_err_to_str(), and s_link.
Referenced by c6_join_phase_associate(), and c6_join_phase_ready().
|
static |
Initialize platform services required by the join application.
Brings up clocks, records live rates, enables module-stop control, initializes delay timing, and opens the console in dependency order.
Definition at line 111 of file main.c.
References c6_join_panic_halt(), k_c6_join_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_cpuclk_hz, and s_pclka_hz.
Referenced by main().
|
static |
Poll until station association succeeds, fails, or times out.
Pumps one bounded C6 announcement batch per iteration, checks the connection latches, and sleeps between attempts.
| true | A connected event arrived within the fixed budget. |
| false | A disconnected event arrived or the budget expired. |
Definition at line 274 of file main.c.
References k_c6_join_assoc_gap_ms, k_c6_join_assoc_tries, k_ra8_c6link_announce_transfers, ra8_c6link_poll(), s_connected, s_disconnected, s_link, and tx_thread_sleep.
Referenced by c6_join_phase_associate().
|
static |
Run provisioning, C6 readiness, association, DHCP, and heartbeat.
Refuses a failed port, receives one bounded runtime record, uses it only for synchronous association, erases it, completes DHCP, and enters the terminal heartbeat with the aggregate verdict.
| [in] | thread_input | Unused ThreadX entry argument. |
Definition at line 422 of file main.c.
References c6_join_heartbeat(), c6_join_phase_associate(), c6_join_phase_ip(), c6_join_phase_ready(), c6_join_put_u32(), c6_join_puts(), k_c6_join_boot_wait_ms, k_ra8_net_provision_timeout_ms, k_ra8_ok, ra8_delay_ms(), ra8_err_to_str(), ra8_net_provision_clear(), ra8_net_provision_receive(), s_events, s_init_err, and s_provision_uart.
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 518 of file main.c.
References c6_join_panic_halt(), c6_join_print_banner(), c6_join_puts(), c6_join_setup_or_halt(), ra8_isr_globals_enable(), s_cpuclk_hz, and s_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 from the ThreadX port; unused, every object here is static. |
Definition at line 482 of file main.c.
References c6_join_puts(), c6_join_worker_entry(), k_c6_join_edge_poll_ms, k_c6_join_sck_hz, k_c6_join_worker_prio, k_ra8_board_pmod1_sci_channel, ra8_esp_hosted_port_init(), s_init_err, s_pclka_hz, s_worker, s_worker_name, s_worker_stack, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
|
static |
|
static |
|
static |
|
static |
|
static |
Port-init result from tx_application_define.
Definition at line 54 of file main.c.
Referenced by c6_join_worker_entry(), tx_application_define(), and wifi_hal_worker_entry().
|
static |
|
static |
Board-console binding for the shared runtime provisioner.
|
static |
Last 802.11 disconnect reason code.
Definition at line 72 of file main.c.
Referenced by c6_join_on_event(), and c6_join_phase_associate().
|
static |
|
static |
|
static |