https://github.com/abt8601/raspi-pacs
Peripheral access crates for the Broadcom microprocessors used in the Raspberry Pi boards
https://github.com/abt8601/raspi-pacs
bcm2711 bcm2835 bcm2837 raspberry-pi rust
Last synced: about 1 year ago
JSON representation
Peripheral access crates for the Broadcom microprocessors used in the Raspberry Pi boards
- Host: GitHub
- URL: https://github.com/abt8601/raspi-pacs
- Owner: abt8601
- License: unlicense
- Created: 2023-03-18T06:50:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-23T01:57:43.000Z (over 1 year ago)
- Last Synced: 2025-04-14T23:12:04.846Z (about 1 year ago)
- Topics: bcm2711, bcm2835, bcm2837, raspberry-pi, rust
- Language: Shell
- Homepage:
- Size: 1.52 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# raspi-pacs
[](https://crates.io/crates/bcm2835-lpa)
[](https://docs.rs/bcm2835-lpa)
[](https://crates.io/crates/bcm2837-lpa)
[](https://docs.rs/bcm2837-lpa)
[](https://crates.io/crates/bcm2711-lpa)
[](https://docs.rs/bcm2711-lpa)
Peripheral access crates
for the Broadcom microprocessors used in the Raspberry Pi boards.
This repository contains the scripts
to generate the PACs for the following MCUs:
- BCM2835, found in the Raspberry Pi 1 and Zero
- BCM2837, found in the Raspberry Pi 3 and Zero 2W
- BCM2711, found in the Raspberry Pi 4
These PACs are generated by [`svd2rust`](https://crates.io/crates/svd2rust)
from the
[SVD files](https://github.com/adafruit/broadcom-peripherals/tree/main-build/svd/gen)
in
[adafruit/broadcom-peripherals](https://github.com/adafruit/broadcom-peripherals),
save that [patches](svd-patches/) are applied
to add the missing tags required by `svd2rust`.
## A Note on Virtual Memory
The PACs expect the memory-mapped registers of the peripherals
to be present on their physical addresses;
therefore, the PACs integrate poorly with virtual memory.
If the register files are offset-mapped to a different base address,
it is advised to generate the PACs by yourself from
[our patched SVD files](https://github.com/abt8601/raspi-pacs/tree/main-build/build/svds)
and using the `--base-address-shift` option of `svd2rust`.
## Feature Flags of the PACs
- `atomic`:
Extends the register API with operations
to atomically set, clear, and toggle specific bits.
- `defmt`:
Include `defmt::Format` implementations.
## Generating the PACs
### Prerequisites for the PACs
- `make`
- `patch`
- [Jinja2 CLI](https://pypi.python.org/pypi/jinja2-cli)
- A Rust toolchain with `cargo` and `rustfmt`
- [`svd2rust`](https://crates.io/crates/svd2rust)
(The latest version that works with our SVD files is 0.31.5.)
- [`form`](https://crates.io/crates/form)
(≥ 0.11 is required for the generated PACs to be compilable on Windows.)
Also, the submodule `broadcom-peripherals` must be checked out.
### Steps to Generate the PACs
To generate the PAC for a particular MCU, run:
```sh
make build/pacs/-lpa
```
where `` is one of `bcm2835`, `bcm2837`, or `bcm2711`.
The generated PAC will be located in `build/pacs/-lpa`.
This step also generates the patched SVD file,
which is located in `build/svds/.svd`.
Or, to generate the PACs for all MCUs at once, run:
```sh
make pacs
```
## Generating Just the SVD Files
### Prerequisites for the SVD Files
- `make`
- `patch`
Also, the submodule `broadcom-peripherals` must be checked out.
### Steps to Generate the SVD Files
To generate the SVD file for a particular MCU, run:
```sh
make build/svds/.svd
```
where `` is one of `bcm2835`, `bcm2837`, or `bcm2711`.
The generated SVD file will be located in `build/svds/.svd`.
Or, to generate the SVD files for all MCUs at once, run:
```sh
make svds
```