|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
The ESP_SERIAL_IF RPC channel: request, response, verdict. More...
#include <stddef.h>#include <stdint.h>#include "c6_fwver.h"#include "esp_hosted_host_fw_ver.h"#include "esp_hosted_interface.h"#include "esp_hosted_os_abstraction.h"#include "esp_hosted_rpc.pb-c.h"#include "esp_hosted_transport.h"#include "protobuf-c/protobuf-c.h"#include "transport_drv.h"Go to the source code of this file.
Data Structures | |
| struct | c6_fwver_rsp |
| Every field this application read out of the RPC response. More... | |
Typedefs | |
| typedef struct c6_fwver_rsp | c6_fwver_rsp_t |
Enumerations | |
| enum | c6_fwver_tlv_t : uint16_t { k_c6_fwver_tlv_t_epname = 0x01U , k_c6_fwver_tlv_t_data = 0x02U , k_c6_fwver_tlv_type = 0U , k_c6_fwver_tlv_len_lo = 1U , k_c6_fwver_tlv_len_hi = 2U , k_c6_fwver_tlv_value = 3U , k_c6_fwver_tlv_ep_len = (uint16_t)(sizeof(RPC_EP_NAME_RSP) - 1U) , k_c6_fwver_tlv_overhead , k_c6_fwver_tlv_shift = 8U , k_c6_fwver_tlv_mask = 0xFFU } |
| The serial endpoint's TLV envelope, tag by tag. More... | |
Functions | |
| static void * | c6_fwver_rpc_pool_alloc (void *allocator_data, size_t size) |
| Allocate through the esp-hosted port's fixed byte pool. | |
| static void | c6_fwver_rpc_pool_free (void *allocator_data, void *pointer) |
| Return a block to the esp-hosted port's fixed byte pool. | |
| static uint16_t | c6_fwver_tlv_head (uint8_t *out, uint16_t at, uint8_t type, uint16_t len) |
| Write one TLV tag header at a cursor. | |
| ra8_err_t | c6_fwver_rpc_request (uint8_t *out, uint16_t cap, uint16_t *out_len) |
| Build the TLV-wrapped RPC firmware-version request. | |
| static const uint8_t * | c6_fwver_tlv_body (const uint8_t *payload, uint16_t len, uint16_t *proto_len) |
| Strip the TLV envelope off a received serial payload. | |
| static void | c6_fwver_rpc_take_target (const ProtobufCBinaryData *target) |
| Copy the response's target string into the record, bounded. | |
| static bool | c6_fwver_rpc_take (const Rpc *msg) |
| Record a decoded message if it is the awaited response. | |
| bool | c6_fwver_rpc_consume (uint8_t if_type, uint8_t if_num, const uint8_t *payload, uint16_t len) |
| Decode an ESP_SERIAL_IF frame as the awaited RPC response. | |
| static void | c6_fwver_rpc_print_response (void) |
| Print the decoded response, field by field. | |
| static void | c6_fwver_rpc_print_crosscheck (void) |
| Report the boot event's version reading beside the RPC's. | |
| static void | c6_fwver_rpc_print_expectation (void) |
| Print what this host expects, before it says what it got. | |
| bool | c6_fwver_rpc_report (void) |
| Print the recorded response and decide the run's verdict. | |
| bool | c6_fwver_dispatch (uint8_t if_type, uint8_t if_num, const uint8_t *payload, uint16_t len) |
| Route a received frame to the module that understands it. | |
Variables | |
| static c6_fwver_rsp_t | s_c6_fwver_rsp |
| The one response this application is waiting for. | |
| static ProtobufCAllocator | s_c6_fwver_allocator |
| The allocator the generated protobuf decoder is handed. | |
The ESP_SERIAL_IF RPC channel: request, response, verdict.
The esp-hosted control plane is protobuf over a two-tag TLV envelope over ESP_SERIAL_IF. All three layers are exercised here:
The request is RPC_ID__Req_GetCoprocessorFwVersion. It was chosen because its answer is checkable: the vendored host driver states its own version in esp_hosted_host_fw_ver.h, and the co-processor image was built from the same pinned upstream commit, so the two must agree exactly. The verdict is therefore the host/co-processor version lock – the hazard #316 exists to police – rather than "some bytes came back".
Definition in file c6_fwver_rpc.c.
| typedef struct c6_fwver_rsp c6_fwver_rsp_t |
| enum c6_fwver_tlv_t : uint16_t |
The serial endpoint's TLV envelope, tag by tag.
Two tags, each a one-byte type followed by a little-endian 16-bit length: the endpoint name, then the protobuf payload. The endpoint-name length is taken from the vendored RPC_EP_NAME_RSP string rather than written down, because upstream requires both endpoint names to have the same length and the parser checks that.
Definition at line 77 of file c6_fwver_rpc.c.
| bool c6_fwver_dispatch | ( | uint8_t | if_type, |
| uint8_t | if_num, | ||
| const uint8_t * | payload, | ||
| uint16_t | len ) |
Route a received frame to the module that understands it.
| [in] | if_type | Interface type from the received header. |
| [in] | if_num | Interface number from the received header. |
| [in] | payload | Frame payload; null is ignored. |
| [in] | len | Payload length in bytes. |
| true | The RPC layer accepted the awaited response. |
| false | Everything else, including announcements. |
len bytes are readable at payload. Definition at line 539 of file c6_fwver_rpc.c.
References c6_fwver_priv_consume(), c6_fwver_put_u32(), c6_fwver_puts(), and c6_fwver_rpc_consume().
Referenced by c6_fwver_phase_caps(), and c6_fwver_phase_request().
| bool c6_fwver_rpc_consume | ( | uint8_t | if_type, |
| uint8_t | if_num, | ||
| const uint8_t * | payload, | ||
| uint16_t | len ) |
Decode an ESP_SERIAL_IF frame as the awaited RPC response.
Unwraps the TLV envelope, unpacks the Rpc message with the vendored codec, and – only when it is the response to this application's request – records every field for the verdict.
| [in] | if_type | Interface type from the received header. |
| [in] | if_num | Interface number from the received header. |
| [in] | payload | Frame payload; null is ignored. |
| [in] | len | Payload length in bytes. |
| true | The response to this request arrived and was decoded. |
| false | The frame was something else, or could not be decoded. |
len bytes are readable at payload. Definition at line 369 of file c6_fwver_rpc.c.
References c6_fwver_put_u32(), c6_fwver_puts(), c6_fwver_rpc_take(), c6_fwver_tlv_body(), s_c6_fwver_allocator, and s_c6_fwver_rsp.
Referenced by c6_fwver_dispatch().
|
static |
Allocate through the esp-hosted port's fixed byte pool.
| [in] | allocator_data | Unused; the pool is a module singleton. |
| [in] | size | Bytes requested. |
| NULL | The fixed pool is exhausted. |
Definition at line 149 of file c6_fwver_rpc.c.
References g_h.
|
static |
Return a block to the esp-hosted port's fixed byte pool.
| [in] | allocator_data | Unused; the pool is a module singleton. |
| [in] | pointer | Block to release; null is ignored. |
pointer came from c6_fwver_rpc_pool_alloc, or is null. Definition at line 168 of file c6_fwver_rpc.c.
References g_h.
|
static |
Report the boot event's version reading beside the RPC's.
Definition at line 450 of file c6_fwver_rpc.c.
References c6_fwver_priv_init_version(), c6_fwver_put_u32(), c6_fwver_puts(), and s_c6_fwver_rsp.
Referenced by c6_fwver_rpc_report().
|
static |
Print what this host expects, before it says what it got.
Definition at line 484 of file c6_fwver_rpc.c.
References c6_fwver_put_hex(), c6_fwver_put_u32(), c6_fwver_puts(), k_c6_fwver_hex_byte, and k_c6_fwver_rpc_uid.
Referenced by c6_fwver_rpc_report().
|
static |
Print the decoded response, field by field.
Definition at line 419 of file c6_fwver_rpc.c.
References c6_fwver_put_hex(), c6_fwver_put_i32(), c6_fwver_put_text(), c6_fwver_put_u32(), c6_fwver_puts(), k_c6_fwver_hex_byte, and s_c6_fwver_rsp.
Referenced by c6_fwver_rpc_report().
| bool c6_fwver_rpc_report | ( | void | ) |
Print the recorded response and decide the run's verdict.
Prints every decoded field, then the version this host expects, and then exactly one PASS/FAIL line. The expectation is the vendored host driver's own version from esp_hosted_host_fw_ver.h, so the check is the host/co-processor version lock rather than a literal written twice.
| true | The co-processor answered with the expected version. |
| false | No response arrived, or a field did not match. |
Definition at line 499 of file c6_fwver_rpc.c.
References c6_fwver_put_u32(), c6_fwver_puts(), c6_fwver_rpc_print_crosscheck(), c6_fwver_rpc_print_expectation(), c6_fwver_rpc_print_response(), k_c6_fwver_rpc_uid, and s_c6_fwver_rsp.
Referenced by c6_fwver_worker_entry().
|
nodiscard |
Build the TLV-wrapped RPC firmware-version request.
Packs an Rpc protobuf message carrying RPC_ID__Req_GetCoprocessorFwVersion with the vendored generated codec, then wraps it in the two-tag TLV envelope the co-processor's serial endpoint expects (endpoint name, then data), exactly as compose_tlv() does in the vendored serial_if.c.
| [out] | out | Buffer to fill; must be non-null. |
| [in] | cap | Bytes available at out. |
| [out] | out_len | Bytes written; must be non-null. |
| k_ra8_ok | The request was built and out_len is its length. |
| k_ra8_err_null_ptr | out or out_len was null. |
| k_ra8_err_invalid_size | cap cannot hold the envelope. |
| k_ra8_err_validation_failed | The generated codec packed a different number of bytes than it predicted. |
cap bytes are writable at out. out_len is non-zero and at most cap. out_len is zero. Definition at line 217 of file c6_fwver_rpc.c.
References c6_fwver_tlv_head(), k_c6_fwver_rpc_uid, k_c6_fwver_tlv_ep_len, k_c6_fwver_tlv_overhead, k_c6_fwver_tlv_t_data, k_c6_fwver_tlv_t_epname, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_err_validation_failed, and k_ra8_ok.
Referenced by c6_fwver_phase_request().
|
static |
Record a decoded message if it is the awaited response.
| [in] | msg | Decoded Rpc message; must be non-null. |
msg. | true | This is the response to this application's request. |
| false | It is an event, a different response, or a different UID. |
msg came from rpc__unpack and is still owned by the caller. msg. msg itself is not modified or freed here. Definition at line 350 of file c6_fwver_rpc.c.
References c6_fwver_rpc_take_target(), and s_c6_fwver_rsp.
Referenced by c6_fwver_rpc_consume().
|
static |
Copy the response's target string into the record, bounded.
| [in] | target | Binary field from the decoded message. |
target's data covers len bytes, or len is zero. Definition at line 322 of file c6_fwver_rpc.c.
References k_c6_fwver_text_max, and s_c6_fwver_rsp.
Referenced by c6_fwver_rpc_take().
|
static |
Strip the TLV envelope off a received serial payload.
| [in] | payload | Frame payload; must be non-null. |
| [in] | len | Payload length in bytes. |
| [out] | proto_len | Protobuf length found; must be non-null. |
| NULL | The tags, the endpoint name or the lengths did not check out. |
len bytes are readable at payload. proto_len is writable. proto_len is non-zero and the returned range lies wholly inside payload. proto_len is zero. Definition at line 273 of file c6_fwver_rpc.c.
References k_c6_fwver_tlv_ep_len, k_c6_fwver_tlv_len_hi, k_c6_fwver_tlv_len_lo, k_c6_fwver_tlv_overhead, k_c6_fwver_tlv_shift, k_c6_fwver_tlv_t_data, k_c6_fwver_tlv_t_epname, k_c6_fwver_tlv_type, and k_c6_fwver_tlv_value.
Referenced by c6_fwver_rpc_consume().
|
static |
Write one TLV tag header at a cursor.
| [out] | out | Buffer being filled; must be non-null. |
| [in] | at | Offset to write at. |
| [in] | type | Tag type. |
| [in] | len | Value length that follows. |
Definition at line 208 of file c6_fwver_rpc.c.
References k_c6_fwver_tlv_len_hi, k_c6_fwver_tlv_len_lo, k_c6_fwver_tlv_mask, k_c6_fwver_tlv_shift, k_c6_fwver_tlv_type, and k_c6_fwver_tlv_value.
Referenced by c6_fwver_rpc_request().
|
static |
The allocator the generated protobuf decoder is handed.
Points at the esp-hosted port's fixed pool, never at newlib's heap: _sbrk in this image is a strong symbol that reports a fatal error, so the default protobuf-c allocator would fault rather than fail.
Definition at line 187 of file c6_fwver_rpc.c.
Referenced by c6_fwver_rpc_consume().
|
static |
The one response this application is waiting for.
File scope because the sink that fills it and the report that judges it are different calls on different stacks.
Definition at line 133 of file c6_fwver_rpc.c.
Referenced by c6_fwver_rpc_consume(), c6_fwver_rpc_print_crosscheck(), c6_fwver_rpc_print_response(), c6_fwver_rpc_report(), c6_fwver_rpc_take(), and c6_fwver_rpc_take_target().