|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
DMAC mem-to-mem coherency HIL proof with the M85 D-cache ENABLED. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cache.h"#include "ra8_cgc.h"#include "ra8_dmac.h"#include "ra8_dmac_regs.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_log.h"#include "ra8_mstp.h"Go to the source code of this file.
Enumerations | |
| enum | dma_coh_config_t : uint32_t { k_dma_coh_baud = 115200U , k_dma_coh_buf_words = 256U , k_dma_coh_poll_limit = 100000U , k_dma_coh_sentinel = 0xA5A5A5A5U } |
| Compile-time settings. More... | |
| enum | dma_coh_byte_t : uint8_t { k_dma_coh_channel = 0U , k_dma_coh_byte_sh = 8U , k_dma_coh_align = 32U } |
| Single-byte constants. More... | |
Functions | |
| static void | internal_park (void) |
| Halt forever in WFI – panic stop on a fatal init failure. | |
| static void | internal_setup_or_halt (void) |
| Bring CGC + MSTP + SCI8 console + LEDs up. | |
| static void | internal_fill_buffers (void) |
| Fill s_src with a deterministic pattern; prime s_dst. | |
| static uint8_t | internal_verify (void) |
| Verify s_dst matches s_src element-by-element. | |
| static ra8_err_t | internal_run_copy (void) |
| Clean src, run the DMAC block copy, then invalidate dst. | |
| static void | internal_report (uint8_t ok) |
| Emit the PASS/FAIL result over VCOM and ITM, toggle an LED. | |
| void | main (void) |
| Application entry: one-shot DMAC coherency proof, then WFI. | |
Variables | |
| static const uint8_t | s_dma_coh_pass_banner [] = "dma_coherency_hil: dma coherent PASS\r\n" |
| VCOM success banner. | |
| static const uint8_t | s_dma_coh_fail_banner [] = "dma_coherency_hil: dma coherent FAIL\r\n" |
| VCOM failure banner (caught by hil.conf HIL_EXPECT_NEGATIVE). | |
| static uint32_t | s_src [k_dma_coh_buf_words] |
| Source buffer – M85 writes leave it dirty in the D-cache. | |
| static uint32_t | s_dst [k_dma_coh_buf_words] |
| Destination buffer the DMAC writes; M85 must invalidate to read. | |
DMAC mem-to-mem coherency HIL proof with the M85 D-cache ENABLED.
Single-core (Cortex-M85) hardware-in-the-loop test that proves the DMA cache-maintenance pattern – clean-before / invalidate-after – keeps a DMAC0 mem-to-mem copy coherent with the M85 L1 D-cache while the cache is turned ON.
This app is the first in the tree to build with RA8_BOOT_ENABLE_CACHE_MPU (set in its CMakeLists.txt). With that flag the shared boot (libs/ra8_board_ek_ra8d2/src/boot/system_init.c) brings up the MPU (5 regions) + I-cache + D-cache + branch predictor. Both buffers live in MPU region 1 (0x22000000, M85-private cacheable SRAM), so the cache hazard is real on silicon.
Sequence (one-shot, then WFI):
Bare EK-RA8D2 only – no shields or external transceivers.
Definition in file main.c.
| enum dma_coh_byte_t : uint8_t |
| enum dma_coh_config_t : uint32_t |
|
static |
Fill s_src with a deterministic pattern; prime s_dst.
s_src[i] = i ^ (i >> 8) are M85 stores that sit dirty in the D-cache. s_dst is primed with a sentinel distinct from every source word so a copy that never lands fails the verify.
Definition at line 201 of file main.c.
References k_dma_coh_buf_words, k_dma_coh_byte_sh, k_dma_coh_sentinel, RA8_INTERNAL, s_dst, and s_src.
Referenced by main().
|
static |
Halt forever in WFI – panic stop on a fatal init failure.
Parks the core; only a debugger or external reset wakes it. Under ra8_emulator a WFI with no pending work triggers RA8_EMU_IDLE_STOP, terminating the run cleanly.
Definition at line 140 of file main.c.
References RA8_INTERNAL.
Referenced by internal_setup_or_halt(), and main().
|
static |
Emit the PASS/FAIL result over VCOM and ITM, toggle an LED.
Chooses one result banner, flushes it to VCOM, mirrors the result through the logging backend, and toggles the matching board LED so both automated and visual probes see one outcome.
| [in] | ok | Non-zero if the coherency check passed. |
Definition at line 350 of file main.c.
References k_ra8_board_led1, k_ra8_board_led2, ra8_board_led_toggle(), ra8_board_uart_console_flush(), ra8_board_uart_console_write(), RA8_INTERNAL, ra8_log_info, s_dma_coh_fail_banner, and s_dma_coh_pass_banner.
Referenced by main().
|
staticnodiscard |
Clean src, run the DMAC block copy, then invalidate dst.
Implements the clean-before / invalidate-after pattern:
| k_ra8_ok | Copy completed and both maintenance ops ran. |
| k_ra8_err_hw_error | A cache op failed or the channel accessor returned NULL. |
| k_ra8_err_hw_timeout | DMSTS.ACT never cleared within the poll bound. |
| (other) | Propagated ra8_dmac_start_block / ra8_dmac_stop error. |
Definition at line 277 of file main.c.
References r_dmac_channel_regs_t::DMREQ, r_dmac_channel_regs_t::DMSTS, k_dma_coh_buf_words, k_dma_coh_channel, k_dma_coh_poll_limit, k_ra8_dmac_width_word, k_ra8_dmreq_swreq_mask, k_ra8_dmsts_act_mask, k_ra8_err_hw_error, k_ra8_err_hw_timeout, k_ra8_ok, ra8_cache_dcache_clean_by_addr(), ra8_cache_dcache_invalidate_by_addr(), ra8_dmac(), ra8_dmac_start_block(), ra8_dmac_stop(), RA8_INTERNAL, s_dst, and s_src.
Referenced by main().
|
static |
Bring CGC + MSTP + SCI8 console + LEDs up.
Panic-halts on fail.
The DMAC0 module clock is ungated by ra8_mstp_init() (ra8_dmac_start references the same MSTP gate). The SCI8 J-Link OB console (TXD8 = PD_02 / RXD8 = PD_03 @ 115200 8N1) comes up through the BSP console API.
Definition at line 163 of file main.c.
References internal_park(), k_dma_coh_baud, k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_init(), RA8_INTERNAL, and ra8_mstp_init().
|
staticnodiscard |
Verify s_dst matches s_src element-by-element.
Must run AFTER ra8_cache_dcache_invalidate_by_addr(s_dst) so the reads miss the cache and fetch the DMAC-written bytes from SRAM.
| 1 | Buffers identical – copy + maintenance coherent. |
| 0 | At least one word differs. |
Definition at line 233 of file main.c.
References k_dma_coh_buf_words, RA8_INTERNAL, s_dst, and s_src.
Referenced by main().
| void main | ( | void | ) |
Application entry: one-shot DMAC coherency proof, then WFI.
The application entry point Reset_Handler hands control to.
Definition at line 377 of file main.c.
References internal_fill_buffers(), internal_park(), internal_report(), internal_run_copy(), internal_setup_or_halt(), internal_verify(), k_ra8_ok, and ra8_isr_globals_enable().
|
static |
VCOM failure banner (caught by hil.conf HIL_EXPECT_NEGATIVE).
Definition at line 97 of file main.c.
Referenced by internal_report().
|
static |
VCOM success banner.
Unique; not a substring of the FAIL line.
Definition at line 94 of file main.c.
Referenced by internal_report().
|
static |
Destination buffer the DMAC writes; M85 must invalidate to read.
1 KiB, 32-byte aligned and a whole number of cache lines so ra8_cache_dcache_invalidate_by_addr drops exactly the buffer's lines.
|
static |
Source buffer – M85 writes leave it dirty in the D-cache.
1 KiB, aligned to a 32-byte D-cache line and an exact whole number of lines, so ra8_cache_dcache_clean_by_addr cleans exactly the buffer with no partial-line spill.