This is a Cargo template for embedded Rust development with Analog Device's MAX78000FTHR board. It uses the max78000-hal
crate.
Currently, only the main ARM Cortex-M4 core is supported. The optional RISC-V core is not supported.
This template is based on the cortex-m-quickstart
template.
- max7800x-hal - Hardware Abstraction Layer for the MAX7800x family of microcontrollers
- max78000-pac - Peripheral Access Crate for the MAX78000
To build embedded programs using this template you'll need:
-
Rust installed via
rustup
. See installation instructions. -
Rust 1.31, 1.30-beta, nightly-2018-09-13 or a newer toolchain.
rustup default beta
- The
cargo generate
subcommand. See installation instructions or simply run:
cargo install cargo-generate
rust-std
components (pre-compiledcore
crate) for the ARM Cortex-M targets. For this MAX78000 template, we are using thethumbv7em-none-eabihf
target, but you could also usethumbv7em-none-eabi
.
rustup target add thumbv7em-none-eabihf
Note
Be sure to check out the embedded Rust book for additional guidance. It covers important things like flashing, running, and debugging programs in detail.
You can generate a new project using this template by running:
cargo generate --git https://github.com/sigpwny/max78000fthr-template.git
Alternatively, you can clone this repository and manually edit the Cargo.toml
file to configure your project. You won't be able to build the project until you've replaced the placeholder values.
[package]
name = "{{project-name}}" # Be sure to replace this with your project name
version = "0.1.0"
authors = ["{{authors}}"] # Be sure to replace this with your name(s)
edition = "2021"
publish = false
You can build the contents in src
with:
cargo build
Alternatively, you can build some of the included example code in examples
with:
# cargo build --example <example-name>
cargo build --example blinky
Note
This flashing method is quick, but is intended only for rapid development. It will also only work for boards with debug enabled. For production, you should use other methods.
The MAX78000FTHR board includes a DAPLink debugger (via a MAX32625 chip) which sits between the Micro-USB port and the MAX78000 microcontroller. This DAPLink can be used to flash the MAX78000.
openocd
- this has to be Analog Device's custom fork of OpenOCD since it includes flash and reset support for the MAX78000.arm-none-eabi-gdb
- Arm GNU Toolchain
Both of the above tools can be installed via Analog Device's MSDK.
In one terminal, start OpenOCD with a GDB server using the following command. This will use the openocd.cfg
file to configure OpenOCD and automatically connect to the board.
# C:\MaximSDK\Tools\OpenOCD\openocd.exe
openocd.exe --search "C:/MaximSDK/Tools/OpenOCD/scripts"
In another terminal, start GDB with the following command:
# C:\MaximSDK\Tools\GNUTools\10.3\bin\arm-none-eabi-gdb.exe
arm-none-eabi-gdb.exe --command=openocd.gdb ./target/thumbv7em-none-eabihf/debug/{{project-name}}
The openocd.gdb
file contains the GDB commands to connect to OpenOCD's GDB server and flash the program (using the load
command). Be sure to customize this file to your project's needs.
You will need to create a binary firmware file (.bin
) from the built ELF file using arm-none-eabi-objcopy
or cargo-binutils
.
TODO: More instructions here.
If you are using a custom bootloader, you will need to format the generated ELF file into a format compatible with your bootloader (most likely, you'll need to use arm-none-eabi-objcopy
or cargo-binutils
). Refer to your bootloader's documentation for more information.
This template includes launch configurations for debugging Cortex-M programs with Visual Studio Code located in the .vscode/
directory. See .vscode/README.md for more information.
If you're not using VS Code, you can safely delete the directory from the generated project.
This template is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.