|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
CRC-32 hardware vs. More...
#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_crc.h"#include "ra8_crc_regs.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | crc_demo_config_t : uint32_t { k_crc_demo_baud = 115200U , k_crc_demo_period_ms = 1000U } |
| Compile-time settings. More... | |
| enum | crc_demo_sw_const_t : uint32_t { k_crc_demo_sw_poly_rev = 0xEDB88320UL , k_crc_demo_sw_init = 0xFFFFFFFFUL , k_crc_demo_sw_xor_out = 0xFFFFFFFFUL , k_crc_demo_byte_mask = 0xFFUL , k_crc_demo_lsb_mask = 0x1UL } |
| Software CRC-32 polynomial + bit constants (reflected). More... | |
| enum | crc_demo_byte_t : uint8_t { k_crc_demo_bits_per_byte = 8U , k_crc_demo_nibble_mask = 0x0FU , k_crc_demo_nibble_shift = 4U , k_crc_demo_alpha_thresh = 10U , k_crc_demo_payload_len = 16U , k_crc_demo_hex_per_word = 8U } |
| Inner-loop bit count for the software CRC. More... | |
Functions | |
| static void | crc_demo_panic_halt (void) |
| Park the CPU forever after a fatal init failure. | |
| static uint8_t | crc_demo_nibble_to_hex (uint8_t nibble) |
| Convert the low nibble of n to its ASCII hex char. | |
| static void | crc_demo_word_to_hex (uint32_t v, uint8_t *dst) |
| Render a 32-bit value as 8 ASCII hex chars (big-endian). | |
| static uint32_t | crc_demo_sw_crc32 (const uint8_t *data, uint32_t len) |
| Software reference CRC-32 (IEEE 802.3, reflected). | |
| static void | crc_demo_setup_or_halt (void) |
| Bring CGC + SysTick + SCI8 + LEDs + CRC unit up. | |
| static ra8_err_t | crc_demo_one_iter (uint8_t *out_match) |
| One iteration: compute hw + sw CRC and emit the comparison line. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | k_crc_demo_payload [k_crc_demo_payload_len] |
| Fixed 16-byte test payload. | |
| static const uint8_t | k_crc_demo_prefix [] = "crc: hw=" |
| Output line tags. | |
| static const uint8_t | k_crc_demo_sw_tag [] = " sw=" |
| static const uint8_t | k_crc_demo_ok_tag [] = " match=Y\r\n" |
| static const uint8_t | k_crc_demo_bad_tag [] = " match=N\r\n" |
| static const uint8_t | k_crc_demo_pass_msg [] = "crc: selftest PASS\r\n" |
| Self-test verdict emitted only on a hw==sw match (success-only). | |
CRC-32 hardware vs.
software cross-check demo for the EK-RA8D2
Brings up CGC + SysTick + SCI8 + LED1 + the on-chip CRC unit (CRC-32 / IEEE 802.3 polynomial). Once a second computes the CRC over a fixed 16-byte test buffer two ways:
Emits "crc: hw=XXXXXXXX sw=XXXXXXXX match=Y\r\n" on the J-Link OB CDC channel and toggles LED1 on every match. On a match it also emits the fixed verdict line "crc: selftest PASS\r\n" (success-only – never printed on the match=N path), which the HIL scrape keys on. LED2 latches if the two ever diverge.
Bare EK-RA8D2 only – no shields or external transceiver.
Definition in file main.c.
| enum crc_demo_byte_t : uint8_t |
Inner-loop bit count for the software CRC.
| enum crc_demo_config_t : uint32_t |
| enum crc_demo_sw_const_t : uint32_t |
|
static |
Convert the low nibble of n to its ASCII hex char.
| [in] | nibble | Lower 4 bits used; upper 4 bits ignored. |
Definition at line 115 of file main.c.
References k_crc_demo_alpha_thresh, and k_crc_demo_nibble_mask.
Referenced by crc_demo_word_to_hex().
|
staticnodiscard |
One iteration: compute hw + sw CRC and emit the comparison line.
| [out] | out_match | Receives 1 if hw == sw, 0 otherwise. |
| k_ra8_ok | Comparison line emitted; *out_match valid. |
| k_ra8_err_hw_error | Hardware CRC compute failed. |
Definition at line 233 of file main.c.
References crc_demo_sw_crc32(), crc_demo_word_to_hex(), k_crc_demo_bad_tag, k_crc_demo_hex_per_word, k_crc_demo_ok_tag, k_crc_demo_pass_msg, k_crc_demo_payload, k_crc_demo_payload_len, k_crc_demo_prefix, k_crc_demo_sw_tag, k_ra8_err_hw_error, k_ra8_ok, ra8_board_uart_console_write(), ra8_crc_compute(), and ra8_crc_reset().
Referenced by main().
|
static |
Park the CPU forever after a fatal init failure.
Definition at line 97 of file main.c.
Referenced by crc_demo_setup_or_halt(), and main().
|
static |
Bring CGC + SysTick + SCI8 + LEDs + CRC unit up.
Definition at line 187 of file main.c.
References crc_demo_panic_halt(), k_crc_demo_baud, k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_crc_poly_32_ieee802_3, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_crc_init(), and ra8_time_init().
Referenced by main().
|
static |
Software reference CRC-32 (IEEE 802.3, reflected).
Bit-serial Sarwate-style implementation; no lookup table so we keep the code review-able and avoid pulling in 1 KB of constants for a HIL test app. Matches the hardware CRC unit when the latter is configured for k_ra8_crc_poly_32_ieee802_3 with the standard preset / xor-out.
| [in] | data | Pointer to len bytes (non-NULL). |
| [in] | len | Byte count. |
Definition at line 170 of file main.c.
References k_crc_demo_bits_per_byte, k_crc_demo_lsb_mask, k_crc_demo_sw_init, k_crc_demo_sw_poly_rev, and k_crc_demo_sw_xor_out.
Referenced by crc_demo_one_iter().
|
static |
Render a 32-bit value as 8 ASCII hex chars (big-endian).
| [in] | v | Value to render. |
| [out] | dst | 8-byte buffer that receives the hex characters. |
Definition at line 135 of file main.c.
References crc_demo_nibble_to_hex(), k_crc_demo_hex_per_word, k_crc_demo_nibble_mask, and k_crc_demo_nibble_shift.
Referenced by crc_demo_one_iter().
| 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.
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.
Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.
The application entry point Reset_Handler hands control to.
Brings up logging and the clock tree, releases the Cortex-M33 (which then blinks LED1 via ra8_pcntr_set_output()), and idles. See the file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the cacheable-SRAM round-trip with the D-cache that SystemInit() enabled through ra8_cache_dcache_enable(), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU + RA8_BOOT_CACHE_VIA_HAL).
The application entry point Reset_Handler hands control to.
Publishes the mailbox, releases the Cortex-M33 into the emitter, yields until it signals done, validates the blob the M33 built, then logs the PASS/FAIL verdict and the chapter count read back from the blob. See the file header for the offload narrative.
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.
Publishes the mailbox, arms the IPC0 wake and configures the LPM block, releases the Cortex-M33 into the reader, waits for the first held page, logs the page-0 verdict, then runs the #150 mode-switch cycle – parking in low-power WFI and waking on the M33's page-turn pokes – before logging the handoff verdict and parking for good. See the file header for the narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the timebase then measures forever.
The application entry point Reset_Handler hands control to.
Arms the RIIC1 target and polls the dispatcher.
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.
Brings up the LIN commander then drives frames.
The application entry point Reset_Handler hands control to.
Brings up logging, "renders" page 0 into the shared mailbox, releases the Cortex-M33 into its hold loop, and parks the M85 in low-power WFI sleep. See the file header for the power-saving narrative.
The application entry point Reset_Handler hands control to.
The USB clock, pins, console, and the SD card all come up before the kernel so the worker only deals with USB stack bring-up.
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.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (MPU enabled, canonical boot map, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the wear-levelling + power-cycle-survival flow, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the program/erase round-trip, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then runs the full ra8_io VFS round-trip over the native-SDHI 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.
Brings up the console and both stdio sinks, retargets the engine's stdio to the in-RAM capture sink, runs the two-backend swap, replays the RAM capture out of the UART, and prints a single PASS/FAIL verdict per abstraction before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then writes + reads + compares one raw 512-byte block straight against ra8_sdcard. On success it prints the exact PASS banner; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII + RSIP, then ThreadX.
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.
Initializes and arms ADC_B, formats each successful channel sample without variadic I/O, emits the verdict, toggles LED1, and delays.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, releases the Cortex-M33 (which then blinks LED1), and idles. See the file header for the teaching narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See the file header for the full behaviour summary.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (cacheable SRAM, RO MRAM const, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches and MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU).
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Lights HOCO + PLL, then runs a 1 Hz blink.
The application entry point Reset_Handler hands control to.
See file header for behaviour summary.
Definition at line 262 of file main.c.
References crc_demo_one_iter(), crc_demo_panic_halt(), crc_demo_setup_or_halt(), k_crc_demo_period_ms, k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().
|
static |
Definition at line 91 of file main.c.
Referenced by crc_demo_one_iter().
|
static |
Definition at line 90 of file main.c.
Referenced by crc_demo_one_iter().
|
static |
Self-test verdict emitted only on a hw==sw match (success-only).
Definition at line 94 of file main.c.
Referenced by crc_demo_one_iter().
|
static |
Fixed 16-byte test payload.
Definition at line 68 of file main.c.
Referenced by crc_demo_one_iter().
|
static |
|
static |
Definition at line 89 of file main.c.
Referenced by crc_demo_one_iter().