This repository contains the data and tools required to generate Peripheral Access Crates (PACs) for Renesas RA microcontrollers. It follows a data-driven approach where chip definitions and register maps are stored in intermediary YAML files.
-
ra-data-types/: Rust crate defining the shared data models for chips, peripherals, and memory maps. -
ra-data-gen/: The tool responsible for extracting data from SVD and Rzone files into the intermediary YAML format. -
ra-metapac-gen/: The generator tool that transforms YAML data into thera-metapacRust crate. -
data/: The intermediary data store.data/chips/: YAML files for each specific Part Number (PN), containing memory maps and peripheral instances.data/registers/: YAML files defining the register blocks, fieldsets, and enums for each peripheral type.
-
d: A helper script to run common tasks like data generation and PAC generation.
The project relies on a two-tier YAML data model to ensure accuracy and deduplication.
Each chip YAML (e.g., r7fa0e1073cfj.yaml) is based on the Chip struct in ra-data-types. It includes:
- Memory Map: Precise boundaries for Flash, RAM, and Data Flash extracted from Renesas
.rzonefiles. - Peripherals: A list of peripheral instances (e.g.,
SRAM,UART) with their base addresses and a reference to their register block definition. - Interrupts: The NVIC interrupt vector table for that specific device.
These files define the internal structure of a peripheral. They are generated using chiptool and include:
- Blocks: The memory layout of the peripheral (registers and their offsets).
- Fieldsets: Bit-level definitions for each register.
- Enums: Named values for register fields.
A core library that ensures consistency between the data extraction tools and the PAC generator. It defines the Chip, Peripheral, Memory, and Interrupt structures used for serialization.
The primary generation engine. It performs the following steps:
- Data Loading: Parses all chip and register YAMLs into memory.
- Deduplication: Identifies unique register blocks used across the entire RA family.
- PAC Generation: Creates a structured Rust crate (
ra-metapac) with:- Shared peripheral modules in
src/peripherals/. - Per-chip modules in
src/chips/. - A
build.rsscript for dynamic chip selection.
- Shared peripheral modules in
- Metadata Generation: Produces a static metadata object for each chip, allowing HALs to be chip-agnostic.
To regenerate the ra-metapac crate from the current YAML data:
./d gen-pacThe output will be generated in the out/ directory.
- Place new SVD or Rzone files in the
sources/directory. - Use the extraction scripts (in
scripts/or via./d) to update the YAML files indata/. - Run
./d gen-pacto update the generated PAC.