|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Complete an esp-hosted RPC round-trip against the ESP32-C6. More...
#include <stdint.h>#include "c6_fwver.h"#include "esp_hosted_interface.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_esp_hosted_port.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_time.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | c6_fwver_pump_budget_t : uint16_t { k_c6_fwver_caps_transfers = 8U } |
| Per-phase transaction budgets, so each phase bounds its own wait. More... | |
Functions | |
| static void | c6_fwver_panic_halt (void) |
| Park the CPU forever after an unrecoverable bring-up failure. | |
| static void | c6_fwver_setup_or_halt (void) |
| Bring clocks, module-stop state, SysTick and the console up. | |
| static void | c6_fwver_phase_caps (void) |
| Send the host-capabilities event and drain the co-processor's. | |
| static void | c6_fwver_phase_request (void) |
| Send the firmware-version request and pump until it is answered. | |
| static void | c6_fwver_heartbeat (bool passed) |
| Print a liveness line forever, never returning. | |
| static void | c6_fwver_worker_entry (ULONG thread_input) |
| Worker thread: report the init, 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_fwver_cpuclk_hz |
| Cached CPUCLK0 rate, used to programme SysTick. | |
| static uint32_t | s_c6_fwver_pclka_hz |
| Cached PCLKA rate, the SCI baud-clock source the port divides. | |
| static ra8_err_t | s_c6_fwver_init_err = k_ra8_err_not_initialized |
| Exact result of ra8_esp_hosted_port_init. | |
| static TX_THREAD | s_c6_fwver_worker |
| Control block of the single application thread. | |
| static CHAR | s_c6_fwver_worker_name [] = "c6_fw_version" |
| Thread name handed to ThreadX. | |
| static UCHAR | s_c6_fwver_worker_stack [k_c6_fwver_worker_stack] |
| Stack backing s_c6_fwver_worker. | |
| static uint8_t | s_c6_fwver_txbuf [k_c6_fwver_tx_max] |
| Staging buffer for the one payload each phase transmits. | |
Complete an esp-hosted RPC round-trip against the ESP32-C6.
The second application built on port/esp-hosted/, and the one that proves the protocol rather than the wire. c6_spi_probe established the physical link and c6_hosted_init established that the port can clock a framed transaction; both stop at "bytes moved, and their shape is sane". This one sends a request the co-processor must parse and answer, then checks the answer's contents:
Definition in file main.c.
| enum c6_fwver_pump_budget_t : uint16_t |
Per-phase transaction budgets, so each phase bounds its own wait.
The capabilities exchange only has to drain whatever the co-processor already queued, so it is short. The request phase has to survive the co-processor scheduling a reply, so it gets the full budget.
| Enumerator | |
|---|---|
| k_c6_fwver_caps_transfers | Transactions the capabilities phase clocks. |
|
static |
Print a liveness line forever, never returning.
| [in] | passed | Verdict the run reached, echoed on every beat. |
Definition at line 311 of file main.c.
References c6_fwver_put_u32(), c6_fwver_puts(), k_c6_fwver_heartbeat_ms, and tx_thread_sleep.
Referenced by c6_fwver_worker_entry().
|
static |
Park the CPU forever after an unrecoverable bring-up failure.
Definition at line 173 of file main.c.
Referenced by c6_fwver_setup_or_halt(), and main().
|
static |
Send the host-capabilities event and drain the co-processor's.
Definition at line 228 of file main.c.
References c6_fwver_dispatch(), c6_fwver_link_pump(), c6_fwver_print_pump(), c6_fwver_priv_host_caps(), c6_fwver_put_u32(), c6_fwver_puts(), k_c6_fwver_caps_transfers, k_c6_fwver_tx_max, k_ra8_ok, ra8_err_to_str(), and s_c6_fwver_txbuf.
Referenced by c6_fwver_worker_entry().
|
static |
Send the firmware-version request and pump until it is answered.
Definition at line 270 of file main.c.
References c6_fwver_dispatch(), c6_fwver_link_pump(), c6_fwver_print_pump(), c6_fwver_put_u32(), c6_fwver_puts(), c6_fwver_rpc_request(), k_c6_fwver_max_transfers, k_c6_fwver_tx_max, k_ra8_ok, ra8_err_to_str(), and s_c6_fwver_txbuf.
Referenced by c6_fwver_worker_entry().
|
static |
Bring clocks, module-stop state, SysTick and the console up.
Definition at line 193 of file main.c.
References c6_fwver_panic_halt(), k_c6_fwver_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_fwver_cpuclk_hz, and s_c6_fwver_pclka_hz.
Referenced by main().
|
static |
Worker thread: report the init, run both phases, judge, heartbeat.
| [in] | thread_input | ThreadX entry argument; unused. |
Definition at line 338 of file main.c.
References c6_fwver_heartbeat(), c6_fwver_phase_caps(), c6_fwver_phase_request(), c6_fwver_puts(), c6_fwver_rpc_report(), k_c6_fwver_boot_wait_ms, k_ra8_ok, ra8_delay_ms(), ra8_err_to_str(), ra8_esp_hosted_mem_dump(), and s_c6_fwver_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 410 of file main.c.
References c6_fwver_panic_halt(), c6_fwver_print_banner(), c6_fwver_puts(), c6_fwver_setup_or_halt(), ra8_isr_globals_enable(), s_c6_fwver_cpuclk_hz, and s_c6_fwver_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 374 of file main.c.
References c6_fwver_puts(), c6_fwver_worker_entry(), k_c6_fwver_edge_poll_ms, k_c6_fwver_sck_hz, k_c6_fwver_worker_prio, k_ra8_board_pmod1_sci_channel, ra8_esp_hosted_port_init(), s_c6_fwver_init_err, s_c6_fwver_pclka_hz, s_c6_fwver_worker, s_c6_fwver_worker_name, s_c6_fwver_worker_stack, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
|
static |
Cached CPUCLK0 rate, used to programme SysTick.
Read once during bring-up, before ThreadX starts.
Definition at line 91 of file main.c.
Referenced by c6_fwver_setup_or_halt(), and main().
|
static |
Exact result of ra8_esp_hosted_port_init.
Recorded in tx_application_define and reported verbatim by the worker, which is the first context that can print after the init.
Definition at line 115 of file main.c.
Referenced by c6_fwver_worker_entry(), and tx_application_define().
|
static |
Cached PCLKA rate, the SCI baud-clock source the port divides.
Handed to the port as ra8_esp_hosted_port_cfg_t::pclk_hz; a stale value silently mis-programs the SPI bit rate, so it is read from the CGC rather than assumed.
Definition at line 103 of file main.c.
Referenced by c6_fwver_setup_or_halt(), main(), and tx_application_define().
|
static |
Staging buffer for the one payload each phase transmits.
Sized by k_c6_fwver_tx_max, which is two orders of magnitude above the packed request; static because this image has no heap.
Definition at line 161 of file main.c.
Referenced by c6_fwver_phase_caps(), and c6_fwver_phase_request().
|
static |
Control block of the single application thread.
ThreadX requires statically allocated control blocks, as does NASA Power of 10 Rule 3.
Definition at line 126 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 138 of file main.c.
Referenced by tx_application_define().
|
static |
Stack backing s_c6_fwver_worker.
Sized by k_c6_fwver_worker_stack. The deepest call the worker makes is the generated protobuf decoder, which walks nested messages.
Definition at line 149 of file main.c.
Referenced by tx_application_define().