|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Eclipse ThreadX + Arm v8-M MPU partition demo for RA8D2. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_mpu.h"#include "ra8_port_constants.h"#include "ra8_port_utils.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | mpu_stack_t : uint16_t { k_mpu_thread_stack_bytes = 1024U } |
| enum | mpu_priority_t : uint8_t { k_mpu_thread_priority = 4U } |
| enum | mpu_period_t : uint16_t { k_mpu_blink_ticks = 1000U } |
| enum | mpu_region_base_t : uintptr_t { k_mpu_region_mram_base = 0x02000000UL , k_mpu_region_sram_base = 0x22000000UL , k_mpu_region_peri_base = 0x40000000UL } |
| Region base addresses for the MPU partition table. More... | |
| enum | mpu_region_size_t : uint32_t { k_mpu_region_mram_size = 0x00100000UL , k_mpu_region_sram_size = 0x00100000UL , k_mpu_region_peri_size = 0x10000000UL } |
| Region sizes (powers of two, bytes). More... | |
| enum | mpu_mair_encoding_t : uint8_t { k_mpu_mair_attr0_normal_wb = 0xFFU , k_mpu_mair_attr1_device = 0x04U } |
| MAIR attribute encodings used by the region table below. More... | |
| enum | mpu_mair0_t : uint32_t { k_mpu_mair0_word } |
| enum | mpu_region_count_t : uint8_t { k_mpu_region_count } |
Functions | |
| static void | internal_thread_entry (ULONG thread_input) |
| Worker thread: blink LED1 to prove MPU did not wedge us. | |
| void | tx_application_define (void *first_unused_memory) |
| void | main (void) |
| Application entry: program MPU, init GPIO, dispatch ThreadX. | |
Variables | |
| static const ra8_mpu_region_t | s_mpu_regions [] |
| Static MPU region table installed at boot. | |
| static const ra8_mpu_cfg_t | s_mpu_cfg |
| Aggregate MPU configuration handed to ra8_mpu_configure(). | |
| static uint8_t | s_thread_stack [k_mpu_thread_stack_bytes] |
| static TX_THREAD | s_thread |
| volatile uint32_t | g_threadx_mpu_partition_match = 0U |
| HIL liveness counter – incremented by the worker thread on every LED-toggle iteration. | |
Eclipse ThreadX + Arm v8-M MPU partition demo for RA8D2.
Demonstrates partitioning the system address map into a small static MPU region table at boot, then handing control to a single ThreadX worker that blinks LED1 at 1 Hz to prove the MPU configuration did not break ordinary code execution.
Region layout (programmed via ra8_mpu_configure):
Default-on PRIVDEFENA lets privileged accesses outside the declared regions fall through to the architectural defaults so the kernel can still touch its bookkeeping pages.
Definition in file main.c.
| enum mpu_mair0_t : uint32_t |
| enum mpu_mair_encoding_t : uint8_t |
MAIR attribute encodings used by the region table below.
Attr 0 = Normal memory, inner+outer write-back, RW-allocate, non-transient (encoding 0xFF per Armv8-M Architecture Reference Manual D1.6.7 "Memory attribute encodings"). Required for the MRAM code region: instruction fetches from device-typed memory are UNPREDICTABLE and most cores HardFault. Attr 1 = device-nGnRnE (encoding 0x04) for the peripheral region.
| Enumerator | |
|---|---|
| k_mpu_mair_attr0_normal_wb | MPU mair attr0 normal wb. |
| k_mpu_mair_attr1_device | MPU mair attr1 device. |
| enum mpu_period_t : uint16_t |
| enum mpu_priority_t : uint8_t |
| enum mpu_region_base_t : uintptr_t |
| enum mpu_region_count_t : uint8_t |
| enum mpu_region_size_t : uint32_t |
| enum mpu_stack_t : uint16_t |
|
static |
Worker thread: blink LED1 to prove MPU did not wedge us.
Toggles the board LED, advances the externally probed liveness counter, and sleeps for the configured ThreadX interval forever. Continued progress demonstrates that the MPU partition permits the scheduler and board-control paths required by this thread.
| [in] | thread_input | ThreadX entry cookie; this demo does not use it. |
Definition at line 208 of file main.c.
References g_threadx_mpu_partition_match, k_mpu_blink_ticks, k_ra8_board_led1, ra8_board_led_toggle(), RA8_INTERNAL, and tx_thread_sleep.
| void main | ( | void | ) |
Application entry: program MPU, init GPIO, dispatch ThreadX.
The application entry point Reset_Handler hands control to.
Definition at line 250 of file main.c.
References k_ra8_board_led1, k_ra8_ok, ra8_board_led_init(), ra8_cgc_init(), ra8_mpu_configure(), and s_mpu_cfg.
| void tx_application_define | ( | void * | first_unused_memory | ) |
Definition at line 218 of file main.c.
References internal_thread_entry(), k_mpu_thread_priority, k_mpu_thread_stack_bytes, s_thread, s_thread_name, s_thread_stack, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
| volatile uint32_t g_threadx_mpu_partition_match = 0U |
HIL liveness counter – incremented by the worker thread on every LED-toggle iteration.
Read externally by scripts/hil/jlink_memprobe.sh via SWD. The probe asserts this counter advances by >= HIL_PROBE_MIN_ADVANCE over the sample window, proving:
The alive-mode check could only prove the chip didn't HardFault; the counter proves the MPU partition did not silently break the scheduler tick or LED-toggle path.
Definition at line 186 of file main.c.
Referenced by internal_thread_entry().
|
static |
Aggregate MPU configuration handed to ra8_mpu_configure().
Definition at line 142 of file main.c.
Referenced by main().
|
static |
Static MPU region table installed at boot.
Three coarse regions cover code, data, and the peripheral block. MRAM + SRAM use attr_idx 0 (Normal write-back); the peripheral region uses attr_idx 1 (device-nGnRnE). A real partitioning policy would split secure / non-secure worlds and apply per-thread sub-regions.
|
static |
Definition at line 160 of file main.c.
Referenced by tx_application_define().
|
static |
Definition at line 159 of file main.c.
Referenced by tx_application_define().