simavr-section 0.1.1

Add simavr-compatible metadata to your binary.
docs.rs failed to build simavr-section-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

Add simavr-compatible metadata to your binary.

The simavr library specifies a format for including AVR-related metadata in a firmware ELF file. This crate ports that format to Rust, to allow AVR binaries authored entirely in Rust to specify simavr-compliant metadata.

The metadata is used to pass various "parameters" to a simulator, such as what microcontroller the code was built for, the expected clock frequency, fuses, and so forth. The same metadata could be read by a programmer to verify the chip being programmed and update fuses as appropriate.

Example

Start by adding the avr_mcu macro to your main.rs. This metadata specifies the core and frequency and is always required.

use simavr_section::avr_mcu;
avr_mcu!(8000000, b"atmega88");

You can then add additional metadata, such as configuring a VCD trace file that the simulator should export:

use simavr_section::{avr_mcu_vcd_file, avr_mcu_vcd_port_pin};
avr_mcu_vcd_file!(b"gtkwave_trace.vcd", 1 /* param ignored due to a bug in simavr */);
avr_mcu_vcd_port_pin!(b'B', 5, b"PORTB5");

Build Flags

To ensure the metadata passes through to the final ELF, you need to add some link args to the rustc call. The easiest way to do this is to add or update your config.toml file with these lines:

[target.'cfg(target_arch = "avr")']
rustflags = ["-C", "link-arg=-Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000"]