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
29
30#include <stdint.h>
31
32#include "ra8_boot_entry.h"
33#include "ra8_cgc.h"
34#include "ra8_dual_core.h"
35#include "ra8_err.h"
36#include "ra8_log.h"
37
39extern uint32_t g_ra8_ls_cpu1_mram_start;
41extern uint32_t g_ra8_ls_cpu1_stack_top;
42
60[[noreturn]] static void park_forever(void)
61{
62 while (1) {
63 __asm volatile("nop");
64 }
65}
66
86[[noreturn]] static void idle_forever(void)
87{
88 while (1) {
89 __asm volatile("wfi");
90 }
91}
92
107void main(void)
108{
109 /* Publish the clock tree the released M33 shares BEFORE logging comes up --
110 * the console derives its baud from PCLKA, so bringing the clock up second
111 * would fix the baud against the reset clocks. Best-effort: a failure only
112 * changes the busy-loop cadence, not the correctness of the blink, so the
113 * verdict is carried forward and narrated once logging is available. */
114 const ra8_err_t clk_err = ra8_cgc_init();
115
116 ra8_log_init();
117 ra8_log_info("M85", "==== RA8D2 dual-core blink (HAL PCNTR primitive) ====");
118 ra8_log_info("M85", "Cortex-M85 primary core online");
119 if (clk_err != k_ra8_ok) {
120 ra8_log_info("M85", "clock init failed -- continuing at reset clocks");
121 }
122
123 ra8_log_info("M85", "releasing Cortex-M33 secondary core ...");
125 ra8_log_info_val("M85", "ra8_cpu1_release rc (0 = ok)", (uint32_t)err);
126 if (err != k_ra8_ok) {
127 ra8_log_info("M85", "release FAILED -- halting");
128 park_forever();
129 }
130
131 ra8_log_info("M85", "M33 released -- it now blinks LED1 via ra8_pcntr_set_output()");
132 ra8_log_info("M85", "M85 entering WFI idle -- low-power co-processor model");
133 idle_forever();
134}
void main(void)
Secure fallback main entry point.
Definition main.c:37
uint32_t g_ra8_ls_cpu1_mram_start
uint32_t g_ra8_ls_cpu1_stack_top
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Definition ra8_cgc.c:727
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