ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
38
39#include <stdint.h>
40
41#include "lowpower_holdpage.h"
42#include "ra8_boot_entry.h"
43#include "ra8_dual_core.h"
44#include "ra8_err.h"
45#include "ra8_log.h"
46
48extern uint32_t g_ra8_ls_cpu1_mram_start;
50extern uint32_t g_ra8_ls_cpu1_stack_top;
51
60typedef enum : uint32_t {
63
80static void render_page0(volatile lowpower_mailbox_t* mb)
81{
82 mb->magic = 0U;
83 mb->page_num = 0U;
84 mb->active_core = (uint32_t)k_lowpower_core_m33;
85 mb->m33_heartbeat = 0U;
86 mb->sw1_events = 0U;
87 __asm volatile("dsb" ::: "memory");
88 mb->magic = (uint32_t)k_lowpower_magic;
89 __asm volatile("dsb" ::: "memory");
90}
91
111[[noreturn]] static void park_low_power(volatile lowpower_mailbox_t* mb)
112{
113 (void)mb; /* Read only inside ra8_log_info_val(), which a non-Debug build elides. */
114 uint32_t wakes = 0U;
115 while (1) {
116 __asm volatile("wfi");
117 wakes++;
118 if ((wakes % (uint32_t)k_m85_park_log_every) == 0U) {
119 ra8_log_info_val("M85", "parked (WFI); M33 hold heartbeat", mb->m33_heartbeat);
120 }
121 }
122}
123
139[[noreturn]] static void park_forever(void)
140{
141 while (1) {
142 __asm volatile("nop");
143 }
144}
145
161void main(void)
162{
163 ra8_log_init();
164 ra8_log_info("M85", "==== RA8D2 low-power hold-page demo ====");
165 ra8_log_info("M85", "Cortex-M85 primary core online");
166 ra8_log_info("M85", "mailbox in shared SRAM at 0x22100000");
167
168 volatile lowpower_mailbox_t* mb = lowpower_mailbox();
169 render_page0(mb);
170 ra8_log_info("M85", "rendered page 0; handing the held page to the M33");
171
172 ra8_log_info("M85", "releasing Cortex-M33 secondary core ...");
174 ra8_log_info_val("M85", "ra8_cpu1_release rc (0 = ok)", (uint32_t)err);
175 if (err != k_ra8_ok) {
176 ra8_log_info("M85", "release FAILED -- halting");
177 park_forever();
178 }
179
180 ra8_log_info("M85", "low-power: page handed to M33; M85 parking (clock-gated posture)");
181 park_low_power(mb);
182}
void main(void)
Secure fallback main entry point.
Definition main.c:37
uint32_t g_ra8_ls_cpu1_mram_start
static void park_low_power(void)
Park the M85 in low-power WFI after the M33 owns the page.
Definition main.c:855
m85_lowpower_const_t
Pacing for the parked-M85 narration.
Definition main.c:60
@ k_m85_park_log_every
Log the M33 heartbeat every Nth WFI wake.
Definition main.c:61
static void render_page0(volatile lowpower_mailbox_t *mb)
"Render" page 0 and publish it to the M33 via the shared mailbox.
Definition main.c:80
uint32_t g_ra8_ls_cpu1_stack_top
Shared-SRAM contract for the low-power "hold the page" dual-core demo.
static volatile lowpower_mailbox_t * lowpower_mailbox(void)
Typed pointer to the fixed-address shared mailbox.
@ k_lowpower_magic
"HOLD" – M85 stamps it when ready.
@ k_lowpower_core_m33
active_core: the M33 holds the page.
Boot entry points shared between a vector table and its startup code.
Dual-core (CPU0 / CPU1) lifecycle helper – public API.
ra8_err_t ra8_cpu1_release(void *entry, void *sp)
Release CPU1 (Cortex-M33) from reset and start it executing.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Lightweight Logging Interface for ra8-firmware.
void ra8_log_init(void)
Initialise the logging backend.
Definition ra8_log.c:379
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Definition ra8_log.h:366
#define ra8_log_info(tag, message)
RA8 log info.
Definition ra8_log.h:364
Cross-core handoff block backed by a fixed shared-SRAM address.
volatile uint32_t page_num
Held page; M85 sets 0, M33 bumps on turn.
volatile uint32_t active_core
Which core owns the page (lowpower_const_t).
volatile uint32_t magic
M85 stamps k_lowpower_magic when ready.
volatile uint32_t m33_heartbeat
M33 increments each hold-loop iteration.
volatile uint32_t sw1_events
M33 counts SW1 (page-turn) press edges.