avr-hal
avr-hal copied to clipboard
Added the ravedude chip command for bare MCU development
This PR adds a ravedude chip command, aimed primarily at anyone doing bare chip development. The behavior of the ravedude chip command is as follows:
ravedude chipcan be used as a cargo runner- The target MCU is autodetected from the ELF metadata in the binary that is being flashed. See
ravedude/src/target_detect.rs. - The programmer is specified either with command line options or with environment variables. There is no provision for specifying the programmer using a configuration file. The rationale for this is
- The programmer and its associated settings (port and baud rate) are not a property of the crate, but are configuration parameters specific to a particular developer and their development system.
- Any crate that wishes to hardcode programmer settings can do so in
.cargo/config.tomland doesn't need a separate config file. - Any crate that wishes to leave programmer settings up to the individual developer can leave them out of
.cargo/config.tomland require the developer to configure them with environment variables - Any developer that wishes to use a file on disk to configure their environment can use
direnvor a similar tool.
ravedude chipsupports opening a serial console after flashing. Serial console settings (port and baud rate) are specified with either command line options or with environment variable. Typically, the baud rate would be specified in.cargo/config.toml(because it's a property of the crate) and the port would be specified in an environment variable (because it's a developer-specific configuration parameter).
In summary, the intended use of ravedude chip is:
- Set
runnerin.cargo/config.tomltoravedude chip(for no serial console after flashing) orravedude chip --console-mode=serial --console-baudrate=NNN(for serial console after flashing) - Set environment variables for
AVR_PROGRAMMER_NAME,AVR_PROGRAMMER_PORT(if not autodetected byavrdude),AVR_PROGRAMMER_BAUDRATE(if not autodetected byavrdude), andAVR_CONSOLE_PORT(if different fromAVR_PROGRAMMER_PORT) using any of the following methods: directly set them in the shell beforecargo run, set them in the[env]section of.cargo/config.toml, or usedirenvor a similar tool.
For consistency, the existing ravedude command has been renamed ravedude board; if neither ravedude chip nor ravedude board has been specified, ravedude board is implied. That is, the following work:
runner = ravedude— works like beforerunner = ravedude board— works same asraveduderunner = ravedude chip— new addition, works as described above.
I am keeping ravedude chip out of the main package docs for now because its only imminent use will be internal (for developing inside MCU crates), but I do plan to add more documentation for it in the future (probably when I add examples in MCU crates, which I am working on in a separate branch).