|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
On-silicon root-of-trust image verify (ECDSA-P256 via tf-psa-crypto). More...
#include <stdint.h>#include <string.h>#include "mbedtls/memory_buffer_alloc.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_rot.h"#include "ra8_time.h"#include "rot_fixture.h"Go to the source code of this file.
Enumerations | |
| enum | rot_const_t : uint32_t { k_rot_baud = 115200U , k_rot_period_ms = 1000U , k_rot_heap_bytes = 0x10000U } |
| Demo tunables. More... | |
| enum | rot_bit_t : uint8_t { k_rot_tamper_bit = 0x01U } |
| Byte flipped in the tamper copy (first body octet). More... | |
Functions | |
| static void | rot_write (const uint8_t *msg, size_t len) |
| static bool | rot_genuine_ok (void) |
| The genuine signed fixture must verify (k_ra8_ok). | |
| static bool | rot_tamper_rejected (void) |
| A one-bit body corruption must be rejected (not k_ra8_ok). | |
| static void | rot_panic_halt (void) |
| static void | rot_setup_or_halt (void) |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | k_rot_msg_pass [] = "rot verify: PASS\r\n" |
| static const uint8_t | k_rot_msg_fail [] = "rot verify: FAIL\r\n" |
| static const uint8_t | k_rot_diag_boot [] = "rot: boot (console up)\r\n" |
| static const uint8_t | k_rot_diag_psa_fail [] = "rot: psa_init FAIL\r\n" |
| static const uint8_t | k_rot_diag_psa_ok [] = "rot: psa_init ok\r\n" |
| static const uint8_t | k_rot_diag_genuine [] = "rot: genuine image ACCEPTED\r\n" |
| static const uint8_t | k_rot_diag_no_gen [] = "rot: genuine image REJECTED (bug)\r\n" |
| static const uint8_t | k_rot_diag_tamper [] = "rot: tampered image REJECTED\r\n" |
| static const uint8_t | k_rot_diag_no_tamp [] = "rot: tampered image ACCEPTED (bug)\r\n" |
| static uint8_t | s_rot_heap [k_rot_heap_bytes] |
| Static heap tf-psa's mbedtls_calloc draws from (no libc heap on target). | |
| static uint8_t | s_rot_tamper [sizeof(k_rot_fixture_image)] |
| Mutable copy of the fixture used for the tamper case. | |
On-silicon root-of-trust image verify (ECDSA-P256 via tf-psa-crypto).
Runs the REAL ra8_rot verify chain on the M85 against a signed image fixture (rot_fixture.h, produced by scripts/secrets/rot_sign.py with the project RoT key): SHA-256 of the body, the anti-rollback version-bind hash, and an ECDSA-P256 signature check via the tf-psa-crypto software backend (the RSIP crypto hardware is dead – see libs/ra8_hal/src/ra8_rsip.c). It proves a working root of trust can authenticate images on this hardware, and that a tampered body is rejected. This is a self-test: it does NOT touch the boot path, so there is no brick risk.
Reports "rot verify: PASS" (genuine accepted AND tamper rejected) or "rot verify: FAIL" over SCI8 (115200 8N1).
Definition in file main.c.
| enum rot_bit_t : uint8_t |
| enum rot_const_t : uint32_t |
| 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 133 of file main.c.
References k_ra8_board_led1, k_ra8_board_led2, k_rot_diag_genuine, k_rot_diag_no_gen, k_rot_diag_no_tamp, k_rot_diag_tamper, k_rot_msg_fail, k_rot_msg_pass, k_rot_period_ms, ra8_board_led_toggle(), ra8_delay_ms(), ra8_isr_globals_enable(), rot_genuine_ok(), rot_panic_halt(), rot_setup_or_halt(), rot_tamper_rejected(), and rot_write().
|
static |
The genuine signed fixture must verify (k_ra8_ok).
Definition at line 74 of file main.c.
References k_ra8_ok, k_rot_fixture_body_len, k_rot_fixture_image, ra8_rot_trailer_after(), and ra8_rot_verify_image().
Referenced by main().
|
static |
Definition at line 96 of file main.c.
Referenced by main(), and rot_setup_or_halt().
|
static |
Definition at line 103 of file main.c.
References k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_ok, k_rot_baud, k_rot_diag_boot, k_rot_diag_psa_fail, k_rot_diag_psa_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_psa_crypto_init(), ra8_time_init(), rot_panic_halt(), rot_write(), and s_rot_heap.
Referenced by main().
|
static |
A one-bit body corruption must be rejected (not k_ra8_ok).
Definition at line 85 of file main.c.
References k_ra8_ok, k_rot_fixture_body_len, k_rot_fixture_image, k_rot_tamper_bit, memcpy(), ra8_rot_trailer_after(), ra8_rot_verify_image(), and s_rot_tamper.
Referenced by main().
|
static |
Definition at line 68 of file main.c.
References ra8_board_uart_console_write().
Referenced by main(), and rot_setup_or_halt().
|
static |
Definition at line 54 of file main.c.
Referenced by rot_setup_or_halt().
|
static |
|
static |
|
static |
|
static |
Definition at line 55 of file main.c.
Referenced by rot_setup_or_halt().
|
static |
Definition at line 56 of file main.c.
Referenced by rot_setup_or_halt().
|
static |
|
static |
|
static |
|
static |
Static heap tf-psa's mbedtls_calloc draws from (no libc heap on target).
Definition at line 63 of file main.c.
Referenced by rot_setup_or_halt().
|
static |
Mutable copy of the fixture used for the tamper case.
Definition at line 66 of file main.c.
Referenced by rot_tamper_rejected().