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

Minimal copy-to-run payload – one image that runs from the SRAM run base. More...

#include <stdint.h>
Include dependency graph for payload.c:

Go to the source code of this file.

Enumerations

enum  payload_probe_t : uintptr_t {
  k_payload_probe_sentinel = 0x22010000U ,
  k_payload_probe_counter = 0x22010004U
}
 Fixed SRAM probe words the bootloader leaves untouched. More...
enum  payload_sentinel_t : uint32_t { k_payload_sentinel_value = 0x9710C0DEU }
 Sentinel value ("#97 1 code"): this payload ran via copy-to-run. More...

Functions

void payload_reset (void)
 Payload reset entry: set the sentinel, then advance a heartbeat forever.

Variables

uint32_t g_ra8_ls_stack_top
 Initial-MSP symbol, defined by payload.ld at the top of the run region.
static const uintptr_t s_vectors [2]
 2-entry vector table: initial MSP + reset, at the image base.

Detailed Description

Minimal copy-to-run payload – one image that runs from the SRAM run base.

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

A tiny, self-contained application linked ONCE at the dfu_bootloader's SRAM run base (k_ra8_dfu_run_base = 0x22020000, see payload.ld). A copy-to-run launcher (ra8_dfu_launch) copies this image to that base and branches here, so the IDENTICAL .bin is bootable from Slot A or Slot B – the proof that copy-to-run removes the per-slot build (issue #97). It backs both the dfu_copy_to_run HIL demo (which embeds and launches it) and the bench staging of ../dfu_bootloader (which stages it into a real slot).

On entry it writes a distinctive sentinel and then advances a heartbeat counter forever, both at a fixed probe word that sits between the bootloader's low .bss and the run base (so neither the bootloader nor this image's copy touches it). A J-Link probe of those two words – plus a PC inside the SRAM run window – confirms the image ran via copy-to-run. Interrupts stay masked (the launcher masked them before the hand-off and this payload never re-enables them), so the 2-entry vector table is sufficient.

Build with examples/ek_ra8d2/hw_validated/hil/dfu_copy_to_run/scripts/ build_payload.sh (also emits payload_image.h for the demo).

Author
Brighton Sikarskie
Date
2026-06-16
Since
0.1.0

Definition in file payload.c.

Enumeration Type Documentation

◆ payload_probe_t

enum payload_probe_t : uintptr_t

Fixed SRAM probe words the bootloader leaves untouched.

0x22010000 lies above the bootloader's low-SRAM footprint and below the run base, so it is owned by neither the bootloader nor this image.

Enumerator
k_payload_probe_sentinel 

Sentinel word (proof-of-run).

k_payload_probe_counter 

Heartbeat counter (liveness).

Definition at line 43 of file payload.c.

◆ payload_sentinel_t

enum payload_sentinel_t : uint32_t

Sentinel value ("#97 1 code"): this payload ran via copy-to-run.

Enumerator
k_payload_sentinel_value 

Distinctive proof-of-run value.

Definition at line 49 of file payload.c.

Function Documentation

◆ payload_reset()

void payload_reset ( void )

Payload reset entry: set the sentinel, then advance a heartbeat forever.

Returns
Does not return.
Precondition
A copy-to-run launcher copied this image to k_ra8_dfu_run_base and set MSP.
Interrupts are masked (the launcher masked them before the hand-off).
Postcondition
The sentinel word holds k_payload_sentinel_value.
The heartbeat counter advances continuously.
Note
Bare entry: no C runtime, no .data/.bss (writes go to fixed addresses).
Non-static so the linker ENTRY(payload_reset) resolves (the launcher actually branches via the vector table, not the ELF entry).
Since
0.1.0

Definition at line 70 of file payload.c.

References k_payload_probe_counter, k_payload_probe_sentinel, and k_payload_sentinel_value.

Variable Documentation

◆ g_ra8_ls_stack_top

uint32_t g_ra8_ls_stack_top
extern

Initial-MSP symbol, defined by payload.ld at the top of the run region.

◆ s_vectors

const uintptr_t s_vectors[2]
static
Initial value:
= {
(uintptr_t)&g_ra8_ls_stack_top,
(uintptr_t)&payload_reset,
}
uint32_t g_ra8_ls_stack_top
void payload_reset(void)
Payload reset entry: set the sentinel, then advance a heartbeat forever.
Definition payload.c:70

2-entry vector table: initial MSP + reset, at the image base.

The launcher reads [0] as the initial MSP and branches to [1]; the reset entry keeps its Thumb bit because it is a function address.

Since
0.1.0

Definition at line 89 of file payload.c.