ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

GPTP hardware-timer demo – proves the HUM Ch 35 counter really runs. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_cgc.h"
#include "ra8_err.h"
#include "ra8_eth_gptp.h"
#include "ra8_isr.h"
#include "ra8_mstp.h"
#include "ra8_time.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  gptp_const_t : uint32_t {
  k_gptp_baud = 115200U ,
  k_gptp_period_ms = 1000U ,
  k_gptp_window_ms = 500U ,
  k_gptp_base_sec = 1000000000U
}
 Demo tunables. More...
enum  gptp_flatten_limit_t : uint64_t { k_gptp_sec_flatten_max = 18446744073ULL }
 Largest seconds value that can be flattened to nanoseconds. More...
enum  gptp_fmt_t : uint32_t {
  k_gptp_radix = 10U ,
  k_gptp_dec_u64_max = 20U ,
  k_gptp_ns_per_ms = 1000000U ,
  k_gptp_ns_per_sec = 1000000000U
}
 Formatting and arithmetic constants. More...
enum  gptp_band_t : uint8_t {
  k_gptp_tolerance_pct = 10U ,
  k_gptp_pct_full = 100U
}
 Accuracy band the measured advance must fall inside. More...

Functions

static void gptp_panic_halt (void)
 Park forever after a fatal init error.
static void gptp_write (const uint8_t *data, uint32_t len)
 Write a byte span to the SCI8 console, discarding the status.
static void gptp_write_u64 (uint64_t val)
 Log one unsigned 64-bit value as decimal ASCII.
static void gptp_log_time (uint64_t sec, uint32_t nsec)
 Log one gptp: t= line – seconds, a dot, then nanoseconds.
static uint64_t gptp_flatten_ns (uint64_t sec, uint32_t nsec)
 Flatten a GPTP sample to nanoseconds.
static bool gptp_probe_presence (void)
 Read the IP-version word and require it to be nonzero.
static bool gptp_advance_ok (uint64_t advance_ns, uint32_t elapsed_ms)
 Decide whether a measured advance matches the SysTick window.
static bool gptp_measure (void)
 Sample the counter twice around a SysTick-timed window.
static bool gptp_run_cycle (void)
 Run one cycle: presence probe plus one advance measurement.
static void gptp_setup_or_halt (void)
 Core bring-up: CGC -> ESWCLK -> MSTP -> TIME -> console + LED.
static ra8_err_t gptp_arm (void)
 Programme the GPTP timer from the live ESWCLK and start it.
void main (void)
 The application entry point Reset_Handler hands control to.

Variables

static const uint8_t k_gptp_ipv_prefix [] = "gptp: ipv="
static const uint8_t k_gptp_time_prefix [] = "gptp: t="
static const uint8_t k_gptp_time_dot [] = "."
static const uint8_t k_gptp_adv_prefix [] = "gptp: adv_ns="
static const uint8_t k_gptp_sys_prefix [] = " sys_ms="
static const uint8_t k_gptp_crlf [] = "\r\n"
static const uint8_t k_gptp_verdict_pass [] = "gptp: clock PASS\r\n"
static const uint8_t k_gptp_verdict_fail [] = "gptp: clock FAIL\r\n"

Detailed Description

GPTP hardware-timer demo – proves the HUM Ch 35 counter really runs.

Tag
[Ring 6 / APP] {World: S}

Exercises the only PTP-related hardware the RA8D2 actually has: the Ethernet Generic PTP Timer of HUM Ch 35 p 1925-1964. That block is a timer – it has no Sync / Announce generator, no domain, no clockIdentity and no BMCA – so this app makes no claim to be an IEEE 1588 or 802.1AS node. It brings the counter up and then measures it.

Bring-up (CGC -> ESWCLK -> MSTP -> TIME -> peripheral):

  1. CGC + SysTick + UART console (SCI8 on PD_02 / PD_03 -> J-Link OB).
  2. ra8_cgc_eswclk_init powers the ESWM domain and starts ESWCLK, which is the GPTP clk input.
  3. ra8_eth_gptp_init derives PTPTIVCt from the live ESWCLK frequency, then the app loads a known epoch into the 78-bit offset and enables timer 0.

Per cycle the app:

  • reads the read-only PTPIPV IP-version word and requires it to be nonzero. That is the presence probe: a reserved aperture reads back zeroes or whatever was last written, while PTPIPV has a nonzero reset value (HUM 35.3.1.1 p 1927);
  • samples the 78-bit GPTP time, waits k_gptp_window_ms measured on SysTick, samples it again, and requires the counter to have advanced by that interval to within k_gptp_tolerance_pct.

The verdict "gptp: clock PASS" therefore means the counter advanced one second per second against an independent time base – not merely that a driver call returned k_ra8_ok.

hw_pending: this stays under hw_pending because the full IEEE-1588 / 802.1AS claim (a bounded sync offset against the bench's gPTP peer) can only be made on the bench. Its counter-advance verdict, however, is now gated in the emulator: tools/ra8_emulator models the HUM Ch 35 GPTP timer (board_periph_gptp.c), whose free-running counter really advances one second per second against the emulator's SysTick, so gptp: clock PASS is asserted on every CI run through the emulator-smoke gate as well as on the bench.

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ gptp_band_t

enum gptp_band_t : uint8_t

Accuracy band the measured advance must fall inside.

Enumerator
k_gptp_tolerance_pct 

Allowed drift vs SysTick, in percent.

k_gptp_pct_full 

Denominator for the percentage above.

Definition at line 89 of file main.c.

◆ gptp_const_t

enum gptp_const_t : uint32_t

Demo tunables.

Enumerator
k_gptp_baud 

SCI8 console baud.

k_gptp_period_ms 

Idle time between measurement cycles.

k_gptp_window_ms 

Measurement window, timed on SysTick.

k_gptp_base_sec 

Epoch seconds loaded into the offset.

Definition at line 63 of file main.c.

◆ gptp_flatten_limit_t

enum gptp_flatten_limit_t : uint64_t

Largest seconds value that can be flattened to nanoseconds.

UINT64_MAX / 1e9: above this, sec * 1e9 wraps.

Enumerator
k_gptp_sec_flatten_max 

floor(2^64 - 1 / 1e9).

Definition at line 76 of file main.c.

◆ gptp_fmt_t

enum gptp_fmt_t : uint32_t

Formatting and arithmetic constants.

Enumerator
k_gptp_radix 

Decimal serialiser radix.

k_gptp_dec_u64_max 

Max decimal digits for a uint64_t.

k_gptp_ns_per_ms 

Nanoseconds in one millisecond.

k_gptp_ns_per_sec 

Nanoseconds in one second.

Definition at line 81 of file main.c.

Function Documentation

◆ gptp_advance_ok()

bool gptp_advance_ok ( uint64_t advance_ns,
uint32_t elapsed_ms )
static

Decide whether a measured advance matches the SysTick window.

Parameters
[in]advance_nsNanoseconds the GPTP counter moved.
[in]elapsed_msMilliseconds SysTick measured over the same window.

The band is a percentage of the SysTick-measured interval, so it scales with the window and needs no absolute tolerance constant. band_ns can never exceed expected_ns, so the lower comparison cannot underflow.

Returns
True iff the two agree to within k_gptp_tolerance_pct.
Return values
trueThe advance is inside the band.
falseThe advance is outside the band, or no time elapsed.
Precondition
elapsed_ms is nonzero (the caller waited a real interval).
Both arguments describe the same measurement window.
Postcondition
No hardware was touched.
The result is false whenever the counter did not move.
Note
Pure and re-entrant.
Since
0.1.0

Definition at line 306 of file main.c.

References k_gptp_ns_per_ms, k_gptp_pct_full, and k_gptp_tolerance_pct.

Referenced by gptp_measure().

◆ gptp_arm()

ra8_err_t gptp_arm ( void )
staticnodiscard

Programme the GPTP timer from the live ESWCLK and start it.

Reads the ESWCLK frequency published by ra8_cgc_eswclk_init, hands it to ra8_eth_gptp_init (which derives PTPTIVCt), loads k_gptp_base_sec into the 78-bit offset and enables the timer unit.

Returns
ra8_err_t error code from the first failing step.
Return values
k_ra8_okThe counter is programmed and running.
OtherForwarded from the failing driver call.
Precondition
gptp_setup_or_halt has started ESWCLK and ungated MSTP.
IRQs are masked or this is single-threaded init.
Postcondition
On k_ra8_ok timer unit 0 is counting.
On failure no partial GPTP state is relied upon by the caller.
Note
Boot-time only; not re-entrant.
Since
0.1.0

Definition at line 465 of file main.c.

References k_gptp_base_sec, k_ra8_gptp_timer_0, k_ra8_ok, ra8_cgc_eswclk_hz(), ra8_eth_gptp_init(), ra8_eth_gptp_set_offset(), and ra8_eth_gptp_timer_enable().

Referenced by main().

◆ gptp_flatten_ns()

uint64_t gptp_flatten_ns ( uint64_t sec,
uint32_t nsec )
static

Flatten a GPTP sample to nanoseconds.

The seconds field is 48 bits wide, so sec * 1e9 would wrap a uint64_t above sec ~= 1.8e10. That is far beyond any epoch this demo loads, but it is a value read straight off a hardware register, so an implausible reading is clamped to UINT64_MAX rather than silently wrapped into a small number that could look like a healthy advance.

Parameters
[in]secSeconds field.
[in]nsecNanoseconds field.
Returns
The sample as a nanosecond count, or UINT64_MAX if sec is too large to flatten.
Precondition
nsec is below one second.
sec came from ra8_eth_gptp_get_time (48-bit range).
Postcondition
The result is monotonic in sec and nsec.
No hardware was touched.
Note
Pure and re-entrant.
Since
0.1.0

Definition at line 242 of file main.c.

References k_gptp_ns_per_sec, and k_gptp_sec_flatten_max.

Referenced by gptp_measure().

◆ gptp_log_time()

void gptp_log_time ( uint64_t sec,
uint32_t nsec )
static

Log one gptp: t= line – seconds, a dot, then nanoseconds.

Prints the two fields verbatim rather than converting to a single nanosecond count, so a bench operator sees exactly what the registers held.

Parameters
[in]secSeconds field of a GPTP sample.
[in]nsecNanoseconds field of the same sample.
Precondition
The console has been initialised.
nsec is below one second.
Postcondition
One timestamp line has been queued.
No driver state was mutated.
Note
Not thread-safe; single-threaded demo loop.
Since
0.1.0

Definition at line 209 of file main.c.

References gptp_write(), gptp_write_u64(), k_gptp_crlf, k_gptp_time_dot, and k_gptp_time_prefix.

Referenced by gptp_measure().

◆ gptp_measure()

bool gptp_measure ( void )
static

Sample the counter twice around a SysTick-timed window.

Returns
True iff both samples read back and the advance matched SysTick.
Return values
trueThe counter advanced by the measured interval.
falseA read failed, or the counter did not track SysTick.
Precondition
gptp_arm enabled timer unit 0.
The console has been initialised.
Postcondition
Two timestamp lines plus one gptp: adv_ns= line were queued.
No GPTP configuration was changed.
Note
Not thread-safe; single-threaded demo loop.
Since
0.1.0

Definition at line 335 of file main.c.

References gptp_advance_ok(), gptp_flatten_ns(), gptp_log_time(), gptp_write(), gptp_write_u64(), k_gptp_adv_prefix, k_gptp_crlf, k_gptp_sys_prefix, k_gptp_window_ms, k_ra8_gptp_timer_0, k_ra8_ok, ra8_delay_ms(), ra8_eth_gptp_get_time(), and ra8_time_ms().

Referenced by gptp_run_cycle().

◆ gptp_panic_halt()

void gptp_panic_halt ( void )
static

Park forever after a fatal init error.

wfi in a bare loop rather than a spin so the part idles cold while a bench operator attaches a debugger.

Precondition
Called only after an unrecoverable bring-up failure.
The caller has already reported the cause it can report.
Postcondition
CPU is parked; only a debugger or reset wakes it.
No further console output is produced.
Note
Never returns; safe from any context.
Since
0.1.0

Definition at line 120 of file main.c.

Referenced by gptp_setup_or_halt(), and main().

◆ gptp_probe_presence()

bool gptp_probe_presence ( void )
static

Read the IP-version word and require it to be nonzero.

A reserved aperture either reads 0 or echoes the last write; PTPIPV is read-only with a nonzero reset value (HUM 35.3.1.1 p 1927), so a nonzero read is evidence the GPTP block is really mapped here.

Returns
True iff the register read succeeded and returned nonzero.
Return values
truePTPIPV read back a nonzero version word.
falseThe read failed, or the aperture returned 0.
Precondition
ra8_eth_gptp_init has succeeded.
The console has been initialised.
Postcondition
One gptp: ipv= line has been queued.
No GPTP state was mutated.
Note
Not thread-safe; single-threaded demo loop.
Since
0.1.0

Definition at line 270 of file main.c.

References gptp_write(), gptp_write_u64(), k_gptp_crlf, k_gptp_ipv_prefix, k_ra8_ok, and ra8_eth_gptp_ip_version().

Referenced by gptp_run_cycle().

◆ gptp_run_cycle()

bool gptp_run_cycle ( void )
static

Run one cycle: presence probe plus one advance measurement.

Both halves run unconditionally so one log block always appears, even when the first check has already failed – a bench operator needs the numbers from the failing cycle, not just the verdict.

Returns
True iff both checks passed.
Return values
truePresence probe and advance measurement both held.
falseAt least one of them did not.
Precondition
gptp_arm has succeeded.
The console has been initialised.
Postcondition
One log block has been queued.
No driver was closed or reconfigured by the cycle.
Note
Not thread-safe; single-threaded demo loop.
Since
0.1.0

Definition at line 392 of file main.c.

References gptp_measure(), and gptp_probe_presence().

Referenced by main().

◆ gptp_setup_or_halt()

void gptp_setup_or_halt ( void )
static

Core bring-up: CGC -> ESWCLK -> MSTP -> TIME -> console + LED.

ESWCLK comes last because ra8_cgc_eswclk_init powers the ESWM domain and needs HOCO and the PLL already stable.

Precondition
Reset defaults are in force (single-threaded boot context).
No peripheral has been claimed yet.
Postcondition
On return every core clock, ESWCLK, console and LED is live.
Any failure parks the CPU via gptp_panic_halt.
Note
Boot-time only; not re-entrant.
Since
0.1.0

Definition at line 419 of file main.c.

References gptp_panic_halt(), k_gptp_baud, k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_eswclk_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().

Referenced by main().

◆ gptp_write()

void gptp_write ( const uint8_t * data,
uint32_t len )
static

Write a byte span to the SCI8 console, discarding the status.

Parameters
[in]dataNon-NULL byte span to transmit.
[in]lenByte count (0 is a no-op).

The console status is discarded deliberately: this app's verdict is about the GPTP counter, and a UART hiccup must not be reported as a clock fault.

Precondition
ra8_board_uart_console_init has succeeded.
data points at len readable bytes.
Postcondition
len bytes have been queued to the console UART.
No driver state was mutated.
Note
Not thread-safe; single-threaded demo loop.
Since
0.1.0

Definition at line 145 of file main.c.

References ra8_board_uart_console_write().

Referenced by gptp_log_time(), gptp_measure(), gptp_probe_presence(), gptp_write_u64(), and main().

◆ gptp_write_u64()

void gptp_write_u64 ( uint64_t val)
static

Log one unsigned 64-bit value as decimal ASCII.

Parameters
[in]valValue to print.

Digits are generated least-significant first into a scratch buffer and reversed, so no division-by-power-of-ten table is needed. Both buffers are k_gptp_dec_u64_max bytes, the exact width of UINT64_MAX at k_gptp_radix, which is what bounds the generate loop.

Precondition
The console has been initialised.
val fits in a uint64_t (always true).
Postcondition
The decimal digits of val have been queued to the console.
Neither scratch buffer outlives the call.
Note
Not thread-safe; single-threaded demo loop.
Since
0.1.0

Definition at line 169 of file main.c.

References gptp_write(), k_gptp_dec_u64_max, and k_gptp_radix.

Referenced by gptp_log_time(), gptp_measure(), and gptp_probe_presence().

◆ 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.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has configured the clock tree and VTOR.
Postcondition
Control does not return; the image runs until reset or halt.
Any value the application wanted to report has been logged, not returned.
Note
Not thread-safe; single-threaded startup context only.
Warning
Only valid while the translation unit is compiled -ffreestanding. A hosted build rejects this signature.
See also
SystemInit()
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up CGC + BSP audio then plays blocks.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the playback loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up CGC + GPT triple, runs sweep.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the sweep loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up clocks + UART + RMII pins, then ThreadX.

Precondition
Reset_Handler has copied .data and zeroed .bss.
Postcondition
On clean entry the kernel runs the worker thread once.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up clocks + UART, then enters ThreadX.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the kernel runs the worker thread forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up LED, console, SDHI pins, then ThreadX.

Precondition
Reset_Handler has copied .data + zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
CPUCLK0 is raised to the PLL1 target before the kernel starts.
On clean entry the SD card thread runs forever.
On any HAL init failure the function halts in __WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the iso-IN feed loop forever.
On any HAL init failure the function halts in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
SystemInit set VTOR / FPU / priority grouping.

The application entry point Reset_Handler hands control to.

See file header.

Precondition
Boot init has completed.
The secure-boot library's BLXNS into NS image either failed or was skipped (the call site in ra8_trustzone_init is a no-op on host builds).
Postcondition
Diagnostic counter latched, CPU parked in a halt loop.
Function never returns.
Note
Single-threaded entry.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success g_eoh_chapters / g_eoh_crc hold the parsed results, the banner is emitted, and g_eoh_heartbeat advances once per frame.
On any failure g_eoh_err is non-zero and the CPU parks (no heartbeat).
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The chapters/ch0-CRC banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the g_etoc_* result globals hold the parsed TOC values, the banner is emitted, and g_etoc_heartbeat advances once per frame.
On any failure g_etoc_err is non-zero and the CPU parks (no heartbeat).
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss; SystemInit set VTOR/FPU.
Postcondition
The shelf scans on the panel; taps open books, browse, and read.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The slab/arena/tile/vmem banner is emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the cache globals are latched and g_pc_heartbeat advances.
On any failure g_pc_err is non-zero and the CPU parks (no heartbeat).
Since
0.1.0

The application entry point Reset_Handler hands control to.

Profiles power modes once a second.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the profile + blink loop.
On any HAL hard error LED2 latches ON.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
The shared board boot files installed the vector table.
Postcondition
The demo has run once and its verdict banner is streaming steadily.
The CPU idles re-emitting the banner (or halts after a fatal init error).
Since
0.1.0

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.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On a clean run the CPU loops forever after the PASS banner.
On any failure the function prints FAIL and halts in WFI.
Note
Not thread-safe; this is the single-threaded app entry.
Since
0.1.0

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.

Precondition
SystemInit configured VTOR / FPU / priority grouping.
The OSPI NOR array is present (modelled in ra8_emulator, real on silicon).
Postcondition
Exactly one PASS or FAIL verdict line has been queued on SCI8.
Control parks in an infinite loop; the function never returns.
Note
Single-threaded; runs to the park loop on the main stack.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The page-count + render-hash banner is emitted; the CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The cal=OK / cal=SKIP result and the finger-free touchcal: ready sentinel are emitted; the CPU then loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The open=OK touch banner is emitted; the CPU then loops in WFI.
Since
0.1.0

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.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR, FPU, priority grouping.
Postcondition
On clean entry the CPU stays in tx_kernel_enter forever.
On any HAL init failure the function halts in WFI.
Note
Single entry point; not re-entrant.
Since
0.1.0

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held in reset by hardware until released here.
Postcondition
The M33 has been released and is blinking LED1.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this template.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
The application links ra8_c6link and ESP-hosted generated codecs.
No hardware validation is inferred from this function.
Postcondition
No c6link operation is attempted.
No network or storage state is modified.
Note
Single-threaded compile fixture.
Since
0.1.0

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).

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit enabled the MPU + I-cache + D-cache via the ra8_cache HAL.
Postcondition
Exactly one banner (PASS or FAIL) has been emitted.
The core is parked in WFI.
Note
Single-threaded; no RTOS and no IRQ sources in this template.
Since
0.1.0

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held inactive by hardware until released here.
Postcondition
The M33 has built a RABOOK1 blob and the M85 has validated it.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this example.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
On success the CPU heartbeats after epaper: PASS.
On any HAL error the console prints epaper: FAIL and the red LED latches on.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The chapters/toc/cover banner is emitted; CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The reader loop runs forever, redrawing on each tap.
A page-1 banner is emitted once after the first render.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The cover-size / framebuffer-CRC banner is emitted; CPU loops in WFI.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The panel shows the reader screen and the input loop runs forever.
Since
0.1.0

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held inactive by hardware until released here.
Postcondition
The M33 has rendered + re-rendered the held page and the M85 is parked.
This function never returns to its caller.
Note
Single-threaded; no RTOS on the M85 in this example.
Since
0.1.0

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The boot banner is emitted; the reader loop services taps forever.
Since
0.1.0

Definition at line 485 of file main.c.

References gptp_arm(), gptp_panic_halt(), gptp_run_cycle(), gptp_setup_or_halt(), gptp_write(), k_gptp_period_ms, k_gptp_verdict_fail, k_gptp_verdict_pass, k_ra8_board_led1, k_ra8_ok, ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().

Variable Documentation

◆ k_gptp_adv_prefix

const uint8_t k_gptp_adv_prefix[] = "gptp: adv_ns="
static

Definition at line 99 of file main.c.

Referenced by gptp_measure().

◆ k_gptp_crlf

const uint8_t k_gptp_crlf[] = "\r\n"
static

Definition at line 101 of file main.c.

Referenced by gptp_log_time(), gptp_measure(), and gptp_probe_presence().

◆ k_gptp_ipv_prefix

const uint8_t k_gptp_ipv_prefix[] = "gptp: ipv="
static

Definition at line 96 of file main.c.

Referenced by gptp_probe_presence().

◆ k_gptp_sys_prefix

const uint8_t k_gptp_sys_prefix[] = " sys_ms="
static

Definition at line 100 of file main.c.

Referenced by gptp_measure().

◆ k_gptp_time_dot

const uint8_t k_gptp_time_dot[] = "."
static

Definition at line 98 of file main.c.

Referenced by gptp_log_time().

◆ k_gptp_time_prefix

const uint8_t k_gptp_time_prefix[] = "gptp: t="
static

Definition at line 97 of file main.c.

Referenced by gptp_log_time().

◆ k_gptp_verdict_fail

const uint8_t k_gptp_verdict_fail[] = "gptp: clock FAIL\r\n"
static

Definition at line 103 of file main.c.

Referenced by main().

◆ k_gptp_verdict_pass

const uint8_t k_gptp_verdict_pass[] = "gptp: clock PASS\r\n"
static

Definition at line 102 of file main.c.

Referenced by main().