#details #tags #avr #trace #vcd #metadata #simavr-section

macro simavr-section-macro

Internal implementation details of the simavr-section crate

1 unstable release

0.1.0 Jan 12, 2022

#11 in #vcd

24 downloads per month
Used in simavr-section

GPL-3.0 license

8KB
130 lines

simavr-section

A crate to store simavr-compatible metadata in your ELF.

Make your AVR firmware self-describing of the expected core, frequency, fuses, and voltages. Configure a simulator to export VCD traces without bothering with any command-line flags.

  • Getting Started
  • Supported Tags
  • More Information
  • Contributing
  • License Information

Getting Started

Start by adding the avr_mcu macro to your main.rs:

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

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"]

Now you can simulate your firmware with no fuss:

> cargo build --release
   Compiling my-awesome-firmware v0.1.0 (/home/avr-freak/dev/my-awesome-firmware)
    Finished release [optimized] target(s) in 13.37s
> run_avr target/avr-attiny85/release/my-awesome-firmware.elf

Supported Tags

  • AVR_MMCU_TAG_NAME
  • AVR_MMCU_TAG_FREQUENCY
  • AVR_MMCU_TAG_VCC
  • AVR_MMCU_TAG_AVCC
  • AVR_MMCU_TAG_AREF
  • AVR_MMCU_TAG_LFUSE
  • AVR_MMCU_TAG_HFUSE
  • AVR_MMCU_TAG_EFUSE
  • AVR_MMCU_TAG_SIGNATURE
  • AVR_MMCU_TAG_SIMAVR_COMMAND
  • AVR_MMCU_TAG_SIMAVR_CONSOLE
  • AVR_MMCU_TAG_VCD_FILENAME
  • AVR_MMCU_TAG_VCD_PERIOD
  • AVR_MMCU_TAG_VCD_TRACE
  • AVR_MMCU_TAG_VCD_PORTPIN
  • AVR_MMCU_TAG_VCD_IRQ
  • AVR_MMCU_TAG_PORT_EXTERNAL_PULL

More Information

Take a look at the documentation with cargo doc --open or by visiting the docs.rs page.

The API is intentionally a direct clone of the macros exposed by simavr, for ease of porting. Refer to the simavr project for further details.

Contributing

All contributions are welcome, whether they're bug reports, feature requests, code changes, or well wishes. Thanks!

To run a full integration test, use test.sh in the root of the project.

License Information

simavr-section is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

simavr-section is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Please see the file LICENSE in the root of this project for a copy of the GNU General Public License, or see http://www.gnu.org/licenses/.

This project incorporates code from the simavr project, which is also licensed under the GPL v3.

Dependencies

~1.5MB
~34K SLoC