An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# raspi-pacs

[![crates.io](https://img.shields.io/crates/v/bcm2835-lpa.svg?label=crates.io%20%28bcm2835-lpa%29)](https://crates.io/crates/bcm2835-lpa)
[![docs.rs](https://img.shields.io/docsrs/bcm2835-lpa?label=docs%20%28bcm2835-lpa%29)](https://docs.rs/bcm2835-lpa)

[![crates.io](https://img.shields.io/crates/v/bcm2837-lpa.svg?label=crates.io%20%28bcm2837-lpa%29)](https://crates.io/crates/bcm2837-lpa)
[![docs.rs](https://img.shields.io/docsrs/bcm2837-lpa?label=docs%20%28bcm2837-lpa%29)](https://docs.rs/bcm2837-lpa)

[![crates.io](https://img.shields.io/crates/v/bcm2711-lpa.svg?label=crates.io%20%28bcm2711-lpa%29)](https://crates.io/crates/bcm2711-lpa)
[![docs.rs](https://img.shields.io/docsrs/bcm2711-lpa?label=docs%20%28bcm2711-lpa%29)](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
```