|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Public entry point of the RA8D2 + ThreadX port of esp-hosted. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_esp_hosted_port_cfg |
| Everything the port needs that is not fixed by the board. More... | |
Typedefs | |
| typedef struct ra8_esp_hosted_port_cfg | ra8_esp_hosted_port_cfg_t |
| typedef void(* | ra8_esp_hosted_event_cb_t) (void *ctx, const char *base, int32_t event_id, const void *data, size_t data_len) |
| Application handler for an event the vendored core posts. | |
Enumerations | |
| enum | ra8_esp_hosted_limits_t : uint32_t { k_ra8_esp_hosted_max_queues = 8U , k_ra8_esp_hosted_max_semaphores = 8U , k_ra8_esp_hosted_max_mutexes = 4U , k_ra8_esp_hosted_max_threads = 4U , k_ra8_esp_hosted_max_timers = 4U , k_ra8_esp_hosted_queue_pool_bytes = 8192U , k_ra8_esp_hosted_pool_bytes = 65536U } |
| Fixed budgets the port allocates out of static storage. More... | |
Functions | |
| ra8_err_t | ra8_esp_hosted_port_set_event_cb (ra8_esp_hosted_event_cb_t cb, void *ctx) |
| Register the handler the port calls when the core posts an event. | |
| 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. | |
| ra8_err_t | ra8_esp_hosted_port_deinit (void) |
| Tear the port down, releasing every pin, interrupt and pool. | |
| bool | ra8_esp_hosted_port_is_ready (void) |
| Report whether the port is currently initialised. | |
| bool | ra8_esp_hosted_port_rx_pending (void) |
| Report whether the co-processor has queued receive data. | |
| void | ra8_esp_hosted_mem_dump (const char *label) |
| Report transport pool occupancy at a named point. | |
| void | ra8_esp_hosted_alloc_failed (const char *func, size_t bytes) |
| Record that an allocation through the vtable could not be served. | |
Public entry point of the RA8D2 + ThreadX port of esp-hosted.
The vendored esp-hosted host driver reaches the hardware through exactly two seams: the ten port_esp_hosted_host_*.h headers, and the 72-entry hosted_osi_funcs_t vtable it finds behind the global g_h. This header is the first-party side of that arrangement – it brings the port up, and it declares the handful of port entry points the port headers expand macros onto.
The physical map came from c6_spi_probe, which scope-qualified every J26 hole on 2026-07-27 at SPI mode 3 / 1 MHz; that probe drives the SCI directly and reaches none of this code, which is why the port needed its own proof.
Definition in file ra8_esp_hosted_port.h.
| typedef void(* ra8_esp_hosted_event_cb_t) (void *ctx, const char *base, int32_t event_id, const void *data, size_t data_len) |
Application handler for an event the vendored core posts.
ESP-IDF hosts deliver esp-hosted events through the IDF event loop. There is no such loop here, and adding a thread and a queue to re-create one would cost more than it buys: the port instead calls this handler synchronously, on the thread that posted, so the application sees exactly one delivery path.
| [in] | ctx | The opaque context registered alongside the handler. |
| [in] | base | Event namespace as a NUL-terminated string; never null. |
| [in] | event_id | Identifier within that namespace. |
| [in] | data | Payload, or null when data_len is zero. Owned by the caller and invalid once the handler returns. |
| [in] | data_len | Payload length in bytes. |
Definition at line 167 of file ra8_esp_hosted_port.h.
| typedef struct ra8_esp_hosted_port_cfg ra8_esp_hosted_port_cfg_t |
| enum ra8_esp_hosted_limits_t : uint32_t |
Fixed budgets the port allocates out of static storage.
NASA Power of 10 Rule 3 forbids dynamic allocation after initialisation, and this board has no heap at all – _sbrk is a strong symbol that reports a fatal error. Every object the vendored core asks the vtable to "allocate" therefore comes out of a fixed pool sized by these bounds, and an over-request fails cleanly rather than growing the address space.
Definition at line 84 of file ra8_esp_hosted_port.h.
| void ra8_esp_hosted_alloc_failed | ( | const char * | func, |
| size_t | bytes ) |
Record that an allocation through the vtable could not be served.
Backs the failure arm of the HOSTED_CALLOC macro. On a fixed-pool port an allocation failure is a budgeting fact rather than a transient one, so the report names the requesting function and the size it wanted – which together are enough to resize k_ra8_esp_hosted_pool_bytes without guesswork.
| [in] | func | Name of the requesting function, normally __func__. A null pointer is replaced with a fixed placeholder. |
| [in] | bytes | Size that could not be served, in bytes. |
Record that an allocation through the vtable could not be served.
Definition at line 275 of file ra8_esp_hosted_log.c.
References ESP_LOG_ERROR, ra8_esp_hosted_log_write(), and s_ra8_esp_hosted_log_tag.
| void ra8_esp_hosted_mem_dump | ( | const char * | label | ) |
Report transport pool occupancy at a named point.
Backs the MEM_DUMP macro the vendored core sprinkles through its allocation paths. Reads the live ThreadX byte-pool statistics – bytes available and fragment count – and emits them at info level under the port's log tag. Those are real numbers on this port because the pool is a fixed carve, so a shrinking largest-fragment is exactly how a fragmentation problem announces itself.
| [in] | label | Short call-site name, used verbatim in the log line. A null pointer is replaced with a fixed placeholder rather than dereferenced. |
Report transport pool occupancy at a named point.
Definition at line 260 of file ra8_esp_hosted_log.c.
References ESP_LOG_INFO, priv_ra8_esp_hosted_rtos_pool_stats(), ra8_esp_hosted_log_write(), and s_ra8_esp_hosted_log_tag.
Referenced by c6_fwver_worker_entry(), c6_hosted_worker_entry(), c6_wifi_worker_entry(), and internal_init_hook().
|
nodiscard |
Tear the port down, releasing every pin, interrupt and pool.
Reverses ra8_esp_hosted_port_init in the opposite order: detaches the side-band interrupts, stops the software edge detector, closes the SCI channel, releases the chip select and the two side-band pins, deletes the pools and marks the port not ready. Objects the vendored core still holds handles to are deleted, so the core must be torn down first.
| k_ra8_ok | Everything was released. |
| k_ra8_err_not_initialized | The port was not up. |
| k_ra8_err_rtos_error | ThreadX refused to delete an object, typically because a thread is still blocked on it. |
Tear the port down, releasing every pin, interrupt and pool.
Definition at line 364 of file ra8_esp_hosted_port.c.
References internal_unwind(), k_ra8_err_not_initialized, and s_ra8_esp_hosted_port_ready.
|
nodiscard |
Bring the esp-hosted port up and publish the OS-abstraction vtable.
Performs the six bring-up steps listed in the file-level documentation. Every step is checked; the first failure unwinds the steps already taken – the SCI channel is closed, claimed pins are released and attached interrupts are detached – so a failed init leaves no pin stranded and a retry after fixing the cause can succeed.
The pool carve is the only allocation the port ever performs, and it happens exactly here, during initialisation, which is what keeps the whole port inside NASA Power of 10 Rule 3.
| [in] | cfg | Clocking and pacing configuration. Must be non-null; pclk_hz and sck_hz must be non-zero, edge_poll_ms must be non-zero, and sci_channel must be below the SCI channel count. |
| k_ra8_ok | Port is up; g_h may be used. |
| k_ra8_err_null_ptr | cfg was null. |
| k_ra8_err_invalid_arg | A configuration field was out of range. |
| k_ra8_err_invalid_state | The port was already initialised. |
| k_ra8_err_gpio_conflict | A link pin is owned by another module. |
| k_ra8_err_rtos_error | ThreadX refused a pool, mutex or timer. |
| k_ra8_err_spi_error | The SCI Simple-SPI channel would not open. |
Bring the esp-hosted port up and publish the OS-abstraction vtable.
Definition at line 331 of file ra8_esp_hosted_port.c.
References ESP_LOGE, ESP_LOGI, internal_bring_up(), internal_unwind(), k_ra8_err_invalid_state, k_ra8_ok, priv_ra8_esp_hosted_port_cfg_check(), priv_ra8_esp_hosted_port_pins_check(), s_esp_hosted_tag, s_ra8_esp_hosted_port_ready, ra8_esp_hosted_port_cfg::sci_channel, and ra8_esp_hosted_port_cfg::sck_hz.
Referenced by tx_application_define().
|
nodiscard |
Report whether the port is currently initialised.
Reads the single module-state flag. Exists so an application can decide whether a teardown is needed without provoking an error return, and so host tests can assert the state machine without reaching into the module.
| true | The port is up. |
| false | The port has never been up, failed to come up, or has been torn down. |
Report whether the port is currently initialised.
Definition at line 374 of file ra8_esp_hosted_port.c.
References s_ra8_esp_hosted_port_ready.
Referenced by c6_fwver_pump_check(), c6_hosted_heartbeat(), internal_init_hook(), internal_ra8_esp_hosted_c6link_delay(), internal_ra8_esp_hosted_c6link_handshake(), internal_ra8_esp_hosted_c6link_transfer(), and ra8_esp_hosted_c6link_bind().
|
nodiscard |
Report whether the co-processor has queued receive data.
Samples the held DATA_READY side-band signal through the bound esp-hosted GPIO seam. This is a non-blocking level check for poll schedulers; it does not clock SPI or consume the pending frame.
| true | DATA_READY is asserted on an initialized port. |
| false | The port is not initialized or DATA_READY is inactive. |
Definition at line 379 of file ra8_esp_hosted_port.c.
References g_h, H_DR_VAL_ACTIVE, H_GPIO_DATA_READY_Pin, H_GPIO_DATA_READY_Port, and s_ra8_esp_hosted_port_ready.
Referenced by internal_rx_worker_entry().
|
nodiscard |
Register the handler the port calls when the core posts an event.
Registering a null handler removes the current one, after which posted events are reported to the core as unconsumed rather than dropped quietly – the core can then decide whether the loss matters.
| [in] | cb | Handler to install, or null to remove the current one. |
| [in] | ctx | Opaque context handed back to the handler. Must be null when cb is null, since there would be nothing to hand it to. |
| k_ra8_ok | The registration was stored. |
| k_ra8_err_invalid_arg | A context was supplied without a handler. |
Register the handler the port calls when the core posts an event.
Definition at line 163 of file ra8_esp_hosted_osi.c.
References k_ra8_err_invalid_arg, k_ra8_ok, s_ra8_esp_hosted_event_cb, and s_ra8_esp_hosted_event_ctx.
Referenced by tx_application_define().