|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ra8_psa_crypto_random() dump over SCI8 for the bare EK-RA8D2 EVM More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_psa_crypto.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | rng_demo_config_t : uint32_t { k_rng_demo_baud = 115200U , k_rng_demo_period_ms = 1000U } |
| Compile-time settings for the demo. More... | |
| enum | rng_demo_byte_t : uint8_t { k_rng_demo_bytes_per_line = 32U , k_rng_demo_hex_per_byte = 2U , k_rng_demo_nibble_mask = 0x0FU , k_rng_demo_nibble_shift = 4U , k_rng_demo_alpha_threshold = 10U } |
| Per-emit byte counts. More... | |
Functions | |
| static void | internal_rng_demo_panic_halt (void) |
| Park the processor after a fatal setup or entropy-path failure. | |
| static uint8_t | internal_rng_demo_nibble_to_hex (uint8_t nibble) |
| Convert a nibble to its ASCII hex representation. | |
| static void | internal_rng_demo_setup_or_halt (void) |
| Bring CGC, SysTick, SCI8, LED1, and PSA crypto up. | |
| static ra8_err_t | internal_rng_demo_emit_one_line (void) |
| Emit one hex line of TRNG output. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | s_rng_demo_prefix [] = "rng: " |
| Fixed prefix and CR/LF tail used on every emit. | |
| static const uint8_t | s_rng_demo_eol [] = "\r\n" |
| static const uint8_t | s_rng_demo_pass_msg [] = "rng: PRNG stub OK (deterministic, NOT entropy)\r\n" |
| Verdict line emitted only after a non-stuck sample is dumped. | |
ra8_psa_crypto_random() dump over SCI8 for the bare EK-RA8D2 EVM
Brings up CGC + SysTick + SCI8 + LED1 + ra8_psa_crypto and once a second pulls 32 bytes from ra8_psa_crypto_random() and emits them as an ASCII hex line on the on-board J-Link OB CDC channel (115200 8N1, TXD8 = PD_02 / RXD8 = PD_03). LED1 toggles once per emit so the heartbeat is also visible without a serial terminal.
Sequence:
No external transceiver, board, or harness is required.
Definition in file main.c.
| enum rng_demo_byte_t : uint8_t |
| enum rng_demo_config_t : uint32_t |
|
staticnodiscard |
Emit one hex line of TRNG output.
Requests one bounded sample, rejects an all-equal stuck pattern, converts every byte to lowercase hex, and emits the sample plus verdict.
| k_ra8_ok | Line transmitted. |
| k_ra8_err_hw_error | Underlying primitive failed. |
Definition at line 185 of file main.c.
References internal_rng_demo_nibble_to_hex(), k_ra8_err_hw_error, k_ra8_ok, k_rng_demo_bytes_per_line, k_rng_demo_hex_per_byte, k_rng_demo_nibble_shift, ra8_board_uart_console_write(), RA8_INTERNAL, ra8_psa_crypto_random(), s_rng_demo_eol, s_rng_demo_pass_msg, and s_rng_demo_prefix.
Referenced by main().
|
static |
Convert a nibble to its ASCII hex representation.
Masks the input to four bits and maps values below ten to decimal digits and the remaining values to lowercase hexadecimal letters.
| [in] | nibble | Lower 4 bits used; upper 4 bits ignored. |
| 0x30..0x39 | Decimal ASCII digit for nibble values zero through nine. |
| 0x61..0x66 | Lowercase ASCII letter for nibble values ten through fifteen. |
Definition at line 113 of file main.c.
References k_rng_demo_alpha_threshold, k_rng_demo_nibble_mask, and RA8_INTERNAL.
Referenced by internal_rng_demo_emit_one_line().
|
static |
Park the processor after a fatal setup or entropy-path failure.
Executes wait-for-interrupt indefinitely so a failed diagnostic cannot continue producing output that could be mistaken for valid samples.
Definition at line 87 of file main.c.
References RA8_INTERNAL.
Referenced by internal_rng_demo_setup_or_halt(), and main().
|
static |
Bring CGC, SysTick, SCI8, LED1, and PSA crypto up.
Initializes each prerequisite in dependency order and transfers to internal_rng_demo_panic_halt on the first error.
Definition at line 135 of file main.c.
References internal_rng_demo_panic_halt(), k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, k_rng_demo_baud, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_psa_crypto_init(), and ra8_time_init().
Referenced by main().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
Definition at line 237 of file main.c.
References internal_rng_demo_emit_one_line(), internal_rng_demo_panic_halt(), internal_rng_demo_setup_or_halt(), k_ra8_board_led1, k_ra8_ok, k_rng_demo_period_ms, ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().
|
static |
Definition at line 65 of file main.c.
Referenced by internal_rng_demo_emit_one_line().
|
static |
Verdict line emitted only after a non-stuck sample is dumped.
Deliberately does NOT claim entropy – ra8_psa_crypto_random returns a deterministic software stub on this silicon (no working RSIP TRNG).
Definition at line 72 of file main.c.
Referenced by internal_rng_demo_emit_one_line().
|
static |
Fixed prefix and CR/LF tail used on every emit.
Definition at line 64 of file main.c.
Referenced by internal_rng_demo_emit_one_line().