|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Error Code Definitions for ra8-firmware. More...
#include <stdint.h>Go to the source code of this file.
Typedefs | |
| typedef ra8_err_codes_t | ra8_err_t |
| Canonical error-return type used by every ra8-firmware API. | |
Functions | |
| static bool | ra8_err_is_error (ra8_err_t err) |
| Test whether a code represents failure. | |
| const char * | ra8_err_to_str (ra8_err_t err) |
| Human-readable string for an error code. | |
Error Code Definitions for ra8-firmware.
Single source of truth for all error codes returned across the firmware. Every public API that can fail returns ra8_err_t; every caller checks it via the macros in ra8_check.h (RA8_RETURN_ON_ERROR, RA8_ERROR_CHECK, etc.). There are no other error channels (no errno, no exceptions, no longjmp, no global error flags) – this is NASA Power of 10 Rule 7 ("check all return values") enforced at the type level.
| Range | Category | Typical source |
|---|---|---|
| 0x000 | Success | Normal return |
| 0x101 – 0x1FF | Generic | Argument/state/lifecycle |
| 0x201 – 0x2FF | Hardware | Peripheral init, GPIO, sensor range, faults |
| 0x301 – 0x3FF | RTOS (reserved) | Future RTOS (not used in v0.x bare-metal) |
| 0x401 – 0x4FF | Communication | Bus-level errors, framing, CRC |
| 0x501 – 0x5FF | Validation | Assertion and pre/post-condition failures |
The RTOS category is preserved (identical values to the rx72n project) so that any shared utility code can be moved between projects without renumbering. The bare-metal firmware does not currently return any k_ra8_err_rtos_* code.
Definition in file ra8_err.h.
| typedef ra8_err_codes_t ra8_err_t |
Canonical error-return type used by every ra8-firmware API.
Always returns a value from ra8_err_codes_t. Use the helpers in ra8_check.h to propagate and check.
| enum ra8_err_codes_t : uint16_t |
Canonical error code list for ra8-firmware.
Every public API that can fail returns one of these values cast to ra8_err_t. Values are grouped by category and use stable hexadecimal numbering so logs, telemetry, and debugger watch expressions decode without needing source.
| Enumerator | |
|---|---|
| k_ra8_ok | Success – operation completed with all postconditions satisfied. The only non-error value. Callers should always compare against k_ra8_ok rather than the numeric 0 for clarity. |
| k_ra8_fail | Generic unspecified failure. Last-resort code when nothing more specific fits. Prefer a purpose-built code when one exists.
|
| k_ra8_err_no_mem | Static buffer exhausted (no dynamic memory on this project). Returned when a statically-sized pool / ring / queue has no space left. In a zero-alloc system this almost always means the buffer was sized too small for the worst-case load.
|
| k_ra8_err_invalid_arg | Invalid function argument. Parameter out of range, NULL where non-NULL required, or logically inconsistent inputs.
|
| k_ra8_err_invalid_state | Module in wrong state for requested operation. E.g. calling _start() before _init() succeeded, or _init() twice in a row.
|
| k_ra8_err_invalid_size | Invalid size parameter (too large, too small, or misaligned).
|
| k_ra8_err_not_found | Requested item not found (lookup / search missed).
|
| k_ra8_err_not_supported | Requested feature not compiled in, not wired, or not supported by this MCU variant.
|
| k_ra8_err_timeout | Operation exceeded its time budget. Generic timeout. For hardware-specific waits (e.g. PLL lock, peripheral busy) prefer k_ra8_err_hw_timeout.
|
| k_ra8_err_busy | Resource busy – blocking operation cannot proceed.
|
| k_ra8_err_no_data | No application data available (e.g. only a control frame arrived). Not a failure condition – the caller should continue polling.
|
| k_ra8_err_would_block | Non-blocking operation would have blocked. Returned by non-blocking APIs when the underlying resource is not immediately available.
|
| k_ra8_err_exists | Item already exists – cannot create again.
|
| k_ra8_err_empty | Container empty – nothing to retrieve.
|
| k_ra8_err_cancelled | Operation cancelled before completion. The operation had no side effects (atomic cancellation).
|
| k_ra8_err_not_initialized | Module not initialized – _init() not yet called successfully.
|
| k_ra8_err_estop | Emergency stop active – operation forbidden until cleared. Safety-critical: do not bypass. Once set, requires explicit reset via the safety supervisor.
|
| k_ra8_err_not_empty | Container still holds members – the operation requires it empty. The exact inverse of k_ra8_err_empty: that one reports "nothing to retrieve", this one reports "something is still in there". Returned by ra8_fs_rmdir() for a directory that still has entries, the POSIX ENOTEMPTY condition. Distinct from k_ra8_err_invalid_arg on purpose: a caller that wants to remove a tree must be able to tell "you named the wrong thing" from "empty it first and retry".
|
| k_ra8_err_access_denied | Operation refused because the target is protected against it. The POSIX EACCES condition, returned when a mutating request is denied by a permission the target itself carries rather than by a bad argument or a broken device. Its first use is the FAT/exFAT read-only attribute: ra8_fs_open() for writing, ra8_fs_write_file(), ra8_fs_unlink() and ra8_fs_rename() return it rather than overwrite or delete a file a host marked read-only. The bit is checked at OPEN time, so ra8_fs_write() on a handle opened before the file became read-only is unaffected. Distinct from k_ra8_err_invalid_arg, which says the request was malformed: here the request is well-formed and the answer is "not allowed".
|
| k_ra8_err_hw_init_failed | Hardware peripheral failed to initialise. Clock gating failed, register verify failed, or the block never reached ready state.
|
| k_ra8_err_hw_not_ready | Hardware peripheral exists but not ready yet. Examples: PLL not locked, ADC not calibrated, LVD still below threshold.
|
| k_ra8_err_hw_timeout | Hardware timed out waiting for a flag or handshake.
|
| k_ra8_err_hw_error | Generic hardware fault detected (error flag set, fault interrupt).
|
| k_ra8_err_gpio_conflict | GPIO pin already owned by another peripheral or driver. Raised by ra8_pin_validator when two modules both try to claim the same pin.
|
| k_ra8_err_gpio_invalid_port | GPIO port index out of range for this MCU. Valid RA8D2 ports are 0..14 (not all pins bonded out on BGA 289).
|
| k_ra8_err_gpio_invalid_pin | GPIO pin index out of range within its port (valid: 0..15).
|
| k_ra8_err_out_of_range | Sensor or peripheral output out of valid range.
|
| k_ra8_err_hw_unmapped | Peripheral register block is not mapped in this MCU variant. Raised when driver code is built for a chip that does not actually have the addressed peripheral.
|
| k_ra8_err_rtos_error | Generic RTOS error (reserved for future use).
|
| k_ra8_err_rtos_thread_create | Thread create failed (reserved for future use).
|
| k_ra8_err_rtos_semaphore | Semaphore API error (reserved for future use).
|
| k_ra8_err_rtos_mutex | Mutex API error (reserved for future use).
|
| k_ra8_err_rtos_queue | Queue / message API error (reserved for future use).
|
| k_ra8_err_rtos_timer | Timer API error (reserved for future use).
|
| k_ra8_err_comm_error | Generic communication error (use a more specific code when possible).
|
| k_ra8_err_spi_error | SPI transfer failed (bus fault, mode fault, overrun, ...).
|
| k_ra8_err_uart_error | UART / SCI error (framing, parity, overrun, break).
|
| k_ra8_err_i2c_error | I2C / IIC error (arbitration lost, NACK, timeout, bus error).
|
| k_ra8_err_crc_mismatch | CRC mismatch detected on received data.
|
| k_ra8_err_protocol_error | Protocol-level error (e.g. unexpected opcode, bad sequence number).
|
| k_ra8_err_nack | Peer responded with NACK (negative acknowledgement).
|
| k_ra8_err_conflict | Conflict with concurrent access detected.
|
| k_ra8_err_retry_limit | Retry budget exhausted – operation still failing after all attempts.
|
| k_ra8_err_validation_failed | Validation rule failed (caller-supplied invariant not satisfied).
|
| k_ra8_err_checksum_mismatch | Stored / transmitted checksum does not match computed value.
|
| k_ra8_err_range_check_failed | Value outside range enforced by RA8_CHECK_RANGE / RA8_CHECK_RANGE_TAG.
|
| k_ra8_err_null_ptr | Pointer was NULL where a valid pointer was required. This is the value returned by RA8_CHECK_NULL_PTR.
|
| k_ra8_err_decomp_output_cap | Decompression output cap breached (ra8_decomp_limits_t). A decode unit (one archive member or one wrapped stream) either declared or actually produced more bytes than the policy's max_output_bytes. The decoder stops fail-closed; nothing past the cap is written.
|
| k_ra8_err_decomp_ratio | Compression ratio bound breached (ra8_decomp_limits_t). A decode unit's output exceeded input * max_ratio + ratio_grace_bytes – the decompression-bomb signature. The decoder stops fail-closed at the breach point.
|
| k_ra8_err_decomp_entries | Archive entry-count cap breached (ra8_decomp_limits_t). An archive enumerated more members than the policy's max_entries – the many-tiny-entries resource-exhaustion shape. The whole archive is rejected fail-closed.
|
| k_ra8_err_decomp_depth | Container nesting-depth cap breached (ra8_decomp_limits_t). Decoder plumbing was asked to stack more layers (e.g. a compressed stream inside a compressed stream) than the policy's max_depth – the recursive-bomb shape. Rejected fail-closed before any inner decode starts.
|
| k_ra8_err_decomp_iterations | Decode-loop iteration budget exhausted (ra8_decomp_limits_t). A decode loop charged more iterations than the policy's max_iterations without finishing – the stuck-stream / no-progress shape (NASA P10 Rule 2 backstop). The decoder stops fail-closed.
|
|
inlinestatic |
Test whether a code represents failure.
| [in] | err | Code to test. |
See implementation for details.
| 0 | Success or default value. |
Definition at line 568 of file ra8_err.h.
References k_ra8_ok.
| const char * ra8_err_to_str | ( | ra8_err_t | err | ) |
Human-readable string for an error code.
Returns a pointer to a static literal describing the code. Useful for logging and UART dumps. The returned pointer is valid for the lifetime of the program and must NOT be freed.
| [in] | err | Code to look up. |
| ok | Returned for k_ra8_ok. |
| <name> | Returned for any known k_ra8_err_* code. |
| unknown | Returned for any code not in the lookup table. |
Human-readable string for an error code.
Walks s_ra8_err_names and returns the matching name. Returns the literal "unknown" if no entry matches.
| [in] | err | Error code to look up. |
| ok | Returned for k_ra8_ok. |
| <name> | Returned for any known k_ra8_err_* code. |
| unknown | Returned for any code not in the table. |
Definition at line 737 of file ra8_log.c.
References s_ra8_err_names, and s_ra8_err_names_count.
Referenced by c6_cam_camera_report_last_error(), c6_fwver_phase_caps(), c6_fwver_phase_request(), c6_fwver_worker_entry(), c6_hosted_worker_entry(), c6_join_phase_ip(), c6_join_phase_ready(), c6_join_report_fault(), c6_join_worker_entry(), c6_wifi_phase_ready(), c6_wifi_report_fault(), c6_wifi_worker_entry(), internal_c6_cam_http_frame(), internal_c6_cam_join(), internal_c6_cam_prepare_camera(), internal_c6_cam_prepare_link(), internal_c6_cam_prepare_media(), internal_c6_cam_report_fault(), internal_c6_cam_worker_entry(), internal_fail(), internal_report_sccb_state(), sensor_report_register(), wifi_hal_report(), wifi_hal_run(), and wifi_hal_worker_entry().