You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This replaces the AoT processing we did to generate the Rust modules
locally. It generates them on the fly at build-time, and only for the
selected MCU. The process is mostly the same, just automated. Some
things became unnecessary though, such as the `modrs.patch`. `form` is
no longer run, in order to minimize the number of files and directories,
but rustfmt is, so that the user can read the source from generated
documentation pages. The patches were updated to not have the `_svd`
key, since that's now handled by the build script. Those that ended up
empty were removed.
@@ -32,63 +33,80 @@ Via the feature you can select which chip you want the register specifications f
32
33
|`atmega2560`||||`attiny2313`|
33
34
|`atmega164pa`||||`attiny2313a`|
34
35
35
-
## Build Instructions
36
-
The version on `crates.io` is pre-built. The following is only necessary when trying to build this crate from source.
37
-
38
-
You need to have [atdf2svd][] (= 0.4.0), [svd2rust][] (= 0.28), [form][] (>= 0.8), [rustfmt][](for the *nightly* toolchain) and [svdtools][] (>= 0.1.9) installed:
39
-
```bash
40
-
cargo install atdf2svd --version 0.4.0
41
-
cargo install svd2rust --version 0.28.0
42
-
cargo install form
43
-
rustup component add --toolchain nightly rustfmt
44
-
pip3 install --user svdtools
45
-
46
-
# check svdtools
47
-
svd --version
48
-
# if a "command not found" error is printed instead of a version,
49
-
# either svdtools is installed incorrectly, or its installation path is missing from the PATH variable.
50
-
# Temporary solution to PATH variable issue is to manually add the path. Like so:
Next, clone this repo and build the device definitions:
61
-
```bash
62
-
git clone https://github.com/Rahix/avr-device
63
-
cd avr-device
64
-
make
65
-
# You can build for just one specific chip using
66
-
# make atmega32u4
67
-
# I suggest building documentation as well
68
-
cargo +nightly doc --features <chip> --open
69
-
```
36
+
The `rt` feature, while optional, provides some minimal
37
+
startup/interrupt-handling code most projects will benefit from. It also enables
38
+
the `critical-section` feature, without which all peripheral access is
39
+
considered `unsafe` and the API becomes more limited.
70
40
71
-
## Internals
72
-
*avr-device* is generated using [`atdf2svd`](https://github.com/Rahix/atdf2svd) and [`svd2rust`](https://github.com/rust-embedded/svd2rust). The vendor-provided *atdf* files can be found in `vendor/`. The intermediate svd files are patched by `svdpatch.py` (Adapted from [`svdpatch.py`](https://github.com/stm32-rs/stm32-rs/blob/master/scripts/svdpatch.py) in [stm32-rs](https://github.com/stm32-rs/stm32-rs)) with device-dependent patches in `patch/`, mainly to improve undescriptive names and missing descriptions.
41
+
## Build Instructions
42
+
The PACs (Peripheral Access Crates, or really modules, in our case) **are not**
43
+
checked into git. Rather, we generate them at build time, via an automated
44
+
process implemented in [`build.rs`](./build.rs). It takes the ATDF files
45
+
Microchip (former Atmel) provides plus some patches of our own making as inputs,
46
+
and outputs a module generated from those device descriptions. These inputs
47
+
**are** checked-in. The process is similar to what the `*bindgen` crates
48
+
provide, just has more steps. So, in short, building should be a matter of
49
+
selecting the features and running cargo.
73
50
74
51
### Adding a new Chip
75
-
To add a new chip, download the *atdf* from <http://packs.download.atmel.com/> (or [avr-mcu/packs/](https://github.com/avr-rust/avr-mcu/tree/master/packs)) and place it in `vendor/`. Be sure to name it like the Rust module that should be generated. Next, you need to integrate it into the base crate and build system. Follow what was done in commit [290613454fbd ("Add basic support for ATmega64")](https://github.com/Rahix/avr-device/commit/290613454fbdc5e4ac98e53deccaf74dafc88963). Please adhere to the alphabetical sorting that is present so far.
76
-
77
-
Next, you **must** create a `<chipname>.yaml` in `patch/` which has at least the following content:
78
-
```yaml
79
-
_svd: ../svd/<chipname>.svd
80
-
```
81
-
82
-
If more patches need to be applied (most likely!), they should be added into this file as well. The patching format is documented in the [`svdtools` README](https://github.com/stm32-rs/svdtools#device-and-peripheral-yaml-format). Ideally, try to reuse the exisiting patches in `patch/common/` or `patch/timer/`.
83
-
84
-
Finally, try building the crate for your MCU with `make <chipname>`.
52
+
To add a new chip:
53
+
54
+
1. Download the ATDF from <http://packs.download.atmel.com/> and place it in
55
+
`vendor/`. Be sure to name it like the Rust module that should be generated.
56
+
2. Add a feature of the same name to `Cargo.toml` (it should enable
57
+
`device-selected`);
58
+
3. Add any needed patches to a yaml file with the same name under the `patch`
59
+
directory, ideally by including some of the snippets present in
60
+
`patch/common` and `patch/timer`; The format is decribed
0 commit comments