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

CPU0 (Cortex-M85 primary core) driver for the low-power hold-page demo. More...

#include <stdint.h>
#include "lowpower_holdpage.h"
#include "ra8_boot_entry.h"
#include "ra8_dual_core.h"
#include "ra8_err.h"
#include "ra8_log.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  m85_lowpower_const_t : uint32_t { k_m85_park_log_every = 240U }
 Pacing for the parked-M85 narration. More...

Functions

static void render_page0 (volatile lowpower_mailbox_t *mb)
 "Render" page 0 and publish it to the M33 via the shared mailbox.
static void park_low_power (volatile lowpower_mailbox_t *mb)
 Park the M85 in low-power WFI sleep, narrating the M33's hold loop.
static void park_forever (void)
 Park the M85 forever after an unrecoverable startup failure.
void main (void)
 CPU0 (Cortex-M85) application entry.

Variables

uint32_t g_ra8_ls_cpu1_mram_start
 Base of the embedded M33 image / its vector table (MRAM_CPU1).
uint32_t g_ra8_ls_cpu1_stack_top
 Initial stack pointer handed to the M33 at release.

Detailed Description

CPU0 (Cortex-M85 primary core) driver for the low-power hold-page demo.

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

This is the firmware that runs on the RA8D2's primary core, the Cortex-M85, out of reset. It demonstrates the #150 power-saving model: for a static e-reader page (text shown, waiting for a tap or a page-turn) the M85 @ 1 GHz is wasted, so the M85 hands the page to the M33 @ 250 MHz and PARKS. The slow core is plenty to hold a rendered page and service the user switch, at a fraction of the power – "power saving = drop to the slow core".

What the M85 does here:

  1. "Renders" page 0. A real GLCDC render is M85-heavy and out of scope for this plumbing demo, so a page marker written into the shared mailbox (see lowpower_holdpage.h) stands in for the rendered framebuffer.
  2. Releases the Cortex-M33 with ra8_cpu1_release (HUM Ch 2.9.1) into its hold loop, then PARKS in a WFI sleep – the low-power posture. From here the M33 owns the page.

The wake path – the M33 signalling the M85 to spin back up for a heavy re-render (opening or compiling a book, see #149) – is the remaining piece tracked in #150; this example lands the M85-parks / M33-holds foundation.

Note
ra8_log_info is compiled to a no-op unless the build defines INFO-level logging (a Debug build). The M33 cannot print in the emulator (ra8_emulator echoes only the primary core's ITM), so the M85 narrates the M33's hold heartbeat from the shared mailbox; a climbing heartbeat is honest proof the M33 is the live core while the M85 sleeps.
Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ m85_lowpower_const_t

enum m85_lowpower_const_t : uint32_t

Pacing for the parked-M85 narration.

While parked the M85 wakes from WFI, reads the M33's hold heartbeat, and re-sleeps. It logs only every Nth wake so the [itm] stream stays readable rather than flooded.

Since
0.1.0
Enumerator
k_m85_park_log_every 

Log the M33 heartbeat every Nth WFI wake.

Definition at line 60 of file main.c.

Function Documentation

◆ main()

void main ( void )

CPU0 (Cortex-M85) application entry.

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.

Precondition
SystemInit has completed core bring-up.
The M33 is held inactive by hardware until released here.
Postcondition
The M33 owns 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

Definition at line 161 of file main.c.

References g_ra8_ls_cpu1_mram_start, g_ra8_ls_cpu1_stack_top, k_ra8_ok, lowpower_mailbox(), park_forever(), park_low_power(), ra8_cpu1_release(), ra8_log_info, ra8_log_info_val, ra8_log_init(), and render_page0().

◆ park_forever()

void park_forever ( void )
static

Park the M85 forever after an unrecoverable startup failure.

Returns
This function never returns.
Note
The core spins in place.
Precondition
A fatal error (e.g. CPU1 release failure) has occurred.
The failure has already been logged.
Postcondition
The M85 makes no further forward progress.
No mailbox state changes.
Note
Distinct from park_low_power: this is an error halt, not the intended low-power sleep.
Since
0.1.0

Definition at line 139 of file main.c.

◆ park_low_power()

void park_low_power ( volatile lowpower_mailbox_t * mb)
static

Park the M85 in low-power WFI sleep, narrating the M33's hold loop.

Parameters
[in]mbPointer to the shared mailbox.
Returns
This function never returns.
Note
The M85 sleeps until power-off (or, in a future revision, an M33 wake interrupt for a heavy re-render).
Precondition
mb is the fixed-address mailbox pointer (never NULL).
The M33 has been released and owns the page.
Postcondition
The M85 spends its time in WFI, not busy-spinning (the power win).
Every k_m85_park_log_every wakes, one liveness line is logged.
Note
On silicon WFI sleeps until an interrupt; with no wake source wired yet the M85 stays asleep, which is exactly the low-power posture. In ra8_emulator WFI fast-forwards, so the narration still advances.
Since
0.1.0

Definition at line 111 of file main.c.

References k_m85_park_log_every, lowpower_mailbox_t::m33_heartbeat, and ra8_log_info_val.

◆ render_page0()

void render_page0 ( volatile lowpower_mailbox_t * mb)
static

"Render" page 0 and publish it to the M33 via the shared mailbox.

Parameters
[out]mbPointer to the shared mailbox.
Returns
Nothing.
Precondition
mb is the fixed-address mailbox pointer (never NULL).
Called before ra8_cpu1_release so the M33 sees a published page.
Postcondition
page_num, active_core, and magic describe a held page owned by the M33, with the counters zeroed.
A dsb has drained the writes to shared SRAM before the M33 starts.
Note
A GLCDC render is M85-heavy; the page marker stands in for it.
Since
0.1.0

Definition at line 80 of file main.c.

References lowpower_mailbox_t::active_core, k_lowpower_core_m33, k_lowpower_magic, lowpower_mailbox_t::m33_heartbeat, lowpower_mailbox_t::magic, lowpower_mailbox_t::page_num, and lowpower_mailbox_t::sw1_events.

Referenced by main().

Variable Documentation

◆ g_ra8_ls_cpu1_mram_start

uint32_t g_ra8_ls_cpu1_mram_start
extern

Base of the embedded M33 image / its vector table (MRAM_CPU1).

◆ g_ra8_ls_cpu1_stack_top

uint32_t g_ra8_ls_cpu1_stack_top
extern

Initial stack pointer handed to the M33 at release.