ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
payload.c
Go to the documentation of this file.
1
34
35#include <stdint.h>
36
43typedef enum : uintptr_t {
47
49typedef enum : uint32_t {
52
54extern uint32_t g_ra8_ls_stack_top;
55
68[[noreturn]] void payload_reset(void);
69
70void payload_reset(void)
71{
72 *(volatile uint32_t*)(uintptr_t)k_payload_probe_sentinel = (uint32_t)k_payload_sentinel_value;
73 volatile uint32_t* const counter = (volatile uint32_t*)(uintptr_t)k_payload_probe_counter;
74 *counter = 0U;
75 /* Heartbeat: advance forever so a J-Link probe sees liveness. Intentional
76 * terminal loop (this is a leaf demo payload, not reusable firmware). */
77 for (;;) {
78 *counter = *counter + 1U;
79 }
80}
81
89[[gnu::section(".vectors"), gnu::used]] static const uintptr_t s_vectors[2] = {
90 (uintptr_t)&g_ra8_ls_stack_top, /* initial MSP */
91 (uintptr_t)&payload_reset, /* reset vector (Thumb bit from the symbol) */
92};
uint32_t g_ra8_ls_stack_top
payload_sentinel_t
Sentinel value ("#97 1 code"): this payload ran via copy-to-run.
Definition payload.c:49
@ k_payload_sentinel_value
Distinctive proof-of-run value.
Definition payload.c:50
static const uintptr_t s_vectors[2]
2-entry vector table: initial MSP + reset, at the image base.
Definition payload.c:89
payload_probe_t
Fixed SRAM probe words the bootloader leaves untouched.
Definition payload.c:43
@ k_payload_probe_counter
Heartbeat counter (liveness).
Definition payload.c:45
@ k_payload_probe_sentinel
Sentinel word (proof-of-run).
Definition payload.c:44
void payload_reset(void)
Payload reset entry: set the sentinel, then advance a heartbeat forever.
Definition payload.c:70